r65964 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65963‎ | r65964 | r65965 >
Date:21:18, 5 May 2010
Author:neilk
Status:deferred
Tags:
Comment:
reverted #65942; change from hooks to triggers causes mw.isValidLang to be undefined when mwEmbed.js runs. (mw.Language.js not loaded at correct time?)
Modified paths:
  • /branches/js2-work/phase3/js/editPage.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php (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/htmlEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Timed_Text.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Timed_Text.html
@@ -4,7 +4,7 @@
55 <head>
66 <title>sample mv embed</title>
77 <!-- <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> -->
8 - <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed&debug=true"></script>
 8+ <script type="text/javascript" src="../jsScriptLoader.php?class=mwEmbed&debug=true"></script>
99 </head>
1010 <body>
1111 <h3> mwEmbed Timed Text Examples:</h3>
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js
@@ -1257,7 +1257,7 @@
12581258 'border' : 0,
12591259 'width' : 15,
12601260 'height' : 11,
1261 - 'src' : mw.getConfig( 'imagesPath' ) + 'magnify-clip.png'
 1261+ 'src' : mw.getConfig( 'images_path' ) + 'magnify-clip.png'
12621262 } ),
12631263
12641264 $j('<span />')
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/loader.js
@@ -3,7 +3,7 @@
44 */
55 // Scope everything in "mw" ( keeps the global namespace clean )
66 ( function( mw ) {
7 -
 7+
88 mw.addClassFilePaths( {
99 "mw.TimedText" : "mw.TimedText.js",
1010 "mw.style.TimedText" : "css/mw.style.TimedText.css",
@@ -12,7 +12,7 @@
1313 "mw.style.TimedTextEdit" : "css/mw.style.TimedTextEdit.css",
1414
1515 "RemoteMwTimedText" : "remotes/RemoteMwTimedText.js"
16 -} );
 16+});
1717
1818 var mwTimedTextRequestSet = [
1919 '$j.fn.menu',
@@ -29,21 +29,18 @@
3030 });
3131
3232 var mwLoadTimedTextFlag = false;
33 -// Always Merge in the timed text libs
 33+// Merge in the timed text libs
