diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index e0984de4..a3273ce4 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -212,4 +212,20 @@ $(document).ready(function() { $('#gollum-revert-form').submit(); }); } + + if( $('#wiki-wrapper.edit').length ){ + $("#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 ){ + $("#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}}' }); + } }); diff --git a/lib/gollum/frontend/templates/create.mustache b/lib/gollum/frontend/templates/create.mustache index 40792fac..1d0697bd 100644 --- a/lib/gollum/frontend/templates/create.mustache +++ b/lib/gollum/frontend/templates/create.mustache @@ -1,4 +1,4 @@ -