70 lines
2.4 KiB
JavaScript
70 lines
2.4 KiB
JavaScript
(function(context,$) {
|
|
|
|
"use strict";
|
|
|
|
context.JK = context.JK || {};
|
|
context.JK.RateSessionDialog = function(app, finishedCallback) {
|
|
var logger = context.JK.logger;
|
|
var dialogId = 'rate-session-dialog';
|
|
var $scopeSelector = "[layout-id='rate-session-dialog']";
|
|
|
|
function showDialog() {
|
|
app.layout.showDialog(dialogId);
|
|
return true; // false if should not show dialog
|
|
}
|
|
|
|
function closeDialog() {
|
|
app.layout.closeDialog(dialogId);
|
|
if (finishedCallback) {
|
|
setTimeout(finishedCallback, 100);
|
|
}
|
|
}
|
|
|
|
function events() {
|
|
$('#btn-rate-session-cancel', $scopeSelector).click(function(evt) {
|
|
closeDialog();
|
|
});
|
|
$('#btn-rate-session-up', $scopeSelector).click(function(evt) {
|
|
$(this).hasClass('selected') ? $(this).removeClass('selected') : $(this).addClass('selected');
|
|
if ($('#btn-rate-session-down').hasClass('selected')) {
|
|
$('#btn-rate-session-down').removeClass('selected')
|
|
}
|
|
});
|
|
$('#btn-rate-session-down', $scopeSelector).click(function(evt) {
|
|
$(this).hasClass('selected') ? $(this).removeClass('selected') : $(this).addClass('selected');
|
|
if ($('#btn-rate-session-up').hasClass('selected')) {
|
|
$('#btn-rate-session-up').removeClass('selected')
|
|
}
|
|
});
|
|
$('#btn-rate-session-send', $scopeSelector).click(function(evt) {
|
|
var url = "/api/participant_histories/"+context.JK.JamServer.clientID+"/rating";
|
|
$.ajax({
|
|
type: "POST",
|
|
url: url
|
|
}).done(function (response) {
|
|
closeDialog();
|
|
});
|
|
});
|
|
}
|
|
|
|
function beforeShow(data) {
|
|
// confirm user should see dialog
|
|
}
|
|
|
|
function afterShow(data) {
|
|
}
|
|
|
|
function initialize() {
|
|
var dialogBindings = {
|
|
'beforeShow' : beforeShow,
|
|
'afterShow' : afterShow
|
|
};
|
|
app.bindDialog(dialogId, dialogBindings);
|
|
events();
|
|
}
|
|
|
|
this.initialize = initialize;
|
|
this.showDialog = showDialog;
|
|
};
|
|
})(window,jQuery);
|