From 05d82c05693960621a43e05107cb9f4640315376 Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Wed, 7 Nov 2012 17:37:29 -0500 Subject: [PATCH] Attach unsaved changes warning to trigger only after changes are made --- lib/gollum/frontend/public/gollum/javascript/gollum.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index 66733437..a3273ce4 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -214,14 +214,18 @@ $(document).ready(function() { } if( $('#wiki-wrapper.edit').length ){ - window.onbeforeunload = function(){ return "Leaving will discard all edits!" }; $("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } ); + $("#gollum-editor-body").one('change', function(){ + window.onbeforeunload = function(){ return "Leaving will discard all edits!" }; + }); $.GollumEditor(); } if( $('#wiki-wrapper.create').length ){ - window.onbeforeunload = function(){ return "Leaving will not create a new page!" }; $("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } ); + $("#gollum-editor-body").one('change', function(){ + window.onbeforeunload = function(){ return "Leaving will not create a new page!" }; + )}; $.GollumEditor({ NewFile: true, MarkupType: '{{default_markup}}' }); } });