http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72114
Revision: 72114
Author: dale
Date: 2010-09-01 16:26:18 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
fixed buggy waitForJqueryUpgrade in mediaWiki remote
Modified Paths:
--------------
branches/MwEmbedStandAlone/remotes/mediaWiki.js
Modified: branches/MwEmbedStandAlone/remotes/mediaWiki.js
===================================================================
--- branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-09-01 16:16:30 UTC
(rev 72113)
+++ branches/MwEmbedStandAlone/remotes/mediaWiki.js 2010-09-01 16:26:18 UTC
(rev 72114)
@@ -526,68 +526,67 @@
if( typeof classSet == 'function') {
callback = classSet;
}
-
- // Inject mwEmbed if needed
- if ( typeof MW_EMBED_VERSION == 'undefined' ) {
- if ( mwUseScriptLoader ) {
- var rurl = mwEmbedHostPath +
'/ResourceLoader.php?class=';
-
- var coma = '';
-
-
- // Add jQuery too if we need it:
- if ( typeof window.jQuery == 'undefined'
- ||
- // force load jquery if version 1.3.2 ( issues
)
- jQuery.fn.jquery == '1.3.2')
- {
- rurl += 'window.jQuery';
- coma = ',';
- }
- // Add Core mwEmbed lib ( if not already defined )
- if( typeof MW_EMBED_VERSION == 'undefined' ){
- rurl += coma + 'mwEmbed,mw.style.mwCommon';
- coma = ',';
+ if ( typeof MW_EMBED_VERSION != 'undefined' ) {
+ mw.load( classSet, callback)
+ return ;
+ }
+ // Inject mwEmbed
+ if ( mwUseScriptLoader ) {
+ var rurl = mwEmbedHostPath + '/ResourceLoader.php?class=';
+
+ var coma = '';
+
+
+ // Add jQuery too if we need it:
+ if ( typeof window.jQuery == 'undefined'
+ ||
+ // force load jquery if version 1.3.2 ( issues )
+ jQuery.fn.jquery == '1.3.2')
+ {
+ rurl += 'window.jQuery';
+ coma = ',';
+ }
+ // Add Core mwEmbed lib ( if not already defined )
+ if( typeof MW_EMBED_VERSION == 'undefined' ){
+ rurl += coma + 'mwEmbed,mw.style.mwCommon';
+ coma = ',';
+ }
+
+ // Add requested classSet to scriptLoader request
+ for( var i=0; i < classSet.length; i++ ){
+ var cName = classSet[i];
+ if( !mwCheckObjectPath( cName ) ){
+ rurl += ',' + cName;
}
-
- // Add requested classSet to scriptLoader request
- for( var i=0; i < classSet.length; i++ ){
- var cName = classSet[i];
- if( !mwCheckObjectPath( cName ) ){
- rurl += ',' + cName;
- }
- }
-
- // Add the remaining arguments
- rurl += '&' + mwGetReqArgs();
- importScriptURI( rurl );
- } else {
-
- // force load jQuery ( issues with '1.3.2' .data
handling
- if( jQuery && jQuery.fn.jquery== '1.3.2' ){
- console.log('load: ' + mwEmbedHostPath +
'/libraries/jquery/jquery-1.4.2.js' );
- importScriptURI( mwEmbedHostPath +
'/libraries/jquery/jquery-1.4.2.js?' + mwGetReqArgs() );
- }
- waitForJQueryUpgrade = function(){
- if( jQuery && jQuery.fn.jquery== '1.3.2' ){
- setTimeout( waitForJQueryUpgrade, 20);
- } else {
- // load mwEmbed js
- importScriptURI( mwEmbedHostPath +
'/mwEmbed.js?' + mwGetReqArgs() );
-
+ }
+
+ // Add the remaining arguments
+ rurl += '&' + mwGetReqArgs();
+ importScriptURI( rurl );
+ waitMwEmbedReady( callback );
+ } else {
+
+ // force load jQuery ( issues with '1.3.2' .data handling
+ if( jQuery && jQuery.fn.jquery== '1.3.2' ){
+ console.log('load: ' + mwEmbedHostPath +
'/libraries/jquery/jquery-1.4.2.js' );
+ importScriptURI( mwEmbedHostPath +
'/libraries/jquery/jquery-1.4.2.js?' + mwGetReqArgs() );
+ }
+ waitForJQueryUpgrade = function(){
+ if( jQuery && jQuery.fn.jquery== '1.3.2' ){
+ setTimeout( waitForJQueryUpgrade, 5);
+ } else {
+ // load mwEmbed js
+ importScriptURI( mwEmbedHostPath +
'/mwEmbed.js?' + mwGetReqArgs() );
+ waitMwEmbedReady( function(){
// Load the class set as part of
mwReady callback
- var instanceCallback = callback;
- var callback = function(){
- mw.load( classSet, function(){
- instanceCallback();
- })
- }
- }
+ mw.load( classSet, function(){
+ callback();
+ })
+ });
}
- waitForJQueryUpgrade();
}
- }
- waitMwEmbedReady( callback );
+ waitForJQueryUpgrade();
+ }
}
/**
@@ -599,9 +598,9 @@
setTimeout( function() {
waitMwEmbedReady( callback );
}, 10 );
- } else {
+ } else {
// Make sure mwEmbed is "setup" by using the addOnLoadHook:
- mw.ready( function(){
+ mw.ready( function(){
callback();
// All enabled pages should check if we have the gadget
already installed
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs