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
This commit is contained in:
Ingo Schommer 2007-09-14 19:30:11 +00:00
parent b1173b174b
commit f7ed6b050f
2 changed files with 14 additions and 4 deletions

View File

@ -79,6 +79,7 @@ Behaviour.register({
'#MainMenu li' : { '#MainMenu li' : {
onclick : function(event) { onclick : function(event) {
return LeftAndMain_window_unload(); // Confirm if there are unsaved changes
window.location.href = this.getElementsByTagName('a')[0].href; window.location.href = this.getElementsByTagName('a')[0].href;
Event.stop(event); Event.stop(event);
} }
@ -90,6 +91,14 @@ Behaviour.register({
w.focus(); w.focus();
return false; 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() { LeftAndMain_window_unload = function() {
window.exiting = true; // this is used by prototype window.exiting = true; // this is used by prototype
if(typeof autoSave == 'function') if(typeof autoSave == 'function') {
autoSave(navigator.appName == "Microsoft Internet Explorer"); return autoSave(true);
}
} }
Event.observe(window, 'beforeunload', LeftAndMain_window_unload); // Event.observe(window, 'beforeunload', LeftAndMain_window_unload);
/** /**
* Unlock the locked status message. * Unlock the locked status message.

View File

@ -410,7 +410,7 @@ function autoSave(confirmation, callAfter) {
if(__callAfter) __callAfter(); if(__callAfter) __callAfter();
} else { } else {
// Cancel was pressed, stay on the current page // Cancel was pressed, stay on the current page
return true; return false;
} }
} else { } else {
options.save(); options.save();