changeset 2406:291f5510d650

adds alert before unload on changing textareas (editor)
author sharky93 <rishabhr123@gmail.com>
date Wed, 21 Aug 2013 23:54:00 +0530
parents 8b7cb57279b8
children b5c19850f8fd
files MoinMoin/templates/basic.js
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/basic.js	Wed Aug 21 19:33:24 2013 +0530
+++ b/MoinMoin/templates/basic.js	Wed Aug 21 23:54:00 2013 +0530
@@ -1,5 +1,15 @@
 $(document).ready(function (){
     // this depends on the id's used for different tab-panes in modify.html (Basic Theme)
+    var edit = false;
     $('#meta, #help').removeClass('active');
     $('textarea').autosize();
+    $('textarea').change(function() {
+    	edit = true;
+    })
+    window.onbeforeunload = function(e) {
+    	if (edit) {
+    		edit = false;
+    		return "You have unsaved changes!";
+    	}
+    }
 });