Changeset 32060
- Timestamp:
- 2017-11-06T18:17:26+13:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts_util.js
r31909 r32060 20 20 var _metadataSetList = new Array(); 21 21 22 23 // If the user is attempting to leave the page, check if there are unsaved changes 24 // and if so, display an "Are you sure you want to leave" message. 25 // https://stackoverflow.com/questions/7080269/javascript-before-leaving-the-page 26 // Newer versions of Firefox/Chrome don't display custom message (security feature): 27 // https://stackoverflow.com/questions/22776544/why-is-jquery-onbeforeunload-not-working-in-chrome-and-firefox 28 // and http://jsfiddle.net/XZAWS/ 29 // jquery bind() is deprecated: https://stackoverflow.com/questions/33654716/is-jquery-bind-deprecated 30 $(window).on("beforeunload", function(event) { 31 if(gs.cgiParams.docEdit == "1") { // like document.xsl, which checks the same var upon onload 32 // shouldn't check for whether changes are saved unless on Doc Editing page (DocEdit=1) 33 // else the following pop up always ends up appearing when attempting 34 // to leave a doc view page in Doc Editing Mode (when not yet actually Doc Editing) 35 var changes = changesToUpdate(); 36 37 if(changes.length > 0) { 38 return "The collection hasn't yet been saved after editing. Are you sure you want to leave?"; 39 } 40 41 } 42 43 }); 44 45 22 46 function encodeDelimiters(meta_value) { 23 47 … … 218 242 var collectionsArray = new Array(); 219 243 collectionsArray.push(collection); 220 buildCollections(collectionsArray); 221 } 244 buildCollections(collectionsArray, null, reloadUponRebuild); // passing in callback to reload the page after build, as requested by Kathy 245 } 246 247 248 function reloadUponRebuild() { 249 // finished rebuilding - reload the page after rebuild, but first 250 // clear transactions array of saved changes, now that we're done processing these changes during rebuild, 251 // since we don't want the "are you sure to leave page" popup which appears on _transactions array being non-empty 252 _transactions = null; 253 location.reload(true); // force reload, not from cache, https://www.w3schools.com/jsref/met_loc_reload.asp 254 } 255 222 256 223 257 function saveAndRebuild(rebuild) … … 276 310 } 277 311 if (rebuild) { 278 buildCollections(_collectionsToBuild);312 buildCollections(_collectionsToBuild, null, reloadUponRebuild); 279 313 } else { 280 314 // reset the save button here 281 enableSaveButtons(true); 315 enableSaveButtons(true); 316 // saving to archives is now done, clear the transactions 317 // that were keeping track of the full text changes that have now 318 // been performed to archives (no member var keeps track of meta changes, only a local var) 319 _transactions = new Array(); 282 320 } 283 321 }
Note:
See TracChangeset
for help on using the changeset viewer.