2014-04-25 05:56:24 +00:00
|
|
|
(function(context,$) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
context.JK = context.JK || {};
|
|
|
|
|
|
|
|
|
|
context.JK.UIHelper = function(app) {
|
|
|
|
|
var logger = context.JK.logger;
|
|
|
|
|
var rest = new context.JK.Rest();
|
|
|
|
|
|
|
|
|
|
function addSessionLike(sessionId, userId, $likeCountSelector, $likeButtonSelector) {
|
|
|
|
|
rest.addSessionLike(sessionId, userId)
|
|
|
|
|
.done(function(response) {
|
|
|
|
|
$likeCountSelector.html(parseInt($likeCountSelector.text()) + 1);
|
|
|
|
|
$likeButtonSelector.unbind("click");
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function addRecordingLike(recordingId, claimedRecordingId, userId, $likeCountSelector, $likeButtonSelector) {
|
|
|
|
|
rest.addRecordingLike(recordingId, claimedRecordingId, userId)
|
|
|
|
|
.done(function(response) {
|
|
|
|
|
$likeCountSelector.html(parseInt($likeCountSelector.text()) + 1);
|
|
|
|
|
$likeButtonSelector.unbind("click");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function launchCommentDialog(entityId, entityType) {
|
|
|
|
|
console.log("launching comment dialog for %o %o", entityType, entityId);
|
|
|
|
|
// TODO: launch comment dialog
|
|
|
|
|
|
|
|
|
|
// var comment = $("#txtSessionComment").val();
|
|
|
|
|
// if ($.trim(comment).length > 0) {
|
|
|
|
|
// rest.addSessionComment(sessionId, JK.currentUserId, comment)
|
|
|
|
|
// .done(function(response) {
|
|
|
|
|
// $("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
|
|
|
|
|
// renderComment(comment, context.JK.currentUserId, context.JK.currentUserName,
|
|
|
|
|
// context.JK.currentUserAvatarUrl, $.timeago(Date.now()), context.JK.currentUserMusician, false);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function launchShareDialog(entityId, entityType) {
|
|
|
|
|
console.log("launching share dialog for %o %o", entityType, entityId);
|
2014-04-26 18:21:17 +00:00
|
|
|
var shareDialog = new JK.ShareDialog(JK.app, entityId, entityType);
|
|
|
|
|
shareDialog.initialize(JK.FacebookHelperInstance);
|
|
|
|
|
|
|
|
|
|
shareDialog.showDialog();
|
2014-04-25 05:56:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.addSessionLike = addSessionLike;
|
|
|
|
|
this.addRecordingLike = addRecordingLike;
|
|
|
|
|
this.launchCommentDialog = launchCommentDialog;
|
|
|
|
|
this.launchShareDialog = launchShareDialog;
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window,jQuery);
|