diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index acbb37c77..2788ecfdb 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -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; diff --git a/web/app/assets/javascripts/leaveSessionWarning.js b/web/app/assets/javascripts/leaveSessionWarning.js new file mode 100644 index 000000000..e7ec15f5a --- /dev/null +++ b/web/app/assets/javascripts/leaveSessionWarning.js @@ -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); diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index 98a0f9440..37043dabf 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -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() { diff --git a/web/app/views/clients/_leaveSessionWarning.html.erb b/web/app/views/clients/_leaveSessionWarning.html.erb new file mode 100644 index 000000000..cdb5c2ee4 --- /dev/null +++ b/web/app/views/clients/_leaveSessionWarning.html.erb @@ -0,0 +1,21 @@ + +
+
+ <%= image_tag "content/icon_alert.png", {:width => 19, :height => 19, :class => 'content-icon' } %> +

Warning

+
+
+ + 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. + +

+
+ CANCEL +
+
+ OK +
+
+
+
\ No newline at end of file diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index 99ecbb825..869d84c16 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -15,6 +15,7 @@ <%= render "vu_meters" %> <%= render "ftue" %> <%= render "terms" %> +<%= render "leaveSessionWarning" %> <%= render "alert" %> <%= render "sidebar" %> <%= render "createSession" %>