aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/styling/script.js
diff options
context:
space:
mode:
authorPhy <git@phy25.com>2019-06-17 18:50:05 -0400
committerPhy <git@phy25.com>2019-06-17 18:50:05 -0400
commitd344c074e95d6ea7784b2a6ab7afb25da0400438 (patch)
tree4d26c298fc26b2912edf2ba1e4e27aefc8931988 /lib/plugins/styling/script.js
parent71519303f461d6b95d93b8f55dc8d57e7febd3e2 (diff)
downloaddokuwiki-d344c074e95d6ea7784b2a6ab7afb25da0400438.tar.gz
dokuwiki-d344c074e95d6ea7784b2a6ab7afb25da0400438.zip
Cleanup styling cookie properly to exit preview
This is inspired by https://forum.dokuwiki.org/thread/14395 and should fix the problem described there (I did a local test which seems to work). Previously styling cookie depends on `window.opener`. Since the popup should be on the same domain as the opener, and the popup's cookie domain is the same as the opener (DokuCookie is used), there is no need to rely on the opener to set the preview cookie. This change will ensure the preview cookie is cleared before the popup is closed, regardless of whether opener exists or not. Also checks on whether opener exists are added as well.
Diffstat (limited to 'lib/plugins/styling/script.js')
-rw-r--r--lib/plugins/styling/script.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/plugins/styling/script.js b/lib/plugins/styling/script.js
index 074c8dc40..3859190c7 100644
--- a/lib/plugins/styling/script.js
+++ b/lib/plugins/styling/script.js
@@ -78,8 +78,8 @@ jQuery(function () {
// reload the main page on close
window.onunload = function(e) {
if(doreload) {
- window.opener.DokuCookie.setValue('styling_plugin', 0);
- window.opener.document.location.reload();
+ DokuCookie.setValue('styling_plugin', 0);
+ if(window.opener) window.opener.document.location.reload();
}
return null;
};
@@ -90,8 +90,8 @@ jQuery(function () {
});
// on first load apply preview
- applyPreview(window.opener);
+ if(window.opener) applyPreview(window.opener);
// enable the preview cookie
- window.opener.DokuCookie.setValue('styling_plugin', 1);
+ DokuCookie.setValue('styling_plugin', 1);
});