From 1bcb503ef69178ec828e165089b95283a0c840db Mon Sep 17 00:00:00 2001 From: Mr B Date: Mon, 31 Oct 2016 18:00:46 +0000 Subject: [PATCH] Update qm.inc.php If the X in bottom right of colorbox popup is clicked it prompts with a 'Are you sure you want to leave this page?'. But the page cannot be recovered from this point so best option seems to be clear all documentDirty so X cancels cleanly. --- assets/plugins/qm/qm.inc.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/assets/plugins/qm/qm.inc.php b/assets/plugins/qm/qm.inc.php index 538636dc43..5b973f75a9 100755 --- a/assets/plugins/qm/qm.inc.php +++ b/assets/plugins/qm/qm.inc.php @@ -542,7 +542,33 @@ function Run() { $'.$jvar.'("body").css({"overflow":"hidden"}); $'.$jvar.'("html").css({"overflow":"hidden"}); $'.$jvar.'("#qmEditor").css({"display":"none"}); - }); + }); + + $'.$jvar.'(document).bind("cbox_cleanup", function(){ + //window is closing and cannot be stopped so clear dirty settings for all fields and tinyMCE + var foundit; + + //loop through the iframes, checking their scr + iframearray = document.getElementsByTagName(\'iframe\'); + + for(var i=0; i < iframearray.length; i++) { + //if the matching colorbox src, we have found the correct iframe + haystack=iframearray[i].src; + needle="'.$this->modx->config["site_url"]."manager/index.php?a=27".'"; + if(haystack.substr(0, needle.length) == needle){ + foundit=iframearray[i]; //assign it to the foundit variable created earlier + break; //no need to keep looking + } + } + if (foundit) { + foundit.contentWindow.window.documentDirty=false; //clear document dirty for fields + //loop through tinyMCE editors and clear any dirty flags + if (typeof(foundit.contentWindow.window.tinyMCE)!==\'undefined\') { + var i, t = foundit.contentWindow.window.tinyMCE.editors;for (i in t){ + if (t.hasOwnProperty(i)){ t[i].isNotDirty=true }} + } + } + }); $'.$jvar.'(document).bind("cbox_closed", function(){ $'.$jvar.'("body").css({"overflow":"auto"});