From 8a45c65b35387631daefc64e74d2c4e4f48e586f Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 24 Nov 2011 15:34:06 +0100 Subject: Refactor the JavaScript code. --- static/js/wiki.js | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'static') diff --git a/static/js/wiki.js b/static/js/wiki.js index 3f61456..4f13af3 100644 --- a/static/js/wiki.js +++ b/static/js/wiki.js @@ -1,3 +1,24 @@ +var mulk; + +if (!mulk) { + mulk = {}; +} + +mulk.savePage = function() { + $.ajax({ + url: "?save", + data: { content: $('#wiki-page-content').html() }, + type: "POST", + success: function() { + mulk.savePage(); + console.log('Success.'); + }, + error: function() { + console.log('Error.'); + } + }); +}; + /* jQuery(function ($) { $('#wiki-page-content').on('blur', function() { @@ -10,7 +31,6 @@ jQuery(function ($) { }); */ - jQuery(function ($) { if (!window.Aloha) { window.Aloha = {}; @@ -18,7 +38,7 @@ jQuery(function ($) { window.Aloha.settings = { logLevels: {'error': true, 'warn': true, 'info': true, 'debug': false}, errorhandling : false, - ribbon: true, + ribbon: false, "i18n": { "current": "de" @@ -52,19 +72,10 @@ jQuery(function ($) { $$('#wiki-page-content').aloha(); var save = function() { console.log('Saving changes.'); - $.ajax({ - url: "?save", - data: { content: $('#wiki-page-content').html() }, - type: "POST", - success: function() { - console.log('Success.'); - }, - error: function() { - console.log('Error.'); - } - }); + mulk.savePage(); }; $('#wiki-page-content').on('blur', save); //$('#wiki-page-content').on('datachanged', save); }); }); + -- cgit v1.2.3