summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-11-25 09:57:02 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-11-25 09:57:02 +0100
commit77e1d239494b7863dbec5e8167d61a0ebb56539a (patch)
tree282bbe4eb05c3f7e8d298a5d7daf7c31224be0cc /static
parentbbbd0b954ef5c564bb7cdfc675b335c86d435e16 (diff)
Fix client-side wiki editing.
Diffstat (limited to 'static')
-rw-r--r--static/js/wiki.js31
1 files 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();
+ });
});
});