summaryrefslogtreecommitdiff
path: root/static/js/wiki.js
blob: 49999ca36237c571654001ce37400ac168e2e393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var mulk;

if (!mulk) {
    mulk = {};
}

mulk.savePage = function() {
    jQuery.ajax({
        url: "?save",
        data: { content: $('#wiki-page-content').html() },
        type: "POST",
        dataType: "text",
        success: function(data) {
            jQuery('#wiki-page-content').html(data);
            console.log('Page saved.');
        },
        error: function() {
            console.log('Error saving content.');
        }
    });
};

jQuery(function ($) {
    Aloha.ready(function() {
	var $$ = Aloha.jQuery;

        $('html').click(function() {
            mulk.savePage();
            $$('#wiki-page-content').mahalo();
        });
        $('#wiki-page-content').click(function(event) {
            event.stopPropagation();
        });
        $('.aloha-floatingmenu').click(function(event) {
            event.stopPropagation();
        });
        $('.aloha-sidebar-bar').click(function(event) {
            event.stopPropagation();
        });

        $('#wiki-page-content').click(function() {
            $$('#wiki-page-content').aloha();
        });
    });
});