From 93ae866e605d0bdfc044acb489c8ae9c3bde43a1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 14 Sep 2007 19:30:54 +0000 Subject: [PATCH] elofgren: USABILITY: Make Newsletter section use new js confirm dialog instead of old modal one. 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@41799 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/NewsletterAdmin_right.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/javascript/NewsletterAdmin_right.js b/javascript/NewsletterAdmin_right.js index 1f73cdef..ad236184 100755 --- a/javascript/NewsletterAdmin_right.js +++ b/javascript/NewsletterAdmin_right.js @@ -488,6 +488,8 @@ function autoSave(confirmation, callAfter) { }); if(__somethingHasChanged) { + // Note: discard and cancel options are no longer used since switching to confirm dialog. + // save is still used if confirmation = false var options = { save: function() { statusMessage('saving...', '', true); @@ -507,8 +509,18 @@ function autoSave(confirmation, callAfter) { } } - if(confirmation) doYouWantToSave(options); - else options.save(); + if(confirmation ) { + if(confirm("Are you sure you want to navigate away from this page?\n\nWARNING: Your changes have not been saved.\n\nPress OK to continue, or Cancel to stay on the current page.")) + { + // OK was pressed, call function for what was clicked on + if(__callAfter) __callAfter(); + } else { + // Cancel was pressed, stay on the current page + return false; + } + } else { + options.save(); + } } else { if(__callAfter) __callAfter();