added unload handler to prevent navigating away when changes exist
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Jan 2007 20:21:53 +0000 (20:21 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Jan 2007 20:21:53 +0000 (20:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6781 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/xul/staff_client/server/patron/ue.js
Evergreen/xul/staff_client/server/patron/ue.xhtml

index 68e4c9e..fd8c9a3 100644 (file)
@@ -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) {
index 40cff81..a0ead4c 100644 (file)
                        Are you sure you wish to perform this action?
                </span>
 
+      <span class='hide_me' id='ue_unsaved_changes'>
+         You have unsaved changes. 
+      </span>
+
        </div>
 
        </body>