summaryrefslogtreecommitdiff
path: root/lib/plugins/styler/script.js
blob: 79df8a88b849cad42bb87bed7bf31a770d308ac7 (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
46
47
48
49
/* DOKUWIKI:include_once iris.js */

jQuery(function () {
    // user openend the admin page, set cookie and redirect
    if (jQuery('#plugin__styler').length) {
        DokuCookie.setValue('styler_plugin', 1);
        document.location.href = document.location.href.replace(/do=admin/, '');
    }

    // The Styler Dialog is currently enabled, display it here and apply the preview styles
    if (DokuCookie.getValue('styler_plugin') == 1) {
        // load dialog
        var $dialog = jQuery(document.createElement('div'));
        jQuery('body').append($dialog);
        $dialog.load(
                DOKU_BASE + '/lib/exe/ajax.php',
            {
                'call': 'plugin_styler',
                'id':   JSINFO.id
            },
            function () {
                // load the preview template
                var now = new Date().getTime();
                var $style = jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]');
                $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now);

                // open the dialog
                var $dlg = $dialog.dialog({
                    'title':    LANG.plugins.styler.menu,
                    'width':    500,
                    'height':   500,
                    'top':      50,
                    'position': { 'my': 'left bottom', 'at': 'left bottom', 'of': window },
                    // bring everything back to normal
                    'close':    function (event, ui) {
                        // disable the styler plugin again
                        DokuCookie.setValue('styler_plugin', 0);
                        // reload
                        document.location.reload()
                    }
                });

                jQuery('.styler .color').iris({
                });

            }
        );
    }
});