@uxello is that what’s going on here: http://modxcms.com/forums/index.php/topic,60277.0.html
I have another suggestion for you Mikko ;-)
When modifiying the resource content as a richtext field (TinyMCE) and then cancelling it brings up a ’Are you sure you want to navigate away...’ message from the TinyMCE autosave feature. But this is too late as the window is already closing. Also a modified standard text field change is not trapped due to the documentDirty=false statement in the cancel button.
I worked around these issues by checking the TinyMCE dirty status in the onclick javascript. Thus the save and cancel buttons at around line 700ish of qm.inc.php could become:
// Add action buttons --- uxello fix nav away messages $mc->addLine('var controls = "<div style=\"padding:4px 0;position:fixed;top:10px;right:-10px;z-index:1000\" id=\"qmcontrols\" class=\"actionButtons\"><ul><li><a href=\"#\" onclick=\"documentDirty=false;document.mutate.save.click();return false;\"><img src=\"media/style/'.$qm_theme.'/images/icons/save.png\" />'.$_lang['save'].'</a></li><li><a href=\"#\" onclick=\" alertcancel=documentDirty; if (typeof(tinyMCE)!==\'undefined\') {var i, t = tinyMCE.editors;for (i in t){ if (t.hasOwnProperty(i)){ if (t[i].isDirty() ) alertcancel =true; }}} continuecancel=true; if (alertcancel) {continuecancel = confirm(\'Document has been modified. Continue cancel (changes will be lost)?\');} if (continuecancel) { documentDirty=false; if (typeof(tinyMCE)!==\'undefined\') { var i, t = tinyMCE.editors;for (i in t){ if (t.hasOwnProperty(i)){ t[i].isNotDirty=true }} } parent.'.$jq_mode.'.fn.colorbox.close();} return false;\"><img src=\"media/style/'.$qm_theme.'/images/icons/stop.png\"/>'.$_lang['cancel'].'</a></li></ul></div>";');
The code is a bit of a mess at the moment but it works ok for one TinyMCE editor in the resource. I have not figured out how to account for having a richtext TV. If you change the text in another TinyMCE instance then switch to one that has not been altered and cancel then it does not work... also no language config for the confirm so only 90% there.
Of course if you are not using TinyMCE as the rich text editor it does not help!
UPDATE: Now got it working for multiple TinyMCE instances.
I’ll add this to todo list. Thanks again Uxello, your suggestions are always welcome!
Quote from: uxello at Feb 07, 2011, 10:22 AM
I have another suggestion for you Mikko ;-)
When modifiying the resource content as a richtext field (TinyMCE) and then cancelling it brings up a ’Are you sure you want to navigate away...’ message from the TinyMCE autosave feature. But this is too late as the window is already closing. Also a modified standard text field change is not trapped due to the documentDirty=false statement in the cancel button.
I worked around these issues by checking the TinyMCE dirty status in the onclick javascript. Thus the save and cancel buttons at around line 700ish of qm.inc.php could become:
// Add action buttons --- uxello fix nav away messages $mc->addLine('var controls = "<div style=\"padding:4px 0;position:fixed;top:10px;right:-10px;z-index:1000\" id=\"qmcontrols\" class=\"actionButtons\"><ul><li><a href=\"#\" onclick=\"documentDirty=false;document.mutate.save.click();return false;\"><img src=\"media/style/'.$qm_theme.'/images/icons/save.png\" />'.$_lang['save'].'</a></li><li><a href=\"#\" onclick=\" alertcancel=documentDirty; if (typeof(tinyMCE)!==\'undefined\') {var i, t = tinyMCE.editors;for (i in t){ if (t.hasOwnProperty(i)){ if (t[i].isDirty() ) alertcancel =true; }}} continuecancel=true; if (alertcancel) {continuecancel = confirm(\'Document has been modified. Continue cancel (changes will be lost)?\');} if (continuecancel) { documentDirty=false; if (typeof(tinyMCE)!==\'undefined\') { var i, t = tinyMCE.editors;for (i in t){ if (t.hasOwnProperty(i)){ t[i].isNotDirty=true }} } parent.'.$jq_mode.'.fn.colorbox.close();} return false;\"><img src=\"media/style/'.$qm_theme.'/images/icons/stop.png\"/>'.$_lang['cancel'].'</a></li></ul></div>";');
The code is a bit of a mess at the moment but it works ok for one TinyMCE editor in the resource. I have not figured out how to account for having a richtext TV. If you change the text in another TinyMCE instance then switch to one that has not been altered and cancel then it does not work... also no language config for the confirm so only 90% there.
Of course if you are not using TinyMCE as the rich text editor it does not help!
UPDATE: Now got it working for multiple TinyMCE instances.
That sure looks like a intimidating line of codeI’ll add this to todo list. Thanks again Uxello, your suggestions are always welcome!
Hi again Mikko, I have reworked my code and also made it take account of clicking the close (cross) in the bottom right of the colorbox to clear any doc diry settings as it cannot be trapped by that stage (using cbox_cleanup binding). Modified file attached. Seach for ’uxello’ comments to find the changes. Hope it might be useful for you.