r65977 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65976‎ | r65977 | r65978 >
Date:02:26, 6 May 2010
Author:dale
Status:deferred
Tags:
Comment:
* restored r65942 with fix for mw.Language.js include
Modified paths:
  • /branches/js2-work/phase3/js/editPage.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/languages/mw.Language.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/languages/mw.Language.js
@@ -29,7 +29,7 @@
3030 }
3131 }
3232
33 - mw.currentClassMissingMessages = true;
 33+ mw.currentClassMissingMessages = false;
3434 /**
3535 * mw.addMessagesKey function
3636 * Adds a msgKey to be pulled in remotely.
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -611,7 +611,7 @@
612612 doHttpUpload: function( params ) {
613613 var _this = this;
614614 // Get a clean setup of the interface dispatch
615 - this.ui.setup( {'title': gM('mwe-upload-in-progress') } );
 615+ this.ui.setup( { 'title' : gM('mwe-upload-in-progress') } );
616616
617617 // Set the interface dispatch to loading ( in case we don't get an update for some time )
618618 this.ui.setLoading();
@@ -634,6 +634,7 @@
635635 _this.action_done = false;
636636
637637 // Do the api request:
 638+ mw.log(" about to run upload request: " + request );
638639 mw.getJSON(_this.apiUrl, request, function( data ) {
639640 _this.processApiResult( data );
640641 });
@@ -1018,7 +1019,7 @@
10191020 'border' : 0,
10201021 'width' : 15,
10211022 'height' : 11,
1022 - 'src' : mw.getConfig( 'images_path' ) + 'magnify-clip.png'
 1023+ 'src' : mw.getConfig( 'imagesPath' ) + 'magnify-clip.png'
10231024 } ),
10241025
10251026 $j('<span />')
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1188,7 +1188,7 @@
11891189
11901190 $j('<img />' )
11911191 .attr( {
1192 - 'src': mw.getConfig('images_path' ) + 'cookies_blocked_MSIE_eye.png',
 1192+ 'src': mw.getConfig('imagesPath' ) + 'cookies_blocked_MSIE_eye.png',
11931193 'alt' : gM('mwe-ie-eye-permision' )
11941194 })
11951195 );
@@ -1771,7 +1771,7 @@
17721772 // Check for missing poster types for audio
17731773 if ( (resource.mime == 'audio/ogg' || resource.mime == 'application/ogg')
17741774 && !resource.poster ) {
1775 - resource.poster = mw.getConfig( 'images_path' ) + 'sound_music_icon-80.png';
 1775+ resource.poster = mw.getConfig( 'imagesPath' ) + 'sound_music_icon-80.png';
17761776 }
17771777
17781778 var $resultThumb = $j( '<img />' )
@@ -2723,17 +2723,19 @@
27242724 mw.log( ":doApiImport:" );
27252725 mw.addLoaderDialog( gM( 'mwe-importing_asset' ) );
27262726
 2727+ alert( 'do copy-by-url import currently dissabled ');
 2728+
27272729 // Load the BaseUploadInterface:
27282730 mw.load(
27292731 [
2730 - 'mw.BaseUploadInterface',
 2732+ 'mw.UploadInterface',
27312733 '$j.ui.progressbar'
27322734 ],
27332735 function() {
2734 - mw.log( 'mvBaseUploadInterface ready' );
 2736+ mw.log( 'mw.UploadInterface ready' );
27352737 // Initiate a upload object ( similar to url copy ):
27362738 // ( mvBaseUploadInterface handles upload errors )
2737 - var uploader = new mw.BaseUploadInterface( {
 2739+ var uploader = new mw.UploadDialogInterface( {
27382740 'apiUrl' : _this.upload_api_target,
27392741 'doneUploadCb': function() {
27402742 mw.log( 'doApiImport:: run callback::' );
@@ -2964,10 +2966,10 @@
29652967 createLayoutSelector: function() {
29662968
29672969 var _this = this;
2968 - var darkBoxUrl = mw.getConfig( 'images_path' ) + 'box_layout_icon_dark.png';
2969 - var lightBoxUrl = mw.getConfig( 'images_path' ) + 'box_layout_icon.png';
2970 - var darkListUrl = mw.getConfig( 'images_path' ) + 'list_layout_icon_dark.png';
2971 - var lightListUrl = mw.getConfig( 'images_path' ) + 'list_layout_icon.png';
 2970+ var darkBoxUrl = mw.getConfig( 'imagesPath' ) + 'box_layout_icon_dark.png';
 2971+ var lightBoxUrl = mw.getConfig( 'imagesPath' ) + 'box_layout_icon.png';
 2972+ var darkListUrl = mw.getConfig( 'imagesPath' ) + 'list_layout_icon_dark.png';
 2973+ var lightListUrl = mw.getConfig( 'imagesPath' ) + 'list_layout_icon.png';
29722974
29732975 var defaultBoxUrl, defaultListUrl;
29742976 if ( _this.displayMode == 'box' ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -104,12 +104,8 @@
105105 } else {
106106 // Issue play request
107107 vid.play();
108 - }
 108+ }
109109
110 -
111 - // Run the "hook" for any extensions that need to bind things to the actual video elemnt
112 - this.runHook( 'postEmbedJS' )
113 -
114110 setTimeout( function() {
115111 _this.monitor();
116112 }, 100 );
@@ -153,8 +149,9 @@
154150 // try to do a play then seek:
155151 this.doPlayThenSeek( percentage )
156152 }
 153+
157154 // Run the onSeeking interface update
158 - this.onSeek();
 155+ this.ctrlBuilder.onSeek();
159156 },
160157
161158 /**
@@ -168,9 +165,7 @@
169166 },
170167
171168 /**
172 - * Do a play request
173 - * then check if the video is ready to play
174 - * then seek
 169+ * Seek in a existing stream
175170 *
176171 * @param {Float} percentage Percentage of the stream to seek to between 0 and 1
177172 */
@@ -380,10 +375,10 @@
381376 * Local method for seeking event
382377 * fired when "seeking"
383378 */
384 - onSeeking: function() {
385 - //mw.log( "onseeking" );
386 - this.seeking = true;
387 - this.setStatus( gM( 'mwe-seeking' ) );
 379+ onSeeking: function() {
 380+ // Run the onSeeking interface update
 381+ this.ctrlBuilder.onSeek();
 382+
388383 // Trigger the html5 seeking event
389384 $j( this ).trigger( 'seeking' );
390385 },
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/loader.js
@@ -17,7 +17,7 @@
1818 mw.load( [
1919 'mw.Firefogg',
2020 'mw.FirefoggRender',
21 - 'mw.BaseUploadInterface'
 21+ 'mw.UploadInterface'
2222 ], function() {
2323 callback( 'FirefoggRender' );
2424 });
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -63,7 +63,9 @@
6464 * @param [Mixed] name Name of configuration value
6565 * {Object} Will iderate through each key and call setConfig
6666 * {String} Will set configuration by string name to value
67 - * @param {String} value Value of configuration name
 67+ * @param
 68+ * {String} value Value of configuration name
 69+ * {Object} value Set of values to be merged
6870 */
6971 mw.setConfig = function ( name, value ) {
7072 if( typeof name == 'object' ) {
@@ -80,7 +82,7 @@
8183 } else {
8284 mwConfig[ name ] = value;
8385 }
84 - }
 86+ }
