From a64715beeb48914b1d9cece001267d96c2e0149c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 10 Apr 2012 21:08:31 +0200 Subject: [PATCH] BUGFIX Calling tinyMCE.init() in sync with entwine rules to avoid uncached loading interfereing with call order (fixes #6877) --- admin/javascript/LeftAndMain.Preview.js | 1 + forms/HtmlEditorConfig.php | 1 - javascript/HtmlEditorField.js | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/admin/javascript/LeftAndMain.Preview.js b/admin/javascript/LeftAndMain.Preview.js index 7b641f90a..a19854236 100644 --- a/admin/javascript/LeftAndMain.Preview.js +++ b/admin/javascript/LeftAndMain.Preview.js @@ -129,6 +129,7 @@ _fixIframeLinks: function() { var doc = this.find('iframe')[0].contentDocument; + if(!doc) return; // Block outside links from going anywhere var links = doc.getElementsByTagName('A'); diff --git a/forms/HtmlEditorConfig.php b/forms/HtmlEditorConfig.php index dc72819bb..3162850b3 100644 --- a/forms/HtmlEditorConfig.php +++ b/forms/HtmlEditorConfig.php @@ -308,7 +308,6 @@ class HtmlEditorConfig { if((typeof tinyMCE != 'undefined')) { $externalPluginsJS var ssTinyMceConfig = " . Convert::raw2json($config) . "; - tinyMCE.init(ssTinyMceConfig); } "; } diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index cee0c3559..d282793c2 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -209,8 +209,17 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; } }); - // Only works after TinyMCE.init() has been invoked, see $(window).bind() call below for details. - this.redraw(); + // Using a global config (generated through HTMLEditorConfig PHP logic). + // Depending on browser cache load behaviour, entwine's DOMMaybeChanged + // can be called before the bottom-most inline script tag is executed, + // which defines the global. If that's the case, wait for the window load. + if(typeof ssTinyMceConfig != 'undefined') { + this.redraw(); + } else { + $(window).bind('load', function() { + self.redraw(); + }); + } this._super(); }, @@ -219,6 +228,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; // Using a global config (generated through HTMLEditorConfig PHP logic) var config = ssTinyMceConfig, self = this, ed = this.getEditor(); + tinyMCE.init(config); + // Avoid flicker (also set in CSS to apply as early as possible) self.css('visibility', '');