From 9b1d5e260aab6f691fa3e2b39704334364a53fa3 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 20 Nov 2011 16:17:57 +0100 Subject: Make Wiki editable. --- static/js/wiki.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 static/js/wiki.js (limited to 'static') diff --git a/static/js/wiki.js b/static/js/wiki.js new file mode 100644 index 0000000..3f61456 --- /dev/null +++ b/static/js/wiki.js @@ -0,0 +1,70 @@ +/* +jQuery(function ($) { + $('#wiki-page-content').on('blur', function() { + // FIXME: Save. + document.designMode = 'off'; + }); + $('#wiki-page-content').on('focus', function() { + document.designMode = 'on'; + }); +}); +*/ + + +jQuery(function ($) { + if (!window.Aloha) { + window.Aloha = {}; + } + window.Aloha.settings = { + logLevels: {'error': true, 'warn': true, 'info': true, 'debug': false}, + errorhandling : false, + ribbon: true, + + "i18n": { + "current": "de" + }, + "repositories": { + }, + "plugins": { + "format": { + config : [ 'b', 'i','sub','sup'], + editables : { + '#title' : [ ], + 'div' : [ 'b', 'i', 'del', 'sub', 'sup' ], + '.article' : [ 'b', 'i', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat'] + } + }, + "list": { + }, + "link": { + config : [ 'a' ], + }, + "table": { + config : [ ], + }, + "image": { + } + } + }; + + Aloha.ready(function() { + var $$ = Aloha.jQuery; + $$('#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.'); + } + }); + }; + $('#wiki-page-content').on('blur', save); + //$('#wiki-page-content').on('datachanged', save); + }); +}); -- cgit v1.2.3