Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js |
— | — | @@ -526,68 +526,67 @@ |
527 | 527 | if( typeof classSet == 'function') { |
528 | 528 | callback = classSet; |
529 | 529 | } |
530 | | - |
531 | | - // Inject mwEmbed if needed |
532 | | - if ( typeof MW_EMBED_VERSION == 'undefined' ) { |
533 | | - if ( mwUseScriptLoader ) { |
534 | | - var rurl = mwEmbedHostPath + '/ResourceLoader.php?class='; |
535 | | - |
536 | | - var coma = ''; |
537 | | - |
538 | | - |
539 | | - // Add jQuery too if we need it: |
540 | | - if ( typeof window.jQuery == 'undefined' |
541 | | - || |
542 | | - // force load jquery if version 1.3.2 ( issues ) |
543 | | - jQuery.fn.jquery == '1.3.2') |
544 | | - { |
545 | | - rurl += 'window.jQuery'; |
546 | | - coma = ','; |
547 | | - } |
548 | | - // Add Core mwEmbed lib ( if not already defined ) |
549 | | - if( typeof MW_EMBED_VERSION == 'undefined' ){ |
550 | | - rurl += coma + 'mwEmbed,mw.style.mwCommon'; |
551 | | - coma = ','; |
| 530 | + if ( typeof MW_EMBED_VERSION != 'undefined' ) { |
| 531 | + mw.load( classSet, callback) |
| 532 | + return ; |
| 533 | + } |
| 534 | + // Inject mwEmbed |
| 535 | + if ( mwUseScriptLoader ) { |
| 536 | + var rurl = mwEmbedHostPath + '/ResourceLoader.php?class='; |
| 537 | + |
| 538 | + var coma = ''; |
| 539 | + |
| 540 | + |
| 541 | + // Add jQuery too if we need it: |
| 542 | + if ( typeof window.jQuery == 'undefined' |
| 543 | + || |
| 544 | + // force load jquery if version 1.3.2 ( issues ) |
| 545 | + jQuery.fn.jquery == '1.3.2') |
| 546 | + { |
| 547 | + rurl += 'window.jQuery'; |
| 548 | + coma = ','; |
| 549 | + } |
| 550 | + // Add Core mwEmbed lib ( if not already defined ) |
| 551 | + if( typeof MW_EMBED_VERSION == 'undefined' ){ |
| 552 | + rurl += coma + 'mwEmbed,mw.style.mwCommon'; |
| 553 | + coma = ','; |
| 554 | + } |
| 555 | + |
| 556 | + // Add requested classSet to scriptLoader request |
| 557 | + for( var i=0; i < classSet.length; i++ ){ |
| 558 | + var cName = classSet[i]; |
| 559 | + if( !mwCheckObjectPath( cName ) ){ |
| 560 | + rurl += ',' + cName; |
552 | 561 | } |
553 | | - |
554 | | - // Add requested classSet to scriptLoader request |
555 | | - for( var i=0; i < classSet.length; i++ ){ |
556 | | - var cName = classSet[i]; |
557 | | - if( !mwCheckObjectPath( cName ) ){ |
558 | | - rurl += ',' + cName; |
559 | | - } |
560 | | - } |
561 | | - |
562 | | - // Add the remaining arguments |
563 | | - rurl += '&' + mwGetReqArgs(); |
564 | | - importScriptURI( rurl ); |
565 | | - } else { |
566 | | - |
567 | | - // force load jQuery ( issues with '1.3.2' .data handling |
568 | | - if( jQuery && jQuery.fn.jquery== '1.3.2' ){ |
569 | | - console.log('load: ' + mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js' ); |
570 | | - importScriptURI( mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js?' + mwGetReqArgs() ); |
571 | | - } |
572 | | - waitForJQueryUpgrade = function(){ |
573 | | - if( jQuery && jQuery.fn.jquery== '1.3.2' ){ |
574 | | - setTimeout( waitForJQueryUpgrade, 20); |
575 | | - } else { |
576 | | - // load mwEmbed js |
577 | | - importScriptURI( mwEmbedHostPath + '/mwEmbed.js?' + mwGetReqArgs() ); |
578 | | - |
| 562 | + } |
| 563 | + |
| 564 | + // Add the remaining arguments |
| 565 | + rurl += '&' + mwGetReqArgs(); |
| 566 | + importScriptURI( rurl ); |
| 567 | + waitMwEmbedReady( callback ); |
| 568 | + } else { |
| 569 | + |
| 570 | + // force load jQuery ( issues with '1.3.2' .data handling |
| 571 | + if( jQuery && jQuery.fn.jquery== '1.3.2' ){ |
| 572 | + console.log('load: ' + mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js' ); |
| 573 | + importScriptURI( mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js?' + mwGetReqArgs() ); |
| 574 | + } |
| 575 | + waitForJQueryUpgrade = function(){ |
| 576 | + if( jQuery && jQuery.fn.jquery== '1.3.2' ){ |
| 577 | + setTimeout( waitForJQueryUpgrade, 5); |
| 578 | + } else { |
| 579 | + // load mwEmbed js |
| 580 | + importScriptURI( mwEmbedHostPath + '/mwEmbed.js?' + mwGetReqArgs() ); |
| 581 | + waitMwEmbedReady( function(){ |
579 | 582 | // Load the class set as part of mwReady callback |
580 | | - var instanceCallback = callback; |
581 | | - var callback = function(){ |
582 | | - mw.load( classSet, function(){ |
583 | | - instanceCallback(); |
584 | | - }) |
585 | | - } |
586 | | - } |
| 583 | + mw.load( classSet, function(){ |
| 584 | + callback(); |
| 585 | + }) |
| 586 | + }); |
587 | 587 | } |
588 | | - waitForJQueryUpgrade(); |
589 | 588 | } |
590 | | - } |
591 | | - waitMwEmbedReady( callback ); |
| 589 | + waitForJQueryUpgrade(); |
| 590 | + } |
592 | 591 | } |
593 | 592 | |
594 | 593 | /** |
— | — | @@ -599,9 +598,9 @@ |
600 | 599 | setTimeout( function() { |
601 | 600 | waitMwEmbedReady( callback ); |
602 | 601 | }, 10 ); |
603 | | - } else { |
| 602 | + } else { |
604 | 603 | // Make sure mwEmbed is "setup" by using the addOnLoadHook: |
605 | | - mw.ready( function(){ |
| 604 | + mw.ready( function(){ |
606 | 605 | callback(); |
607 | 606 | |
608 | 607 | // All enabled pages should check if we have the gadget already installed |