Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php |
— | — | @@ -566,7 +566,7 @@ |
567 | 567 | |
568 | 568 | // Included script without script-loader |
569 | 569 | // Generate the localized msgs inline since we can't rely on ScriptLoader to localize |
570 | | - $inlineMsg = $this->mScriptLoader->getInlineMsgFromClass( $className ); |
| 570 | + $inlineMsg = $this->mScriptLoader->getAddMessagesFromClass( $className ); |
571 | 571 | if( $inlineMsg != '' ) { |
572 | 572 | $this->addScript( Html::inlineScript( $inlineMsg ) ); |
573 | 573 | } |
Index: trunk/extensions/JS2Support/mwEmbed/languages/mw.Language.js |
— | — | @@ -184,10 +184,13 @@ |
185 | 185 | * Swap in an array of values for $1, $2, $n for a given msg key |
186 | 186 | * |
187 | 187 | * @param string messageKey The msg key to lookup |
188 | | - * @param {Array} args An array of string or jquery objects to be swapped in |
| 188 | + * @param {Array} args An array of string or jQuery objects to be swapped in |
189 | 189 | * @return string |
190 | 190 | */ |
191 | | - replaceStringArgs : function() { |
| 191 | + replaceStringArgs : function() { |
| 192 | + if( ! this.arguments ) { |
| 193 | + return ; |
| 194 | + } |
192 | 195 | // Replace Values |
193 | 196 | for ( var v = 0; v < this.arguments.length; v++ ) { |
194 | 197 | if( typeof this.arguments[v] == 'undefined' ) { |
Index: trunk/extensions/JS2Support/mwEmbed/languages/mw.Parser.js |
— | — | @@ -2,12 +2,11 @@ |
3 | 3 | * Mediawiki language text parser |
4 | 4 | */ |
5 | 5 | |
6 | | - // Setup jQuery swap string constant |
| 6 | +// Setup swap string constants |
| 7 | +var JQUERY_SWAP_STRING = 'ZjQuerySwapZ'; |
| 8 | +var LINK_SWAP_STRING = 'ZreplaceZ'; |
7 | 9 | |
8 | | - |
9 | 10 | ( function( mw ) { |
10 | | - var JQUERY_SWAP_STRING = 'ZjQuerySwapZ'; |
11 | | - var LINK_SWAP_STRING = 'ZreplaceZ'; |
12 | 11 | |
13 | 12 | // The parser magic global |
14 | 13 | var pMagicSet = { }; |
Index: trunk/extensions/JS2Support/mwEmbed/mwEmbed.js |
— | — | @@ -300,7 +300,7 @@ |
301 | 301 | load: function( loadRequest, instanceCallback ) { |
302 | 302 | // Ensure the callback is only called once per load instance |
303 | 303 | var callback = function(){ |
304 | | - if( instanceCallback ){ |
| 304 | + if( instanceCallback ) { |
305 | 305 | instanceCallback( loadRequest ); |
306 | 306 | instanceCallback = null; |
307 | 307 | } |
— | — | @@ -563,7 +563,7 @@ |
564 | 564 | // Issue the request to load the class (include class name in result callback: |
565 | 565 | mw.getScript( scriptRequest, function( scriptRequest ) { |
566 | 566 | |
567 | | - // If its a "syle sheet" manually set its class to true |
| 567 | + // If its a "style sheet" manually set its class to true |
568 | 568 | var ext = scriptRequest.substr( scriptRequest.split('?')[0].lastIndexOf( '.' ), 4 ).toLowerCase(); |
569 | 569 | if( ext == '.css' && className.substr(0,8) == 'mw.style' ){ |
570 | 570 | mw.style[ className.substr( 9 ) ] = true; |
— | — | @@ -578,36 +578,27 @@ |
579 | 579 | |
580 | 580 | // If ( debug mode ) and the script include is missing class messages |
581 | 581 | // do a separate request to retrieve the msgs |
582 | | - if( mw.currentClassMissingMessages ){ |
583 | | - mw.loadClassMessages( className, function(){ |
584 | | - //reset the currentClassMissingMessages flag |
| 582 | + if( mw.currentClassMissingMessages ) { |
| 583 | + mw.loadClassMessages( className, function() { |
| 584 | + // Reset the currentClassMissingMessages flag |
585 | 585 | mw.currentClassMissingMessages = false; |
586 | | - // Run the onDone callback |
| 586 | + |
| 587 | + // Run the onDone callback |
587 | 588 | mw.loadDone( className ); |
588 | 589 | }); |
589 | 590 | } else { |
590 | | - // Call load done ( when in debug mode the scriptLoader |
591 | | - // is not able to append the loadDone call |
592 | | - mw.loadDone( className ); |
| 591 | + // If not using the script-loader make sure the className is avaliable before firing the loadDone |
| 592 | + if( !mw.getScriptLoaderPath() ) { |
| 593 | + mw.waitForObject( className, function( className ) { |
| 594 | + // Once object is ready run loadDone |
| 595 | + mw.loadDone( className ); |
| 596 | + } ); |
| 597 | + } else { |
| 598 | + // loadDone should be appended to the bottom of the script-loader response |
| 599 | + //mw.loadDone( className ); |
| 600 | + } |
593 | 601 | } |
594 | | - } ); |
595 | | - //mw.log( 'done with running getScript request ' ); |
596 | | - |
597 | | - /* |
598 | | - * ( If scriptLoader is not enabled ) |
599 | | - * |
600 | | - * Check if the class is ready: |
601 | | - * ( not all browsers support onLoad script attribute ) |
602 | | - * In the case of a "class" we can pull the javascript state until its ready |
603 | | - */ |
604 | | - if( !mw.getScriptLoaderPath() ) { |
605 | | - setTimeout( function() { |
606 | | - mw.waitForObject( className, function( className ) { |
607 | | - // Once object is ready run loadDone |
608 | | - mw.loadDone( className ); |
609 | | - } ); |
610 | | - }, 25 ); |
611 | | - } |
| 602 | + } ); |
612 | 603 | }, |
613 | 604 | |
614 | 605 | /** |
— | — | @@ -1961,8 +1952,9 @@ |
1962 | 1953 | // Set up mvEmbed utility jQuery bindings |
1963 | 1954 | mw.dojQueryBindings(); |
1964 | 1955 | |
1965 | | - // Speical Hack for condtional jquery ui inclution ( once Usability extension |
1966 | | - // registers the jquery.ui skin in mw.sytle this won't be needed: |
| 1956 | + |
| 1957 | + // Special Hack for conditional jquery ui inclusion ( once Usability extension |
| 1958 | + // registers the jquery.ui skin in mw.style this won't be needed: |
1967 | 1959 | if( mw.hasJQueryUiCss() ){ |
1968 | 1960 | mw.style[ mw.getConfig( 'jQueryUISkin' ) ] = true; |
1969 | 1961 | } |
— | — | @@ -1995,8 +1987,8 @@ |
1996 | 1988 | |
1997 | 1989 | /** |
1998 | 1990 | * Checks for jquery ui css by name jquery-ui-1.7.2.css |
1999 | | - * NOTE: this is kind of a hack for usability jquery-ui |
2000 | | - * in the future usability should register the class in mw.skin |
| 1991 | + * NOTE: this is a hack for usability jquery-ui |
| 1992 | + * in the future usability should register a class in mw.skin |
2001 | 1993 | * |
2002 | 1994 | * @return true if found, return false if not found |
2003 | 1995 | */ |
— | — | @@ -2004,7 +1996,7 @@ |
2005 | 1997 | var hasUiCss = false; |
2006 | 1998 | // Load the jQuery ui skin if usability skin not set |
2007 | 1999 | $j( 'link' ).each( function( na, linkNode ){ |
2008 | | - if( $j( linkNode ).attr( 'href' ).indexOf('jquery-ui-1.7.2.css') != -1 ) { |
| 2000 | + if( $j( linkNode ).attr( 'href' ).indexOf( 'jquery-ui-1.7.2.css' ) != -1 ) { |
2009 | 2001 | hasUiCss = true; |
2010 | 2002 | return false; |
2011 | 2003 | } |
— | — | @@ -2250,7 +2242,7 @@ |
2251 | 2243 | ' class="ui-state-default ui-corner-all ui-icon_link ' + |
2252 | 2244 | className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' + |
2253 | 2245 | '<span class="btnText">' + msg + '</span></a>'; |
2254 | | - } |
| 2246 | + }; |
2255 | 2247 | |
2256 | 2248 | // Shortcut to jQuery button ( should replace all btnHtml with button ) |
2257 | 2249 | var mw_default_button_options = { |
— | — | @@ -2265,7 +2257,8 @@ |
2266 | 2258 | |
2267 | 2259 | // The icon id that precceeds the button link: |
2268 | 2260 | 'icon_id' : 'carat-1-n' |
2269 | | - } |
| 2261 | + }; |
| 2262 | + |
2270 | 2263 | $.button = function( options ) { |
2271 | 2264 | var options = $j.extend( mw_default_button_options, options); |
2272 | 2265 | |
— | — | @@ -2288,7 +2281,7 @@ |
2289 | 2282 | .text( options.text ) |
2290 | 2283 | ); |
2291 | 2284 | return $btn; |
2292 | | - } |
| 2285 | + }; |
2293 | 2286 | |
2294 | 2287 | // Shortcut to bind hover state |
2295 | 2288 | $.fn.buttonHover = function() { |
— | — | @@ -2301,7 +2294,7 @@ |
2302 | 2295 | } |
2303 | 2296 | ) |
2304 | 2297 | return this; |
2305 | | - } |
| 2298 | + }; |
2306 | 2299 | |
2307 | 2300 | /** |
2308 | 2301 | * Resize a dialog to fit the window |
— | — | @@ -2322,9 +2315,9 @@ |
2323 | 2316 | 'right':'0px', |
2324 | 2317 | 'bottom':'0px' |
2325 | 2318 | } ); |
2326 | | - } |
| 2319 | + }; |
2327 | 2320 | |
2328 | | - } )( jQuery ); |
| 2321 | + } )( $j ); |
2329 | 2322 | } |
2330 | 2323 | |
2331 | 2324 | } )( window.mw ); |
— | — | @@ -2443,4 +2436,4 @@ |
2444 | 2437 | if( dollarFlag ) { |
2445 | 2438 | window[ '$' ] = jQuery.noConflict(); |
2446 | 2439 | } |
2447 | | -} |
\ No newline at end of file |
| 2440 | +} |
Index: trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | // The raw requested class |
53 | 53 | private static $rawClassList = ''; |
54 | 54 | |
55 | | - // The includeAllModuleMessages string regular expresion |
| 55 | + // The includeAllModuleMessages string regular expression |
56 | 56 | private static $includeAllMsgsRegEx = "/mw\.includeAllModuleMessages\s*\(\s*\)\;?/"; |
57 | 57 | |
58 | 58 | /** |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | |
133 | 133 | // Output the loaders js |
134 | 134 | $loaderJS = jsClassLoader::getCombinedLoaderJs(); |
135 | | - // Transform the loader text to remove debug statments and |
| 135 | + // Transform the loader text to remove debug statements and |
136 | 136 | // update language msgs if any are present |
137 | 137 | $this->output .= $this->transformScriptText( $loaderJS , 'mwEmbed'); |
138 | 138 | |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Output "special" IE comment tag to support "special" mwEmbed tags. |
152 | | - $this->notMinifiedTopOutput .='/*@cc_on\'video source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})@*/'."\n"; |
| 152 | + $this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n"; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
— | — | @@ -387,25 +387,24 @@ |
388 | 388 | * Special function to transform css output and wrap in js call |
389 | 389 | */ |
390 | 390 | private function transformCssOutput( $classKey, $cssString , $path ='') { |
| 391 | + global $wgScriptLoaderRelativeCss; |
391 | 392 | // Minify and update paths on cssString: |
392 | 393 | $cssOptions = array(); |
393 | 394 | |
394 | 395 | // Set comments preservation based on debug state |
395 | 396 | $cssOptions[ 'preserveComments' ] = ( $this->debug ); |
396 | 397 | |
397 | | - $serverUri = $this->getScriptLoaderUri(); |
398 | | - |
399 | 398 | // Check for the two jsScriptLoader entry points: |
400 | | - if( strpos( $serverUri, 'mwScriptLoader.php') !== false ){ |
| 399 | + if( $wgScriptLoaderRelativeCss ) { |
401 | 400 | // Using the local mediaWiki entry point we should have our $wgScriptPath global |
402 | 401 | global $wgScriptPath; |
403 | | - $cssOptions[ 'prependRelativePath' ] = $wgScriptPath . '/' . dirname( $path ) . '/'; |
404 | | - } else if( strpos( $serverUri, 'jsScriptLoader.php') !== false ){ |
405 | | - // NOTE:: We HAVE to use an absolute url remote jsScriptLoader.php entry point. |
406 | | - // this is because relative urls won't work when inserted into the DOM head |
407 | | - // ( ie we package the css with javascript ) |
408 | | - $cssOptions[ 'prependRelativePath' ] = |
409 | | - str_replace('jsScriptLoader.php', '', $serverUri) |
| 402 | + $prePendPath = ( $wgScriptPath == '' ) ? '' : $wgScriptPath . '/'; |
| 403 | + $cssOptions[ 'prependRelativePath' ] = $prePendPath . dirname( $path ) . '/'; |
| 404 | + } else { |
| 405 | + // Get the server URL |
| 406 | + $serverUri = $this->getScriptLoaderUri(); |
| 407 | + |
| 408 | + $cssOptions[ 'prependRelativePath' ] = str_replace('jsScriptLoader.php', '', $serverUri) |
410 | 409 | . dirname( $path ) . '/'; |
411 | 410 | } |
412 | 411 | |
— | — | @@ -789,6 +788,7 @@ |
790 | 789 | /* |
791 | 790 | * Transform script text with language key substitution |
792 | 791 | * and clear out debug lines if present. |
| 792 | + * @param {String} $scriptText Text string to be transformed |
793 | 793 | */ |
794 | 794 | function transformScriptText( $scriptText , $moduleName){ |
795 | 795 | global $wgEnableScriptLocalization; |
— | — | @@ -801,7 +801,6 @@ |
802 | 802 | if ( $wgEnableScriptLocalization ){ |
803 | 803 | // Get the mw.addMessage javascript from scriptText and moduleName |
804 | 804 | $addMessageJs = $this->getAddMessagesFromScriptText( & $scriptText , $moduleName); |
805 | | - |
806 | 805 | //@@NOTE getAddMessagesFromClass could identify which mode we are in and we would not need to |
807 | 806 | // try each of these search patterns in the same order as before. |
808 | 807 | |
— | — | @@ -950,7 +949,7 @@ |
951 | 950 | * @param {String} $class Name of class to get inline messages for. |
952 | 951 | * @return in-line msg javascript text or empty string if no msgs need to be localized. |
953 | 952 | */ |
954 | | - function getAddMessagesFromClass( $class ) { |
| 953 | + function getAddMessagesFromClass( $className ) { |
955 | 954 | $scriptText = $this->getScriptText( $className ); |
956 | 955 | $moduleName = jsClassLoader::getClassModuleName( $className ); |
957 | 956 | return $this->getAddMessagesFromScriptText( $scriptText, $moduleName ); |
— | — | @@ -981,11 +980,10 @@ |
982 | 981 | * @return {Array} decoded json array of message key value pairs |
983 | 982 | */ |
984 | 983 | function getMsgKeysFromScriptText( & $scriptString , $moduleName){ |
985 | | - global $wgExtensionJavascriptModules, $wgExtensionMessagesFiles; |
| 984 | + global $wgExtensionMessagesFiles; |
986 | 985 | |
987 | 986 | // Try for includeAllModuleMsgs function call |
988 | | - if ( preg_match ( self::$includeAllMsgsRegEx, $scriptString ) !== false ) { |
989 | | - |
| 987 | + if ( preg_match ( self::$includeAllMsgsRegEx, $scriptString ) !== 0 ) { |
990 | 988 | // Get the module $messages keys |
991 | 989 | if( $moduleName && isset( $wgExtensionMessagesFiles[ $moduleName ] ) ) { |
992 | 990 | |
— | — | @@ -1033,7 +1031,7 @@ |
1034 | 1032 | * @param {Array} $jmsg Associative array of message key -> message value pairs |
1035 | 1033 | * @param {String} $langCode Language code override |
1036 | 1034 | */ |
1037 | | - static public function updateMessageValues(& $messegeArray, $langCode = false){ |
| 1035 | + static public function updateMessageValues( & $messegeArray, $langCode = false ){ |
1038 | 1036 | global $wgLang; |
1039 | 1037 | // Check the langCode |
1040 | 1038 | if(!$langCode && $wgLang) { |
Index: trunk/extensions/JS2Support/JS2Support.php |
— | — | @@ -56,6 +56,13 @@ |
57 | 57 | $wgExtensionJavascriptModules = array(); |
58 | 58 | |
59 | 59 | /** |
| 60 | +* If the mwEmbed loader.js javascript should be used to get a list of enabled modules |
| 61 | +* This is for stand-alone usage and is set to false for mediaWiki. |
| 62 | +* ( all modules should be loaded from $wgExtensionJavascriptModules var ) |
| 63 | +*/ |
| 64 | +$wgUseMwEmbedLoaderModuleList = false; |
| 65 | + |
| 66 | +/** |
60 | 67 | * The set of script-loader Named Paths, populated via extensions and javascript module loaders |
61 | 68 | */ |
62 | 69 | $wgScriptLoaderNamedPaths = array(); |
— | — | @@ -114,9 +121,15 @@ |
115 | 122 | */ |
116 | 123 | $wgScriptModifiedMsgCheck = false; |
117 | 124 | |
| 125 | +/** |
| 126 | + * If the scriptloader should output relative css paths |
| 127 | + * Should be set to false if the script-loader is on a different domain |
| 128 | + * from your css |
| 129 | + */ |
| 130 | +$wgScriptLoaderRelativeCss = true; |
118 | 131 | |
119 | 132 | /** |
120 | | - * boolean; if we should enable javascript localization (it loads mw.addMessages json |
| 133 | + * boolean; if scriptLoader should localize script text(it loads mw.addMessages json |
121 | 134 | * call with mediaWiki msgs) |
122 | 135 | */ |
123 | 136 | $wgEnableScriptLocalization = true; |
Index: trunk/extensions/JS2Support/JS2AutoLoader.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /**************************** |
5 | | -* JS2 AutoLoader.php |
| 5 | +* JS2 AutoLoader php files |
6 | 6 | *****************************/ |
7 | 7 | $wgAutoloadClasses = array_merge( $wgAutoloadClasses, array( |
8 | 8 | 'JSMin' => $js2Dir . 'mwEmbed/includes/library/JSMin.php', |
Index: trunk/extensions/JS2Support/README |
— | — | @@ -48,10 +48,11 @@ |
49 | 49 | Once you include the extension you can use the following: |
50 | 50 | |
51 | 51 | To add a javascript or css to the named paths ( so that the script loader can load it by name ) |
52 | | -$wgScriptLoaderNamedPaths[ 'myExtension' ] = 'extensions/myExtension/myExtension.js'; |
| 52 | +$wgScriptLoaderNamedPaths[ 'myJavascriptFile' ] = 'extensions/myExtension/myJavascriptFile.js'; |
53 | 53 | |
54 | 54 | Then in your php you can include your with the following line: |
55 | | -$wgOut->addScriptClass( 'myExtension' /* scriptloader named path */ , 'page'/* group bucket id */ ); |
| 55 | +$wgOut->addScriptClass( 'myJavascriptFile' /* scriptloader named path */ , 'page'/* group bucket id */ ); |
| 56 | + |
56 | 57 | This lets you use the named-path for includes and gives you control over script grouping with the |
57 | 58 | grouping argument. If for example your script is included on a set of special pages then you could |
58 | 59 | create a bucket id string for that set to not mangle the cache of each special page . |
— | — | @@ -63,9 +64,10 @@ |
64 | 65 | If you would like to keep compatibility with non-js2 extension support you can use the base outputPage |
65 | 66 | addScriptFile method: |
66 | 67 | $wgOut->addScriptFile( 'extensions/myExtension/myExtension.js' ) |
| 68 | + |
67 | 69 | This way regardless of if your running the js2support extension or not script-includes will continue to work. |
68 | 70 | But you won't be able to control the script bucket, and the script-loader will have to guess |
69 | | -what group to put it in. ( This should be resolved with updates to the trunk output page) |
| 71 | +what group to put it in. |
70 | 72 | |
71 | 73 | For more info see ScriptLoaderOutputPage.php $mScriptLoaderClassList |
72 | 74 | |