r65942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65941‎ | r65942 | r65943 >
Date:06:21, 5 May 2010
Author:dale
Status:deferred
Tags:
Comment:
* switched to .bind and .trigger based hook system ( instead of the custom addHook, runHook calls )
* jQuery is now included by default (previously it was loaded on demand and meant "loader.js" files could not do top level jquery calls / binds
* some initial clean up to that effect )
* some variable name updates
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=mwEmbed&debug=true"></script>
 8+ <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,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( 'images_path' ) + 'magnify-clip.png'
 1261+ 'src' : mw.getConfig( 'imagesPath' ) + '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,18 +29,21 @@
3030 });
3131
3232 var mwLoadTimedTextFlag = false;
33 -// Merge in the timed text libs
 33+// Always Merge in the timed text libs
3434 if( mw.getConfig( 'textInterface' ) == 'always' ) {
3535 mwLoadTimedTextFlag = true;
3636 }
 37+
3738 /**
38 -* Setup the load embedPlayer visit tag function hook.
 39+* Setup the load embedPlayer visit tag addSetupHook function
3940 *
4041 * Check if the video tags in the page support timed text
4142 * this way we can add our timed text libraries to the initial
4243 * request and avoid an extra round trip to the server
4344 */
44 -mw.addHook( 'LoaderEmbedPlayerVisitTag', function( playerElement ) {
 45+
 46+// Bind the loader embed player tag viewing
 47+$j( mw ).bind( 'LoaderEmbedPlayerVisitTag', function( event, playerElement ) {
4548 // If add timed text flag not already set check for itext, and sources
4649 if( ! mwLoadTimedTextFlag ) {
4750 if( $j( playerElement ).find( 'itext' ).length != 0 ) {
@@ -55,14 +58,15 @@
5659 }
5760 }
5861 } );
59 -
6062 // Update the player loader request with timedText if the flag has been set
61 -mw.addHook( 'LoaderEmbedPlayerUpdateRequest', function( classRequest ) {
 63+$j( mw ).bind( 'LoaderEmbedPlayerUpdateRequest', function( event, classRequest ) {
6264 // Add timed text items if flag set.
6365 if( mwLoadTimedTextFlag ) {
6466 $j.merge( classRequest, mwTimedTextRequestSet );
65 - }
 67+ }
 68+
6669 } );
 70+
6771
6872 // TimedText editor:
6973 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 - embedPlayer.addHook( 'monitor', function() {
163 - _this.monitor();
164 - } )
 162+ $j( embedPlayer ).bind( 'onMonitor', function() {
 163+ _this.monitor()
 164+ } );
165165
166 - embedPlayer.addHook( 'play', function() {
 166+ $j( embedPlayer ).bind( 'onPlay', 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( 'images_path' ) + 'magnify-clip.png'
 1022+ 'src' : mw.getConfig( 'imagesPath' ) + '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('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 />' )
@@ -2964,10 +2964,10 @@
29652965 createLayoutSelector: function() {
29662966
29672967 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';
 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';
29722972
29732973 var defaultBoxUrl, defaultListUrl;
29742974 if ( _this.displayMode == 'box' ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -108,57 +108,50 @@
109109 /**
110110 * Add a DOM ready check for player tags
111111
112 -* We use mw.addDOMReadyHook instead of mw.ready so that
113 -* player interfaces are ready once mw.ready is called.
 112+* We use mw.addSetupHook instead of mw.ready() so that
 113+* player interfaces can be ready before mw.ready() is called.
114114 */
115 -mw.addDOMReadyHook( function() {
 115+mw.addSetupHook( function( callback ) {
116116 if( mw.documentHasPlayerTags() ) {
117 - var rewriteElementCount = 0;
 117+ var rewriteElementCount = 0;
118118
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 );
 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+ })
163156 }
164157 });
165158
@@ -205,8 +198,8 @@
206199 // Add skin name to playerSkins
207200 playerSkins[ mw.valid_skins[ n ] ] = true;
208201 }
209 - }
210 - mw.runHook( 'LoaderEmbedPlayerVisitTag', playerElement );
 202+ }
 203+ $j( mw ).trigger( 'LoaderEmbedPlayerVisitTag', playerElement );
211204 } );
212205
213206 // Add the player skins css and js to the load request:
@@ -231,11 +224,14 @@
232225 // Safari gets slower load since we have to detect ogg support
233226 if( typeof HTMLVideoElement == 'object' && !$j.browser.safari ) {
234227 dependencyRequest[0].push( 'nativeEmbed' )
235 - }
 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+ );
236235
237 - // Run the EmbedPlayer loader hook ( so that modules can add dependencies to the request )
238 - mw.runHook( 'LoaderEmbedPlayerUpdateRequest', dependencyRequest[ 0 ] );
239 -
240236
241237 // Load the video libs:
242238 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 - mw.runHook( 'EmbedPlayerManagerReady' );
 267+ $j( mw ).trigger( '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,7 +299,6 @@
300300 init: function( ) {
301301 this.callbackFunctions = [];
302302 this.playerList = [];
303 - mw.addHookSystem ( this );
304303 },
305304
306305 /**
@@ -372,11 +371,12 @@
373372 var playlistPlayer = new mw.PlayList( element, attributes );
374373
375374 // Swap in playlist player interface
376 - _this.swapEmbedPlayerElement( element, playlistPlayer );
 375+ _this.swapEmbedPlayerElement( element, playerInterface );
377376
378 - // Pass the id to any hook that needs to interface prior to showPlayer code
379 - _this.runHook( 'swapedPlayerId', playerInterface.id );
 377+ // Pass the id to any hook that needs to interface prior to checkPlayerSources
 378+ $j( _this ).trigger ( 'swapedPlayerId', playerInterface.id );
380379
 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 - _this.runHook( 'swapedPlayerId', playerInterface.id );
 401+ $j( _this ).trigger ( '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,10 +560,9 @@
561561 // Remove the player loader spinner:
562562 $j('#loadSpiner_' + player.id ).remove();
563563
564 - // Run the player ready hook
565 - player.runHook( 'playerReady' );
 564+ // Run the player ready trigger
 565+ $j( player ).trigger( 'playerReady' );
566566
567 - // Check if all the players are ready
568567 var is_ready = true;
569568 for ( var i = 0; i < this.playerList.length; i++ ) {
570569 var currentPlayer = $j( '#' + this.playerList[i] ).get( 0 );
@@ -595,7 +594,7 @@
596595
597596 mediaSource.prototype = {
598597 // MIME type of the source.
599 - mimeType: null,
 598+ mimeType:null,
600599
601600 // URI of the source.
602601 uri:null,
@@ -648,7 +647,7 @@
649648 if ( typeof pUrl[ 'queryKey' ][ 't' ] != 'undefined' ) {
650649 this[ 'URLTimeEncoding' ] = true;
651650 }
652 - // Set the source attributes local var
 651+
653652 var sourceAttr = mw.getConfig( 'embedPlayerSourceAttributes' );
654653
655654 for ( var i = 0; i < sourceAttr.length; i++ ) { // array loop:
@@ -973,15 +972,15 @@
974973 * @return mediaSource elements.
975974 * @type Array
976975 */
977 - getSources: function( mime_filter ) {
978 - if ( !mime_filter ) {
 976+ getSources: function( mimeFilter ) {
 977+ if ( !mimeFilter ) {
979978 return this.sources;
980979 }
981980 // Apply mime filter:
982981 var source_set = new Array();
983982 for ( var i = 0; i < this.sources.length ; i++ ) {
984983 if ( this.sources[i].mimeType &&
985 - this.sources[i].mimeType.indexOf( mime_filter ) != -1 )
 984+ this.sources[i].mimeType.indexOf( mimeFilter ) != -1 )
986985 source_set.push( this.sources[i] );
987986 }
988987 return source_set;
@@ -1144,7 +1143,7 @@
11451144 // make sure an existing element with the same src does not already exist:
11461145 for ( var i = 0; i < this.sources.length; i++ ) {
11471146 if ( this.sources[i].src == newSrc ) {
1148 - // Source already exists update any new attributes:
 1147+ // Source already exists update any new attr:
11491148 this.sources[i].updateSource( element );
11501149 return this.sources[i];
11511150 }
@@ -1152,8 +1151,8 @@
11531152 }
11541153 // Create a new source
11551154 var source = new mediaSource( element );
1156 -
1157 - this.sources.push( source );
 1155+
 1156+ this.sources.push( source );
11581157 mw.log( 'tryAddSource: added source ::' + source + 'sl:' + this.sources.length );
11591158 return source;
11601159 },
@@ -1169,7 +1168,7 @@
11701169 if ( this.isPlayableType( this.sources[i].mimeType ) ) {
11711170 playableSources.push( this.sources[i] );
11721171 } else {
1173 - mw.log( "type " + this.sources[i].mimeType + 'is not playable' );
 1172+ //mw.log( "type " + this.sources[i].mimeType + 'is not playable' );
11741173 }
11751174 };
11761175 return playableSources;
@@ -1244,9 +1243,6 @@
12451244 // Stores the loading errors
12461245 'loadError' : false,
12471246
1248 - // Loading external data flag ( for delaying interface updates )
1249 - 'loading_external_data' : false,
1250 -
12511247 // Thumbnail updating flag ( to avoid rewriting an thumbnail thats already being updated)
12521248 'thumbnail_updating' : false,
12531249
@@ -1285,12 +1281,10 @@
12861282 init: function( element, customAttributes ) {
12871283 var _this = this;
12881284 // Set customAttributes if unset:
1289 - if ( !customAttributes )
 1285+ if ( !customAttributes ) {
12901286 customAttributes = { };
 1287+ }
12911288
1292 - //Add a hook system to the embedPlayer
1293 - mw.addHookSystem( _this );
1294 -
12951289 var playerAttributes = mw.getConfig( 'embedPlayerAttributes' );
12961290 // Setup the player Interface from supported attributes:
12971291 for ( var attr in playerAttributes ) {
@@ -1371,8 +1365,8 @@
13721366 }
13731367
13741368 // Add the mediaElement object with the elements sources:
1375 - this.mediaElement = new mediaElement( element );
1376 -
 1369+ this.mediaElement = new mediaElement( element );
 1370+
13771371 },
13781372
13791373 /**
@@ -1431,6 +1425,7 @@
14321426 ) {
14331427 var defaultSize = mw.getConfig( 'videoSize' ).split( 'x' );
14341428 this['width'] = defaultSize[0];
 1429+
14351430 // Special height default for audio tag ( if not set )
14361431 if( element.tagName.toLowerCase() == 'audio' ) {
14371432 this['height'] = 0;
@@ -1464,7 +1459,7 @@
14651460 * If we need to get media sources form an external file
14661461 * that request is issued here
14671462 */
1468 - checkPlayerSources: function( callbackChain ) {
 1463+ checkPlayerSources: function() {
14691464 mw.log( 'f:checkPlayerSources: ' + this.id );
14701465 var _this = this;
14711466 var sourceCount = this.mediaElement.getPlayableSources().length;
@@ -1482,19 +1477,16 @@
14831478 } );
14841479 return ;
14851480 }
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 - }
14951481
 1482+ // Run embedPlayer sources hook
 1483+ $j( this ).trigger ( 'checkPlayerSources', function(){
 1484+ // Continue application flow and check for Timed Text
 1485+ _this.checkForTimedText();
 1486+ });
