All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 26a5fa07 authored by Jonathon Duerig's avatar Jonathon Duerig

Add beforeunload event handlers for use in tutorial pages.

If the portal pages are wrapped in an iframe, they notify the outer page as the user navigates around the portal. They also notify the outer page when the user navigates away from the portal.
parent 3b30c14c
......@@ -171,14 +171,15 @@ $(function () {
});
// Warn user if they have not saved changes.
window.onbeforeunload = function() {
$(window).on('beforeunload.portal',
function() {
if (! form_modified)
return null;
return undefined;
return "You have unsaved changes!";
}
});
}
function DisableUnsavedWarning(form) {
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
}
function MarkFormUnsaved() {
form_modified = true;
......
......@@ -101,6 +101,8 @@ window.APT_OPTIONS.initialize = function (sup)
return false;
});
}
window.APT_OPTIONS.startPage();
$(window).on('beforeunload.common', APT_OPTIONS.endPage);
$('body').show();
};
......@@ -178,3 +180,15 @@ window.APT_OPTIONS.fetchTemplateList = function (nameList) {
}
return result;
};
window.APT_OPTIONS.startPage = function () {
if (window.parent) {
window.parent.postMessage({ url: window.location.href}, '*')
}
}
window.APT_OPTIONS.endPage = function () {
if (window.parent) {
window.parent.postMessage({ url: "None"}, '*')
}
}
......@@ -39,7 +39,7 @@ $(function ()
var source = document.getElementById('source').innerHTML;
editor.setValue(atob(source));
editor.selection.clearSelection();
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
$('#waitwait-modal').modal({ backdrop: 'static', keyboard: false, show: false });
sup.DownloadOnClick($('#saveButton'), getSaveText, 'saved.py', saveComplete);
......@@ -88,7 +88,7 @@ $(function ()
{
removeSplit();
}
window.onbeforeunload = beforeUnload;
$(window).on('beforeunload.portal', beforeUnload);
}
function getSaveText()
......@@ -105,7 +105,7 @@ $(function ()
function saveComplete()
{
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
}
function load()
......@@ -122,7 +122,7 @@ $(function ()
var contents = e.target.result;
editor.setValue(contents);
editor.selection.clearSelection();
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
removeSplit();
// jacksInput.trigger('change-topology', [{ rspec: contents }]);
};
......@@ -527,14 +527,14 @@ $(function ()
function submitEdit(event)
{
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
$('#waitwait-modal').modal('show');
return true;
}
function submitCreate(event)
{
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
$('#waitwait-modal').modal('show');
return true;
}
......
......@@ -102,11 +102,11 @@ $(function ()
}
// Warn user if they have not saved changes.
window.onbeforeunload = function() {
$(window).on('beforeunload.portal', function() {
if (! modified)
return null;
return undefined;
return "You have unsaved changes!";
}
});
// Generate the templates.
var manage_html = manageTemplate({
......@@ -425,7 +425,7 @@ $(function ()
return false;
}
// Disable the Stay on Page alert above.
window.onbeforeunload = null;
$(window).off('beforeunload.portal');
WaitWait();
return true;
});
......
......@@ -260,11 +260,11 @@ $(function ()
modified = true;
});
// Warn user if they have not saved changes.
window.onbeforeunload = function() {
$(window).on('beforeunload.portal', function() {
if (! modified)
return null;
return "You have unsaved changes!";
}
});
}
var xmlthing = sup.CallServerMethod(null,
"groups", "MemberList",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment