From c2f2dedb56cd3872aa50d58de0cb3083b36b7872 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 26 Jun 2015 14:04:20 +0200 Subject: reset page back to normal on closing dialog --- lib/plugins/styling/script.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'lib/plugins/styling/script.js') diff --git a/lib/plugins/styling/script.js b/lib/plugins/styling/script.js index 409148471..6fc2b9043 100644 --- a/lib/plugins/styling/script.js +++ b/lib/plugins/styling/script.js @@ -2,12 +2,15 @@ jQuery(function () { + var doreload = 1; + var $styling_plugin = jQuery('#plugin__styling'); if (!$styling_plugin.length) return; // add the color picker $styling_plugin.find('.color').iris({}); + // add button on main page if (!$styling_plugin.hasClass('ispopup')) { var $hl = $styling_plugin.find('h1').first(); var $btn = jQuery(''); @@ -20,6 +23,23 @@ jQuery(function () { return; } + // reload the main page on close + window.onunload = function(e) { + if(doreload) { + window.opener.document.location.reload(); + } + return null; + }; + + // don't reload on our own buttons + jQuery('input[type=submit]').click(function(e){ + doreload = false; + }); + + // remove style + var $style = window.opener.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]'); + $style.attr('href', ''); + // append the loader screen $loader = window.opener.jQuery('#plugin__styling_loader'); if (!$loader.length) { @@ -41,8 +61,11 @@ jQuery(function () { window.opener.jQuery('body').append($loader); } - // load preview in main window - var now = new Date().getTime(); - var $style = window.opener.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]'); - $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now); + // load preview in main window (timeout works around chrome updating CSS weirdness) + window.setTimeout(function() { + var now = new Date().getTime(); + $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now); + }, 500); + + }); -- cgit v1.2.3