From aec092c914fb4a78fbc46361839822928694aca4 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Mon, 28 May 2012 06:56:42 +0000 Subject: Patch for #404 --- .../Javascripts/source/prado/controls/htmlarea.js | 69 +++++++++++++++++++--- 1 file changed, 62 insertions(+), 7 deletions(-) (limited to 'framework/Web/Javascripts') diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea.js b/framework/Web/Javascripts/source/prado/controls/htmlarea.js index 595b7928..4cb37c6f 100644 --- a/framework/Web/Javascripts/source/prado/controls/htmlarea.js +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea.js @@ -12,19 +12,14 @@ Prado.WebUI.THtmlArea = Class.create(Prado.WebUI.Control, { initialize: function($super, options) { - options.ID = options.elements; + options.ID = options.EditorOptions.elements; $super(options); }, - onInit : function(options) + onInit : function(options) { - if (typeof(tinyMCE)=='undefined') - throw "TinyMCE libraries must be loaded first"; - this.options = options; - tinyMCE.init(options); - var obj = this; this.ajaxresponder = { onComplete : function(request) @@ -34,6 +29,59 @@ Prado.WebUI.THtmlArea = Class.create(Prado.WebUI.Control, } }; this.registerAjaxHook(); + + this.registerInstance(); + }, + + registerInstance: function() + { + if (typeof tinyMCE_GZ == 'undefined') + { + if (typeof tinyMCE == 'undefined') + { + if (typeof Prado.CallbackRequest != 'undefined') + if (typeof Prado.CallbackRequest.transport != 'undefined') + { + // we're in a callback + // try it again in some time, as tinyMCE is most likely still loading + this.setTimeout(this.registerInstance.bind(this), 50); + return; + } + throw "TinyMCE libraries must be loaded first"; + } + Prado.WebUI.THtmlArea.tinyMCELoadState = 255; + this.initInstance(); + } + else + if (Prado.WebUI.THtmlArea.tinyMCELoadState==255) + this.initInstance(); + else + { + Prado.WebUI.THtmlArea.pendingRegistrations.push(this.options.ID); + if (Prado.WebUI.THtmlArea.tinyMCELoadState==0) + { + Prado.WebUI.THtmlArea.tinyMCELoadState = 1; + tinyMCE_GZ.init( + this.options.CompressionOptions, + this.compressedScriptsLoaded.bind(this) + ); + } + } + }, + + compressedScriptsLoaded: function() + { + Prado.WebUI.THtmlArea.tinyMCELoadState = 255; + tinymce.dom.Event._pageInit(); + var wrapper; + while(Prado.WebUI.THtmlArea.pendingRegistrations.length>0) + if (wrapper = Prado.Registry.get(Prado.WebUI.THtmlArea.pendingRegistrations.pop())) + wrapper.initInstance(); + }, + + initInstance: function() + { + tinyMCE.init(this.options.EditorOptions); }, checkInstance: function() @@ -92,3 +140,10 @@ Prado.WebUI.THtmlArea = Class.create(Prado.WebUI.Control, } }); +Object.extend(Prado.WebUI.THtmlArea, +{ + pendingRegistrations : [], + tinyMCELoadState : 0 +}); + + -- cgit v1.2.3