From 77e1d239494b7863dbec5e8167d61a0ebb56539a Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 25 Nov 2011 09:57:02 +0100 Subject: Fix client-side wiki editing. --- static/js/wiki.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/static/js/wiki.js b/static/js/wiki.js index 4cffdab..c8cf944 100644 --- a/static/js/wiki.js +++ b/static/js/wiki.js @@ -11,29 +11,33 @@ mulk.savePage = function() { type: "POST", dataType: "text", success: function(data) { - mulk.savePage(); - console.log(data); jQuery('#wiki-page-content').html(data); - console.log('Success.'); + console.log('Page saved.'); }, error: function() { - console.log('Error.'); + console.log('Error saving content.'); } }); + $('#wiki-page-content').removeAttr('contenteditable'); }; /* jQuery(function ($) { $('#wiki-page-content').on('blur', function() { - // FIXME: Save. + mulk.savePage(); + document.designMode = 'off'; + }); + $('body').on('click', function() { + mulk.savePage(); document.designMode = 'off'; }); - $('#wiki-page-content').on('focus', function() { + $('#wiki-page-content').on('dblclick', function() { document.designMode = 'on'; }); }); */ + jQuery(function ($) { if (!window.Aloha) { window.Aloha = {}; @@ -73,12 +77,17 @@ jQuery(function ($) { Aloha.ready(function() { var $$ = Aloha.jQuery; $$('#wiki-page-content').aloha(); - var save = function() { - console.log('Saving changes.'); + var editable = Aloha.editables[0]; + editable.disable(); + $('#wiki-page-content').on('blur', function() { mulk.savePage(); - }; - $('#wiki-page-content').on('blur', save); - //$('#wiki-page-content').on('datachanged', save); + editable.disable(); + }); + $('#wiki-page-content').on('focus', function() { + }); + $('#wiki-page-content').dblclick(function() { + editable.enable(); + }); }); }); -- cgit v1.2.3