Index: branches/js2-work/phase3/js/mwEmbed/languages/mw.Language.js |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | | - mw.currentClassMissingMessages = true; |
| 33 | + mw.currentClassMissingMessages = false; |
34 | 34 | /** |
35 | 35 | * mw.addMessagesKey function |
36 | 36 | * Adds a msgKey to be pulled in remotely. |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js |
— | — | @@ -611,7 +611,7 @@ |
612 | 612 | doHttpUpload: function( params ) { |
613 | 613 | var _this = this; |
614 | 614 | // 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') } ); |
616 | 616 | |
617 | 617 | // Set the interface dispatch to loading ( in case we don't get an update for some time ) |
618 | 618 | this.ui.setLoading(); |
— | — | @@ -634,6 +634,7 @@ |
635 | 635 | _this.action_done = false; |
636 | 636 | |
637 | 637 | // Do the api request: |
| 638 | + mw.log(" about to run upload request: " + request ); |
638 | 639 | mw.getJSON(_this.apiUrl, request, function( data ) { |
639 | 640 | _this.processApiResult( data ); |
640 | 641 | }); |
— | — | @@ -1018,7 +1019,7 @@ |
1019 | 1020 | 'border' : 0, |
1020 | 1021 | 'width' : 15, |
1021 | 1022 | 'height' : 11, |
1022 | | - 'src' : mw.getConfig( 'images_path' ) + 'magnify-clip.png' |
| 1023 | + 'src' : mw.getConfig( 'imagesPath' ) + 'magnify-clip.png' |
1023 | 1024 | } ), |
1024 | 1025 | |
1025 | 1026 | $j('<span />') |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -1188,7 +1188,7 @@ |
1189 | 1189 | |
1190 | 1190 | $j('<img />' ) |
1191 | 1191 | .attr( { |
1192 | | - 'src': mw.getConfig('images_path' ) + 'cookies_blocked_MSIE_eye.png', |
| 1192 | + 'src': mw.getConfig('imagesPath' ) + 'cookies_blocked_MSIE_eye.png', |
1193 | 1193 | 'alt' : gM('mwe-ie-eye-permision' ) |
1194 | 1194 | }) |
1195 | 1195 | ); |
— | — | @@ -1771,7 +1771,7 @@ |
1772 | 1772 | // Check for missing poster types for audio |
1773 | 1773 | if ( (resource.mime == 'audio/ogg' || resource.mime == 'application/ogg') |
1774 | 1774 | && !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'; |
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | var $resultThumb = $j( '<img />' ) |
— | — | @@ -2723,17 +2723,19 @@ |
2724 | 2724 | mw.log( ":doApiImport:" ); |
2725 | 2725 | mw.addLoaderDialog( gM( 'mwe-importing_asset' ) ); |
2726 | 2726 | |
| 2727 | + alert( 'do copy-by-url import currently dissabled '); |
| 2728 | + |
2727 | 2729 | // Load the BaseUploadInterface: |
2728 | 2730 | mw.load( |
2729 | 2731 | [ |
2730 | | - 'mw.BaseUploadInterface', |
| 2732 | + 'mw.UploadInterface', |
2731 | 2733 | '$j.ui.progressbar' |
2732 | 2734 | ], |
2733 | 2735 | function() { |
2734 | | - mw.log( 'mvBaseUploadInterface ready' ); |
| 2736 | + mw.log( 'mw.UploadInterface ready' ); |
2735 | 2737 | // Initiate a upload object ( similar to url copy ): |
2736 | 2738 | // ( mvBaseUploadInterface handles upload errors ) |
2737 | | - var uploader = new mw.BaseUploadInterface( { |
| 2739 | + var uploader = new mw.UploadDialogInterface( { |
2738 | 2740 | 'apiUrl' : _this.upload_api_target, |
2739 | 2741 | 'doneUploadCb': function() { |
2740 | 2742 | mw.log( 'doApiImport:: run callback::' ); |
— | — | @@ -2964,10 +2966,10 @@ |
2965 | 2967 | createLayoutSelector: function() { |
2966 | 2968 | |
2967 | 2969 | 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'; |
2972 | 2974 | |
2973 | 2975 | var defaultBoxUrl, defaultListUrl; |
2974 | 2976 | if ( _this.displayMode == 'box' ) { |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js |
— | — | @@ -104,12 +104,8 @@ |
105 | 105 | } else { |
106 | 106 | // Issue play request |
107 | 107 | vid.play(); |
108 | | - } |
| 108 | + } |
109 | 109 | |
110 | | - |
111 | | - // Run the "hook" for any extensions that need to bind things to the actual video elemnt |
112 | | - this.runHook( 'postEmbedJS' ) |
113 | | - |
114 | 110 | setTimeout( function() { |
115 | 111 | _this.monitor(); |
116 | 112 | }, 100 ); |
— | — | @@ -153,8 +149,9 @@ |
154 | 150 | // try to do a play then seek: |
155 | 151 | this.doPlayThenSeek( percentage ) |
156 | 152 | } |
| 153 | + |
157 | 154 | // Run the onSeeking interface update |
158 | | - this.onSeek(); |
| 155 | + this.ctrlBuilder.onSeek(); |
159 | 156 | }, |
160 | 157 | |
161 | 158 | /** |
— | — | @@ -168,9 +165,7 @@ |
169 | 166 | }, |
170 | 167 | |
171 | 168 | /** |
172 | | - * Do a play request |
173 | | - * then check if the video is ready to play |
174 | | - * then seek |
| 169 | + * Seek in a existing stream |
175 | 170 | * |
176 | 171 | * @param {Float} percentage Percentage of the stream to seek to between 0 and 1 |
177 | 172 | */ |
— | — | @@ -380,10 +375,10 @@ |
381 | 376 | * Local method for seeking event |
382 | 377 | * fired when "seeking" |
383 | 378 | */ |
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 | + |
388 | 383 | // Trigger the html5 seeking event |
389 | 384 | $j( this ).trigger( 'seeking' ); |
390 | 385 | }, |
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/loader.js |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | mw.load( [ |
19 | 19 | 'mw.Firefogg', |
20 | 20 | 'mw.FirefoggRender', |
21 | | - 'mw.BaseUploadInterface' |
| 21 | + 'mw.UploadInterface' |
22 | 22 | ], function() { |
23 | 23 | callback( 'FirefoggRender' ); |
24 | 24 | }); |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -63,7 +63,9 @@ |
64 | 64 | * @param [Mixed] name Name of configuration value |
65 | 65 | * {Object} Will iderate through each key and call setConfig |
66 | 66 | * {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 |
68 | 70 | */ |
69 | 71 | mw.setConfig = function ( name, value ) { |
70 | 72 | if( typeof name == 'object' ) { |
— | — | @@ -80,7 +82,7 @@ |
81 | 83 | } else { |
82 | 84 | mwConfig[ name ] = value; |
83 | 85 | } |
84 | | - } |
| 86 | + } |
85 | 87 | |
86 | 88 | /** |
87 | 89 | * Set a default config value |
— | — | @@ -122,8 +124,8 @@ |
123 | 125 | * Modules that want to use "User Config" should call |
124 | 126 | * this setup function in their moduleLoader code. |
125 | 127 | * |
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 |
128 | 130 | * |
129 | 131 | * By abstracting user preference we could eventually integrate |
130 | 132 | * a persistent per-account preference system on the server. |
— | — | @@ -557,6 +559,7 @@ |
558 | 560 | instanceCallback = null; |
559 | 561 | } |
560 | 562 | } |
| 563 | + |
561 | 564 | // Check for empty loadRequest ( directly return the callback ) |
562 | 565 | if( mw.isEmpty( loadRequest ) ) { |
563 | 566 | mw.log( 'Empty load request: ' + loadRequest ); |
— | — | @@ -812,7 +815,8 @@ |
813 | 816 | + _this.getClassPath( className ) ); |
814 | 817 | } |
815 | 818 | |
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 |
817 | 821 | if( mw.currentClassMissingMessages ){ |
818 | 822 | mw.loadClassMessages( className, function(){ |
819 | 823 | //reset the currentClassMissingMessages flag |
— | — | @@ -1039,7 +1043,7 @@ |
1040 | 1044 | * mediaWiki JSON a wrapper for jQuery getJSON: |
1041 | 1045 | * ( could also be named mw.apiRequest ) |
1042 | 1046 | * |
1043 | | - * The mediaWiki version lets you skip the url part |
| 1047 | + * The mwEmbed version lets you skip the url part |
1044 | 1048 | * mw.getJSON( [url], data, callback, [timeoutCallback] ); |
1045 | 1049 | * |
1046 | 1050 | * Lets you assume: |
— | — | @@ -1048,18 +1052,19 @@ |
1049 | 1053 | * callback parameter is not needed for the request data |
1050 | 1054 | * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param |
1051 | 1055 | * 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 |
1054 | 1058 | * |
1055 | 1059 | * @param {Mixed} url or data request |
1056 | 1060 | * @param {Mixed} data or callback |
1057 | 1061 | * @param {Function} callbcak function called on success |
1058 | 1062 | * @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 |
1060 | 1064 | */ |
1061 | | - mw.getJSON = function() { |
1062 | | - // Set up the url |
1063 | | - |
| 1065 | + mw.getJSON = function() { |
| 1066 | + // Proccess the arguments: |
| 1067 | + |
| 1068 | + // Set up the url |
1064 | 1069 | var url = false; |
1065 | 1070 | url = ( typeof arguments[0] == 'string' ) ? arguments[0] : mw.getLocalApiUrl(); |
1066 | 1071 | |
— | — | @@ -1203,7 +1208,8 @@ |
1204 | 1209 | * |
1205 | 1210 | * @param {String} [apiUrl] Optional target API URL (uses default local api if unset) |
1206 | 1211 | * @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 |
1208 | 1214 | */ |
1209 | 1215 | mw.getToken = function( apiUrl, title, callback ) { |
1210 | 1216 | // Make the apiUrl be optional: |
— | — | @@ -1235,7 +1241,8 @@ |
1236 | 1242 | /** |
1237 | 1243 | * Api helper to grab the username |
1238 | 1244 | * @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. |
1240 | 1247 | */ |
1241 | 1248 | // Stub feature apiUserNameCache to avoid multiple calls |
1242 | 1249 | // ( a more general api cache framework should be devloped ) |
— | — | @@ -1295,7 +1302,7 @@ |
1296 | 1303 | * addLoaderDialog |
1297 | 1304 | * small helper for displaying a loading dialog |
1298 | 1305 | * |
1299 | | - * @param msg text text of the loader msg |
| 1306 | + * @param {String} msg_txt text text of the loader msg |
1300 | 1307 | */ |
1301 | 1308 | mw.addLoaderDialog = function( msg_txt ) { |
1302 | 1309 | mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() ); |
— | — | @@ -1362,16 +1369,11 @@ |
1363 | 1370 | * Close the loader dialog created with addLoaderDialog |
1364 | 1371 | */ |
1365 | 1372 | 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(); |
1376 | 1378 | } |
1377 | 1379 | |
1378 | 1380 | |
— | — | @@ -1517,7 +1519,7 @@ |
1518 | 1520 | var mwReadyFlag = false; |
1519 | 1521 | |
1520 | 1522 | /** |
1521 | | - * Enables load hooks to run once DOM is "ready" |
| 1523 | + * Enables load hooks to run once mwEmbeed is "ready" |
1522 | 1524 | * Will ensure jQuery is available, is in the $j namespace |
1523 | 1525 | * and mw interfaces and configuration has been loaded and applied |
1524 | 1526 | * |
— | — | @@ -1530,20 +1532,7 @@ |
1531 | 1533 | mw.ready = function( callback ) { |
1532 | 1534 | if( mwReadyFlag === false ) { |
1533 | 1535 | // 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 ); |
1548 | 1537 | } |
1549 | 1538 | // If mwReadyFlag is already "true" issue the callback directly: |
1550 | 1539 | callback(); |
— | — | @@ -1551,6 +1540,7 @@ |
1552 | 1541 | |
1553 | 1542 | /** |
1554 | 1543 | * Runs all the queued functions |
| 1544 | + * called by mwEmbedSetup |
1555 | 1545 | */ |
1556 | 1546 | mw.runReadyFunctions = function ( ) { |
1557 | 1547 | // Run all the queued functions: |
— | — | @@ -1643,7 +1633,7 @@ |
1644 | 1634 | }; |
1645 | 1635 | //mw.log(" append script: " + script.src ); |
1646 | 1636 | // Append the script to the DOM: |
1647 | | - head.appendChild( script ); |
| 1637 | + head.appendChild( script ); |
1648 | 1638 | }; |
1649 | 1639 | |
1650 | 1640 | /** |
— | — | @@ -2153,149 +2143,176 @@ |
2154 | 2144 | |
2155 | 2145 | mw.log( 'mw:setupMwEmbed :: ' + mw.getMwEmbedSrc() ); |
2156 | 2146 | |
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(){ |
2175 | 2149 | |
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 ) |
2201 | 2165 | }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 | + } |
2203 | 2171 | } |
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 | + } ); |
2206 | 2211 | }); |
2207 | | - }); |
| 2212 | + }); |
2208 | 2213 | }; |
2209 | 2214 | |
| 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 | + |
2210 | 2234 | /** |
2211 | | - * Check for module loaders, and localization |
| 2235 | + * Check for script-loader module loaders, and localization files |
2212 | 2236 | * |
2213 | | - * Note if using a scriptLoader all the loaders and localization converters |
| 2237 | + * NOTE: if using the ScriptLoader all the loaders and localization converters |
2214 | 2238 | * are included automatically. |
2215 | 2239 | */ |
2216 | | - mw.moduleLoaderCheck = function( callback ) { |
| 2240 | + mw.checkModuleLoaderFiles = function( callback ) { |
2217 | 2241 | mw.log( 'doLoaderCheck::' ); |
2218 | 2242 | |
2219 | 2243 | // Check if we are using scriptloader ( handles loader include automatically ) |
2220 | 2244 | 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(); |
2226 | 2246 | return ; |
2227 | 2247 | } |
| 2248 | + |
| 2249 | + // Load the configured modules / components |
| 2250 | + // The follow code is ONLY RUN in debug / raw file mode |
| 2251 | + var loaderRequest = []; |
2228 | 2252 | |
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 | + |
2241 | 2271 | |
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 ; |
2251 | 2278 | } |
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 = []; |
2253 | 2289 | |
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' ); |
2261 | 2300 | } |
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 = []; |
2272 | 2301 | |
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 | + } |
2284 | 2316 | |
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 | | - } ); |
2300 | 2317 | } |
2301 | 2318 | |
2302 | 2319 | /** |
— | — | @@ -2339,29 +2356,7 @@ |
2340 | 2357 | var mwDomReadyFlag = false; |
2341 | 2358 | |
2342 | 2359 | // 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; |
2366 | 2361 | |
2367 | 2362 | /** |
2368 | 2363 | * This will get called when the DOM is ready |
— | — | @@ -2374,28 +2369,9 @@ |
2375 | 2370 | mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length ); |
2376 | 2371 | // Set the onDomReady Flag |
2377 | 2372 | 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(); |
2400 | 2376 | } |
2401 | 2377 | |
2402 | 2378 | /** |
— | — | @@ -2560,6 +2536,7 @@ |
2561 | 2537 | * mwEmbed.js is included without jQuery |
2562 | 2538 | * and we need our own "ready" system so that |
2563 | 2539 | * mwEmbed interfaces can support async built out |
| 2540 | +* and the inclution of jQuery. |
2564 | 2541 | */ |
2565 | 2542 | var mwDomIsReady = false; |
2566 | 2543 | function runMwDomReady(){ |
— | — | @@ -2638,8 +2615,13 @@ |
2639 | 2616 | } |
2640 | 2617 | |
2641 | 2618 | |
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 | + */ |
2644 | 2626 | if( window.jQuery ){ |
2645 | 2627 | var dollarFlag = false; |
2646 | 2628 | if( $ && $.fn && $.fn.jquery ){ |
— | — | @@ -2647,8 +2629,13 @@ |
2648 | 2630 | // jQuery and do a removal call if too old |
2649 | 2631 | dollarFlag = true; |
2650 | 2632 | } |
2651 | | - window['$j'] = jQuery.noConflict(); |
| 2633 | + window[ '$j' ] = jQuery.noConflict(); |
2652 | 2634 | if( dollarFlag ) { |
2653 | | - window['$'] = jQuery.noConflict(); |
| 2635 | + window[ '$' ] = jQuery.noConflict(); |
2654 | 2636 | } |
2655 | 2637 | } |
| 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 @@ |
24 | 24 | 'local_wiki_apiUrl': wgServer + wgScriptPath + '/api.php' |
25 | 25 | }; |
26 | 26 | |
27 | | -mw.ready( function() { |
| 27 | +mw.ready( function() { |
28 | 28 | mw.log( "edit page mw.ready::" ); |
29 | 29 | var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); |
30 | 30 | // Kind of tricky, it would be nice to use run on ready "loader" call here |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | mw.log( 'Do old toolbar bind:' ); |
63 | 63 | didWikiEditorBind = true; |
64 | 64 | $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">' ); |
66 | 66 | |
67 | 67 | $j( '#btn-add-media-wiz' ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) ); |
68 | 68 | mw.load( 'AddMedia.addMediaWizard', function() { |