jam-cloud/web/app/assets/javascripts/ui_helper.js

46 lines
1.5 KiB
JavaScript

(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(options) {
var commentDialog = new JK.CommentDialog(JK.app, options);
commentDialog.initialize();
commentDialog.showDialog();
}
function launchShareDialog(entityId, entityType) {
var shareDialog = new JK.ShareDialog(JK.app, entityId, entityType);
shareDialog.initialize(JK.FacebookHelperInstance);
shareDialog.showDialog();
}
this.addSessionLike = addSessionLike;
this.addRecordingLike = addRecordingLike;
this.launchCommentDialog = launchCommentDialog;
this.launchShareDialog = launchShareDialog;
return this;
};
})(window,jQuery);