3434 if( mw.getConfig( 'textInterface' ) == 'always' ) {
3535 mwLoadTimedTextFlag = true;
3636 }
37 -
3837 /**
39 -* Setup the load embedPlayer visit tag addSetupHook function
 38+* Setup the load embedPlayer visit tag function hook.
4039 *
4140 * Check if the video tags in the page support timed text
4241 * this way we can add our timed text libraries to the initial
4342 * request and avoid an extra round trip to the server
4443 */
45 -
46 -// Bind the loader embed player tag viewing
47 -$j( mw ).bind( 'LoaderEmbedPlayerVisitTag', function( event, playerElement ) {
 44+mw.addHook( 'LoaderEmbedPlayerVisitTag', function( playerElement ) {
4845 // If add timed text flag not already set check for itext, and sources
4946 if( ! mwLoadTimedTextFlag ) {
5047 if( $j( playerElement ).find( 'itext' ).length != 0 ) {
@@ -58,15 +55,14 @@
5956 }
6057 }
6158 } );
 59+
6260 // Update the player loader request with timedText if the flag has been set
63 -$j( mw ).bind( 'LoaderEmbedPlayerUpdateRequest', function( event, classRequest ) {
 61+mw.addHook( 'LoaderEmbedPlayerUpdateRequest', function( classRequest ) {
6462 // Add timed text items if flag set.
6563 if( mwLoadTimedTextFlag ) {
6664 $j.merge( classRequest, mwTimedTextRequestSet );
67 - }
68 -
 65+ }
6966 } );
70 -
7167
7268 // TimedText editor:
7369 mw.addModuleLoader( 'TimedText.Edit', function( callback ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -158,11 +158,11 @@
159159 }
160160
161161 // Set up embedPlayer hooks:
162 - $j( embedPlayer ).bind( 'onMonitor', function() {
163 - _this.monitor()
164 - } );
 162+ embedPlayer.addHook( 'monitor', function() {
 163+ _this.monitor();
 164+ } )
165165
166 - $j( embedPlayer ).bind( 'onPlay', function() {
 166+ embedPlayer.addHook( 'play', function() {
167167 // Will load and setup timedText sources (if not loaded already loaded )
168168 _this.setupTextSources();
169169 } );
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -1018,7 +1018,7 @@
10191019 'border' : 0,
10201020 'width' : 15,
10211021 'height' : 11,
1022 - 'src' : mw.getConfig( 'imagesPath' ) + 'magnify-clip.png'
 1022+ 'src' : mw.getConfig( 'images_path' ) + 'magnify-clip.png'
10231023 } ),
10241024
10251025 $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('imagesPath' ) + 'cookies_blocked_MSIE_eye.png',
 1192+ 'src': mw.getConfig('images_path' ) + '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( 'imagesPath' ) + 'sound_music_icon-80.png';
 1775+ resource.poster = mw.getConfig( 'images_path' ) + 'sound_music_icon-80.png';
17761776 }
17771777
17781778 var $resultThumb = $j( '<img />' )
@@ -2964,10 +2964,10 @@
29652965 createLayoutSelector: function() {
29662966
29672967 var _this = this;
2968 - var darkBoxUrl = mw.getConfig( 'imagesPath' ) + 'box_layout_icon_dark.png';
2969 - var lightBoxUrl = mw.getConfig( 'imagesPath' ) + 'box_layout_icon.png';
2970 - var darkListUrl = mw.getConfig( 'imagesPath' ) + 'list_layout_icon_dark.png';
2971 - var lightListUrl = mw.getConfig( 'imagesPath' ) + 'list_layout_icon.png';
 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';
29722972
29732973 var defaultBoxUrl, defaultListUrl;
29742974 if ( _this.displayMode == 'box' ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -108,50 +108,57 @@
109109 /**
110110 * Add a DOM ready check for player tags
111111
112 -* We use mw.addSetupHook instead of mw.ready() so that
113 -* player interfaces can be ready before mw.ready() is called.
 112+* We use mw.addDOMReadyHook instead of mw.ready so that
 113+* player interfaces are ready once mw.ready is called.
114114 */
115 -mw.addSetupHook( function( callback ) {
 115+mw.addDOMReadyHook( function() {
116116 if( mw.documentHasPlayerTags() ) {
117 - var rewriteElementCount = 0;
 117+ var rewriteElementCount = 0;
118118
119 - // Set each player to loading ( as early on as possible )
120 - $j( mw.getConfig( 'rewritePlayerTags' ) ).each( function( index, element ){
121 -
122 - // Assign an the element an ID (if its missing one)
123 - if ( $j( element ).attr( "id" ) == '' ) {
124 - $j( element ).attr( "id", 'v' + ( rewriteElementCount++ ) );
125 - }
126 -
127 - // Add an absolute positioned loader
128 - var pos = $j( element ).offset();
129 - var left = ( $j( element ).width() ) ?
130 - parseInt( pos.left + ( .4 * $j( element ).width() ) ) :
131 - pos.left + 30;
132 - var top = ( $j( element ).height() ) ?
133 - parseInt( pos.top + ( .4 * $j( element ).height() ) ) :
134 - pos.left + 30;
135 - $j('body').append(
136 - $j('<div />')
137 - .loadingSpinner()
138 - .attr('id', 'loadSpiner_' + $j( element ).attr('id') )
139 - .css({
140 - 'width' : 32,
141 - 'height' : 32,
142 - 'position': 'absolute',
143 - 'top' : top,
144 - 'left' : left
145 - })
146 - )
147 - //$j( element ).hide();
148 - });
149 - // Load the embedPlayer module ( then run queued hooks )
150 - mw.load( 'EmbedPlayer', function ( ) {
151 - // Rewrite the rewritePlayerTags with the
152 - $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer();
153 - // Run the setup callback now that we have setup all the players
154 - callback();
155 - })
 119+ // Add the setup hook since we have player tags
 120+ mw.addSetupHook( function( callback ) {
 121+
 122+ // Set each player to loading ( as early on as possible )
 123+ $j( mw.getConfig( 'rewritePlayerTags' ) ).each( function( index, element ){
 124+
 125+ // Assign an the element an ID (if its missing one)
 126+ if ( $j( element ).attr( "id" ) == '' ) {
 127+ $j( element ).attr( "id", 'v' + ( rewriteElementCount++ ) );
 128+ }
 129+
 130+ // Add an absolute positioned loader
 131+ var pos = $j( element ).offset();
 132+ var left = ( $j( element ).width() ) ?
 133+ parseInt( pos.left + ( .4 * $j( element ).width() ) ) :
 134+ pos.left + 30;
 135+ var top = ( $j( element ).height() ) ?
 136+ parseInt( pos.top + ( .4 * $j( element ).height() ) ) :
 137+ pos.left + 30;
 138+ $j('body').append(
 139+ $j('<div />')
 140+ .loadingSpinner()
 141+ .attr('id', 'loadSpiner_' + $j( element ).attr('id') )
 142+ .css({
 143+ 'width' : 32,
 144+ 'height' : 32,
 145+ 'position': 'absolute',
 146+ 'top' : top,
 147+ 'left' : left
 148+ })
 149+ )
 150+ //$j( element ).hide();
 151+ });
 152+ // Load the embedPlayer module ( then run queued hooks )
 153+ mw.load( 'EmbedPlayer', function ( ) {
 154+ // Rewrite the rewritePlayerTags with the
 155+ $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer();
 156+ // Run the setup callback now that we have setup all the players
 157+ callback();
 158+ })
 159+ });
 160+
 161+ // Tell mwEmbed to run setup
 162+ mw.setConfig( 'runSetupMwEmbed', true );
156163 }
157164 });
158165
@@ -198,8 +205,8 @@
199206 // Add skin name to playerSkins
200207 playerSkins[ mw.valid_skins[ n ] ] = true;
201208 }
202 - }
203 - $j( mw ).trigger( 'LoaderEmbedPlayerVisitTag', playerElement );
 209+ }
 210+ mw.runHook( 'LoaderEmbedPlayerVisitTag', playerElement );
204211 } );
205212
206213 // Add the player skins css and js to the load request:
@@ -224,14 +231,11 @@
225232 // Safari gets slower load since we have to detect ogg support
226233 if( typeof HTMLVideoElement == 'object' && !$j.browser.safari ) {
227234 dependencyRequest[0].push( 'nativeEmbed' )
228 - }
229 -
230 - // Run the EmbedPlayer loader hook ( so that modules can add dependencies to the request )
231 - $j( mw ).trigger( 'LoaderEmbedPlayerUpdateRequest',
232 - [ dependencyRequest[ 0 ] ] /* Put into an array to be the first argument
233 - in jQuery trigger argument passing */
234 - );
 235+ }
235236
 237+ // Run the EmbedPlayer loader hook ( so that modules can add dependencies to the request )
 238+ mw.runHook( 'LoaderEmbedPlayerUpdateRequest', dependencyRequest[ 0 ] );
 239+
236240
237241 // Load the video libs:
238242 mw.load( dependencyRequest, function() {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -248,11 +248,11 @@
249249 * @param [ Optional ] {Function} callback Function to be called once video interfaces are ready
250250 *
251251 */
252 - $.fn.embedPlayer = function( attributes, callback ) {
 252+ $.fn.embedPlayer = function( attributes, callback ) {
253253 mw.log('embedPlayer on: ' + this.selector);
254254 var player_select = this.selector;
255255
256 - //Handle optional include of attributes argument:
 256+ // Handle optional include of attributes argument:
257257 if( typeof attributes == 'function' ){
258258 callback = attributes;
259259 }
@@ -263,14 +263,14 @@
264264 mw.playerManager = new EmbedPlayerManager();
265265
266266 // Run the global hooks that mw.playerManager is ready
267 - $j( mw ).trigger( 'EmbedPlayerManagerReady' );
 267+ mw.runHook( 'EmbedPlayerManagerReady' );
268268 }
269269
270 - //Add the embedPlayer ready callback
271 - if( typeof callback == 'function' ){
 270+ // Add the embedPlayer ready callback
 271+ if( typeof callback == 'function' ) {
272272 mw.playerManager.addCallback( callback );
273 - }
274 -
 273+ }
 274+
275275 // Add each selected element to the player manager:
276276 $j( player_select ).each( function(na, playerElement) {
277277 mw.playerManager.addElement( playerElement, attributes);
@@ -299,6 +299,7 @@
300300 init: function( ) {
301301 this.callbackFunctions = [];
302302 this.playerList = [];
 303+ mw.addHookSystem ( this );
303304 },
304305
305306 /**
@@ -371,12 +372,11 @@
372373 var playlistPlayer = new mw.PlayList( element, attributes );
373374
374375 // Swap in playlist player interface
375 - _this.swapEmbedPlayerElement( element, playerInterface );
 376+ _this.swapEmbedPlayerElement( element, playlistPlayer );
376377
377 - // Pass the id to any hook that needs to interface prior to checkPlayerSources
378 - $j( _this ).trigger ( 'swapedPlayerId', playerInterface.id );
 378+ // Pass the id to any hook that needs to interface prior to showPlayer code
 379+ _this.runHook( 'swapedPlayerId', playerInterface.id );
379380
380 -
381381 // Issue the checkPlayerSources call to the new playlist interface:
382382 $j( '#' + playlistPlayer.id ).get(0).showPlayer();
383383 } );
@@ -394,10 +394,10 @@
395395 mw.log("runPlayerSwap::" + $j( element ).attr('id') );
396396 ranPlayerSwapFlag = true;
397397 var playerInterface = new mw.EmbedPlayer( element , attributes);
398 - _this.swapEmbedPlayerElement( element, playerInterface );
 398+ _this.swapEmbedPlayerElement( element, playerInterface );
399399
400400 // Pass the id to any hook that needs to interface prior to checkPlayerSources
401 - $j( _this ).trigger ( 'swapedPlayerId', playerInterface.id );
 401+ _this.runHook( 'swapedPlayerId', playerInterface.id );
402402
403403 // Issue the checkPlayerSources call to the new player interface:
404404 // make sure to use the element that is in the DOM:
@@ -560,9 +560,10 @@
561561 // Remove the player loader spinner:
562562 $j('#loadSpiner_' + player.id ).remove();
563563
564 - // Run the player ready trigger
565 - $j( player ).trigger( 'playerReady' );
 564+ // Run the player ready hook
 565+ player.runHook( 'playerReady' );
566566
 567+ // Check if all the players are ready
567568 var is_ready = true;
568569 for ( var i = 0; i < this.playerList.length; i++ ) {
569570 var currentPlayer = $j( '#' + this.playerList[i] ).get( 0 );
@@ -594,7 +595,7 @@
595596
596597 mediaSource.prototype = {
597598 // MIME type of the source.
598 - mimeType:null,
 599+ mimeType: null,
599600
600601 // URI of the source.
601602 uri:null,
@@ -647,7 +648,7 @@
648649 if ( typeof pUrl[ 'queryKey' ][ 't' ] != 'undefined' ) {
649650 this[ 'URLTimeEncoding' ] = true;
650651 }
651 -
 652+ // Set the source attributes local var
652653 var sourceAttr = mw.getConfig( 'embedPlayerSourceAttributes' );
653654
654655 for ( var i = 0; i < sourceAttr.length; i++ ) { // array loop:
@@ -972,15 +973,15 @@
973974 * @return mediaSource elements.
974975 * @type Array
975976 */
976 - getSources: function( mimeFilter ) {
977 - if ( !mimeFilter ) {
 977+ getSources: function( mime_filter ) {
 978+ if ( !mime_filter ) {
978979 return this.sources;
979980 }
980981 // Apply mime filter:
981982 var source_set = new Array();
982983 for ( var i = 0; i < this.sources.length ; i++ ) {
983984 if ( this.sources[i].mimeType &&
984 - this.sources[i].mimeType.indexOf( mimeFilter ) != -1 )
 985+ this.sources[i].mimeType.indexOf( mime_filter ) != -1 )
985986 source_set.push( this.sources[i] );
986987 }
987988 return source_set;
@@ -1143,7 +1144,7 @@
11441145 // make sure an existing element with the same src does not already exist:
11451146 for ( var i = 0; i < this.sources.length; i++ ) {
11461147 if ( this.sources[i].src == newSrc ) {
1147 - // Source already exists update any new attr:
 1148+ // Source already exists update any new attributes:
11481149 this.sources[i].updateSource( element );
11491150 return this.sources[i];
11501151 }
@@ -1151,8 +1152,8 @@
11521153 }
11531154 // Create a new source
11541155 var source = new mediaSource( element );
1155 -
1156 - this.sources.push( source );
 1156+
 1157+ this.sources.push( source );
11571158 mw.log( 'tryAddSource: added source ::' + source + 'sl:' + this.sources.length );
11581159 return source;
11591160 },
@@ -1168,7 +1169,7 @@
11691170 if ( this.isPlayableType( this.sources[i].mimeType ) ) {
11701171 playableSources.push( this.sources[i] );
11711172 } else {
1172 - //mw.log( "type " + this.sources[i].mimeType + 'is not playable' );
 1173+ mw.log( "type " + this.sources[i].mimeType + 'is not playable' );
11731174 }
11741175 };
11751176 return playableSources;
@@ -1243,6 +1244,9 @@
12441245 // Stores the loading errors
12451246 'loadError' : false,
12461247
 1248+ // Loading external data flag ( for delaying interface updates )
 1249+ 'loading_external_data' : false,
 1250+
12471251 // Thumbnail updating flag ( to avoid rewriting an thumbnail thats already being updated)
12481252 'thumbnail_updating' : false,
12491253
@@ -1281,10 +1285,12 @@
12821286 init: function( element, customAttributes ) {
12831287 var _this = this;
12841288 // Set customAttributes if unset:
1285 - if ( !customAttributes ) {
 1289+ if ( !customAttributes )
12861290 customAttributes = { };
1287 - }
12881291
 1292+ //Add a hook system to the embedPlayer
 1293+ mw.addHookSystem( _this );
 1294+
12891295 var playerAttributes = mw.getConfig( 'embedPlayerAttributes' );
12901296 // Setup the player Interface from supported attributes:
12911297 for ( var attr in playerAttributes ) {
@@ -1365,8 +1371,8 @@
13661372 }
13671373
13681374 // Add the mediaElement object with the elements sources:
1369 - this.mediaElement = new mediaElement( element );
1370 -
 1375+ this.mediaElement = new mediaElement( element );
 1376+
13711377 },
13721378
13731379 /**
@@ -1425,7 +1431,6 @@
14261432 ) {
14271433 var defaultSize = mw.getConfig( 'videoSize' ).split( 'x' );
14281434 this['width'] = defaultSize[0];
1429 -
14301435 // Special height default for audio tag ( if not set )
14311436 if( element.tagName.toLowerCase() == 'audio' ) {
14321437 this['height'] = 0;
@@ -1459,7 +1464,7 @@
14601465 * If we need to get media sources form an external file
14611466 * that request is issued here
14621467 */
1463 - checkPlayerSources: function() {
 1468+ checkPlayerSources: function( callbackChain ) {
14641469 mw.log( 'f:checkPlayerSources: ' + this.id );
14651470 var _this = this;
14661471 var sourceCount = this.mediaElement.getPlayableSources().length;
@@ -1477,16 +1482,19 @@
14781483 } );
14791484 return ;
14801485 }
 1486+ // Check for hooks to handle checkPlayerSources
 1487+ if( this.hooks[ 'checkPlayerSources' ].length ) {
 1488+ this.runHook( 'checkPlayerSources', function(){
 1489+ _this.checkForTimedText();
 1490+ });
 1491+ } else {
 1492+ // no hooks run check for timed text directly
 1493+ _this.checkForTimedText();
 1494+ }
14811495
1482 - // Run embedPlayer sources hook
1483 - $j( this ).trigger ( 'checkPlayerSources', function(){
1484 - // Continue application flow and check for Timed Text
1485 - _this.checkForTimedText();
1486 - });
14871496 },
1488 -
14891497 /**
1490 - * Load Source video info from mediaWiki Api title key ( this.apiTitleKey )
 1498+ * Load Source video info From Api title key ( this.apiTitleKey )
14911499 * @param {Function} callback Function called once loading is complete
14921500 */
14931501 loadSourceFromApi: function( callback ){
@@ -1602,7 +1610,7 @@
16031611 // Auto select player based on default order
16041612 if ( !this.mediaElement.selectedSource ) {
16051613 // check for parent clip:
1606 - if ( typeof this.pc != 'undefined' ) {
 1614+ if ( typeof this.pc != 'undefined' ) {
16071615 mw.log( 'no sources, type:' + this.type + ' check for html' );
16081616 // debugger;
16091617 // do load player if just displaying innerHTML:
@@ -1621,6 +1629,7 @@
16221630 // Inherit the playback system of the selected player:
16231631 this.inheritEmbedPlayer();
16241632 } else {
 1633+
16251634 // No source's playable
16261635 var missingType = '';
16271636 var or = '';
@@ -1628,6 +1637,7 @@
16291638 missingType += or + this.mediaElement.sources[i].mimeType;
16301639 or = ' or ';
16311640 }
 1641+
16321642 // Get from parent playlist if set:
16331643 if ( this.pc ){
16341644 missingType = this.pc.type;
@@ -1770,21 +1780,32 @@
17711781 mw.log( 'updated seek_time_sec: ' + mw.seconds2npt ( this.seek_time_sec ) );
17721782 this.stop();
17731783 this.didSeekJump = true;
 1784+
17741785 // Update the slider
17751786 this.updatePlayHead( percent );
 1787+
 1788+ // Do play request in 100ms ( give the dom time to swap out the embed player )
 1789+ setTimeout( function() {
 1790+ _this.play()
 1791+ }, 100 );
17761792 }
1777 - // Do play request in 100ms ( give the dom time to swap out the embed player )
1778 - setTimeout( function() {
1779 - _this.play()
1780 - }, 100 );
17811793
17821794 // Run the onSeeking interface update
1783 - // NOTE ctrlBuilder should really bind to html5 events rather
1784 - // than explicitly calling it or inheriting stuff.
1785 - this.ctrlBuilder.onSeek();
1786 - },
 1795+ this.onSeek();
 1796+
 1797+ },
17871798
17881799 /**
 1800+ * function fired once seeking is taking place
 1801+ */
 1802+ onSeek: function(){
 1803+ // Update the interface:
 1804+ this.setStatus( gM( 'mwe-seeking' ) );
 1805+ // Run the seeking hook
 1806+ this.runHook( 'onSeek' );
 1807+ },
 1808+
 1809+ /**
17891810 * Seeks to the requested time and issues a callback when ready
17901811 * (should be overwritten by client that supports frame serving)
17911812 */
@@ -1818,7 +1839,7 @@
18191840 this.bufferStartFlag = false;
18201841 this.bufferEndFlag = false;
18211842
1822 - // Make sure the player is
 1843+
18231844 mw.log( 'performing embed for ' + _this.id );
18241845 // mw.log('should embed:' + embed_code);
18251846 _this.doEmbedHTML()
@@ -1830,8 +1851,7 @@
18311852 * On clip done action. Called once a clip is done playing
18321853 */
18331854 onClipDone: function() {
1834 - mw.log( 'base:onClipDone' );
1835 -
 1855+ mw.log( 'base:onClipDone' );
18361856
18371857 // Stop the clip (load the thumbnail etc)
18381858 this.stop();
@@ -1850,11 +1870,11 @@
18511871 }
18521872 // Do the ctrlBuilder onClip done interface
18531873 this.ctrlBuilder.onClipDone();
1854 -
1855 - // Fire the html5 ended binding
 1874+
 1875+ // Fire the html5 ended binding / event
18561876 $j( this ).trigger( 'ended' );
18571877
1858 - // Update the clip done playing count:
 1878+ //Set the clip done playing count:
18591879 this.donePlayingCount ++;
18601880 },
18611881
@@ -1877,8 +1897,8 @@
18781898 // Make sure the ctrlBuilder bindings are up-to-date
18791899 this.ctrlBuilder.addControlHooks();
18801900
1881 - // Once the thumbnail is shown run the mediaReady trigger
1882 - $j( this ).trigger( 'mediaLoaded' );
 1901+ // Once the thumbnail is shown run the mediaReady hook
 1902+ this.runHook( 'mediaLoaded' );
18831903 },
18841904
18851905 /**
@@ -1903,6 +1923,7 @@
19041924 this.ctrlBuilder = new ctrlBuilder( this );
19051925
19061926 var _this = this;
 1927+
19071928 // Make sure we have interface_wrap
19081929 if( $j( this ).parent( '.interface_wrap' ).length == 0 ) {
19091930 // Select "player"
@@ -1945,9 +1966,9 @@
19461967 * @param {String} [misssingType] missing type mime
19471968 */
19481969 showPluginMissingHTML : function( misssingType ) {
1949 - // Remove the loading spinner if present:
 1970+ //remove the loading spinner if present:
19501971 $j('#loadSpiner_' + this.id ).remove();
1951 -
 1972+
19521973 // If the native video is already displayed hide it:
19531974 if( $j( '#' + this.pid ).length != 0 ){
19541975 $j('#loadSpiner_' + this.id ).remove();
@@ -2005,7 +2026,7 @@
20062027 this.mediaElement.updateSourceTimes( start_npt, end_npt );
20072028
20082029 // update mv_time
2009 - this.ctrlBuilder.setStatus( start_npt + '/' + end_npt );
 2030+ this.setStatus( start_npt + '/' + end_npt );
20102031
20112032 // reset slider
20122033 this.updatePlayHead( 0 );
@@ -2157,9 +2178,8 @@
21582179 mw.log( 'embedPlayer:updateThumbnailHTML::' + this.id );
21592180 var thumb_html = '';
21602181 var class_atr = '';
2161 - var style_atr = '';
 2182+ var style_atr = '';
21622183
2163 -
21642184 if( this.useNativeControls() ){
21652185 this.showNativePlayer();
21662186 return ;
@@ -2167,9 +2187,9 @@
21682188
21692189 // Set by default thumb value if not found
21702190 var posterSrc = ( this.poster ) ? this.poster :
2171 - mw.getConfig( 'imagesPath' ) + 'vid_default_thumb.jpg';
 2191+ mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg';
21722192
2173 - // Poster support is not very consistant in browsers
 2193+ // Poster support is not very good in all browsers
21742194 // use a jpg poster image:
21752195 $j( this ).html(
21762196 $j( '<img />' )
@@ -2184,7 +2204,7 @@
21852205 })
21862206 .addClass( 'playerPoster' )
21872207 );
2188 -
 2208+
21892209 if ( this.controls
21902210 && this.height > this.ctrlBuilder.getComponentHeight( 'playButtonLarge' )
21912211 ) {
@@ -2197,7 +2217,7 @@
21982218 /**
21992219 * Checks if native controls should be used
22002220 *
2201 - * @param [player] Object Optional player object to check controls attribute
 2221+ * @param [player] Object Optional player object to check controls attribute
22022222 * @returns boolean true if the mwEmbed player interface should be used
22032223 * false if the mwEmbed player interface should not be used
22042224 */
@@ -2487,12 +2507,14 @@
24882508 this.doPlayTracking();
24892509 }
24902510
2491 - //Run play hook:
2492 - $j( this ).trigger( 'onPlay' );
2493 - // If we previusly finished playing this clip run the "replay hook"
 2511+ // Run play hook:
 2512+ this.runHook( 'play' );
 2513+
 2514+ // If we previusly finished playing this clip run the "replay hook"
24942515 if( this.donePlayingCount > 0 ){
2495 - $j( this ).trigger( 'onReplay' );
 2516+ this.runHook( 'replay' );
24962517 }
 2518+
24972519 },
24982520
24992521 /**
@@ -2565,7 +2587,7 @@
25662588 this.showThumbnail();
25672589 this.bufferedPercent = 0; // reset buffer state
25682590 this.updatePlayHead( 0 );
2569 - this.ctrlBuilder.setStatus( this.getTimeRange() );
 2591+ this.setStatus( this.getTimeRange() );
25702592 }
25712593
25722594 //Bind play-btn-large play
@@ -2688,13 +2710,14 @@
26892711 if ( parseInt( this.startOffset ) != 0 ) {
26902712 // If start offset include that calculation
26912713 this.updatePlayHead( ( this.currentTime - this.startOffset ) / this.duration );
2692 - var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + parseFloat( this.duration ) ) : '';
2693 - this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et );
 2714+ var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) +
 2715+ parseFloat( this.duration ) ) : '';
 2716+ this.setStatus( mw.seconds2npt( this.currentTime ) + et );
26942717 } else {
26952718 this.updatePlayHead( this.currentTime / this.duration );
26962719 // Only include the end time if longTimeDisp is enabled:
26972720 var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( this.duration ) : '';
2698 - this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et );
 2721+ this.setStatus( mw.seconds2npt( this.currentTime ) + et );
26992722 }
27002723 }
27012724 // Check if we are "done"
@@ -2706,16 +2729,16 @@
27072730 } else {
27082731 // Media lacks duration just show end time
27092732 if ( this.isStoped() ) {
2710 - this.ctrlBuilder.setStatus( this.getTimeRange() );
 2733+ this.setStatus( this.getTimeRange() );
27112734 } else if ( this.isPaused() ) {
2712 - this.ctrlBuilder.setStatus( gM( 'mwe-paused' ) );
 2735+ this.setStatus( gM( 'mwe-paused' ) );
27132736 } else if ( this.isPlaying() ) {
27142737 if ( this.currentTime && ! this.duration )
2715 - this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + ' /' );
 2738+ this.setStatus( mw.seconds2npt( this.currentTime ) + ' /' );
27162739 else
2717 - this.ctrlBuilder.setStatus( " - - - " );
 2740+ this.setStatus( " - - - " );
27182741 } else {
2719 - this.ctrlBuilder.setStatus( this.getTimeRange() );
 2742+ this.setStatus( this.getTimeRange() );
27202743 }
27212744 }
27222745
@@ -2728,13 +2751,14 @@
27292752 }, 250 )
27302753 }
27312754
2732 - $j( this ).trigger( 'onMonitor' );
 2755+ this.runHook( 'monitor' );
27332756 },
27342757
27352758 /**
27362759 * Update the buffer status based on the local bufferedPercent var
27372760 */
27382761 updateBufferStatus: function() {
 2762+
27392763 // Get the buffer target based for playlist vs clip
27402764 $buffer = this.$interface.find( '.mw_buffer' );
27412765
@@ -2754,14 +2778,15 @@
27552779 // if we have not already run the buffer start hook
27562780 if( this.bufferedPercent > 0 && !this.bufferStartFlag ) {
27572781 this.bufferStartFlag = true;
2758 - $j( this ).trigger( 'onBufferStart' );
 2782+ this.runHook( 'bufferStart' );
27592783 }
27602784
27612785 // if we have not already run the buffer end hook
27622786 if( this.bufferedPercent == 1 && !this.bufferEndFlag){
27632787 this.bufferEndFlag = true;
2764 - $j( this ).trigger( 'onBufferEnd' );
 2788+ this.runHook( 'bufferEnd' );
27652789 }
 2790+
27662791 },
27672792
27682793 /**
@@ -2821,7 +2846,7 @@
28222847 this.jump_time = options['start'];
28232848 this.seek_time_sec = mw.npt2seconds( options['start'] );
28242849 // trim output to
2825 - this.ctrlBuilder.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) );
 2850+ this.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) );
28262851 mw.log( 'DO update: ' + this.jump_time );
28272852 this.updateThumbTime( rel_start_sec );
28282853 },
@@ -2832,10 +2857,20 @@
28332858 hideHighlight: function() {
28342859 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
28352860 $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide();
2836 - this.ctrlBuilder.setStatus( this.getTimeRange() );
2837 - },
 2861+ this.setStatus( this.getTimeRange() );
 2862+ },
28382863
 2864+ /**
 2865+ * Updates the player status that displays short text msgs and the play clock
 2866+ * @param {String} value Status string value to update
 2867+ */
 2868+ setStatus: function( value ) {
 2869+ // update status:
 2870+ this.$interface.find( '.time-disp' ).html( value );
 2871+ },
28392872
 2873+
 2874+
28402875 /**
28412876 * Helper Functions for selected source
28422877 */
@@ -3037,9 +3072,9 @@
30383073 /**
30393074 * Checks if a player is supported by id
30403075 */
3041 - isSupportedPlayer: function( playerId ){
 3076+ isSupportedPlayer: function( player_id ){
30423077 for( var i=0; i < this.players.length; i++ ){
3043 - if( this.players[i].id == playerId ){
 3078+ if( this.players[i].id == player_id ){
30443079 return true;
30453080 }
30463081 }
@@ -3098,26 +3133,26 @@
30993134 /**
31003135 * Sets the format preference.
31013136 *
3102 - * @param {String} mimeFormat Prefered format
 3137+ * @param {String} mime_format Prefered format
31033138 */
3104 - setFormatPreference : function ( mimeFormat ) {
3105 - this.preference['format_preference'] = mimeFormat;
 3139+ setFormatPreference : function ( mime_format ) {
 3140+ this.preference['format_preference'] = mime_format;
31063141 mw.setUserConfig( 'playerPref', this.preference);
31073142 },
31083143
31093144 /**
31103145 * Sets the player preference
31113146 *
3112 - * @param {String} playerId Prefered player id
 3147+ * @param {String} player_id Prefered player id
31133148 * @param {String} mimeType Mime type for the associated player stream
31143149 */
3115 - setPlayerPreference : function( playerId, mimeType ) {
 3150+ setPlayerPreference : function( player_id, mimeType ) {
31163151 var selected_player = null;
31173152 for ( var i = 0; i < this.players.length; i++ ) {
3118 - if ( this.players[i].id == playerId ) {
 3153+ if ( this.players[i].id == player_id ) {
31193154 selected_player = this.players[i];
3120 - mw.log( 'choosing ' + playerId + ' for ' + mimeType );
3121 - this.preference[ mimeType ] = playerId;
 3155+ mw.log( 'choosing ' + player_id + ' for ' + mimeType );
 3156+ this.preference[ mimeType ] = player_id;
31223157 mw.setUserConfig( 'playerPref', this.preference );
31233158 break;
31243159 }
@@ -3176,12 +3211,12 @@
31773212 /**
31783213 * If the browsers supports a given mimetype
31793214 *
3180 - * @param {String} mimeType Mime type for browser plug-in check
 3215+ * @param {String} mimetype Mime type for browser plug-in check
31813216 */
3182 - supportedMimeType: function( mimeType ) {
3183 - for ( var i =0; i < navigator.plugins.length; i++ ) {
 3217+ supportedMimeType: function( mimetype ) {
 3218+ for ( var i = navigator.plugins.length; i-- > 0; ) {
31843219 var plugin = navigator.plugins[i];
3185 - if ( typeof plugin[ mimeType ] != "undefined" )
 3220+ if ( typeof plugin[mimetype] != "undefined" )
31863221 return true;
31873222 }
31883223 return false;
@@ -3191,23 +3226,23 @@
31923227 * Detects what plug-ins the client supports
31933228 */
31943229 detect: function() {
3195 - mw.log( "embedPlayer: running detect" );
 3230+ mw.log( "embedPlayer: running detect" );
31963231 this.players = new mediaPlayers();
31973232 // every browser supports html rendering:
31983233 this.players.addPlayer( htmlPlayer );
3199 - // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to
3200 - // search navigator.mimeTypes to see if it's installed
3201 - var javaEnabled = navigator.javaEnabled();
3202 - // Some browsers filter out duplicate mime types, hiding some plugins
3203 - var uniqueMimesOnly = $j.browser.opera || $j.browser.safari;
3204 - // Opera will switch off javaEnabled in preferences if java can't be found.
3205 - // And it doesn't register an application/x-java-applet mime type like Mozilla does.
3206 - if ( javaEnabled ) {
3207 - this.players.addPlayer( cortadoPlayer );
3208 - }
 3234+ // In Mozilla, navigator.javaEnabled() only tells us about preferences, we need to
 3235+ // search navigator.mimeTypes to see if it's installed
 3236+ var javaEnabled = navigator.javaEnabled();
 3237+ // Some browsers filter out duplicate mime types, hiding some plugins
 3238+ var uniqueMimesOnly = $j.browser.opera || $j.browser.safari;
 3239+ // Opera will switch off javaEnabled in preferences if java can't be found.
 3240+ // And it doesn't register an application/x-java-applet mime type like Mozilla does.
 3241+ if ( javaEnabled ) {
 3242+ this.players.addPlayer( cortadoPlayer );
 3243+ }
32093244
3210 - // ActiveX plugins
3211 - if ( $j.browser.msie ) {
 3245+ // ActiveX plugins
 3246+ if ( $j.browser.msie ) {
32123247 // check for flash
32133248 if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash' ) ) {
32143249 // try to get the flash version for omtk include:
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/ctrlBuilder.js
@@ -836,25 +836,6 @@
837837 // Related videos could be shown here
838838 },
839839
840 - /**
841 - * The ctrl builder updates the interface on seeking
842 - */
843 - onSeek: function(){
844 - // Update the interface:
845 - this.setStatus( gM( 'mwe-seeking' ) );
846 - // Run the seeking hook
847 - $j( this.embedPlayer ).trigger( 'onSeek' );
848 - },
849 -
850 - /**
851 - * Updates the player status that displays short text msgs and the play clock
852 - * @param {String} value Status string value to update
853 - */
854 - setStatus: function( value ) {
855 - // update status:
856 - this.embedPlayer.$interface.find( '.time-disp' ).html( value );
857 - },
858 -
859840 /**
860841 * Option menu items
861842 *
@@ -1604,9 +1585,9 @@
16051586 embedPlayer.jump_time = mw.seconds2npt( parseFloat( parseFloat( embedPlayer.getDuration() ) * perc ) + embedPlayer.start_time_sec );
16061587 // mw.log('perc:' + perc + ' * ' + embedPlayer.getDuration() + ' jt:'+ this.jump_time);
16071588 if ( _this.longTimeDisp ) {
1608 - ctrlObj.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
 1589+ embedPlayer.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
16091590 } else {
1610 - ctrlObj.setStatus( embedPlayer.jump_time );
 1591+ embedPlayer.setStatus( embedPlayer.jump_time );
16111592 }
16121593 // Update the thumbnail / frame
16131594 if ( embedPlayer.isPlaying == false ) {
@@ -1624,7 +1605,7 @@
16251606 // set seek time (in case we have to do a url seek)
16261607 embedPlayer.seek_time_sec = mw.npt2seconds( embedPlayer.jump_time, true );
16271608 mw.log( 'do jump to: ' + embedPlayer.jump_time + ' perc:' + perc + ' sts:' + embedPlayer.seek_time_sec );
1628 - ctrlObj.setStatus( gM( 'mwe-seeking' ) );
 1609+ embedPlayer.setStatus( gM( 'mwe-seeking' ) );
16291610 embedPlayer.doSeek( perc );
16301611 }
16311612 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js
@@ -275,6 +275,7 @@
276276 * Local implementation of swapPlayerElement
277277 */
278278 swapPlayerElement:function() {
 279+ this.loading_external_data = false
279280 this.ready_to_play = true;
280281 return ;
281282 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -104,8 +104,12 @@
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+
110114 setTimeout( function() {
111115 _this.monitor();
112116 }, 100 );
@@ -149,9 +153,8 @@
150154 // try to do a play then seek:
151155 this.doPlayThenSeek( percentage )
152156 }
153 -
154157 // Run the onSeeking interface update
155 - this.ctrlBuilder.onSeek();
 158+ this.onSeek();
156159 },
157160
158161 /**
@@ -377,10 +380,10 @@
378381 * Local method for seeking event
379382 * fired when "seeking"
380383 */
381 - onSeeking: function() {
382 - // Run the onSeeking interface update
383 - this.ctrlBuilder.onSeek();
384 -
 384+ onSeeking: function() {
 385+ //mw.log( "onseeking" );
 386+ this.seeking = true;
 387+ this.setStatus( gM( 'mwe-seeking' ) );
385388 // Trigger the html5 seeking event
386389 $j( this ).trigger( 'seeking' );
387390 },
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -63,9 +63,7 @@
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
68 - * {String} value Value of configuration name
69 - * {Object} value Set of values to be merged
 67+ * @param {String} value Value of configuration name
7068 */
7169 mw.setConfig = function ( name, value ) {
7270 if( typeof name == 'object' ) {
@@ -82,7 +80,7 @@
8381 } else {
8482 mwConfig[ name ] = value;
8583 }
86 - }
 84+ }
8785
8886 /**
8987 * Set a default config value
@@ -124,8 +122,8 @@
125123 * Modules that want to use "User Config" should call
126124 * this setup function in their moduleLoader code.
127125 *
128 - * For performance interfaces using "user config"
129 - * should load '$j.cookie' & 'JSON' in their module loader
 126+ * For performance interfaces should load '$j.cookie' & 'JSON'
 127+ * in their grouped load request
130128 *
131129 * By abstracting user preference we could eventually integrate
132130 * a persistent per-account preference system on the server.
@@ -559,7 +557,6 @@
560558 instanceCallback = null;
561559 }
562560 }
563 -
564561 // Check for empty loadRequest ( directly return the callback )
565562 if( mw.isEmpty( loadRequest ) ) {
566563 mw.log( 'Empty load request: ' + loadRequest );
@@ -1042,7 +1039,7 @@
10431040 * mediaWiki JSON a wrapper for jQuery getJSON:
10441041 * ( could also be named mw.apiRequest )
10451042 *
1046 - * The mwEmbed version lets you skip the url part
 1043+ * The mediaWiki version lets you skip the url part
10471044 * mw.getJSON( [url], data, callback, [timeoutCallback] );
10481045 *
10491046 * Lets you assume:
@@ -1051,19 +1048,18 @@
10521049 * callback parameter is not needed for the request data
10531050 * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param
10541051 * format is set to "json" automatically
1055 - * automatically issues request over "POST" if the request api post type
1056 - * automatically will setup apiProxy where request is cross domain
 1052+ * automatically issues request over "POST" if the request requires a post
 1053+ * automatically will setup apiProxy where needed.
10571054 *
10581055 * @param {Mixed} url or data request
10591056 * @param {Mixed} data or callback
10601057 * @param {Function} callbcak function called on success
10611058 * @param {Function} callbackTimeout - optional function called on timeout
1062 - * Setting timeout callback also avoids default timed-out dialog for proxy requests
 1059+ * Setting timeout callback also avoids default dialog display for timed-out proxy calls.
10631060 */
1064 - mw.getJSON = function() {
1065 - // Proccess the arguments:
1066 -
1067 - // Set up the url
 1061+ mw.getJSON = function() {
 1062+ // Set up the url
 1063+
10681064 var url = false;
10691065 url = ( typeof arguments[0] == 'string' ) ? arguments[0] : mw.getLocalApiUrl();
10701066
@@ -1207,8 +1203,7 @@
12081204 *
12091205 * @param {String} [apiUrl] Optional target API URL (uses default local api if unset)
12101206 * @param {String} title The wiki page title you want to edit
1211 - * @param {callback} callback Function to pass the token to.
1212 - * issues callback with "false" if token not retrived
 1207+ * @param {callback} callback Function to pass the token to returns false if token not retrived
12131208 */
12141209 mw.getToken = function( apiUrl, title, callback ) {
12151210 // Make the apiUrl be optional:
@@ -1240,8 +1235,7 @@
12411236 /**
12421237 * Api helper to grab the username
12431238 * @param {String} [apiUrl] Optional target API url (uses default local api if unset)
1244 - * @param {Function} callback Function to callback with username or false if not found
1245 - * @param {Boolean} fresh A fresh check is issued.
 1239+ * @param {Function} callback Function to callback with username or false if not found
12461240 */
12471241 // Stub feature apiUserNameCache to avoid multiple calls
12481242 // ( a more general api cache framework should be devloped )
@@ -1301,7 +1295,7 @@
13021296 * addLoaderDialog
13031297 * small helper for displaying a loading dialog
13041298 *
1305 - * @param {String} msg_txt text text of the loader msg
 1299+ * @param msg text text of the loader msg
13061300 */
13071301 mw.addLoaderDialog = function( msg_txt ) {
13081302 mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() );
@@ -1368,11 +1362,16 @@
13691363 * Close the loader dialog created with addLoaderDialog
13701364 */
13711365 mw.closeLoaderDialog = function() {
1372 - // Make sure the dialog class is present
1373 - if( !mw.isset( '$j.ui.dialog' ) ) {
1374 - return false;
1375 - }
1376 - $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove();
 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+ } );
13771376 }
13781377
13791378
@@ -1518,7 +1517,7 @@
15191518 var mwReadyFlag = false;
15201519
15211520 /**
1522 - * Enables load hooks to run once mwEmbeed is "ready"
 1521+ * Enables load hooks to run once DOM is "ready"
15231522 * Will ensure jQuery is available, is in the $j namespace
15241523 * and mw interfaces and configuration has been loaded and applied
15251524 *
@@ -1531,7 +1530,20 @@
15321531 mw.ready = function( callback ) {
15331532 if( mwReadyFlag === false ) {
15341533 // Add the callbcak to the onLoad function stack
1535 - mwOnLoadFunctions.push ( callback );
 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 ;
15361548 }
15371549 // If mwReadyFlag is already "true" issue the callback directly:
15381550 callback();
@@ -1539,7 +1551,6 @@
15401552
15411553 /**
15421554 * Runs all the queued functions
1543 - * called by mwEmbedSetup
15441555 */
15451556 mw.runReadyFunctions = function ( ) {
15461557 // Run all the queued functions:
@@ -1632,7 +1643,7 @@
16331644 };
16341645 //mw.log(" append script: " + script.src );
16351646 // Append the script to the DOM:
1636 - head.appendChild( script );
 1647+ head.appendChild( script );
16371648 };
16381649
16391650 /**
@@ -2154,70 +2165,60 @@
21552166 }
21562167
21572168 // Make sure we have jQuery and the common skin
2158 - mw.load( 'window.jQuery', function() {
2159 -
2160 - // Add jQuery to $j var.
 2169+ // NOTE mw.style.mwCommon should be factored out into
 2170+ // seperate module specifc classes
 2171+ mw.load( 'window.jQuery', function() {
21612172 if ( ! window[ '$j' ] ) {
21622173 window[ '$j' ] = jQuery.noConflict();
21632174 }
21642175
2165 - // Get loader, config and language files
2166 - // ( if not already set via script-loader )
2167 - mw.checkScriptLoaderFiles( function() {
2168 -
2169 - // Update the image path
2170 - mw.setConfig( 'imagesPath', mw.getMwEmbedPath() + 'skins/common/images/' );
2171 -
2172 - // Set up AJAX to not send dynamic URLs for loading scripts
2173 - $j.ajaxSetup( {
2174 - cache: true
2175 - } );
2176 -
2177 - // Update the magic keywords
2178 - mw.Language.magicSetup();
2179 -
2180 - // Set up mvEmbed utility jQuery bindings
2181 - mw.dojQueryBindings();
2182 -
2183 - // Make sure style sheets are loaded:
2184 - mw.load( [
2185 - 'mw.style.mwCommon',
2186 - 'mw.style.' + mw.getConfig( 'jQueryUISkin' )
2187 - ], function(){
2188 -
2189 - // Run all the setup function hooks
2190 - // NOTE: setup functions are added via addSetupHook calls
2191 - // and must include a callback.
2192 - //
2193 - // Once complete we can run .ready() queued functions
2194 - function runSetupFunctions() {
2195 - if( mwSetupFunctions.length ) {
2196 - mwSetupFunctions.shift()( function() {
2197 - runSetupFunctions();
2198 - } );
2199 - }else{
2200 - mw.runReadyFunctions();
2201 - }
 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+ } );
 2201+ }else{
 2202+ mw.runReadyFunctions();
22022203 }
2203 - runSetupFunctions();
2204 - });
2205 - } );
 2204+ }
 2205+ runSetupFunctions();
 2206+ });
22062207 });
22072208 };
22082209
22092210 /**
2210 - * Check for script-loader module loaders, and localization files
 2211+ * Check for module loaders, and localization
22112212 *
2212 - * NOTE: if using the ScriptLoader all the loaders and localization converters
 2213+ * Note if using a scriptLoader all the loaders and localization converters
22132214 * are included automatically.
22142215 */
2215 - mw.checkScriptLoaderFiles = function( callback ) {
 2216+ mw.moduleLoaderCheck = function( callback ) {
22162217 mw.log( 'doLoaderCheck::' );
22172218
22182219 // Check if we are using scriptloader ( handles loader include automatically )
22192220 if( mw.getScriptLoaderPath() ) {
22202221 // Do a async call to callback in cases where DOM is ready before we get to
2221 - // loader config code
 2222+ // loader config code in the same file.
22222223 setTimeout(function() {
22232224 callback();
22242225 }, 1);
@@ -2225,12 +2226,12 @@
22262227 }
22272228
22282229 // Add the Core loader to the request
2229 - // The follow code is ONLY RUN in debug / raw file mode
2230 -
 2230+ // The follow code is only run in debug / raw file mode
22312231 mw.load( 'loader.js', function() {
22322232 // Load all the "loaders" of the enabled modules:
22332233 var loaderRequest = [];
22342234
 2235+
22352236 //Load enabled components
22362237 var enabledComponents = mw.getConfig( 'coreComponents' );
22372238 function loadEnabledComponents( enabledComponents ){
@@ -2250,7 +2251,7 @@
22512252 loadEnabledComponents( enabledComponents );
22522253
22532254
2254 - // Set the loader context and get each loader individually
 2255+ //Set the loader context and get each loader individually ( only in debug mode )
22552256 function loadEnabledModules( enabledModules ){
22562257 if( ! enabledModules.length ){
22572258 // If no more modules left load the LanguageFile
@@ -2338,7 +2339,29 @@
23392340 var mwDomReadyFlag = false;
23402341
23412342 // Flag to register if the domreadyHooks have been called
2342 - var mwModuleLoaderCheckFlag = false;
 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+ }
23432366
23442367 /**
23452368 * This will get called when the DOM is ready
@@ -2351,9 +2374,28 @@
23522375 mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length );
23532376 // Set the onDomReady Flag
23542377 mwDomReadyFlag = true;
2355 -
2356 - // Setup MwEmbed
2357 - mw.setupMwEmbed();
 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+ });
23582400 }
23592401
23602402 /**
@@ -2518,7 +2560,6 @@
25192561 * mwEmbed.js is included without jQuery
25202562 * and we need our own "ready" system so that
25212563 * mwEmbed interfaces can support async built out
2522 -* and the inclution of jQuery.
25232564 */
25242565 var mwDomIsReady = false;
25252566 function runMwDomReady(){
@@ -2597,13 +2638,8 @@
25982639 }
25992640
26002641
2601 -/*
2602 - * Hack to keep jQuery in $ when its
2603 - * already there, but also use noConflict to get $j = jQuery
2604 - *
2605 - * This way sites that use $ for jQuery continue to work after
2606 - * including mwEmbed.js
2607 - */
 2642+// Hack to keep jQuery in $ when its
 2643+// already there, but also use noConflict to get $j = jQuery
26082644 if( window.jQuery ){
26092645 var dollarFlag = false;
26102646 if( $ && $.fn && $.fn.jquery ){
@@ -2611,13 +2647,8 @@
26122648 // jQuery and do a removal call if too old
26132649 dollarFlag = true;
26142650 }
2615 - window[ '$j' ] = jQuery.noConflict();
 2651+ window['$j'] = jQuery.noConflict();
26162652 if( dollarFlag ) {
2617 - window[ '$' ] = jQuery.noConflict();
 2653+ window['$'] = jQuery.noConflict();
26182654 }
26192655 }
2620 -
2621 -// If using the script-loader and jQuery has not been set give a warning to the user:
2622 -if( mw.getScriptLoaderPath() && !window.jQuery ) {
2623 - alert( 'jQuery is required for mwEmbed, please update your script-loader request' );
2624 -}
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php
@@ -120,7 +120,6 @@
121121
122122 // mwEmbed is a core component so it includes loaders and other styles
123123 if( $classKey == 'mwEmbed' && $this->outputFormat != 'messages' ){
124 -
125124 // Output core components ( parts of mwEmbed that are in different files )
126125 $this->output .= jsClassLoader::getCombinedComponentJs( $this );
127126
Index: branches/js2-work/phase3/js/editPage.js
@@ -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( 'imagesPath' ) + 'Button_add_media.png">' );
 65+ mw.getConfig( 'images_path' ) + '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() {

Status & tagging log