14961487 },
 1488+
14971489 /**
1498 - * Load Source video info From Api title key ( this.apiTitleKey )
 1490+ * Load Source video info from mediaWiki Api title key ( this.apiTitleKey )
14991491 * @param {Function} callback Function called once loading is complete
15001492 */
15011493 loadSourceFromApi: function( callback ){
@@ -1610,7 +1602,7 @@
16111603 // Auto select player based on default order
16121604 if ( !this.mediaElement.selectedSource ) {
16131605 // check for parent clip:
1614 - if ( typeof this.pc != 'undefined' ) {
 1606+ if ( typeof this.pc != 'undefined' ) {
16151607 mw.log( 'no sources, type:' + this.type + ' check for html' );
16161608 // debugger;
16171609 // do load player if just displaying innerHTML:
@@ -1629,7 +1621,6 @@
16301622 // Inherit the playback system of the selected player:
16311623 this.inheritEmbedPlayer();
16321624 } else {
1633 -
16341625 // No source's playable
16351626 var missingType = '';
16361627 var or = '';
@@ -1637,7 +1628,6 @@
16381629 missingType += or + this.mediaElement.sources[i].mimeType;
16391630 or = ' or ';
16401631 }
1641 -
16421632 // Get from parent playlist if set:
16431633 if ( this.pc ){
16441634 missingType = this.pc.type;
@@ -1780,32 +1770,21 @@
17811771 mw.log( 'updated seek_time_sec: ' + mw.seconds2npt ( this.seek_time_sec ) );
17821772 this.stop();
17831773 this.didSeekJump = true;
1784 -
17851774 // Update the slider
17861775 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 );
17921776 }
 1777+ // Do play request in 100ms ( give the dom time to swap out the embed player )
 1778+ setTimeout( function() {
 1779+ _this.play()
 1780+ }, 100 );
17931781
17941782 // Run the onSeeking interface update
1795 - this.onSeek();
1796 -
1797 - },
 1783+ // NOTE ctrlBuilder should really bind to html5 events rather
 1784+ // than explicitly calling it or inheriting stuff.
 1785+ this.ctrlBuilder.onSeek();
 1786+ },
