xref: /dokuwiki/lib/plugins/styling/script.js (revision 3e2beab52631135f77d0ad5b6ed297458bfff2f2)
1/* DOKUWIKI:include_once iris.js */
2
3jQuery(function () {
4
5    var $styling_plugin = jQuery('#plugin__styling');
6    if (!$styling_plugin.length) return;
7
8
9    if (!$styling_plugin.hasClass('ispopup')) {
10        var $hl = $styling_plugin.find('h1').first();
11        var $btn = jQuery('<button class="btn">' + LANG.plugins.styling.popup + '</button>');
12        $hl.append($btn);
13
14        $btn.click(function (e) {
15            var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=false,width=500,height=500";
16            window.open(DOKU_BASE + 'lib/plugins/styling/popup.php', 'styling', windowFeatures)
17        });
18        return;
19    }
20
21    // add the color picker
22    $styling_plugin.find('.color').iris({});
23
24    // append the loader screen
25    $loader = window.opener.jQuery('#plugin__styling_loader');
26    if (!$loader.length) {
27        $loader = jQuery('<div id="plugin__styling_loader">' + LANG.plugins.styling.loader + '</div>');
28        $loader.css({
29            'position':         'absolute',
30            'width':            '100%',
31            'height':           '100%',
32            'top':              0,
33            'left':             0,
34            'z-index':          5000,
35            'background-color': '#fff',
36            'opacity':          '0.7',
37            'color':            '#000',
38            'font-size':        '40px',
39            'text-align':       'center',
40            'line-height':      '90px'
41        });
42        window.opener.jQuery('body').append($loader);
43    }
44
45    // load preview in main window
46    var now = new Date().getTime();
47    var $style = window.opener.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]');
48    $style.attr('href', '');
49    $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now);
50
51
52});
53