Index: branches/js2-work/phase3/js/mwEmbed/tests/testLang.html |
— | — | @@ -10,10 +10,10 @@ |
11 | 11 | <script type="text/javascript" > |
12 | 12 | var scriptLoaderURID = 't17'; |
13 | 13 | //for just setting one or two to test at a time for debug |
14 | | -//var langKeyDebug = [ 'en', 'ar' ]; //pl |
| 14 | +var langKeyDebug = [ 'ar' ]; //pl |
15 | 15 | //var langKeyDebug = [ 'az', 'da', 'pt', 'fr', 'lv', 'en']; |
16 | 16 | //var langKeyDebug = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl']; |
17 | | -var langKeyDebug = mw.getConfig( 'languageCodeList' ); |
| 17 | +//var langKeyDebug = mw.getConfig( 'languageCodeList' ); |
18 | 18 | |
19 | 19 | mw.ready( function(){ |
20 | 20 | //do mauall script loaders calls to test multiple languages: |
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -103,8 +103,20 @@ |
104 | 104 | $fileContent |
105 | 105 | ); |
106 | 106 | } |
107 | | - |
108 | 107 | /** |
| 108 | + * Get the language file javascript |
| 109 | + * @param String $languageJs The language file javascript |
| 110 | + */ |
| 111 | + public static function getLanguageJs( $langKey = 'en' ){ |
| 112 | + global $wgMwEmbedDirectory; |
| 113 | + $path = $wgMwEmbedDirectory . 'includes/languages/classes/Language' . ucfirst( $langKey ) . '.js'; |
| 114 | + if( is_file( $path ) ){ |
| 115 | + $languageJs = file_get_contents( $path ); |
| 116 | + return $languageJs; |
| 117 | + } |
| 118 | + return ''; |
| 119 | + } |
| 120 | + /** |
109 | 121 | * Get the combined loader javascript |
110 | 122 | * |
111 | 123 | * @return the combined loader jss |
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | |
19 | 19 | $IP = realpath( dirname( __FILE__ ) . '/../' ); |
20 | 20 | |
21 | | -// $wgMwEmbedDirectory becomes the root $IP |
| 21 | +// $wgMwEmbedDirectory becomes the root file system: |
22 | 22 | $wgMwEmbedDirectory = ''; |
23 | 23 | |
24 | 24 | $wgUseFileCache = true; |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -76,6 +76,7 @@ |
77 | 77 | 'debug' : false, |
78 | 78 | |
79 | 79 | // Valid language codes ( has a file in /includes/languages/classes/Language{code}.js ) |
| 80 | + // TODO: mirror the mw language "fallback" system |
80 | 81 | 'languageCodeList': ['en', 'am', 'ar', 'bat_smg', 'be_tarak', 'be', 'bh', |
81 | 82 | 'bs', 'cs', 'cu', 'cy', 'dsb', 'fr', 'ga', 'gd', 'gv', 'he', 'hi', |
82 | 83 | 'hr', 'hsb', 'hy', 'ksh', 'ln', 'lt', 'lv', 'mg', 'mk', 'mo', 'mt', |
— | — | @@ -83,7 +84,7 @@ |
84 | 85 | 'sr_ec', 'sr_el', 'sr', 'ti', 'tl', 'uk', 'wa' |
85 | 86 | ], |
86 | 87 | |
87 | | - // Default user language is "en" Can be overwiteen by: |
| 88 | + // Default user language is "en" Can be overwritten by: |
88 | 89 | // "uselang" url param |
89 | 90 | // wgUserLang global |
90 | 91 | 'userLanguage' : 'en', |
— | — | @@ -364,7 +365,7 @@ |
365 | 366 | if ( tObj.param.length == 0 ) { |
366 | 367 | return ''; |
367 | 368 | } |
368 | | - // Restore the count ( if it got converted earlier ) |
| 369 | + // Restore the count into a Number ( if it got converted earlier ) |
369 | 370 | var count = mw.lang.convertNumber( tObj.arg, true ); |
370 | 371 | |
371 | 372 | // Do convertPlural call |
— | — | @@ -400,9 +401,9 @@ |
401 | 402 | /** |
402 | 403 | * Convert a number using the digitTransformTable |
403 | 404 | * @param Number number to be converted |
404 | | - * @param Bollean latin if we should return the latin type 0-10 |
| 405 | + * @param Bollean typeInt if we should return a number of type int |
405 | 406 | */ |
406 | | - mw.lang.convertNumber = function( number, latin ) { |
| 407 | + mw.lang.convertNumber = function( number, typeInt ) { |
407 | 408 | if( !mw.lang.digitTransformTable ) |
408 | 409 | return number; |
409 | 410 | |
— | — | @@ -410,7 +411,7 @@ |
411 | 412 | var transformTable = mw.lang.digitTransformTable; |
412 | 413 | |
413 | 414 | // Check if the "restore" to latin number flag is set: |
414 | | - if( latin ){ |
| 415 | + if( typeInt ){ |
415 | 416 | if( parseInt( number ) == number ) |
416 | 417 | return number; |
417 | 418 | var tmp = []; |
— | — | @@ -429,7 +430,7 @@ |
430 | 431 | convertedNumber += numberString[i]; |
431 | 432 | } |
432 | 433 | } |
433 | | - return ( latin )? parseInt( convertedNumber) : convertedNumber; |
| 434 | + return ( typeInt )? parseInt( convertedNumber) : convertedNumber; |
434 | 435 | } |
435 | 436 | |
436 | 437 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -58,9 +58,10 @@ |
59 | 59 | // Setup file cache object |
60 | 60 | $this->sFileCache = new simpleFileCache( $this->requestKey ); |
61 | 61 | if ( $this->sFileCache->isFileCached() ) { |
62 | | - // Just output headers so we can use PHP's @readfile:: |
| 62 | + // Output headers |
63 | 63 | $this->outputJsHeaders(); |
64 | | - $this->sFileCache->loadFromFileCache(); |
| 64 | + // Output cached file |
| 65 | + $this->sFileCache->outputFile(); |
65 | 66 | return true; |
66 | 67 | } |
67 | 68 | return false; |
— | — | @@ -111,7 +112,10 @@ |
112 | 113 | |
113 | 114 | // If the core mwEmbed class entry point include all the loader js |
114 | 115 | if( $classKey == 'mwEmbed' ){ |
| 116 | + // Output the loaders: |
115 | 117 | $this->jsout .= jsClassLoader::getCombinedLoaderJs(); |
| 118 | + // Output the current language class js |
| 119 | + $this->jsout .= jsClassLoader::getLanguageJs( $this->langCode ); |
116 | 120 | } |
117 | 121 | } |
118 | 122 | |
— | — | @@ -146,12 +150,12 @@ |
147 | 151 | } |
148 | 152 | } |
149 | 153 | /** |
150 | | - * Get the onDone javascript callback for a given class list |
| 154 | + * Get the loadDone javascript callback for a given class list |
151 | 155 | * |
152 | 156 | * Enables a done loading callback for browsers like safari |
153 | 157 | * that don't consistently support the <script>.onload call |
154 | 158 | * |
155 | | - * @return String |
| 159 | + * @return String javascript to tell mwEmbed that the requested class set is loaded |
156 | 160 | */ |
157 | 161 | static private function getOnDoneCallback( ){ |
158 | 162 | return 'if(mw && mw.loadDone){mw.loadDone(\'' . |
— | — | @@ -184,6 +188,7 @@ |
185 | 189 | * Optional function to use the google closer compiler to minify js |
186 | 190 | * @param {String} $js_string Javascript string to be minified |
187 | 191 | * @param {String} $requestKey request key used for temporary name in closure compile |
| 192 | + * @return minified js, or false if minification failed. |
188 | 193 | */ |
189 | 194 | static function getClosureMinifiedJs( & $js_string, $requestKey=''){ |
190 | 195 | if( !is_file( $wgJavaPath ) || ! is_file( $wgClosureCompilerPath ) ){ |
— | — | @@ -797,9 +802,9 @@ |
798 | 803 | } |
799 | 804 | |
800 | 805 | /** |
801 | | - * Loads and outputs the file from file cache |
| 806 | + * Loads and outputs the file from the file cache |
802 | 807 | */ |
803 | | - public function loadFromFileCache() { |
| 808 | + public function outputFile() { |
804 | 809 | if ( jsScriptLoader::clientAcceptsGzip() && substr( $this->filename, -3 ) == '.gz' ) { |
805 | 810 | header( 'Content-Encoding: gzip' ); |
806 | 811 | readfile( $this->filename ); |
Index: branches/js2-work/phase3/js/editPage.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -/* |
| 2 | +/** |
3 | 3 | * JS2-style replacement for MediaWiki edit.js |
4 | 4 | * (right now it just supports the toolbar) |
5 | 5 | */ |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | mw.log( 'Failed to bind via build section bind via target:' ); |
75 | 75 | $j( ".tool[rel='file']" ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) ); |
76 | 76 | mw.load( 'AddMedia.addMediaWizard', function(){ |
77 | | - if( $j( ".tool[rel='file']" ).length != 0 ){ |
| 77 | + if( $j( ".tool[rel='file']" ).size() != 0 ){ |
78 | 78 | $j( ".tool[rel='file']" ).unbind().addMediaWizard( amwConf ); |
79 | 79 | } |
80 | 80 | }); |