17981787
17991788 /**
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 - /**
18101789 * Seeks to the requested time and issues a callback when ready
18111790 * (should be overwritten by client that supports frame serving)
18121791 */
@@ -1839,7 +1818,7 @@
18401819 this.bufferStartFlag = false;
18411820 this.bufferEndFlag = false;
18421821
1843 -
 1822+ // Make sure the player is
18441823 mw.log( 'performing embed for ' + _this.id );
18451824 // mw.log('should embed:' + embed_code);
18461825 _this.doEmbedHTML()
@@ -1851,7 +1830,8 @@
18521831 * On clip done action. Called once a clip is done playing
18531832 */
18541833 onClipDone: function() {
1855 - mw.log( 'base:onClipDone' );
 1834+ mw.log( 'base:onClipDone' );
 1835+
18561836
18571837 // Stop the clip (load the thumbnail etc)
18581838 this.stop();
@@ -1870,11 +1850,11 @@
18711851 }
18721852 // Do the ctrlBuilder onClip done interface
18731853 this.ctrlBuilder.onClipDone();
1874 -
1875 - // Fire the html5 ended binding / event
 1854+
 1855+ // Fire the html5 ended binding
18761856 $j( this ).trigger( 'ended' );
18771857
1878 - //Set the clip done playing count:
 1858+ // Update the clip done playing count:
