97 lines
3.7 KiB
JavaScript
97 lines
3.7 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();
|
|
var sessionUtils = context.JK.SessionUtils;
|
|
|
|
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();
|
|
return commentDialog.showDialog();
|
|
}
|
|
|
|
function launchShareDialog(entityId, entityType) {
|
|
var shareDialog = new JK.ShareDialog(JK.app, entityId, entityType);
|
|
shareDialog.initialize(JK.FacebookHelperInstance);
|
|
return shareDialog.showDialog();
|
|
}
|
|
|
|
function launchRsvpSubmitDialog(sessionId) {
|
|
var rsvpDialog = new JK.RsvpSubmitDialog(JK.app, sessionId);
|
|
rsvpDialog.initialize();
|
|
return rsvpDialog.showDialog();
|
|
}
|
|
|
|
function launchRsvpCancelDialog(sessionId, rsvpRequestId) {
|
|
var rsvpDialog = new JK.RsvpCancelDialog(JK.app, sessionId, rsvpRequestId);
|
|
rsvpDialog.initialize();
|
|
return rsvpDialog.showDialog();
|
|
}
|
|
|
|
function launchRsvpCreateSlotDialog(sessionId, instrumentIds, rsvpRequesterName, createSlotsCallback) {
|
|
var rsvpDialog = new JK.RsvpCreateSlotDialog(JK.app, sessionId, instrumentIds, rsvpRequesterName, createSlotsCallback);
|
|
rsvpDialog.initialize();
|
|
return rsvpDialog.showDialog();
|
|
}
|
|
|
|
function launchSessionStartDialog(session) {
|
|
sessionUtils.ensureValidClient(app, context.JK.GearUtils, function() {
|
|
var sessionStartDialog = new JK.SessionStartDialog(JK.app, session);
|
|
sessionStartDialog.initialize();
|
|
return sessionStartDialog.showDialog();
|
|
});
|
|
}
|
|
|
|
function launchInstrumentSelectorDialog(type, instruments, callback) {
|
|
var instrumentSelectorDialog = new JK.InstrumentSelectorDialog(JK.app, type, instruments, callback);
|
|
instrumentSelectorDialog.initialize();
|
|
return instrumentSelectorDialog.showDialog();
|
|
}
|
|
|
|
function launchGenreSelectorDialog(type, genres, callback) {
|
|
var genreSelectorDialog = new JK.GenreSelectorDialog(JK.app, type, genres, callback);
|
|
genreSelectorDialog.initialize();
|
|
return genreSelectorDialog.showDialog();
|
|
}
|
|
|
|
function launchRecordingSelectorDialog(recordings, selectedRecordings, callback) {
|
|
var recordingSelectorDialog = new JK.RecordingSelectorDialog(JK.app, recordings, selectedRecordings, callback);
|
|
recordingSelectorDialog.initialize();
|
|
return recordingSelectorDialog.showDialog();
|
|
}
|
|
|
|
this.addSessionLike = addSessionLike;
|
|
this.addRecordingLike = addRecordingLike;
|
|
this.launchCommentDialog = launchCommentDialog;
|
|
this.launchShareDialog = launchShareDialog;
|
|
this.launchRsvpSubmitDialog = launchRsvpSubmitDialog;
|
|
this.launchRsvpCancelDialog = launchRsvpCancelDialog;
|
|
this.launchRsvpCreateSlotDialog = launchRsvpCreateSlotDialog;
|
|
this.launchSessionStartDialog = launchSessionStartDialog;
|
|
this.launchGenreSelectorDialog = launchGenreSelectorDialog;
|
|
this.launchRecordingSelectorDialog = launchRecordingSelectorDialog;
|
|
|
|
return this;
|
|
};
|
|
|
|
})(window,jQuery); |