1/* DOKUWIKI:include_once iris.js */ 2 3jQuery(function () { 4 5 var doreload = 1; 6 7 var $styling_plugin = jQuery('#plugin__styling'); 8 if (!$styling_plugin.length) return; 9 10 // add the color picker 11 $styling_plugin.find('.color').iris({}); 12 13 // add button on main page 14 if (!$styling_plugin.hasClass('ispopup')) { 15 var $hl = $styling_plugin.find('h1').first(); 16 var $btn = jQuery('<button class="btn">' + LANG.plugins.styling.popup + '</button>'); 17 $hl.append($btn); 18 19 $btn.click(function (e) { 20 var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=false,width=500,height=500"; 21 window.open(DOKU_BASE + 'lib/plugins/styling/popup.php', 'styling', windowFeatures) 22 }); 23 return; 24 } 25 26 // reload the main page on close 27 window.onunload = function(e) { 28 if(doreload) { 29 window.opener.document.location.reload(); 30 } 31 return null; 32 }; 33 34 // don't reload on our own buttons 35 jQuery('input[type=submit]').click(function(e){ 36 doreload = false; 37 }); 38 39 // remove style 40 var $style = window.opener.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]'); 41 $style.attr('href', ''); 42 43 // append the loader screen 44 $loader = window.opener.jQuery('#plugin__styling_loader'); 45 if (!$loader.length) { 46 $loader = jQuery('<div id="plugin__styling_loader">' + LANG.plugins.styling.loader + '</div>'); 47 $loader.css({ 48 'position': 'absolute', 49 'width': '100%', 50 'height': '100%', 51 'top': 0, 52 'left': 0, 53 'z-index': 5000, 54 'background-color': '#fff', 55 'opacity': '0.7', 56 'color': '#000', 57 'font-size': '40px', 58 'text-align': 'center', 59 'line-height': '90px' 60 }); 61 window.opener.jQuery('body').append($loader); 62 } 63 64 // load preview in main window (timeout works around chrome updating CSS weirdness) 65 window.setTimeout(function() { 66 var now = new Date().getTime(); 67 $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now); 68 }, 500); 69 70 71}); 72