merge develop

This commit is contained in:
Brian Smith 2014-02-04 20:23:08 -05:00
commit 11fbcc96e7
11 changed files with 219 additions and 145 deletions

View File

@ -0,0 +1,72 @@
(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.FacebookHelper = function(app) {
var logger = context.JK.logger;
var loginStatusDeferred = null;
var $self = $(this);
var connected = false;
function promptLogin() {
if(connected) {
// instantly return previous login info
//return loginStatusDeferred;
}
loginStatusDeferred = $.Deferred();
FB.login(function(response) {
handle_fblogin_response(response);
}, {scope:'publish_stream'});
return loginStatusDeferred;
}
function handle_fblogin_response(response) {
if(response.status == "connected") {
connected = true;
}
$self.triggerHandler('fb.login_response', {response: response});
loginStatusDeferred.resolve(response);
}
function initialize(fbAppID) {
loginStatusDeferred = $.Deferred();
var fbAppID_ = fbAppID;
window.fbAsyncInit = function() {
FB.init({
appId : fbAppID_,
// channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html',
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow server to access the session?
xfbml : true, // parse XFBML tags on this page?
oauth : true, // enable OAuth 2.0
});
// listen to see if the user is known/logged in
FB.getLoginStatus(function(response) {
handle_fblogin_response(response);
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
}
this.initialize = initialize;
this.promptLogin = promptLogin;
};
})(window, jQuery);

View File

@ -287,7 +287,7 @@
app.bindDialog('inviteUsers', dialogBindings);
callFB(fbAppID);
//callFB(fbAppID);
};
this.initialize = initialize;

View File

@ -98,7 +98,7 @@
registerEvents(false);
}
function initialize(){
function initialize(facebookHelper){
var dialogBindings = {
'beforeShow' : beforeShow,
'afterHide': afterHide

View File

@ -1,10 +1,66 @@
$(function() {
(function(context, $) {
function like() {
context.JK.ShowRecording = function(app) {
var logger = context.JK.logger;
var rest = new JK.Rest();
var recordingId = null;
var claimedRecordingId = null;
}
function like() {
rest.addRecordingLike(recordingId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
// search click handler
$('#btnlike').click(like);
function play() {
rest.addRecordingPlay(recordingId, JK.currentUserId)
.done(function(response) {
$("#spnPlayCount").html(parseInt($("#spnPlayCount").text()) + 1);
});
}
});
function addComment() {
var comment = $("#txtRecordingComment").val();
if ($.trim(comment).length > 0) {
rest.addRecordingComment(recordingId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
function initialize(_claimedRecordingId, _recordingId) {
recordingId = _recordingId;
claimedRecordingId = _claimedRecordingId;
if (JK.currentUserId) {
var shareDialog = new JK.ShareDialog(JK.app, claimedRecordingId, "recording");
shareDialog.initialize(context.JK.FacebookHelperInstance);
$("#btnShare").click(function(e) {
shareDialog.showDialog();
});
$("#txtRecordingComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtRecordingComment").attr("disabled", "disabled");
$("#txtRecordingComment").val("You must be logged in to add a comment.");
}
$("#btnLike").click(like);
$("#btnPlay").click(play);
}
this.initialize = initialize;
}
})(window, jQuery);

View File

@ -1,10 +1,57 @@
$(function() {
(function(context, $) {
function like() {
context.JK.ShowMusicSession = function(app) {
var logger = context.JK.logger;
var rest = new JK.Rest();
var sessionId = null;
}
function like() {
rest.addSessionLike(sessionId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
// search click handler
$('#btnlike').click(like);
function addComment() {
var comment = $("#txtSessionComment").val();
if ($.trim(comment).length > 0) {
rest.addSessionComment(sessionId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
});
function initialize(musicSessionId) {
sessionId = musicSessionId;
if (context.JK.currentUserId) {
var shareDialog = new JK.ShareDialog(context.JK.app, sessionId, "session");
shareDialog.initialize(context.JK.FacebookHelperInstance);
$("#btnShare").click(function(e) {
shareDialog.showDialog();
});
$("#txtSessionComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtSessionComment").attr("disabled", "disabled");
$("#txtSessionComment").val("You must be logged in to add a comment.");
}
$("#btnLike").click(like);
}
this.initialize = initialize;
}
})(window, jQuery);

View File

@ -5,6 +5,7 @@
//= require AAA_Log
//= require AAC_underscore
//= require globals
//= require facebook_helper
//= require web/signupDialog
//= require web/signinDialog
//= require invitationDialog

View File

@ -20,8 +20,8 @@
<td valign="top" width="48%">
<div class="ml10">
<h3>Share a Link:</h3><br />
<% unless share_token.blank? %>
<%= true ? '' : "#{root_url}#{share_token}" %>
<% unless true # share_token.blank? %>
<%= "#{root_url}#{share_token}" %>
<% end %>
<div class="right"><a class="button-orange">COPY LINK</a></div>
</div>

View File

@ -95,11 +95,14 @@
var recordingManager = new JK.RecordingManager();
var facebookHelper = new JK.FacebookHelper(JK.app);
facebookHelper.initialize('<%= SampleApp::Application.config.facebook_key %>');
var invitationDialog = new JK.InvitationDialog(JK.app);
invitationDialog.initialize('<%= SampleApp::Application.config.facebook_key %>');
var shareDialog = new JK.ShareDialog(JK.app);
shareDialog.initialize();
shareDialog.initialize(facebookHelper);
var localRecordingsDialog = new JK.LocalRecordingsDialog(JK.app);
localRecordingsDialog.initialize();

View File

@ -66,8 +66,12 @@
JK.app = JK.JamKazam();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false}});
var facebookHelper = new JK.FacebookHelper(JK.app);
JK.FacebookHelperInstance = facebookHelper;
facebookHelper.initialize('<%= SampleApp::Application.config.facebook_key %>');
var invitationDialog = new JK.InvitationDialog(JK.app);
invitationDialog.initialize();
invitationDialog.initialize(facebookHelper);
var userDropdown = new JK.UserDropdown(JK.app);
userDropdown.initialize(invitationDialog);
@ -75,11 +79,11 @@
var signupDialog = new JK.SignupDialog(JK.app);
signupDialog.initialize();
var signinDialog = new JK.SigninDialog(JK.app);
signinDialog.initialize();
})
</script>
<%= yield(:extra_js) %>
<%= render "shared/ga" %>
<!-- version info: <%= version %> -->
</body>

View File

@ -80,62 +80,11 @@
<%= render :partial => "clients/shareDialog", :locals => {:session => @music_session, :share_token => @music_session.share_token} %>
<script type="text/javascript">
$(function () {
JK = JK || {};
<% if current_user %>
JK.currentUserId = '<%= current_user.id %>';
<% else %>
JK.currentUserId = null;
<% end %>
if (JK.currentUserId) {
JK.app = JK.JamKazam();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false}});
var shareDialog = new JK.ShareDialog(JK.app, @music_session.id, "session");
shareDialog.initialize();
$("#btnShare").click(function(e) {
shareDialog.showDialog();
});
$("#txtSessionComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtSessionComment").attr("disabled", "disabled");
$("#txtSessionComment").val("You must be logged in to add a comment.");
}
JK.sessionId = "<%= @music_session.music_session_id %>";
var rest = new JK.Rest();
$("#btnLike").click(like);
function like() {
rest.addSessionLike(JK.sessionId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
function addComment() {
var comment = $("#txtSessionComment").val();
if ($.trim(comment).length > 0) {
rest.addSessionComment(JK.sessionId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
})
</script>
<% content_for :extra_js do %>
<script type="text/javascript">
$(function () {
var showMusicSession = new JK.ShowMusicSession(JK.app);
showMusicSession.initialize("<%= @music_session.music_session_id %>");
})
</script>
<% end %>

View File

@ -79,70 +79,12 @@
<%= render :partial => "clients/shareDialog", :locals => {:recording => @claimed_recording, :share_token => @claimed_recording.share_token} %>
<script type="text/javascript">
$(function () {
<% content_for :extra_js do %>
<script type="text/javascript">
$(function () {
var showRecording = new JK.ShowRecording(JK.app);
showRecording.initialize("<%= @claimed_recording.id %>", "<%= @claimed_recording.recording_id %>");
})
</script>
<% end %>
JK = JK || {};
<% if current_user %>
JK.currentUserId = '<%= current_user.id %>';
<% else %>
JK.currentUserId = null;
<% end %>
if (JK.currentUserId) {
JK.app = JK.JamKazam();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false}});
var shareDialog = new JK.ShareDialog(JK.app, '<%= @claimed_recording.id %>', "recording");
shareDialog.initialize();
$("#btnShare").click(function(e) {
shareDialog.showDialog();
});
$("#txtRecordingComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtRecordingComment").attr("disabled", "disabled");
$("#txtRecordingComment").val("You must be logged in to add a comment.");
}
JK.recordingId = "<%= @claimed_recording.recording.id %>";
var rest = new JK.Rest();
$("#btnLike").click(like);
$("#btnPlay").click(play);
function like() {
rest.addRecordingLike(JK.recordingId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
function play() {
rest.addRecordingPlay(JK.recordingId, JK.currentUserId)
.done(function(response) {
$("#spnPlayCount").html(parseInt($("#spnPlayCount").text()) + 1);
});
}
function addComment() {
var comment = $("#txtRecordingComment").val();
if ($.trim(comment).length > 0) {
rest.addRecordingComment(JK.recordingId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
})
</script>