From f7ed6b050fb9a6381a8c5364046b574ff897fec3 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 14 Sep 2007 19:30:11 +0000 Subject: [PATCH] elofgren: USABILITY: 1. Always use confirmation when calling autoSave, not just for 'Microsoft Internet Explorer' since the new confirm() dialog works in all browsers. 2. Make MainMenu? links call LeftAndMain?_window_unload() to check for unsaved changes before loading new page. Don't register LeftAndMain?_window_unload with window 'beforeunload' event because it cannot stop the page unload and the save check is now done via links (where stopping the unload works). 3. Make external Logo link open in a new window like the Menu-help link to prevent unsaved changes being lost. More info: http://www.elijahlofgren.com/silverstripe/alert-users-when-leaving-tab-with-unsaved-changes/ (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@41798 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/LeftAndMain.js | 16 +++++++++++++--- javascript/LeftAndMain_right.js | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/javascript/LeftAndMain.js b/javascript/LeftAndMain.js index f755d65d..a99bee30 100644 --- a/javascript/LeftAndMain.js +++ b/javascript/LeftAndMain.js @@ -79,6 +79,7 @@ Behaviour.register({ '#MainMenu li' : { onclick : function(event) { + return LeftAndMain_window_unload(); // Confirm if there are unsaved changes window.location.href = this.getElementsByTagName('a')[0].href; Event.stop(event); } @@ -90,6 +91,14 @@ Behaviour.register({ w.focus(); return false; } + }, + + '#Logo' : { + onclick : function() { + var w = window.open(this.getElementsByTagName('a')[0].href); + w.focus(); + return false; + } } }) @@ -166,11 +175,12 @@ function isVisible(el) { LeftAndMain_window_unload = function() { window.exiting = true; // this is used by prototype - if(typeof autoSave == 'function') - autoSave(navigator.appName == "Microsoft Internet Explorer"); + if(typeof autoSave == 'function') { + return autoSave(true); + } } -Event.observe(window, 'beforeunload', LeftAndMain_window_unload); +// Event.observe(window, 'beforeunload', LeftAndMain_window_unload); /** * Unlock the locked status message. diff --git a/javascript/LeftAndMain_right.js b/javascript/LeftAndMain_right.js index 05da26e9..7dcf970b 100755 --- a/javascript/LeftAndMain_right.js +++ b/javascript/LeftAndMain_right.js @@ -410,7 +410,7 @@ function autoSave(confirmation, callAfter) { if(__callAfter) __callAfter(); } else { // Cancel was pressed, stay on the current page - return true; + return false; } } else { options.save();