Skip to content

Commit

Permalink
Fix ckeditor#101: CKEDITOR.domReady fix - check if really readyState …
Browse files Browse the repository at this point in the history
…is complete.
  • Loading branch information
Reinmar committed Jul 4, 2012
1 parent 028abe7 commit 33756e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Compressed version of core/ckeditor_base.js. See original for instructions.
/*jsl:ignore*/
window.CKEDITOR||(window.CKEDITOR=function(){var c={timestamp:"",version:"%VERSION%",revision:"%REV%",rnd:Math.floor(900*Math.random())+100,_:{pending:[]},status:"unloaded",basePath:function(){var a=window.CKEDITOR_BASEPATH||"";if(!a)for(var d=document.getElementsByTagName("script"),b=0;b<d.length;b++){var e=d[b].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(e){a=e[1];break}}-1==a.indexOf(":/")&&(a=0===a.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+a:location.href.match(/^[^\?]*\/(?:)/)[0]+ a);if(!a)throw'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.';return a}(),getUrl:function(a){-1==a.indexOf(":/")&&0!==a.indexOf("/")&&(a=this.basePath+a);this.timestamp&&("/"!=a.charAt(a.length-1)&&!/[&?]t=/.test(a))&&(a+=(0<=a.indexOf("?")?"&":"?")+"t="+this.timestamp);return a},domReady:function(){function a(){try{document.addEventListener?document.removeEventListener("DOMContentLoaded",a, !1):document.attachEvent&&document.detachEvent("onreadystatechange",a)}catch(b){}for(var e;e=d.shift();)e()}var d=[];return function(b){d.push(b);"complete"===document.readyState&&setTimeout(a,1);if(1==d.length)if(document.addEventListener)document.addEventListener("DOMContentLoaded",a,!1),window.addEventListener("load",a,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",a);window.attachEvent("onload",a);b=!1;try{b=!window.frameElement}catch(e){}if(document.documentElement.doScroll&& b){var c=function(){try{document.documentElement.doScroll("left")}catch(b){setTimeout(c,1);return}a()};c()}}}}()},f=window.CKEDITOR_GETURL;if(f){var g=c.url;c.url=function(a){return f.call(c,a)||g.call(c,a)}}return c}());
window.CKEDITOR||(window.CKEDITOR=function(){var b={timestamp:"",version:"%VERSION%",revision:"%REV%",rnd:Math.floor(900*Math.random())+100,_:{pending:[]},status:"unloaded",basePath:function(){var a=window.CKEDITOR_BASEPATH||"";if(!a)for(var b=document.getElementsByTagName("script"),c=0;c<b.length;c++){var d=b[c].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(d){a=d[1];break}}-1==a.indexOf(":/")&&(a=0===a.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+a:location.href.match(/^[^\?]*\/(?:)/)[0]+a);if(!a)throw'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.';return a}(),getUrl:function(a){-1==a.indexOf(":/")&&0!==a.indexOf("/")&&(a=this.basePath+a);this.timestamp&&("/"!=a.charAt(a.length-1)&&!/[&?]t=/.test(a))&&(a+=(0<=a.indexOf("?")?"&":"?")+"t="+this.timestamp);return a},domReady:function(){function a(){try{document.addEventListener?(document.removeEventListener("DOMContentLoaded",a,!1),b()):document.attachEvent&&"complete"===document.readyState&&(document.detachEvent("onreadystatechange",a),b())}catch(d){}}function b(){for(var a;a=c.shift();)a()}var c=[];return function(b){c.push(b);"complete"===document.readyState&&setTimeout(a,1);if(1==c.length)if(document.addEventListener)document.addEventListener("DOMContentLoaded",a,!1),window.addEventListener("load",a,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",a);window.attachEvent("onload",a);b=!1;try{b=!window.frameElement}catch(e){}if(document.documentElement.doScroll&&b){var f=function(){try{document.documentElement.doScroll("left")}catch(b){setTimeout(f,1);return}a()};f()}}}}()},e=window.CKEDITOR_GETURL;if(e){var g=b.url;b.url=function(a){return e.call(b,a)||g.call(b,a)}}return b}());
/*jsl:end*/

if ( CKEDITOR.loader )
Expand Down
14 changes: 10 additions & 4 deletions core/ckeditor_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ if ( !window.CKEDITOR ) {
*/
window.CKEDITOR = (function() {
var CKEDITOR =
/** @lends CKEDITOR */
{
/** @lends CKEDITOR */ {

/**
* A constant string unique for each release of CKEditor. Its value
Expand Down Expand Up @@ -202,12 +201,19 @@ if ( !window.CKEDITOR ) {
function onReady() {
try {
// Cleanup functions for the document ready method
if ( document.addEventListener )
if ( document.addEventListener ) {
document.removeEventListener( 'DOMContentLoaded', onReady, false );
else if ( document.attachEvent )
executeCallbacks();
}
// Make sure body exists, at least, in case IE gets a little overzealous.
else if ( document.attachEvent && document.readyState === 'complete' ) {
document.detachEvent( 'onreadystatechange', onReady );
executeCallbacks();
}
} catch ( er ) {}
}

function executeCallbacks() {
var i;
while ( ( i = callbacks.shift() ) )
i();
Expand Down

0 comments on commit 33756e5

Please sign in to comment.