8587
8688 /**
8789 * Set a default config value
@@ -122,8 +124,8 @@
123125 * Modules that want to use "User Config" should call
124126 * this setup function in their moduleLoader code.
125127 *
126 - * For performance interfaces should load '$j.cookie' & 'JSON'
127 - * in their grouped load request
 128+ * For performance interfaces using "user config"
 129+ * should load '$j.cookie' & 'JSON' in their module loader
128130 *
129131 * By abstracting user preference we could eventually integrate
130132 * a persistent per-account preference system on the server.
@@ -557,6 +559,7 @@
558560 instanceCallback = null;
559561 }
560562 }
 563+
561564 // Check for empty loadRequest ( directly return the callback )
562565 if( mw.isEmpty( loadRequest ) ) {
563566 mw.log( 'Empty load request: ' + loadRequest );
@@ -812,7 +815,8 @@
813816 + _this.getClassPath( className ) );
814817 }
815818
816 - // If ( debug mode ) and the script include
 819+ // If ( debug mode ) and the script include is missing class messages
 820+ // do a seperate request to retrive the msgs
817821 if( mw.currentClassMissingMessages ){
818822 mw.loadClassMessages( className, function(){
819823 //reset the currentClassMissingMessages flag
@@ -1039,7 +1043,7 @@
10401044 * mediaWiki JSON a wrapper for jQuery getJSON:
10411045 * ( could also be named mw.apiRequest )
10421046 *
1043 - * The mediaWiki version lets you skip the url part
 1047+ * The mwEmbed version lets you skip the url part
10441048 * mw.getJSON( [url], data, callback, [timeoutCallback] );
10451049 *
10461050 * Lets you assume:
@@ -1048,18 +1052,19 @@
10491053 * callback parameter is not needed for the request data
10501054 * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param
10511055 * format is set to "json" automatically
1052 - * automatically issues request over "POST" if the request requires a post
1053 - * automatically will setup apiProxy where needed.
 1056+ * automatically issues request over "POST" if the request api post type
 1057+ * automatically will setup apiProxy where request is cross domain
10541058 *
10551059 * @param {Mixed} url or data request
10561060 * @param {Mixed} data or callback
10571061 * @param {Function} callbcak function called on success
10581062 * @param {Function} callbackTimeout - optional function called on timeout
1059 - * Setting timeout callback also avoids default dialog display for timed-out proxy calls.
 1063+ * Setting timeout callback also avoids default timed-out dialog for proxy requests
10601064 */
1061 - mw.getJSON = function() {
1062 - // Set up the url
1063 -
 1065+ mw.getJSON = function() {
 1066+ // Proccess the arguments:
 1067+
 1068+ // Set up the url
10641069 var url = false;
10651070 url = ( typeof arguments[0] == 'string' ) ? arguments[0] : mw.getLocalApiUrl();
10661071
@@ -1203,7 +1208,8 @@
12041209 *
12051210 * @param {String} [apiUrl] Optional target API URL (uses default local api if unset)
12061211 * @param {String} title The wiki page title you want to edit
1207 - * @param {callback} callback Function to pass the token to returns false if token not retrived
 1212+ * @param {callback} callback Function to pass the token to.
 1213+ * issues callback with "false" if token not retrived
12081214 */
12091215 mw.getToken = function( apiUrl, title, callback ) {
12101216 // Make the apiUrl be optional:
@@ -1235,7 +1241,8 @@
12361242 /**
12371243 * Api helper to grab the username
12381244 * @param {String} [apiUrl] Optional target API url (uses default local api if unset)
1239 - * @param {Function} callback Function to callback with username or false if not found
 1245+ * @param {Function} callback Function to callback with username or false if not found
 1246+ * @param {Boolean} fresh A fresh check is issued.
12401247 */
12411248 // Stub feature apiUserNameCache to avoid multiple calls
12421249 // ( a more general api cache framework should be devloped )
@@ -1295,7 +1302,7 @@
12961303 * addLoaderDialog
12971304 * small helper for displaying a loading dialog
12981305 *
1299 - * @param msg text text of the loader msg
 1306+ * @param {String} msg_txt text text of the loader msg
13001307 */
13011308 mw.addLoaderDialog = function( msg_txt ) {
13021309 mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() );
@@ -1362,16 +1369,11 @@
13631370 * Close the loader dialog created with addLoaderDialog
13641371 */
13651372 mw.closeLoaderDialog = function() {
1366 - mw.load( [
1367 - [
1368 - '$j.ui'
1369 - ],
1370 - [
1371 - '$j.ui.dialog'
1372 - ]
1373 - ], function() {
1374 - $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove();
1375 - } );
 1373+ // Make sure the dialog class is present
 1374+ if( !mw.isset( '$j.ui.dialog' ) ) {
 1375+ return false;
 1376+ }
 1377+ $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove();
13761378 }
13771379
13781380
@@ -1517,7 +1519,7 @@
15181520 var mwReadyFlag = false;
15191521
15201522 /**
1521 - * Enables load hooks to run once DOM is "ready"
 1523+ * Enables load hooks to run once mwEmbeed is "ready"
15221524 * Will ensure jQuery is available, is in the $j namespace
15231525 * and mw interfaces and configuration has been loaded and applied
15241526 *
@@ -1530,20 +1532,7 @@
15311533 mw.ready = function( callback ) {
15321534 if( mwReadyFlag === false ) {
15331535 // Add the callbcak to the onLoad function stack
1534 - mwOnLoadFunctions.push ( callback );
1535 -
1536 - // Set the mwSetup flag. So that onLoad functions can
1537 - // be called once mwEmbed interfaces are setup.
1538 - if( !mwDomReadyFlag ) {
1539 - //mw.log( 'set config flag' );
1540 - mw.setConfig( 'runSetupMwEmbed', true );
1541 - }else{
1542 - //DOM is already ready run setup directly ( will run mwOnLoadFunctions on finish )
1543 - // This is needed beccause we support dynamic setup once we hit a mw.ready
1544 - // ( otherwise we would run setup on every include )
1545 - mw.setupMwEmbed();
1546 - }
1547 - return ;
 1536+ mwOnLoadFunctions.push ( callback );
15481537 }
15491538 // If mwReadyFlag is already "true" issue the callback directly:
15501539 callback();
@@ -1551,6 +1540,7 @@
15521541
15531542 /**
15541543 * Runs all the queued functions
 1544+ * called by mwEmbedSetup
15551545 */
15561546 mw.runReadyFunctions = function ( ) {
15571547 // Run all the queued functions:
@@ -1643,7 +1633,7 @@
16441634 };
16451635 //mw.log(" append script: " + script.src );
16461636 // Append the script to the DOM:
1647 - head.appendChild( script );
 1637+ head.appendChild( script );
16481638 };
16491639
16501640 /**
@@ -2153,149 +2143,176 @@
21542144
21552145 mw.log( 'mw:setupMwEmbed :: ' + mw.getMwEmbedSrc() );
21562146
2157 - // Set the User language
2158 - if( typeof wgUserLanguage != 'undefined' && mw.isValidLang( wgUserLanguage) ) {
2159 - mw.setConfig( 'userLanguage', wgUserLanguage )
2160 - }else{
2161 - // Grab it from the included url
2162 - var langKey = mw.parseUri( mw.getMwEmbedSrc() ).queryKey['uselang'];
2163 - if ( langKey && mw.isValidLang( langKey ) ) {
2164 - mw.setConfig( 'userLanguage', langKey);
2165 - }
2166 - }
2167 -
2168 - // Make sure we have jQuery and the common skin
2169 - // NOTE mw.style.mwCommon should be factored out into
2170 - // seperate module specifc classes
2171 - mw.load( 'window.jQuery', function() {
2172 - if ( ! window[ '$j' ] ) {
2173 - window[ '$j' ] = jQuery.noConflict();
2174 - }
 2147+ // Check core mwEmbed loader.js file ( to get configuration and paths )
 2148+ mw.checkCoreLoaderFile( function(){
21752149
2176 - mw.setConfig( 'images_path', mw.getMwEmbedPath() + 'skins/common/images/' );
2177 -
2178 - // Set up AJAX to not send dynamic URLs for loading scripts
2179 - $j.ajaxSetup( {
2180 - cache: true
2181 - } );
2182 -
2183 - // Update the magic keywords
2184 - mw.Language.magicSetup();
2185 -
2186 - // Set up mvEmbed utility jQuery bindings
2187 - mw.dojQueryBindings();
2188 -
2189 - // Make sure style sheets are loaded:
2190 - mw.load( [
2191 - 'mw.style.mwCommon',
2192 - 'mw.style.' + mw.getConfig( 'jQueryUISkin' )
2193 - ], function(){
2194 - // Run all the setup function hooks
2195 - // Once complete we can run .ready queued functions
2196 - function runSetupFunctions() {
2197 - if( mwSetupFunctions.length ) {
2198 - mwSetupFunctions.pop()( function() {
2199 - runSetupFunctions();
2200 - } );
 2150+ // Make sure we have jQuery
 2151+ mw.load( 'window.jQuery', function() {
 2152+
 2153+ // Add jQuery to $j var.
 2154+ if ( ! window[ '$j' ] ) {
 2155+ window[ '$j' ] = jQuery.noConflict();
 2156+ }
 2157+
 2158+ // Get module loader.js, and language files
 2159+ // ( will hit callback directly if set via script-loader )
 2160+ mw.checkModuleLoaderFiles( function() {
 2161+
 2162+ // Set the User language
 2163+ if( typeof wgUserLanguage != 'undefined' && mw.isValidLang( wgUserLanguage) ) {
 2164+ mw.setConfig( 'userLanguage', wgUserLanguage )
22012165 }else{
2202 - mw.runReadyFunctions();
 2166+ // Grab it from the included url
 2167+ var langKey = mw.parseUri( mw.getMwEmbedSrc() ).queryKey['uselang'];
 2168+ if ( langKey && mw.isValidLang( langKey ) ) {
 2169+ mw.setConfig( 'userLanguage', langKey);
 2170+ }
22032171 }
2204 - }
2205 - runSetupFunctions();
 2172+
 2173+
 2174+ // Update the image path
 2175+ mw.setConfig( 'imagesPath', mw.getMwEmbedPath() + 'skins/common/images/' );
 2176+
 2177+ // Set up AJAX to not send dynamic URLs for loading scripts
 2178+ $j.ajaxSetup( {
 2179+ cache: true
 2180+ } );
 2181+
 2182+ // Update the magic keywords
 2183+ mw.Language.magicSetup();
 2184+
 2185+ // Set up mvEmbed utility jQuery bindings
 2186+ mw.dojQueryBindings();
 2187+
 2188+ // Make sure style sheets are loaded:
 2189+ mw.load( [
 2190+ 'mw.style.mwCommon',
 2191+ 'mw.style.' + mw.getConfig( 'jQueryUISkin' )
 2192+ ], function(){
 2193+
 2194+ // Run all the setup function hooks
 2195+ // NOTE: setup functions are added via addSetupHook calls
 2196+ // and must include a callback.
 2197+ //
 2198+ // Once complete we can run .ready() queued functions
 2199+ function runSetupFunctions() {
 2200+ if( mwSetupFunctions.length ) {
 2201+ mwSetupFunctions.shift()( function() {
 2202+ runSetupFunctions();
 2203+ } );
 2204+ }else{
 2205+ mw.runReadyFunctions();
 2206+ }
 2207+ }
 2208+ runSetupFunctions();
 2209+ });
 2210+ } );
22062211 });
2207 - });
 2212+ });
22082213 };
22092214
 2215+ /**
 2216+ * Loads the core mwEmbed "loader.js" file config
 2217+ *
 2218+ * NOTE: if using the ScriptLoader all the loaders and localization converters
 2219+ * are included automatically
 2220+ *
 2221+ * @param {Function} callback Function called once core loader file is loaded
 2222+ */
 2223+ mw.checkCoreLoaderFile = function( callback ) {
 2224+ // Check if we are using scriptloader ( handles loader include automatically )
 2225+ if( mw.getScriptLoaderPath() ) {
 2226+ callback();
 2227+ return ;
 2228+ }
 2229+ // Add the Core loader to the request
 2230+ // The follow code is ONLY RUN in debug / raw file mode
 2231+ mw.load( 'loader.js', callback );
 2232+ }
 2233+
22102234 /**
2211 - * Check for module loaders, and localization
 2235+ * Check for script-loader module loaders, and localization files
22122236 *
2213 - * Note if using a scriptLoader all the loaders and localization converters
 2237+ * NOTE: if using the ScriptLoader all the loaders and localization converters
22142238 * are included automatically.
22152239 */
2216 - mw.moduleLoaderCheck = function( callback ) {
 2240+ mw.checkModuleLoaderFiles = function( callback ) {
22172241 mw.log( 'doLoaderCheck::' );
22182242
22192243 // Check if we are using scriptloader ( handles loader include automatically )
22202244 if( mw.getScriptLoaderPath() ) {
2221 - // Do a async call to callback in cases where DOM is ready before we get to
2222 - // loader config code in the same file.
2223 - setTimeout(function() {
2224 - callback();
2225 - }, 1);
 2245+ callback();
22262246 return ;
22272247 }
 2248+
 2249+ // Load the configured modules / components
 2250+ // The follow code is ONLY RUN in debug / raw file mode
 2251+ var loaderRequest = [];
22282252
2229 - // Add the Core loader to the request
2230 - // The follow code is only run in debug / raw file mode
2231 - mw.load( 'loader.js', function() {
2232 - // Load all the "loaders" of the enabled modules:
2233 - var loaderRequest = [];
2234 -
2235 -
2236 - //Load enabled components
2237 - var enabledComponents = mw.getConfig( 'coreComponents' );
2238 - function loadEnabledComponents( enabledComponents ){
2239 - if( ! enabledComponents.length ){
2240 - // If no more components load modules::
 2253+ //Load enabled components
 2254+ var enabledComponents = mw.getConfig( 'coreComponents' );
 2255+ function loadEnabledComponents( enabledComponents ){
 2256+ if( ! enabledComponents.length ){
 2257+ // If no more components load modules::
 2258+
 2259+ // Add the enabledModules loaders:
 2260+ var enabledModules = mw.getConfig( 'enabledModules' );
 2261+ loadEnabledModules( enabledModules );
 2262+ return ;
 2263+ }
 2264+ var componentName = enabledComponents.shift();
 2265+ mw.load( componentName, function(){
 2266+ loadEnabledComponents( enabledComponents );
 2267+ } );
 2268+ }
 2269+ loadEnabledComponents( enabledComponents );
 2270+
22412271
2242 - // Add the enabledModules loaders:
2243 - var enabledModules = mw.getConfig( 'enabledModules' );
2244 - loadEnabledModules( enabledModules );
2245 - return ;
2246 - }
2247 - var componentName = enabledComponents.shift();
2248 - mw.load( componentName, function(){
2249 - loadEnabledComponents( enabledComponents );
2250 - } );
 2272+ // Set the loader context and get each loader individually
 2273+ function loadEnabledModules( enabledModules ){
 2274+ if( ! enabledModules.length ){
 2275+ // If no more modules left load the LanguageFile
 2276+ addLanguageFile();
 2277+ return ;
22512278 }
2252 - loadEnabledComponents( enabledComponents );
 2279+ var moduleName = enabledModules.shift();
 2280+ mw.setConfig( 'loaderContext', 'modules/' + moduleName + '/' );
 2281+ mw.load( 'modules/' + moduleName + '/loader.js', function(){
 2282+ loadEnabledModules( enabledModules );
 2283+ } );
 2284+ }
 2285+
 2286+ function addLanguageFile(){
 2287+ // Add the language file
 2288+ var langLoaderRequest = [];
22532289
2254 -
2255 - //Set the loader context and get each loader individually ( only in debug mode )
2256 - function loadEnabledModules( enabledModules ){
2257 - if( ! enabledModules.length ){
2258 - // If no more modules left load the LanguageFile
2259 - addLanguageFile();
2260 - return ;
 2290+ if( mw.getConfig( 'userLanguage' ) ) {
 2291+ var langCode = mw.getConfig( 'userLanguage' );
 2292+
 2293+ // Load the language class if not default 'en'
 2294+ var transformKey = mw.getLangTransformKey( langCode );
 2295+ if( transformKey != 'en' ){
 2296+ // Upper case the first letter:
 2297+ langCode = langCode.substr(0,1).toUpperCase() + langCode.substr( 1, langCode.length );
 2298+ langLoaderRequest.push( 'languages/classes/Language' +
 2299+ langCode + '.js' );
22612300 }
2262 - var moduleName = enabledModules.shift();
2263 - mw.setConfig( 'loaderContext', 'modules/' + moduleName + '/' );
2264 - mw.load( 'modules/' + moduleName + '/loader.js', function(){
2265 - loadEnabledModules( enabledModules );
2266 - } );
2267 - }
2268 -
2269 - function addLanguageFile(){
2270 - // Add the language file
2271 - var langLoaderRequest = [];
22722301
2273 - if( mw.getConfig( 'userLanguage' ) ) {
2274 - var langCode = mw.getConfig( 'userLanguage' );
2275 -
2276 - // Load the language class if not default 'en'
2277 - var transformKey = mw.getLangTransformKey( langCode );
2278 - if( transformKey != 'en' ){
2279 - // Upper case the first letter:
2280 - langCode = langCode.substr(0,1).toUpperCase() + langCode.substr( 1, langCode.length );
2281 - langLoaderRequest.push( 'languages/classes/Language' +
2282 - langCode + '.js' );
2283 - }
 2302+ }
 2303+ if ( ! langLoaderRequest.length ) {
 2304+ callback();
 2305+ return ;
 2306+ }
 2307+
 2308+ // Load the launage if set
 2309+ mw.load( langLoaderRequest, function(){
 2310+ mw.log( 'Done moduleLoaderCheck request' );
 2311+ // Set the mwModuleLoaderCheckFlag flag to true
 2312+ mwModuleLoaderCheckFlag = true;
 2313+ callback();
 2314+ } );
 2315+ }
22842316
2285 - }
2286 - if ( ! langLoaderRequest.length ) {
2287 - callback();
2288 - return ;
2289 - }
2290 -
2291 - // Load the launage if set
2292 - mw.load( langLoaderRequest, function(){
2293 - mw.log( 'Done moduleLoaderCheck request' );
2294 - // Set the mwModuleLoaderCheckFlag flag to true
2295 - mwModuleLoaderCheckFlag = true;
2296 - callback();
2297 - } );
2298 - }
2299 - } );
23002317 }
23012318
23022319 /**
@@ -2339,29 +2356,7 @@
23402357 var mwDomReadyFlag = false;
23412358
23422359 // Flag to register if the domreadyHooks have been called
2343 - var mwModuleLoaderCheckFlag = false;
2344 -
2345 - // Functions to run on DOM ready
2346 - var mwOnDOMReadyFunctions = [];
2347 -
2348 - /**
2349 - * Dom ready hooks are for module loaders that want to conditionally
2350 - * set setup hooks.
2351 - *
2352 - * This enables modules to build out interfaces asynchronously
2353 - * to be "ready" at mw.ready call time.
2354 - *
2355 - * @param {Function} callback Function to be called at dom ready
2356 - */
2357 - mw.addDOMReadyHook = function( callback ) {
2358 - if ( mwModuleLoaderCheckFlag ) {
2359 - mw.log( "Possible Error: calling mw.addDOMReadyHook after moduleLoader check ?" );
2360 - callback ( );
2361 - } else {
2362 - // Add the dom ready check to the function queue:
2363 - mwOnDOMReadyFunctions.push( callback );
2364 - }
2365 - }
 2360+ var mwModuleLoaderCheckFlag = false;
23662361
23672362 /**
23682363 * This will get called when the DOM is ready
@@ -2374,28 +2369,9 @@
23752370 mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length );
23762371 // Set the onDomReady Flag
23772372 mwDomReadyFlag = true;
2378 -
2379 - // Make sure we have all the module loader.js files included
2380 - // ( where we are not using the script-loader )
2381 - mw.moduleLoaderCheck( function( ) {
2382 -
2383 - // Run dom ready hooks:
2384 - while( mwOnDOMReadyFunctions.length ) {
2385 - mwOnDOMReadyFunctions.pop()();
2386 - }
2387 -
2388 - // Check for the force setup flag:
2389 - if ( mw.getConfig( 'runSetupMwEmbed' ) ) {
2390 - mw.setupMwEmbed();
2391 - return ;
2392 - }
2393 -
2394 - // Check for queued functions that use mw interfaces:
2395 - if ( mwOnLoadFunctions.length ) {
2396 - mw.setupMwEmbed();
2397 - return ;
2398 - }
2399 - });
 2373+
 2374+ // Setup MwEmbed
 2375+ mw.setupMwEmbed();
24002376 }
24012377
24022378 /**
@@ -2560,6 +2536,7 @@
25612537 * mwEmbed.js is included without jQuery
25622538 * and we need our own "ready" system so that
25632539 * mwEmbed interfaces can support async built out
 2540+* and the inclution of jQuery.
25642541 */
25652542 var mwDomIsReady = false;
25662543 function runMwDomReady(){
@@ -2638,8 +2615,13 @@
26392616 }
26402617
26412618
2642 -// Hack to keep jQuery in $ when its
2643 -// already there, but also use noConflict to get $j = jQuery
 2619+/*
 2620+ * Hack to keep jQuery in $ when its
 2621+ * already there, but also use noConflict to get $j = jQuery
 2622+ *
 2623+ * This way sites that use $ for jQuery continue to work after
 2624+ * including mwEmbed.js
 2625+ */
26442626 if( window.jQuery ){
26452627 var dollarFlag = false;
26462628 if( $ && $.fn && $.fn.jquery ){
@@ -2647,8 +2629,13 @@
26482630 // jQuery and do a removal call if too old
26492631 dollarFlag = true;
26502632 }
2651 - window['$j'] = jQuery.noConflict();
 2633+ window[ '$j' ] = jQuery.noConflict();
26522634 if( dollarFlag ) {
2653 - window['$'] = jQuery.noConflict();
 2635+ window[ '$' ] = jQuery.noConflict();
26542636 }
26552637 }
 2638+
 2639+// If using the script-loader and jQuery has not been set give a warning to the user:
 2640+if( mw.getScriptLoaderPath() && !window.jQuery ) {
 2641+ alert( 'jQuery is required for mwEmbed, please update your script-loader request' );
 2642+}
\ No newline at end of file
Index: branches/js2-work/phase3/js/editPage.js
@@ -23,7 +23,7 @@
2424 'local_wiki_apiUrl': wgServer + wgScriptPath + '/api.php'
2525 };
2626
27 -mw.ready( function() {
 27+mw.ready( function() {
2828 mw.log( "edit page mw.ready::" );
2929 var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig );
3030 // Kind of tricky, it would be nice to use run on ready "loader" call here
@@ -61,7 +61,7 @@
6262 mw.log( 'Do old toolbar bind:' );
6363 didWikiEditorBind = true;
6464 $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
65 - mw.getConfig( 'images_path' ) + 'Button_add_media.png">' );
 65+ mw.getConfig( 'imagesPath' ) + 'Button_add_media.png">' );
6666
6767 $j( '#btn-add-media-wiz' ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) );
6868 mw.load( 'AddMedia.addMediaWizard', function() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65942* switched to .bind and .trigger based hook system ( instead of the custom ad...dale06:21, 5 May 2010

Status & tagging log