From 76c8d3206c64589c16c22fea6f9f93faa1f7022a Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Wed, 7 Nov 2012 17:34:42 -0500 Subject: [PATCH] Consolidated create and edit page's javascript into the global gollum.js --- .../frontend/public/gollum/javascript/gollum.js | 12 ++++++++++++ lib/gollum/frontend/templates/create.mustache | 10 +--------- lib/gollum/frontend/templates/edit.mustache | 8 -------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index e0984de4..66733437 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -212,4 +212,16 @@ $(document).ready(function() { $('#gollum-revert-form').submit(); }); } + + if( $('#wiki-wrapper.edit').length ){ + window.onbeforeunload = function(){ return "Leaving will discard all edits!" }; + $("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } ); + $.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; } ); + $.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 @@ -
+
@@ -8,13 +8,5 @@
- {{something}} diff --git a/lib/gollum/frontend/templates/edit.mustache b/lib/gollum/frontend/templates/edit.mustache index 5063fab0..bccf1584 100644 --- a/lib/gollum/frontend/templates/edit.mustache +++ b/lib/gollum/frontend/templates/edit.mustache @@ -10,11 +10,3 @@
{{>editor}}
-