VRFS-658 warn user when navigating away from session

This commit is contained in:
Brian Smith 2014-02-22 13:43:11 -05:00
parent 51ad34d611
commit a2307e16b7
5 changed files with 89 additions and 6 deletions

View File

@ -451,7 +451,36 @@
return true;
}
function onSessionLeaveWarningAccepted(args) {
changeScreen(args.screen, args.data);
}
function onSessionLeaveWarningDeclined() {
context.location = "/client#/session/" + context.JK.CurrentSessionModel.id();
closeDialog('leave-session-warning');
}
function changeToScreen(screen, data) {
if (screen === currentScreen) {
return;
}
// special case to prompt user if they really want to leave session
if (currentScreen === "session") {
var args = {};
args.screen = screen;
args.data = data;
var leaveSessionWarningDialog = new context.JK.LeaveSessionWarningDialog(context.JK.app, onSessionLeaveWarningAccepted, onSessionLeaveWarningDeclined, args);
leaveSessionWarningDialog.initialize();
showDialog('leave-session-warning');
return;
}
else {
changeScreen(screen, data);
}
}
function changeScreen(screen, data) {
previousScreen = currentScreen;
currentScreen = screen;

View File

@ -0,0 +1,33 @@
(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.LeaveSessionWarningDialog = function(app, acceptCallback, declinedCallback, args) {
var logger = context.JK.logger;
var dialogId = 'leave-session-warning';
var $scopeSelector = "[layout-id='leave-session-warning']";
function events() {
$('#btn-accept', $scopeSelector).click(function(evt) {
if (acceptCallback) {
acceptCallback(args);
}
app.layout.closeDialog(dialogId);
});
$('#btn-cancel', $scopeSelector).click(function(evt) {
if (declinedCallback) {
declinedCallback();
}
});
}
function initialize() {
events();
}
this.initialize = initialize;
};
})(window,jQuery);

View File

@ -98,7 +98,7 @@
16: {"title": "", "message": ""}, // DECODE_VIOLATIONS,
17: {"title": "", "message": ""}, // LAST_THRESHOLD
18: {"title": "", "message": ""}, // WIFI_NETWORK_ALERT, //user or peer is using wifi
19: {"title": "No Audio Configuration", "message": "You cannot join the session because you do not have a valid audio configuration."}, // NO_VALID_AUDIO_CONFIG, // alert the user to popup a config
19: {"title": "No Audio Configuration", "message": "You cannot join the session because you do not have a valid audio configuration."}, // NO_VALID_AUDIO_CONFIG,
20: {"title": "", "message": ""}, // AUDIO_DEVICE_NOT_PRESENT, // the audio device is not connected
21: {"title": "", "message": ""}, // RECORD_PLAYBACK_STATE, // record/playback events have occurred
22: {"title": "", "message": ""}, // RUN_UPDATE_CHECK_BACKGROUND, //this is auto check - do
@ -424,11 +424,10 @@
});
}
function beforeHide(data) {
// track that the screen is inactive, to disable body-level handlers
screenActive = false;
sessionModel.leaveCurrentSession()
.fail(app.ajaxError);
function beforeHide(data) {
screenActive = false;
sessionModel.leaveCurrentSession()
.fail(app.ajaxError);
}
function handleTransitionsInRecordingPlayback() {

View File

@ -0,0 +1,21 @@
<!-- Terms Dialog -->
<div class="dialog" layout="dialog" layout-id="leave-session-warning" style="max-width:550px;">
<div class="content-head">
<%= image_tag "content/icon_alert.png", {:width => 19, :height => 19, :class => 'content-icon' } %>
<h1>Warning</h1>
</div>
<div class="dialog-inner">
<span>
WARNING: This action will result in you leaving this session. You will no longer be
able to transmit or hear audio. Click OK below to proceed.
</span>
<br clear="left" /><br />
<div class="left">
<a id="btn-cancel" layout-action="close" class="button-orange">CANCEL</a>
</div>
<div class="right">
<a id="btn-accept" layout-action="close" class="button-orange">OK</a>
</div>
<br clear="all" />
</div>
</div>

View File

@ -15,6 +15,7 @@
<%= render "vu_meters" %>
<%= render "ftue" %>
<%= render "terms" %>
<%= render "leaveSessionWarning" %>
<%= render "alert" %>
<%= render "sidebar" %>
<%= render "createSession" %>