From: erickson Date: Wed, 17 Jan 2007 20:21:53 +0000 (+0000) Subject: added unload handler to prevent navigating away when changes exist X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f23b578537064e8aa728aa11da9a0ea6d96a3225;p=Evergreen.git added unload handler to prevent navigating away when changes exist git-svn-id: svn://svn.open-ils.org/ILS/trunk@6781 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Evergreen/xul/staff_client/server/patron/ue.js b/Evergreen/xul/staff_client/server/patron/ue.js index 68e4c9e59f..fd8c9a3de9 100644 --- a/Evergreen/xul/staff_client/server/patron/ue.js +++ b/Evergreen/xul/staff_client/server/patron/ue.js @@ -12,7 +12,6 @@ var groupsCache = {}; var netLevelsCache = {}; //var guardianNote = null; - /* fetch the necessary data to start off */ function uEditInit() { @@ -28,6 +27,26 @@ function uEditInit() { setTimeout( function() { uEditBuild(); uEditShowPage('uedit_userid'); }, 20 ); + + /* + window.onunload = function() { + if( ! confirm($('ue_unsaved_changes').innerHTML) ) + location.href = location.href; + } + */ + + +} + +function uEditSetUnload() { + window.onbeforeunload = function(evt) { + //evt.returnValue = ('ue_unsaved_changes').innerHTML; + return $('ue_unsaved_changes').innerHTML; + }; +} + +function uEditClearUnload() { + window.onbeforeunload = null; } /* ------------------------------------------------------------------------------ */ @@ -341,6 +360,8 @@ function uEditOnChange(field) { uEditIterateFields(function(f) { uEditCheckValid(f); }); uEditCheckErrors(); + + uEditSetUnload(); } @@ -479,6 +500,8 @@ function uEditSaveUser(cloneme) { req.send(true); var newuser = req.result(); + uEditClearUnload(); + var evt; if( (evt = checkILSEvent(newuser)) || ! newuser ) { if(evt) { diff --git a/Evergreen/xul/staff_client/server/patron/ue.xhtml b/Evergreen/xul/staff_client/server/patron/ue.xhtml index 40cff81987..a0ead4cd3b 100644 --- a/Evergreen/xul/staff_client/server/patron/ue.xhtml +++ b/Evergreen/xul/staff_client/server/patron/ue.xhtml @@ -1003,6 +1003,10 @@ Are you sure you wish to perform this action? + + You have unsaved changes. + +