Index: trunk/extensions/JS2Support/JS2Support.i18n.php |
— | — | @@ -61,13 +61,6 @@ |
62 | 62 | 'js2support-desc' => 'Apoio JS2 en forma de extensión', |
63 | 63 | ); |
64 | 64 | |
65 | | -/** Swiss German (Alemannisch) |
66 | | - * @author Als-Holder |
67 | | - */ |
68 | | -$messages['gsw'] = array( |
69 | | - 'js2support-desc' => 'JS2-Unterstitzig dur e Erwyterig', |
70 | | -); |
71 | | - |
72 | 65 | /** Upper Sorbian (Hornjoserbsce) |
73 | 66 | * @author Michawiki |
74 | 67 | */ |
Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * ScriptLoaderOutputPage extends OutputPage with script-loader calls |
| 10 | + * ScriptLoaderOutputPage extends OutputPage with script-loader calls |
11 | 11 | */ |
12 | 12 | class ScriptLoaderOutputPage extends OutputPage { |
13 | 13 | // Flag javascript Classes loaded |
— | — | @@ -22,11 +22,15 @@ |
23 | 23 | * Default Buckets include: |
24 | 24 | * 'page' - Default, Script part of the "current page" |
25 | 25 | * to improve cache hit rate only put scripts / css |
26 | | - * into the page bucket if specific to a page |
| 26 | + * into the page bucket if specific to a particular page ( and no other ) |
27 | 27 | * ( ie Special:Upload or action=edit ) |
28 | 28 | * 'user' - scripts /css specific to the current logged in user |
29 | | - * 'core' - scripts /css loaded on every page view |
30 | | - * ( mwEmbed.js, jQuery, and wikibits are in this bucket by deafult ) |
| 29 | + * 'allpage' - scripts /css loaded on every page view |
| 30 | + * ( jQuery, mwEmbed.js and wikibits are in this bucket by default ) |
| 31 | + * 'abritraryString' - Arbitrary script grouping bucket string |
| 32 | + * For example if you had a script that was included on |
| 33 | + * all category pages then the bucket could be 'category' |
| 34 | + * this way you would not break the cache for other per page scripts |
31 | 35 | */ |
32 | 36 | var $mScriptLoaderClassList = array( |
33 | 37 | 'js'=> array(), |
— | — | @@ -39,7 +43,7 @@ |
40 | 44 | // Local scriptLoader instance object |
41 | 45 | var $mScriptLoader = null; |
42 | 46 | |
43 | | -/** |
| 47 | + /** |
44 | 48 | * Add a JavaScript file out of skins/common, or a given relative path. |
45 | 49 | * |
46 | 50 | * @param $file String: filename in skins/common or complete on-server path |
— | — | @@ -83,9 +87,9 @@ |
84 | 88 | if( isset( $reqSet['title'] ) && $reqSet != '' ) { |
85 | 89 | // Make sure the title ends with .js or css |
86 | 90 | if( substr( $reqSet['title'], -3 ) != '.js' && |
87 | | - substr( $reqSet['title'], -3 ) != 'css' && |
88 | | - $reqSet['title'] != '-' ){ |
89 | | - return false; |
| 91 | + substr( $reqSet['title'], -3 ) != 'css' && |
| 92 | + $reqSet['title'] != '-' ){ |
| 93 | + return false; |
90 | 94 | } |
91 | 95 | |
92 | 96 | $className = 'WT:' . $reqSet['title']; |
— | — | @@ -119,7 +123,7 @@ |
120 | 124 | // Add site JS if enabled: |
121 | 125 | if( $wgUseSiteJs ) { |
122 | 126 | $this->addScriptClass( 'WT:-|useskin=' . |
123 | | - urlencode( $sk->getSkinName() ) .'|gen=js' ); |
| 127 | + urlencode( $sk->getSkinName() ) .'|gen=js' ); |
124 | 128 | } |
125 | 129 | |
126 | 130 | // Add user js if enabled: |
— | — | @@ -145,7 +149,7 @@ |
146 | 150 | } |
147 | 151 | |
148 | 152 | // Add our core scripts to mScripts ( includes jQuery, mwEmbed & wikibits ) |
149 | | - $this->includeCoreJS(); |
| 153 | + $this->includeAllPageJS(); |
150 | 154 | |
151 | 155 | |
152 | 156 | // If the script-loader is enabled get script-loader classes per buckets |
— | — | @@ -227,7 +231,7 @@ |
228 | 232 | return ''; |
229 | 233 | } |
230 | 234 | } |
231 | | - |
| 235 | + |
232 | 236 | // If script-loader enabled check if we can add the script via script-loader |
233 | 237 | if( $wgEnableScriptLoader ) { |
234 | 238 | global $wgStylePath, $wgScript; |
— | — | @@ -235,7 +239,7 @@ |
236 | 240 | if( strpos( $style, $wgScript ) === false ) { |
237 | 241 | $style = $wgStylePath ."/". $style; |
238 | 242 | } |
239 | | - $cssClass = $this->getClassFromPath( $style ); |
| 243 | + $cssClass = $this->getClassFromPath( $style ); |
240 | 244 | if( $cssClass ) { |
241 | 245 | $this->addScriptClass( $cssClass, $bucketKey, 'css'); |
242 | 246 | // Update the options for this script bucket. ( css has per-bucket options ) |
— | — | @@ -251,7 +255,7 @@ |
252 | 256 | * These will be applied to various media & IE conditionals. |
253 | 257 | */ |
254 | 258 | public function buildCssLinks() { |
255 | | - global $wgEnableScriptLoader; |
| 259 | + global $wgEnableScriptLoader; |
256 | 260 | $scriptLoaderCss = ''; |
257 | 261 | if( $wgEnableScriptLoader ){ |
258 | 262 | $scriptLoaderCss = $this->getScriptLoaderCss(); |
— | — | @@ -269,16 +273,18 @@ |
270 | 274 | * |
271 | 275 | * @since 1.17 |
272 | 276 | */ |
273 | | - public function includeCoreJS ( ) { |
| 277 | + public function includeAllPageJS ( ) { |
274 | 278 | global $wgExtensionJavascriptLoader, $wgEnableScriptLoader, |
275 | | - $wgJSAutoloadClasses, $wgScriptPath; |
| 279 | + $wgScriptLoaderNamedPaths, $wgScriptPath; |
276 | 280 | |
277 | | - // Set core Classes ( note wikibits will be phased out ) |
| 281 | + // Set core Classes |
278 | 282 | $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' ); |
279 | 283 | |
280 | | - // Merge in any scripts that have been set as "core" |
281 | | - if( isset( $this->mScriptLoaderClassList[ 'js' ][ 'core' ] ) ) { |
282 | | - $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'js' ][ 'core' ] ); |
| 284 | + // Merge in any scripts that have been set as "allpage" |
| 285 | + // Since the all page are on every page view they should just be part of the core |
| 286 | + // script request. |
| 287 | + if( isset( $this->mScriptLoaderClassList[ 'js' ][ 'allpage' ] ) ) { |
| 288 | + $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'js' ][ 'allpage' ] ); |
283 | 289 | } |
284 | 290 | |
285 | 291 | // Make sure scripts are the first scripts include on the page. |
— | — | @@ -288,6 +294,7 @@ |
289 | 295 | $this->mScripts = ''; |
290 | 296 | |
291 | 297 | if( $wgEnableScriptLoader ) { |
| 298 | + $this->mScripts = "\n<!-- Script bucket: allpage --> \n"; |
292 | 299 | $this->mScripts = $this->getLinkedScriptLoaderJs( $coreClasses ); |
293 | 300 | } else { |
294 | 301 | // No ScriptLoader manually add the classes: |
— | — | @@ -309,12 +316,12 @@ |
310 | 317 | * Get style sheets grouped by "media", "condition" & "bucket" attributes |
311 | 318 | * call getLinkedScriptLoaderCss for each group |
312 | 319 | */ |
313 | | - private function getScriptLoaderCss( ){ |
314 | | - |
| 320 | + private function getScriptLoaderCss( ){ |
| 321 | + |
315 | 322 | $s=''; |
316 | 323 | foreach( $this->mScriptLoaderClassList['css'] as $bucketKey => $classSet ){ |
317 | 324 | // Note we don't include the "core" bucket since its handled by |
318 | | - // includeCoreJS |
| 325 | + // includeAllPageJS |
319 | 326 | if( count( $classSet) ) { |
320 | 327 | $options = $this->getClassBucketOptions( $bucketKey ); |
321 | 328 | $s .= "\n<!-- Css bucket: " . htmlspecialchars( $bucketKey ) . "--> \n"; |
— | — | @@ -354,9 +361,11 @@ |
355 | 362 | private function getScriptLoaderJs(){ |
356 | 363 | $s=''; |
357 | 364 | foreach( $this->mScriptLoaderClassList['js'] as $bucket => $classSet ){ |
358 | | - // Note we don't include the "core" bucket since its handled by |
359 | | - // includeCoreJS |
360 | | - if( count( $classSet) && $bucket != 'core' ){ |
| 365 | + // Note we don't include the "allpage" bucket since its handled by |
| 366 | + // includeAllPageJS |
| 367 | + // allpage scripts are handled separately to ensure |
| 368 | + // they are at the top of the page. |
| 369 | + if( count( $classSet) && $bucket != 'allpage' ){ |
361 | 370 | $s .= "\n<!-- Script bucket: $bucket --> \n"; |
362 | 371 | $s .= $this->getLinkedScriptLoaderJs( $classSet ); |
363 | 372 | } |
— | — | @@ -383,7 +392,7 @@ |
384 | 393 | * @return boolean False if the class wasn't found, True on success |
385 | 394 | */ |
386 | 395 | function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') { |
387 | | - global $wgDebugJavaScript, $wgJSAutoloadClasses, $IP, |
| 396 | + global $wgDebugJavaScript, $wgScriptLoaderNamedPaths, $IP, |
388 | 397 | $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, |
389 | 398 | $wgUser; |
390 | 399 | |
— | — | @@ -458,12 +467,12 @@ |
459 | 468 | * @return String script path or Boolean false if not found |
460 | 469 | */ |
461 | 470 | function getClassFromPath( $path ) { |
462 | | - global $wgJSAutoloadClasses, $wgScriptPath; |
| 471 | + global $wgScriptLoaderNamedPaths, $wgScriptPath; |
463 | 472 | // Make sure we have the scriptClass paths loaded: |
464 | 473 | jsClassLoader::loadClassPaths(); |
465 | 474 | |
466 | 475 | // Check the autoload js class list |
467 | | - foreach( $wgJSAutoloadClasses as $className => $classPath ) { |
| 476 | + foreach( $wgScriptLoaderNamedPaths as $className => $classPath ) { |
468 | 477 | $classPath = "{$wgScriptPath}/{$classPath}"; |
469 | 478 | if( $path == $classPath ){ |
470 | 479 | return $className; |
— | — | @@ -560,7 +569,7 @@ |
561 | 570 | } |
562 | 571 | |
563 | 572 | // Add the latest msg rev id if $wgScriptModifiedMsgCheck is enabled |
564 | | - // NOTE this is too slow so its disabled ( we need to cache the msg key in the database ) |
| 573 | + // NOTE this is too slow so its disabled ( we need to cache the most recent msg key in the database ) |
565 | 574 | /* |
566 | 575 | if( $wgScriptModifiedMsgCheck ){ |
567 | 576 | $dbr = wfGetDB( DB_SLAVE ); |
Index: trunk/extensions/JS2Support/JS2Support.php |
— | — | @@ -17,28 +17,88 @@ |
18 | 18 | $wgExtensionMessagesFiles[ 'JS2Support' ] = $dir . 'JS2Support.i18n.php'; |
19 | 19 | $wgAutoloadClasses[ 'ScriptLoaderOutputPage' ] = $dir . 'ScriptLoaderOutputPage.php'; |
20 | 20 | |
| 21 | +$wgAutoloadClasses = array_merge( $wgAutoloadClasses, |
| 22 | + array( |
| 23 | + 'JSMin' => $dir . 'js/mwEmbed/includes/library/JSMin.php', |
| 24 | + 'Minify_CSS' => $dir . 'js/mwEmbed/includes/library/CSS.php', |
| 25 | + 'Minify_CommentPreserver' => $dir . 'js/mwEmbed/includes/library/CommentPreserver.php', |
| 26 | + 'Minify_CSS_Compressor' => $dir . 'js/mwEmbed/includes/library/CSS/Compressor.php', |
| 27 | + 'Minify_CSS_UriRewriter' => $dir . 'js/mwEmbed/includes/library/CSS/UriRewriter.php', |
| 28 | + 'JSMinException' => $dir . 'js/mwEmbed/includes/minify/JSMin.php', |
| 29 | + 'jsScriptLoader' => $dir . 'js/mwEmbed/jsScriptLoader.php', |
| 30 | + 'jsClassLoader' => $dir . 'js/mwEmbed/includes/jsClassLoader.php', |
| 31 | + 'simpleFileCache' => $dir . 'js/mwEmbed/jsScriptLoader.php', |
| 32 | + ) |
| 33 | +); |
| 34 | + |
| 35 | +// Autoloader for core mediaWiki JavaScript files (path is from the MediaWiki root folder) |
| 36 | +// All other named paths should be merged with this global |
| 37 | +$wgScriptLoaderNamedPaths = array( |
| 38 | + 'ajax' => 'skins/common/ajax.js', |
| 39 | + 'ajaxwatch' => 'skins/common/ajaxwatch.js', |
| 40 | + 'allmessages' => 'skins/common/allmessages.js', |
| 41 | + 'block' => 'skins/common/block.js', |
| 42 | + 'changepassword' => 'skins/common/changepassword.js', |
| 43 | + 'diff' => 'skins/common/diff.js', |
| 44 | + 'edit' => 'skins/common/edit.js', |
| 45 | + 'enhancedchanges.js' => 'skins/common/enhancedchanges.js', |
| 46 | + 'history' => 'skins/common/history.js', |
| 47 | + 'htmlform' => 'skins/common/htmlform.js', |
| 48 | + 'IEFixes' => 'skins/common/IEFixes.js', |
| 49 | + 'metadata' => 'skins/common/metadata.js', |
| 50 | + 'mwsuggest' => 'skins/common/mwsuggest.js', |
| 51 | + 'prefs' => 'skins/common/prefs.js', |
| 52 | + 'preview' => 'skins/common/preview.js', |
| 53 | + 'protect' => 'skins/common/protect.js', |
| 54 | + 'rightclickedit' => 'skins/common/rightclickedit.js', |
| 55 | + 'sticky' => 'skins/common/sticky.js', |
| 56 | + 'upload' => 'skins/common/upload.js', |
| 57 | + 'wikibits' => 'skins/common/wikibits.js', |
| 58 | + |
| 59 | + // Css bindings |
| 60 | + 'mw.style.shared' => 'skins/common/shared.css', |
| 61 | + 'mw.style.commonPrint' => 'skins/common/commonPrint.css', |
| 62 | + 'mw.style.vectorMainLTR' => 'skins/vector/main-ltr.css', |
| 63 | + 'mw.style.vectorMainRTR' => 'skins/vector/main-rtl.css', |
| 64 | + |
| 65 | + // Monobook css |
| 66 | + 'mw.sytle.mbMain' => 'skins/monobook/main.css', |
| 67 | + 'mw.style.mbIE5' => 'skins/monobook/IE50Fixes.css', |
| 68 | + 'mw.style.mbIE55' => 'skins/monobook/IE55Fixes.css', |
| 69 | + 'mw.style.mbIE60' => 'skins/skins/monobook/IE60Fixes.css', |
| 70 | + 'mw.style.mbIE7' => 'skins/monobook/IE70Fixes.css', |
| 71 | +); |
| 72 | + |
| 73 | + |
| 74 | +/** |
| 75 | + * Remap output page |
| 76 | + */ |
21 | 77 | $wgExtensionFunctions[] = 'wfReMapOutputPage'; |
22 | | - |
23 | 78 | function wfReMapOutputPage(){ |
24 | 79 | global $wgOut; |
25 | 80 | $wgOut = new StubObject( 'wgOut', 'ScriptLoaderOutputPage' ); |
26 | 81 | } |
27 | | -require_once( $dir . 'JS2AutoLoader.php' ); |
28 | 82 | |
29 | 83 | |
| 84 | + |
| 85 | +/*************************** |
| 86 | +* LocalSettings.php enabled js extensions |
| 87 | +****************************/ |
| 88 | +require_once( $dir . 'AddMediaWizard/AddMediaWizard.php' ); |
| 89 | + |
30 | 90 | /**************************** |
31 | | -* DefaultSettings.php |
| 91 | +* DefaultSettings.php |
32 | 92 | *****************************/ |
33 | 93 | |
34 | 94 | /* |
35 | | - * Array mapping JavaScript class to web path for use by the script loader. |
36 | | - * This is populated in AutoLoader.php. |
| 95 | + * Simple global to tell extensions JS2 support is available |
37 | 96 | */ |
38 | | -$wgJSAutoloadClasses = array(); |
| 97 | +$wgEnableJS2system = true; |
39 | 98 | |
| 99 | + |
40 | 100 | /** |
41 | 101 | * For defining the location of loader.js files of |
42 | | - * Extension mwEmbed modules. ( ie modules hosted inside of extensions ) |
| 102 | + * for js-modules. ( ie modules hosted inside of extensions ) |
43 | 103 | */ |
44 | 104 | $wgExtensionJavascriptLoader = array(); |
45 | 105 | |
— | — | @@ -101,7 +161,7 @@ |
102 | 162 | /** |
103 | 163 | * Path for mwEmbed normally js/mwEmbed/ |
104 | 164 | */ |
105 | | -$wgMwEmbedDirectory = "extensions/JS2Support/js/mwEmbed/"; |
| 165 | +$wgMwEmbedDirectory = "extensions/JS2Support/js/mwEmbed"; |
106 | 166 | |
107 | 167 | /** |
108 | 168 | * Enables javascript on debugging |
— | — | @@ -111,4 +171,3 @@ |
112 | 172 | $wgDebugJavaScript = false; |
113 | 173 | |
114 | 174 | |
115 | | -/* AddMedia Extension EntryPoints */ |
Index: trunk/extensions/JS2Support/JS2AutoLoader.php |
— | — | @@ -3,19 +3,18 @@ |
4 | 4 | /**************************** |
5 | 5 | * JS2 AutoLoader.php |
6 | 6 | *****************************/ |
7 | | -$wgAutoloadClasses = array_merge( $wgAutoloadClasses, |
8 | | - array( |
9 | | - 'JSMin' => $dir . 'js/mwEmbed/includes/library/JSMin.php', |
10 | | - 'Minify_CSS' => $dir . 'js/mwEmbed/includes/library/CSS.php', |
11 | | - 'Minify_CommentPreserver' => $dir . 'js/mwEmbed/includes/library/CommentPreserver.php', |
12 | | - 'Minify_CSS_Compressor' => $dir . 'js/mwEmbed/includes/library/CSS/Compressor.php', |
13 | | - 'Minify_CSS_UriRewriter' => $dir . 'js/mwEmbed/includes/library/CSS/UriRewriter.php', |
14 | | - 'JSMinException' => $dir . 'js/mwEmbed/includes/minify/JSMin.php', |
15 | | - 'jsScriptLoader' => $dir . 'js/mwEmbed/jsScriptLoader.php', |
16 | | - 'jsClassLoader' => $dir . 'js/mwEmbed/includes/jsClassLoader.php', |
17 | | - 'simpleFileCache' => $dir . 'js/mwEmbed/jsScriptLoader.php', |
18 | | - ) |
| 7 | +$mwEmbedAutoLoadClasses = array( |
| 8 | + 'JSMin' => $dir . 'mwEmbed/includes/library/JSMin.php', |
| 9 | + 'Minify_CSS' => $dir . 'mwEmbed/includes/library/CSS.php', |
| 10 | + 'Minify_CommentPreserver' => $dir . 'mwEmbed/includes/library/CommentPreserver.php', |
| 11 | + 'Minify_CSS_Compressor' => $dir . 'mwEmbed/includes/library/CSS/Compressor.php', |
| 12 | + 'Minify_CSS_UriRewriter' => $dir . 'mwEmbed/includes/library/CSS/UriRewriter.php', |
| 13 | + 'JSMinException' => $dir . 'mwEmbed/includes/minify/JSMin.php', |
| 14 | + 'jsScriptLoader' => $dir . 'mwEmbed/jsScriptLoader.php', |
| 15 | + 'jsClassLoader' => $dir . 'mwEmbed/includes/jsClassLoader.php', |
| 16 | + 'simpleFileCache' => $dir . 'mwEmbed/jsScriptLoader.php', |
19 | 17 | ); |
| 18 | +$wgAutoloadClasses = array_merge( $wgAutoloadClasses, $mwEmbedAutoLoadClasses); |
20 | 19 | |
21 | 20 | // Autoloader for core mediaWiki JavaScript files (path is from the MediaWiki folder) |
22 | 21 | $wgJSAutoloadLocalClasses = array( |
— | — | @@ -40,23 +39,10 @@ |
41 | 40 | 'upload' => 'skins/common/upload.js', |
42 | 41 | 'wikibits' => 'skins/common/wikibits.js', |
43 | 42 | |
44 | | - // JS2 entry points |
| 43 | + // js2 entry points |
45 | 44 | 'uploadPage' => $dir . 'uploadPage.js', |
46 | 45 | 'editPage' => $dir . 'editPage.js', |
47 | 46 | 'ajaxCategories' => $dir . 'ajaxcategories.js', |
48 | | - 'apiProxyPage' => $dir . 'apiProxyPage.js', |
49 | | - |
50 | | - // Css bindings |
51 | | - 'mw.style.shared' => 'skins/common/shared.css', |
52 | | - 'mw.style.commonPrint' => 'skins/common/commonPrint.css', |
53 | | - 'mw.style.vectorMainLTR' => 'skins/vector/main-ltr.css', |
54 | | - |
55 | | - //monobook css |
56 | | - 'mw.sytle.mbMain' => 'skins/monobook/main.css', |
57 | | - 'mw.style.mbIE5' => 'skins/monobook/IE50Fixes.css', |
58 | | - 'mw.style.mbIE55' => 'skins/monobook/IE55Fixes.css', |
59 | | - 'mw.style.mbIE60' => 'skins/skins/monobook/IE60Fixes.css', |
60 | | - 'mw.style.mbIE7' => 'skins/monobook/IE70Fixes.css', |
61 | | - |
| 47 | + 'apiProxyPage' => $dir . 'apiProxyPage.js' |
62 | 48 | ); |
63 | 49 | ?> |
Index: trunk/extensions/JS2Support/mwScriptLoader.php |
— | — | @@ -24,8 +24,8 @@ |
25 | 25 | * http://www.gnu.org/copyleft/gpl.html |
26 | 26 | */ |
27 | 27 | |
28 | | -// First do a quick check for the cached file |
29 | | -define('MW_CACHE_SCRIPT_CHECK', true); |
| 28 | +// Set a constant so the script-loader knows its not being used in "stand alone mode" |
| 29 | +define( 'SCRIPTLOADER_MEDIAWIKI', true); |
30 | 30 | |
31 | 31 | require_once( dirname(__FILE__) . '/js/mwEmbed/jsScriptLoader.php'); |
32 | 32 | // Do quick cache check via jsScriptLoader |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | |
38 | 38 | // Else no-cache hit load up mediaWiki stuff and continue scriptloader processing: |
39 | 39 | |
40 | | -// Change to root mediaWiki directory |
| 40 | +// Change to root mediaWiki directory |
41 | 41 | chdir( '../../' ); |
42 | 42 | |
43 | 43 | // include WebStart.php |
— | — | @@ -64,3 +64,4 @@ |
65 | 65 | $myScriptLoader->doScriptLoader(); |
66 | 66 | |
67 | 67 | wfProfileOut( 'mwScriptLoader.php' ); |
| 68 | + |
Index: trunk/extensions/JS2Support/README |
— | — | @@ -0,0 +1,70 @@ |
| 2 | += JS2 Support Extension = |
| 3 | + |
| 4 | +To add the base js2 library support simply add the following to your LocalSettings.php: |
| 5 | +require_once( "$IP/extensions/JS2Support/JS2Support.php" ); |
| 6 | + |
| 7 | +== LocalSettings.php to enable all js2 components == |
| 8 | + |
| 9 | +# Base JS2 Support |
| 10 | +require_once( "$IP/extensions/JS2Support/JS2Support.php" ); |
| 11 | + |
| 12 | +# Add Media Wizard |
| 13 | +require_once( "$IP/extensions/JS2Support/AddMediaWizard/AddMediaWizard.php" ); |
| 14 | + |
| 15 | +# Upload Wizard |
| 16 | +require_once( "$IP/extensions/JS2Support/UploadWizard/UploadWizard.php" ); |
| 17 | + |
| 18 | +# Ogg Handler with new player, transcoding + subtitle support. |
| 19 | +require_once( "$IP/extensions/JS2Support/OggHandler/OggHandler.php" ); |
| 20 | + |
| 21 | +== Developing and Debug mode == |
| 22 | + |
| 23 | +By default js2 support groups script and css requests, disable script grouping set: |
| 24 | +$wgEnableScriptLoader = false; |
| 25 | + |
| 26 | +If you want a fresh copy of the scripts and to disable minification in grouped requests set: |
| 27 | +$wgDebugJavaScript = true; |
| 28 | + |
| 29 | + |
| 30 | +== Using JS2 with existing extensions == |
| 31 | + |
| 32 | +Simply add the Named path to wgScriptLoaderNamedPaths variable |
| 33 | +$wgScriptLoaderNamedPaths[ 'myExtension' ] = 'extensions/myExtension/myExtension.js'; |
| 34 | + |
| 35 | +If you would like to keep compatibility with non-js2 extension support you can then |
| 36 | +just use the base outputPage addScriptFile method |
| 37 | +$wgOut->addScriptFile( 'extensions/myExtension/myExtension.js' ) |
| 38 | + |
| 39 | +If you want to have JS2Support be a dependency of your extension you can then use something like: |
| 40 | +$wgOut->addScriptClass( 'myExtension', 'page' ); |
| 41 | +This lets you use the namedPath for includes and gives you control over script grouping. |
| 42 | +For more info see ScriptLoaderOutputPage.php $mScriptLoaderClassList |
| 43 | + |
| 44 | + |
| 45 | +== Using JS2 with js-modules == |
| 46 | + |
| 47 | +JS Modules are reusable pieces of javascript that can be dynamically configured, loaded |
| 48 | +and executed in arbitrary javascript contexts. |
| 49 | + |
| 50 | +JS modules include "module loaders" that build request sets of the dependent javascript |
| 51 | +and css classes for a given interface component in the context of user or application |
| 52 | +configuration. |
| 53 | + |
| 54 | +When an application wants to use that interface component it calls the module loader. |
| 55 | +The module loader checks relevant configuration and javascript application state for existing |
| 56 | +satisfied dependencies or browser specific libraries, then issues a single script-loader |
| 57 | +request that retrieves all the needed javascript, css and localized message text for |
| 58 | +that interface in minfied, gziped |
| 59 | + |
| 60 | +For now see example modules, more documentation to follow. |
| 61 | + |
| 62 | +== Using JS2 localization system == |
| 63 | + |
| 64 | +The JS2 Localization system works similar to its php counterpart. |
| 65 | +( it even support for {{PLURAL}} transforms ) |
| 66 | + |
| 67 | +To enable JS2 localization of included scripts include the |
| 68 | +msg keys you want included with a given class in the head of the javascript file: |
| 69 | + |
| 70 | +mw.addMessegeKeys( ['list', 'of', 'msg-keys' ] ); |
| 71 | + |