18791859 this.donePlayingCount ++;
18801860 },
18811861
@@ -1897,8 +1877,8 @@
18981878 // Make sure the ctrlBuilder bindings are up-to-date
18991879 this.ctrlBuilder.addControlHooks();
19001880
1901 - // Once the thumbnail is shown run the mediaReady hook
1902 - this.runHook( 'mediaLoaded' );
 1881+ // Once the thumbnail is shown run the mediaReady trigger
 1882+ $j( this ).trigger( 'mediaLoaded' );
19031883 },
19041884
19051885 /**
@@ -1923,7 +1903,6 @@
19241904 this.ctrlBuilder = new ctrlBuilder( this );
19251905
19261906 var _this = this;
1927 -
19281907 // Make sure we have interface_wrap
19291908 if( $j( this ).parent( '.interface_wrap' ).length == 0 ) {
19301909 // Select "player"
@@ -1966,9 +1945,9 @@
19671946 * @param {String} [misssingType] missing type mime
19681947 */
19691948 showPluginMissingHTML : function( misssingType ) {
1970 - //remove the loading spinner if present:
 1949+ // Remove the loading spinner if present:
19711950 $j('#loadSpiner_' + this.id ).remove();
1972 -
 1951+
19731952 // If the native video is already displayed hide it:
19741953 if( $j( '#' + this.pid ).length != 0 ){
19751954 $j('#loadSpiner_' + this.id ).remove();
@@ -2026,7 +2005,7 @@
20272006 this.mediaElement.updateSourceTimes( start_npt, end_npt );
20282007
20292008 // update mv_time
2030 - this.setStatus( start_npt + '/' + end_npt );
 2009+ this.ctrlBuilder.setStatus( start_npt + '/' + end_npt );
20312010
20322011 // reset slider
20332012 this.updatePlayHead( 0 );
@@ -2178,8 +2157,9 @@
21792158 mw.log( 'embedPlayer:updateThumbnailHTML::' + this.id );
21802159 var thumb_html = '';
21812160 var class_atr = '';
2182 - var style_atr = '';
 2161+ var style_atr = '';
21832162
 2163+
21842164 if( this.useNativeControls() ){
21852165 this.showNativePlayer();
21862166 return ;
@@ -2187,9 +2167,9 @@
21882168
21892169 // Set by default thumb value if not found
21902170 var posterSrc = ( this.poster ) ? this.poster :
2191 - mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg';
 2171+ mw.getConfig( 'imagesPath' ) + 'vid_default_thumb.jpg';
21922172
2193 - // Poster support is not very good in all browsers
 2173+ // Poster support is not very consistant in browsers
21942174 // use a jpg poster image:
21952175 $j( this ).html(
21962176 $j( '<img />' )
@@ -2204,7 +2184,7 @@
22052185 })
22062186 .addClass( 'playerPoster' )
22072187 );
2208 -
 2188+
22092189 if ( this.controls
22102190 && this.height > this.ctrlBuilder.getComponentHeight( 'playButtonLarge' )
22112191 ) {
@@ -2217,7 +2197,7 @@
22182198 /**
22192199 * Checks if native controls should be used
22202200 *
2221 - * @param [player] Object Optional player object to check controls attribute
 2201+ * @param [player] Object Optional player object to check controls attribute
22222202 * @returns boolean true if the mwEmbed player interface should be used
22232203 * false if the mwEmbed player interface should not be used
22242204 */
@@ -2507,14 +2487,12 @@
25082488 this.doPlayTracking();
25092489 }
25102490
2511 - // Run play hook:
2512 - this.runHook( 'play' );
2513 -
2514 - // If we previusly finished playing this clip run the "replay hook"
 2491+ //Run play hook:
 2492+ $j( this ).trigger( 'onPlay' );
 2493+ // If we previusly finished playing this clip run the "replay hook"
25152494 if( this.donePlayingCount > 0 ){
2516 - this.runHook( 'replay' );
 2495+ $j( this ).trigger( 'onReplay' );
25172496 }
2518 -
25192497 },
25202498
25212499 /**
@@ -2587,7 +2565,7 @@
25882566 this.showThumbnail();
25892567 this.bufferedPercent = 0; // reset buffer state
25902568 this.updatePlayHead( 0 );
2591 - this.setStatus( this.getTimeRange() );
 2569+ this.ctrlBuilder.setStatus( this.getTimeRange() );
25922570 }
25932571
25942572 //Bind play-btn-large play
@@ -2710,14 +2688,13 @@
27112689 if ( parseInt( this.startOffset ) != 0 ) {
27122690 // If start offset include that calculation
27132691 this.updatePlayHead( ( this.currentTime - this.startOffset ) / this.duration );
2714 - var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) +
2715 - parseFloat( this.duration ) ) : '';
2716 - this.setStatus( mw.seconds2npt( this.currentTime ) + et );
 2692+ var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + parseFloat( this.duration ) ) : '';
 2693+ this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et );
27172694 } else {
27182695 this.updatePlayHead( this.currentTime / this.duration );
27192696 // Only include the end time if longTimeDisp is enabled:
27202697 var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( this.duration ) : '';
2721 - this.setStatus( mw.seconds2npt( this.currentTime ) + et );
 2698+ this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + et );
27222699 }
27232700 }
27242701 // Check if we are "done"
@@ -2729,16 +2706,16 @@
27302707 } else {
27312708 // Media lacks duration just show end time
27322709 if ( this.isStoped() ) {
2733 - this.setStatus( this.getTimeRange() );
 2710+ this.ctrlBuilder.setStatus( this.getTimeRange() );
27342711 } else if ( this.isPaused() ) {
2735 - this.setStatus( gM( 'mwe-paused' ) );
 2712+ this.ctrlBuilder.setStatus( gM( 'mwe-paused' ) );
27362713 } else if ( this.isPlaying() ) {
27372714 if ( this.currentTime && ! this.duration )
2738 - this.setStatus( mw.seconds2npt( this.currentTime ) + ' /' );
 2715+ this.ctrlBuilder.setStatus( mw.seconds2npt( this.currentTime ) + ' /' );
27392716 else
2740 - this.setStatus( " - - - " );
 2717+ this.ctrlBuilder.setStatus( " - - - " );
27412718 } else {
2742 - this.setStatus( this.getTimeRange() );
 2719+ this.ctrlBuilder.setStatus( this.getTimeRange() );
27432720 }
27442721 }
27452722
@@ -2751,14 +2728,13 @@
27522729 }, 250 )
27532730 }
27542731
2755 - this.runHook( 'monitor' );
 2732+ $j( this ).trigger( 'onMonitor' );
27562733 },
27572734
27582735 /**
27592736 * Update the buffer status based on the local bufferedPercent var
27602737 */
27612738 updateBufferStatus: function() {
2762 -
27632739 // Get the buffer target based for playlist vs clip
27642740 $buffer = this.$interface.find( '.mw_buffer' );
27652741
@@ -2778,15 +2754,14 @@
27792755 // if we have not already run the buffer start hook
27802756 if( this.bufferedPercent > 0 && !this.bufferStartFlag ) {
27812757 this.bufferStartFlag = true;
2782 - this.runHook( 'bufferStart' );
 2758+ $j( this ).trigger( 'onBufferStart' );
27832759 }
27842760
27852761 // if we have not already run the buffer end hook
27862762 if( this.bufferedPercent == 1 && !this.bufferEndFlag){
27872763 this.bufferEndFlag = true;
2788 - this.runHook( 'bufferEnd' );
 2764+ $j( this ).trigger( 'onBufferEnd' );
27892765 }
2790 -
27912766 },
27922767
27932768 /**
@@ -2846,7 +2821,7 @@
28472822 this.jump_time = options['start'];
28482823 this.seek_time_sec = mw.npt2seconds( options['start'] );
28492824 // trim output to
2850 - this.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) );
 2825+ this.ctrlBuilder.setStatus( gM( 'mwe-seek_to', mw.seconds2npt( this.seek_time_sec ) ) );
28512826 mw.log( 'DO update: ' + this.jump_time );
28522827 this.updateThumbTime( rel_start_sec );
28532828 },
@@ -2857,20 +2832,10 @@
28582833 hideHighlight: function() {
28592834 var eid = ( this.pc ) ? this.pc.pp.id:this.id;
28602835 $j( '#mv_seeker_' + eid + ' .mv_highlight' ).hide();
2861 - this.setStatus( this.getTimeRange() );
2862 - },
 2836+ this.ctrlBuilder.setStatus( this.getTimeRange() );
 2837+ },
28632838
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 - },
28722839
2873 -
2874 -
28752840 /**
28762841 * Helper Functions for selected source
28772842 */
@@ -3072,9 +3037,9 @@
30733038 /**
30743039 * Checks if a player is supported by id
30753040 */
3076 - isSupportedPlayer: function( player_id ){
 3041+ isSupportedPlayer: function( playerId ){
30773042 for( var i=0; i < this.players.length; i++ ){
3078 - if( this.players[i].id == player_id ){
 3043+ if( this.players[i].id == playerId ){
30793044 return true;
30803045 }
30813046 }
@@ -3133,26 +3098,26 @@
31343099 /**
31353100 * Sets the format preference.
31363101 *
3137 - * @param {String} mime_format Prefered format
 3102+ * @param {String} mimeFormat Prefered format
31383103 */
3139 - setFormatPreference : function ( mime_format ) {
3140 - this.preference['format_preference'] = mime_format;
 3104+ setFormatPreference : function ( mimeFormat ) {
 3105+ this.preference['format_preference'] = mimeFormat;
31413106 mw.setUserConfig( 'playerPref', this.preference);
31423107 },
31433108
31443109 /**
31453110 * Sets the player preference
31463111 *
3147 - * @param {String} player_id Prefered player id
 3112+ * @param {String} playerId Prefered player id
31483113 * @param {String} mimeType Mime type for the associated player stream
31493114 */
3150 - setPlayerPreference : function( player_id, mimeType ) {
 3115+ setPlayerPreference : function( playerId, mimeType ) {
31513116 var selected_player = null;
31523117 for ( var i = 0; i < this.players.length; i++ ) {
3153 - if ( this.players[i].id == player_id ) {
 3118+ if ( this.players[i].id == playerId ) {
31543119 selected_player = this.players[i];
3155 - mw.log( 'choosing ' + player_id + ' for ' + mimeType );
3156 - this.preference[ mimeType ] = player_id;
 3120+ mw.log( 'choosing ' + playerId + ' for ' + mimeType );
 3121+ this.preference[ mimeType ] = playerId;
31573122 mw.setUserConfig( 'playerPref', this.preference );
31583123 break;
31593124 }
@@ -3211,12 +3176,12 @@
32123177 /**
32133178 * If the browsers supports a given mimetype
32143179 *
3215 - * @param {String} mimetype Mime type for browser plug-in check
 3180+ * @param {String} mimeType Mime type for browser plug-in check
32163181 */
3217 - supportedMimeType: function( mimetype ) {
3218 - for ( var i = navigator.plugins.length; i-- > 0; ) {
 3182+ supportedMimeType: function( mimeType ) {
 3183+ for ( var i =0; i < navigator.plugins.length; i++ ) {
32193184 var plugin = navigator.plugins[i];
3220 - if ( typeof plugin[mimetype] != "undefined" )
 3185+ if ( typeof plugin[ mimeType ] != "undefined" )
32213186 return true;
32223187 }
32233188 return false;
@@ -3226,23 +3191,23 @@
32273192 * Detects what plug-ins the client supports
32283193 */
32293194 detect: function() {
3230 - mw.log( "embedPlayer: running detect" );
 3195+ mw.log( "embedPlayer: running detect" );
32313196 this.players = new mediaPlayers();
32323197 // every browser supports html rendering:
32333198 this.players.addPlayer( htmlPlayer );
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 - }
 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+ }
32443209
3245 - // ActiveX plugins
3246 - if ( $j.browser.msie ) {
 3210+ // ActiveX plugins
 3211+ if ( $j.browser.msie ) {
32473212 // check for flash
32483213 if ( this.testActiveX( 'ShockwaveFlash.ShockwaveFlash' ) ) {
32493214 // try to get the flash version for omtk include:
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/skins/ctrlBuilder.js
@@ -836,6 +836,25 @@
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+
840859 /**
841860 * Option menu items
842861 *
@@ -1585,9 +1604,9 @@
15861605 embedPlayer.jump_time = mw.seconds2npt( parseFloat( parseFloat( embedPlayer.getDuration() ) * perc ) + embedPlayer.start_time_sec );
15871606 // mw.log('perc:' + perc + ' * ' + embedPlayer.getDuration() + ' jt:'+ this.jump_time);
15881607 if ( _this.longTimeDisp ) {
1589 - embedPlayer.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
 1608+ ctrlObj.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
15901609 } else {
1591 - embedPlayer.setStatus( embedPlayer.jump_time );
 1610+ ctrlObj.setStatus( embedPlayer.jump_time );
15921611 }
15931612 // Update the thumbnail / frame
15941613 if ( embedPlayer.isPlaying == false ) {
@@ -1605,7 +1624,7 @@
16061625 // set seek time (in case we have to do a url seek)
16071626 embedPlayer.seek_time_sec = mw.npt2seconds( embedPlayer.jump_time, true );
16081627 mw.log( 'do jump to: ' + embedPlayer.jump_time + ' perc:' + perc + ' sts:' + embedPlayer.seek_time_sec );
1609 - embedPlayer.setStatus( gM( 'mwe-seeking' ) );
 1628+ ctrlObj.setStatus( gM( 'mwe-seeking' ) );
16101629 embedPlayer.doSeek( perc );
16111630 }
16121631 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js
@@ -275,7 +275,6 @@
276276 * Local implementation of swapPlayerElement
277277 */
278278 swapPlayerElement:function() {
279 - this.loading_external_data = false
280279 this.ready_to_play = true;
281280 return ;
282281 }
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 /**
@@ -380,10 +377,10 @@
381378 * Local method for seeking event
382379 * fired when "seeking"
383380 */
384 - onSeeking: function() {
385 - //mw.log( "onseeking" );
386 - this.seeking = true;
387 - this.setStatus( gM( 'mwe-seeking' ) );
 381+ onSeeking: function() {
 382+ // Run the onSeeking interface update
 383+ this.ctrlBuilder.onSeek();
 384+
388385 // Trigger the html5 seeking event
389386 $j( this ).trigger( 'seeking' );
390387 },
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 );
@@ -1039,7 +1042,7 @@
10401043 * mediaWiki JSON a wrapper for jQuery getJSON:
10411044 * ( could also be named mw.apiRequest )
10421045 *
1043 - * The mediaWiki version lets you skip the url part
 1046+ * The mwEmbed version lets you skip the url part
10441047 * mw.getJSON( [url], data, callback, [timeoutCallback] );
10451048 *
10461049 * Lets you assume:
@@ -1048,18 +1051,19 @@
10491052 * callback parameter is not needed for the request data
10501053 * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param
10511054 * 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.
 1055+ * automatically issues request over "POST" if the request api post type
 1056+ * automatically will setup apiProxy where request is cross domain
10541057 *
10551058 * @param {Mixed} url or data request
10561059 * @param {Mixed} data or callback
10571060 * @param {Function} callbcak function called on success
10581061 * @param {Function} callbackTimeout - optional function called on timeout
1059 - * Setting timeout callback also avoids default dialog display for timed-out proxy calls.
 1062+ * Setting timeout callback also avoids default timed-out dialog for proxy requests
10601063 */
1061 - mw.getJSON = function() {
1062 - // Set up the url
1063 -
 1064+ mw.getJSON = function() {
 1065+ // Proccess the arguments:
 1066+
 1067+ // Set up the url
10641068 var url = false;
10651069 url = ( typeof arguments[0] == 'string' ) ? arguments[0] : mw.getLocalApiUrl();
10661070
@@ -1203,7 +1207,8 @@
12041208 *
12051209 * @param {String} [apiUrl] Optional target API URL (uses default local api if unset)
12061210 * @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
 1211+ * @param {callback} callback Function to pass the token to.
 1212+ * issues callback with "false" if token not retrived
12081213 */
12091214 mw.getToken = function( apiUrl, title, callback ) {
12101215 // Make the apiUrl be optional:
@@ -1235,7 +1240,8 @@
12361241 /**
12371242 * Api helper to grab the username
12381243 * @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
 1244+ * @param {Function} callback Function to callback with username or false if not found
 1245+ * @param {Boolean} fresh A fresh check is issued.
12401246 */
12411247 // Stub feature apiUserNameCache to avoid multiple calls
12421248 // ( a more general api cache framework should be devloped )
@@ -1295,7 +1301,7 @@
12961302 * addLoaderDialog
12971303 * small helper for displaying a loading dialog
12981304 *
1299 - * @param msg text text of the loader msg
 1305+ * @param {String} msg_txt text text of the loader msg
13001306 */
13011307 mw.addLoaderDialog = function( msg_txt ) {
13021308 mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() );
@@ -1362,16 +1368,11 @@
13631369 * Close the loader dialog created with addLoaderDialog
13641370 */
13651371 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 - } );
 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();
13761377 }
13771378
13781379
@@ -1517,7 +1518,7 @@
15181519 var mwReadyFlag = false;
15191520
15201521 /**
1521 - * Enables load hooks to run once DOM is "ready"
 1522+ * Enables load hooks to run once mwEmbeed is "ready"
15221523 * Will ensure jQuery is available, is in the $j namespace
15231524 * and mw interfaces and configuration has been loaded and applied
15241525 *
@@ -1530,20 +1531,7 @@
15311532 mw.ready = function( callback ) {
15321533 if( mwReadyFlag === false ) {
15331534 // 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 ;
 1535+ mwOnLoadFunctions.push ( callback );
15481536 }
15491537 // If mwReadyFlag is already "true" issue the callback directly:
15501538 callback();
@@ -1551,6 +1539,7 @@
15521540
15531541 /**
15541542 * Runs all the queued functions
 1543+ * called by mwEmbedSetup
15551544 */
15561545 mw.runReadyFunctions = function ( ) {
15571546 // Run all the queued functions:
@@ -1643,7 +1632,7 @@
16441633 };
16451634 //mw.log(" append script: " + script.src );
16461635 // Append the script to the DOM:
1647 - head.appendChild( script );
 1636+ head.appendChild( script );
16481637 };
16491638
16501639 /**
@@ -2165,60 +2154,70 @@
21662155 }
21672156
21682157 // 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() {
 2158+ mw.load( 'window.jQuery', function() {
 2159+
 2160+ // Add jQuery to $j var.
21722161 if ( ! window[ '$j' ] ) {
21732162 window[ '$j' ] = jQuery.noConflict();
21742163 }
21752164
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();
 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+ }
22032202 }
2204 - }
2205 - runSetupFunctions();
2206 - });
 2203+ runSetupFunctions();
 2204+ });
 2205+ } );
22072206 });
22082207 };
22092208
22102209 /**
2211 - * Check for module loaders, and localization
 2210+ * Check for script-loader module loaders, and localization files
22122211 *
2213 - * Note if using a scriptLoader all the loaders and localization converters
 2212+ * NOTE: if using the ScriptLoader all the loaders and localization converters
22142213 * are included automatically.
22152214 */
2216 - mw.moduleLoaderCheck = function( callback ) {
 2215+ mw.checkScriptLoaderFiles = function( callback ) {
22172216 mw.log( 'doLoaderCheck::' );
22182217
22192218 // Check if we are using scriptloader ( handles loader include automatically )
22202219 if( mw.getScriptLoaderPath() ) {
22212220 // Do a async call to callback in cases where DOM is ready before we get to
2222 - // loader config code in the same file.
 2221+ // loader config code
22232222 setTimeout(function() {
22242223 callback();
22252224 }, 1);
@@ -2226,12 +2225,12 @@
22272226 }
22282227
22292228 // Add the Core loader to the request
2230 - // The follow code is only run in debug / raw file mode
 2229+ // The follow code is ONLY RUN in debug / raw file mode
 2230+
22312231 mw.load( 'loader.js', function() {
22322232 // Load all the "loaders" of the enabled modules:
22332233 var loaderRequest = [];
22342234
2235 -
22362235 //Load enabled components
22372236 var enabledComponents = mw.getConfig( 'coreComponents' );
22382237 function loadEnabledComponents( enabledComponents ){
@@ -2251,7 +2250,7 @@
22522251 loadEnabledComponents( enabledComponents );
22532252
22542253
2255 - //Set the loader context and get each loader individually ( only in debug mode )
 2254+ // Set the loader context and get each loader individually
22562255 function loadEnabledModules( enabledModules ){
22572256 if( ! enabledModules.length ){
22582257 // If no more modules left load the LanguageFile
@@ -2339,29 +2338,7 @@
23402339 var mwDomReadyFlag = false;
23412340
23422341 // 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 - }
 2342+ var mwModuleLoaderCheckFlag = false;
23662343
23672344 /**
23682345 * This will get called when the DOM is ready
@@ -2374,28 +2351,9 @@
23752352 mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length );
23762353 // Set the onDomReady Flag
23772354 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 - });
 2355+
 2356+ // Setup MwEmbed
 2357+ mw.setupMwEmbed();
24002358 }
24012359
24022360 /**
@@ -2560,6 +2518,7 @@
25612519 * mwEmbed.js is included without jQuery
25622520 * and we need our own "ready" system so that
25632521 * mwEmbed interfaces can support async built out
 2522+* and the inclution of jQuery.
25642523 */
25652524 var mwDomIsReady = false;
25662525 function runMwDomReady(){
@@ -2638,8 +2597,13 @@
26392598 }
26402599
26412600
2642 -// Hack to keep jQuery in $ when its
2643 -// already there, but also use noConflict to get $j = jQuery
 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+ */
26442608 if( window.jQuery ){
26452609 var dollarFlag = false;
26462610 if( $ && $.fn && $.fn.jquery ){
@@ -2647,8 +2611,13 @@
26482612 // jQuery and do a removal call if too old
26492613 dollarFlag = true;
26502614 }
2651 - window['$j'] = jQuery.noConflict();
 2615+ window[ '$j' ] = jQuery.noConflict();
26522616 if( dollarFlag ) {
2653 - window['$'] = jQuery.noConflict();
 2617+ window[ '$' ] = jQuery.noConflict();
26542618 }
26552619 }
 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,6 +120,7 @@
121121
122122 // mwEmbed is a core component so it includes loaders and other styles
123123 if( $classKey == 'mwEmbed' && $this->outputFormat != 'messages' ){
 124+
124125 // Output core components ( parts of mwEmbed that are in different files )
125126 $this->output .= jsClassLoader::getCombinedComponentJs( $this );
126127
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( '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() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r65977* restored r65942 with fix for mw.Language.js includedale02:26, 6 May 2010
r65987more r65942 merge fixesdale17:12, 6 May 2010

Status & tagging log