r62812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62811‎ | r62812 | r62813 >
Date:05:26, 22 February 2010
Author:dale
Status:deferred
Tags:
Comment:
~ unstable commit ~
* whitespace fixes for "){" ") {"
* rewrite of "optionsMenu" system
* moved option menu items display / logic from embedPlayer to ctrBuilder
Modified paths:
  • /branches/js2-work/phase3/js/editPage.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/languages/classes/LanguageLt.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/jquery.simpleUploadForm.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.FirefoggGUI.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/flickrSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/NestedCallbackIframe.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/index.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/colorpicker.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/eye.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/layout.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/utils.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/mw.ClipEdit.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/pixastic-editor/editor.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/pixastic-lib/pixastic-editor/editor.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.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/omtkEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/vlcEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.FirefoggRender.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/playlistEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/remotes/RemoteMwSequencer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/jquery.menu/jquery.menu.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/TimedText/mw.TimedTextEdit.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/remotes/RemoteMwTimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/common/common.css (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Audio.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/editPage.js
@@ -42,7 +42,7 @@
4343 mw.log( 'Added via wikiEditor bind' );
4444 // Display a loader ( since its triggered onClick )
4545 mw.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) );
46 - mw.load( 'AddMedia.addMediaWizard', function(){
 46+ mw.load( 'AddMedia.addMediaWizard', function() {
4747 mw.closeLoaderDialog();
4848 $j.addMediaWizard( amwConf );
4949 });
@@ -61,7 +61,7 @@
6262 mw.getConfig( 'images_path' ) + 'Button_add_media.png">' );
6363
6464 $j( '#btn-add-media-wiz' ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) );
65 - mw.load( 'AddMedia.addMediaWizard', function(){
 65+ mw.load( 'AddMedia.addMediaWizard', function() {
6666 $j( '#btn-add-media-wiz' ).addMediaWizard(
6767 amwConf
6868 );
@@ -71,9 +71,12 @@
7272 // Make sure the wikieditor got binded:
7373 if ( !didWikiEditorBind ) {
7474 mw.log( 'Failed to bind via build section bind via target:' );
75 - $j( ".tool[rel='file']" ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) );
76 - mw.load( 'AddMedia.addMediaWizard', function(){
77 - if( $j( ".tool[rel='file']" ).size() != 0 ){
 75+
 76+ $j( ".tool[rel='file']" )
 77+ .attr( 'title', gM( 'mwe-loading-add-media-wiz' ) );
 78+
 79+ mw.load( 'AddMedia.addMediaWizard', function() {
 80+ if( $j( ".tool[rel='file']" ).size() != 0 ) {
7881 $j( ".tool[rel='file']" ).unbind().addMediaWizard( amwConf );
7982 }
8083 });
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Audio.html
@@ -2,7 +2,8 @@
33 <html>
44 <head>
55 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 - <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
 6+ <!-- <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> -->
 7+ <script type="text/javascript" src="../jsScriptLoader.php?class=mwEmbed&debug=true"></script>
78 <title>Audio Player sample</title>
89 </head>
910 <body>
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html
@@ -4,15 +4,15 @@
55 <head>
66 <title> Sample Themed Player </title>
77 Pre-loading demo ( stuff ) likely needed for video display
8 - <!-- <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script>
9 -
 8+ <!-- <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script>
109 <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=mwEmbed"></script>
1110 <link rel="stylesheet" href="../skins/styles.css" type="text/css" media="screen" />
1211 <link rel="stylesheet" href="../skins/mvpcf/EmbedPlayer.css" type="text/css" media="screen" />
13 - <link rel="stylesheet" href="../skins/kskin/EmbedPlayer.css" type="text/css" media="screen" />
 12+ <link rel="stylesheet" href="../skins/kskin/EmbedPlayer.css" type="text/css" media="screen" />
1413
15 - -->
16 - <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
 14+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
 15+ -->
 16+ <script type="text/javascript" src="../jsScriptLoader.php?debug=true&class=mwEmbed"></script>
1717
1818
1919 </head>
@@ -23,7 +23,7 @@
2424 To play with dynamic Themes install <a href="http://jqueryui.com/themeroller/developertool/">Themeroller</a><p><p>
2525
2626 <div style="width:450px;float:left">
27 -<video
 27+<video
2828 style="width:400px;height:300px"
2929 src="http://localhost/lucky.ogv"
3030 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
@@ -32,7 +32,7 @@
3333 durationHint="60" >
3434 </video>
3535
36 -
 36+<!--
3737 <video
3838 style="width:208px;height:160px;float:left"
3939 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
@@ -41,6 +41,7 @@
4242 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
4343 durationHint="60">
4444 </video>
 45+
4546 <b>Source Code used:</b><br>
4647 <textarea cols="50" rows="7"><video style="width:400px;height:288px" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
4748 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"></video></textarea>
@@ -69,7 +70,7 @@
7071 <textarea cols="50" rows="7"><video class="kskin" style="width:400px;height:288px" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
7172 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"></video></textarea>
7273 </div>
73 -
 74+ -->
7475
7576 </body>
7677 </html>
Index: branches/js2-work/phase3/js/mwEmbed/includes/languages/classes/LanguageLt.js
@@ -13,13 +13,13 @@
1414
1515
1616 //if no number with word, then use $form[0] for singular and $form[1] for plural or zero
17 - if( forms.length == 2 ){
 17+ if( forms.length == 2 ) {
1818 return count == 1 ? forms[0] : forms[1];
1919 }
2020
2121 forms = mw.lang.preConvertPlural( forms, 3 );
2222 mw.log( 'Count: ' + count + ' mod 10: ' + (count % 10 ) + ' mod 100: ' + (count % 100) );
23 - if (count % 10 == 1 && count % 100 != 11 ){
 23+ if (count % 10 == 1 && count % 100 != 11 ) {
2424 mw.log('return form 0 for count:' + count );
2525 return forms[0];
2626 }
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -10,7 +10,7 @@
1111 return this.init( embedPlayer, options );
1212 };
1313
14 -/*
 14+/**
1515 * controlsBuilder prototype:
1616 */
1717 ctrlBuilder.prototype = {
@@ -20,7 +20,7 @@
2121 playerClass : 'mv-player',
2222
2323 // Long string display of time value
24 - long_time_disp: true,
 24+ longTimeDisp: true,
2525
2626 // If the options menu outside of player
2727 external_options : true,
@@ -35,12 +35,20 @@
3636 supportedComponets: {
3737
3838 // All playback types support options
39 - 'options':true,
40 -
41 - // All playback types support kalturaAttribution
42 - // to enable or disable use mw.setConfig( 'kalturaAttribution', [true|false] )
43 - 'kalturaAttribution' : true
44 - },
 39+ 'options': true
 40+ },
 41+
 42+ // Default supported menu items is merged with skin menu items
 43+ supportedMenuItems: {
 44+ 'playerSelect' : true,
 45+
 46+ // Download the file menu
 47+ 'download' : true,
 48+
 49+ // Share the video menu
 50+ 'share' : true
 51+ },
 52+
4553 /**
4654 * Initialization Object for the control builder
4755 *
@@ -51,9 +59,9 @@
5260 this.embedPlayer = embedPlayer;
5361
5462 // Check for skin overrides for ctrlBuilder
55 - if ( window[ embedPlayer.skinName + 'Config'] ) {
 63+ if ( window[ embedPlayer.skinName + 'Config' ] ) {
5664
57 - // Clone as to not override prototype:
 65+ // Clone as to not override prototype with the skin config
5866 var _this = $j.extend( true, { }, this, window[ embedPlayer.skinName + 'Config'] );
5967
6068 return _this;
@@ -85,8 +93,10 @@
8694 .addClass( 'ui-state-default ui-widget-header ui-helper-clearfix control-bar' )
8795 .css('display', 'block')
8896 );
 97+
8998 //Add the Controls with their bindings
9099 this.addControlComponents();
 100+
91101 // Add hooks once Controls are in DOM
92102 this.addControlHooks();
93103 },
@@ -96,8 +106,9 @@
97107 * @returns the interface html string
98108 */
99109 addControlComponents: function( ) {
100 - var _this = this;
 110+ var _this = this;
101111 mw.log( 'f:controlsBuilder:: opt:' + this.options );
 112+
102113 // Set up local pointer to the embedPlayer
103114 var embedPlayer = this.embedPlayer;
104115
@@ -108,26 +119,24 @@
109120
110121 // Make pointer to the embedPlayer
111122 this.embedPlayer = embedPlayer;
 123+
 124+ // Build the supportedComponets list
 125+ this.supportedComponets = $j.extend( this.supportedComponets, embedPlayer.supports );
112126
113 - var _this = this;
114 - this.supportedComponets = $j.extend(this.supportedComponets, embedPlayer.supports);
115 -
116127 // Check for timed text support:
117128 if( embedPlayer.isTimedTextSupported() ){
118 - this.supportedComponets['timed_text'] = true;
 129+ this.supportedComponets['timedText'] = true;
 130+ }
 131+ // Check for kalturaAttribution
 132+ if( mw.getConfig( 'kalturaAttribution' ) ){
 133+ this.supportedComponets[ 'kalturaAttribution' ] = true;
119134 }
120 -
121 - // Append options to body (if not already there)
122 - if ( this.external_options && $j( '#mv_vid_options_' + this.id ).length == 0 ){
123 - $j( 'body' ).append( this.getComponent( 'optionsMenu' ) );
124 - }
125135
126 -
127 -
128 - // Build component output:
 136+
 137+ // Output components
129138 for ( var component_id in this.components ) {
130139
131 - // Check for explit skip (component === false )
 140+ // Check for (component === false ) and skip
132141 if( this.components[ component_id ] === false ){
133142 continue;
134143 }
@@ -135,12 +144,7 @@
136145 // Special case with playhead skip if we have > 30px of space for it
137146 if ( component_id == 'playHead' && this.available_width < 30 ){
138147 continue;
139 - }
140 -
141 - // Special case of kalturaAttribution skip if set in configuration
142 - if( component_id == 'kalturaAttribution' && mw.getConfig( 'kalturaAttribution' ) == false ){
143 - continue;
144 - }
 148+ }
145149
146150 // Make sure the given components is supported:
147151 if ( this.supportedComponets[ component_id ] ) {
@@ -195,87 +199,15 @@
196200 if ( _this.checkNativeWarning( ) ) {
197201 _this.doNativeWarning();
198202 }
199 -
 203+ // Do png fix for ie6
200204 if ( $j.browser.msie && $j.browser.version <= 6 ) {
201205 $j('#' + embedPlayer.id + ' .play-btn-large' ).pngFix();
202 - }
203 -
204 -
205 - // Captions binding:
206 - $target.find( '.timed-text' ).unbind().buttonHover().click( function() {
207 - embedPlayer.showTextInterface();
208 - } );
209 -
210 - // Options binding:
211 - $target.find( '.options-btn' ).unbind().buttonHover().click( function() {
212 - embedPlayer.doOptionsHTML();
213 - } );
214 -
215 - // Fullscreen binding:
216 - $target.find( '.fullscreen-btn' ).unbind().buttonHover().click( function() {
217 - embedPlayer.fullscreen();
218 - } );
219 -
220 - // Playhead binding
221 - mw.log( " should add slider binding: " + $target.find( '.play_head' ).length );
222 - $target.find( '.play_head' ).slider( {
223 - range: "min",
224 - value: 0,
225 - min: 0,
226 - max: 1000,
227 - start: function( event, ui ) {
228 - var id = ( embedPlayer.pc != null ) ? embedPlayer.pc.pp.id:embedPlayer.id;
229 - embedPlayer.userSlide = true;
230 - $j( id + ' .play-btn-large' ).fadeOut( 'fast' );
231 - // If playlist always start at 0
232 - embedPlayer.start_time_sec = ( embedPlayer.instanceOf == 'mvPlayList' ) ? 0:
233 - mw.npt2seconds( embedPlayer.getTimeRange().split( '/' )[0] );
234 - },
235 - slide: function( event, ui ) {
236 - var perc = ui.value / 1000;
237 - embedPlayer.jump_time = mw.seconds2npt( parseFloat( parseFloat( embedPlayer.getDuration() ) * perc ) + embedPlayer.start_time_sec );
238 - // mw.log('perc:' + perc + ' * ' + embedPlayer.getDuration() + ' jt:'+ this.jump_time);
239 - if ( _this.long_time_disp ) {
240 - embedPlayer.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
241 - } else {
242 - embedPlayer.setStatus( embedPlayer.jump_time );
243 - }
244 - // Update the thumbnail / frame
245 - if ( embedPlayer.isPlaying == false ) {
246 - embedPlayer.updateThumbPerc( perc );
247 - }
248 - },
249 - change:function( event, ui ) {
250 - // Only run the onChange event if done by a user slide
251 - // (otherwise it runs times it should not)
252 - if ( embedPlayer.userSlide ) {
253 - embedPlayer.userSlide = false;
254 - embedPlayer.seeking = true;
255 - // Stop the monitor timer (if we can)
256 - embedPlayer.stopMonitor();
257 -
258 - var perc = ui.value / 1000;
259 - // set seek time (in case we have to do a url seek)
260 - embedPlayer.seek_time_sec = mw.npt2seconds( embedPlayer.jump_time, true );
261 - mw.log( 'do jump to: ' + embedPlayer.jump_time + ' perc:' + perc + ' sts:' + embedPlayer.seek_time_sec );
262 - embedPlayer.setStatus( gM( 'mwe-seeking' ) );
263 - embedPlayer.doSeek( perc );
264 - }
265 - }
266 - } );
267 -
268 - // Up the z-index of the default status indicator:
269 - $target.find( '.play_head .ui-slider-handle' ).css( 'z-index', 4 );
270 - $target.find( '.play_head .ui-slider-range' ).addClass( 'ui-corner-all' ).css( 'z-index', 2 );
271 -
272 - // Extended class list for jQuery ui themeing
273 - //(we can probably refactor this with custom buffering highlighter)
274 - $target.find( '.play_head' ).append( this.getBufferHtml() );
 206+ }
275207
276 - var $opt = $j( '#mv_vid_options_' + embedPlayer.id );
 208+ //var $opt = $j( '#mv_vid_options_' + embedPlayer.id );
277209
278210 // videoOptions ... @@todo should be merged with something more like kskin.js:
279 - $opt.find( '.vo_selection' ).click( function() {
 211+ /*$opt.find( '.vo_selection' ).click( function() {
280212 embedPlayer.displayOverlay();
281213 embedPlayer.showPlayerSelect( embedPlayer.$interface.find( '.videoOptionsComplete' ) );
282214 $opt.hide();
@@ -295,6 +227,7 @@
296228 $opt.hide();
297229 return false;
298230 } );
 231+ */
299232
300233 this.doVolumeBinding();
301234
@@ -303,6 +236,10 @@
304237 this.addSkinControlBindings();
305238 }
306239 },
 240+
 241+ /**
 242+ * Close a menu overlay
 243+ */
307244 closeMenuOverlay: function(){
308245 var _this = this;
309246 var $overlay = $j( '#blackbg_' + this.embedPlayer.id );
@@ -433,7 +370,7 @@
434371 var embedPlayer = this.embedPlayer;
435372 var _this = this;
436373 embedPlayer.$interface.find( '.volume_control' ).unbind().buttonHover().click( function() {
437 - mw.log( 'clicked volume control' );
 374+ mw.log( 'Volume control toggle' );
438375 embedPlayer.toggleMute();
439376 } );
440377
@@ -493,16 +430,354 @@
494431 embedPlayer.$interface.find( '.volume-slider' ).slider( sliderConf );
495432 },
496433
 434+ /**
 435+ * Get the options menu ul with li menu items
 436+ */
 437+ getOptionsMenu: function( ) {
 438+ $optionsMenu = $j( '<ul />' );
 439+ for( var i in this.optionMenuItems ){
 440+
 441+ // Make sure its supported in the current ctrlBuilder config:
 442+ if( ! this.supportedMenuItems[ i ] ) {
 443+ continue;
 444+ }
 445+ $optionsMenu.append(
 446+ this.optionMenuItems[i]( this )
 447+ );
 448+ }
 449+ return $optionsMenu;
 450+ },
 451+
 452+ /**
 453+ * Option menu items
 454+ *
 455+ * @return
 456+ * 'li' a li line item with click action for that menu item
 457+ */
 458+ optionMenuItems: {
 459+ // Player select menu item
 460+ 'playerSelect': function( ctrlObj ){
 461+ return $j.getLineItem(
 462+ gM( 'mwe-chose_player' ),
 463+ 'gear',
 464+ function( ) {
 465+ ctrObj.displayOverlay(
 466+ ctrlObj.getPlayerSelect()
 467+ );
 468+ }
 469+ )
 470+ },
 471+
 472+ // Download the file menu
 473+ 'download': function( ctrlObj ) {
 474+ return $j.getLineItem(
 475+ gM( 'mwe-download' ),
 476+ 'disk',
 477+ function( ) {
 478+ ctrObj.displayOverlay( gM('loading' ) );
 479+ ctrlObj.showDownload( $j( ctrlObj.embedPlayer ).find( '.overlay-content' ) );
 480+ }
 481+ )
 482+ },
 483+
 484+ // Share the video menu
 485+ 'share': function( ctrlObj ) {
 486+ return $j.getLineItem(
 487+ gM( 'mwe-share' ),
 488+ 'mail-closed',
 489+ function( ) {
 490+ ctrlObj.showShare();
 491+ }
 492+ )
 493+ }
 494+ },
 495+
497496 /**
498 - * Get the Buffer Html that overlays the playhead
 497+ * Generic function to display custom HTML overlay
 498+ * on video.
 499+ *
 500+ * @param {String} overlayContent content to be displayed
499501 */
500 - getBufferHtml:function() {
501 - return '<div class="ui-slider-range ui-slider-range-min ui-widget-header ' +
502 - 'ui-state-highlight ui-corner-all ' +
503 - 'mw_buffer" style="width:0px;height:100%;z-index:1;top:0px" />';
 502+ displayOverlay: function( overlayContent ) {
 503+ var _this = this;
 504+ var embedPlayer = this.embedPlayer;
 505+
 506+ if ( !this.supportedComponets[ 'overlays' ] ) {
 507+ embedPlayer.stop();
 508+ }
 509+
 510+ // Fade in if the overlay is not already displayed:
 511+ var fade_in = true;
 512+ if ( $j( '#blackbg_' + this.id ).length != 0 ) {
 513+ fade_in = false;
 514+ $j( '#blackbg_' + this.id ).remove();
 515+ }
 516+
 517+ $closeButton = $j('<span />')
 518+ .text( gM('mwe-close_btn') )
 519+ .css({
 520+ 'float' : 'right',
 521+ 'color' : '#FFF',
 522+ 'cursor' : 'pointer',
 523+ 'background' : '#111',
 524+ 'margin-right': '10px',
 525+ 'text-decoration' : 'underline'
 526+ })
 527+ .click(function() {
 528+ _this.ctrlBuilder.closeMenuOverlay();
 529+ })
 530+
 531+
 532+ $overlayMenu = $j('<div />')
 533+ .attr({
 534+ 'id' : 'blackbg_' + this.id
 535+ })
 536+ .addClass( 'videoComplete' )
 537+ .css({
 538+ 'height' : this.ctrlBuilder.getOverlayHeight(),
 539+ 'width' : this.ctrlBuilder.getOverlayWidth()
 540+ })
 541+ .append(
 542+ $closeButton,
 543+ $j('<div />')
 544+ .addClass( 'overlay-content' )
 545+ .append( $overlayContent )
 546+ )
 547+ this.$interface.prepend( $overlayMenu );
 548+
 549+ if ( fade_in )
 550+ $j( '#blackbg_' + this.id ).fadeIn( "slow" );
 551+ else
 552+ $j( '#blackbg_' + this.id ).show();
 553+ return false; // onclick action return false
 554+ },
 555+ /**
 556+ * Show the "share" msg
 557+ *
 558+ * TODO share should be enabled via <embed> tag usage to be compatible
 559+ * with sites social networking sites that allow <embed> tags but not js
 560+ *
 561+ * @param {Object} $target Target jQuery object to set share html
 562+ */
 563+ showShare:function( $target ) {
 564+ var embedPlayer = this.embedPlayer;
 565+ var embed_code = embedPlayer.getEmbeddingHTML();
 566+ var _this = this;
 567+ $target.empty();
 568+ $shareList = $j( '<ul />' );
 569+
 570+ $shareList
 571+ .append(
 572+ $j('<li />')
 573+ .append(
 574+ $j('<a />')
 575+ .attr('href', '#')
 576+ .addClass( 'active' )
 577+ .text(
 578+ gM( 'mwe-embed_site_or_blog' )
 579+ )
 580+ )
 581+ )
 582+
 583+ $target.append(
 584+ $j( '<h2 />' )
 585+ .text( gM( 'mwe-share_this_video' ) )
 586+ .append(
 587+ $shareList
 588+ )
 589+ );
 590+
 591+ $target.append(
 592+ $j('<div />')
 593+ .addClass( 'source_wrap' )
 594+ .html(
 595+ $j( '<textarea />' )
 596+ .html( embed_code )
 597+ .click( function() {
 598+ $j( this ).select();
 599+ })
 600+ ),
 601+
 602+ $j('<button />')
 603+ .addClass( 'ui-state-default ui-corner-all copycode' )
 604+ .text( gM( 'mwe-copy-code' ) )
 605+ .click(function() {
 606+ $target.find( 'textarea' ).focus().select();
 607+ // Copy the text if supported:
 608+ if ( document.selection ) {
 609+ CopiedTxt = document.selection.createRange();
 610+ CopiedTxt.execCommand( "Copy" );
 611+ }
 612+ } ),
 613+
 614+ $j('<div />')
 615+ .addClass( "ui-state-highlight ui-corner-all" )
 616+ .html(
 617+ gM( 'mwe-read_before_embed' )
 618+ )
 619+ );
504620 },
 621+ /**
 622+ * Shows the Player Select interface
 623+ *
 624+ * @param {Object} $target jQuery target for output
 625+ */
 626+ getPlayerSelect: function( ) {
 627+ mw.log('showPlayerSelect');
 628+
 629+ var embedPlayer = this.embedPlayer;
 630+
 631+ $playerSelect = $j('<div />')
 632+ .append(
 633+ $j( '<h2 />' )
 634+ .text( gM( 'mwe-chose_player' ) )
 635+ );
 636+
 637+ $j.each( embedPlayer.mediaElement.getPlayableSources(), function( source_id, source ) {
 638+ var playable = mw.EmbedTypes.players.defaultPlayer( source.getMIMEType() );
 639+
 640+ var is_selected = ( source == embedPlayer.mediaElement.selected_source );
 641+
 642+ $playerSelect.append(
 643+ $j( '<h2 />' )
 644+ .text( source.getTitle() )
 645+ );
 646+
 647+ if ( playable ) {
 648+ $playerList = $j('<ul />');
 649+ // output the player select code:
 650+ var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
 651+
 652+ for ( var i = 0; i < supporting_players.length ; i++ ) {
 653+ var $playerLink = $j( '<a />')
 654+ .attr({
 655+ 'href' : '#',
 656+ 'rel' : 'sel_source',
 657+ 'id' : 'sc_' + source_id + '_' + supporting_players[i].id
 658+ })
 659+ .text( supporting_players[i].getName() )
 660+ .click( function() {
 661+ var iparts = $j( this ).attr( 'id' ).replace(/sc_/ , '' ).split( '_' );
 662+ var source_id = iparts[0];
 663+ var default_player_id = iparts[1];
 664+ mw.log( 'source id: ' + source_id + ' player id: ' + default_player_id );
 665+
 666+ embedPlayer.ctrlBuilder.closeMenuOverlay();
 667+ embedPlayer.mediaElement.selectSource( source_id );
 668+
 669+ mw.EmbedTypes.players.setPlayerPreference( default_player_id,
 670+ _this.mediaElement.sources[ source_id ].getMIMEType() );
 671+
 672+ // Issue a stop
 673+ embedPlayer.stop();
 674+
 675+ // Don't follow the # link:
 676+ return false;
 677+ } );
 678+
 679+ if ( embedPlayer.selected_player.id == supporting_players[i].id && is_selected ) {
 680+ $playerLink
 681+ .addClass('active' );
 682+ }
 683+ $playerList.append(
 684+ $j( '<li />' ).append(
 685+ $playerLink
 686+ )
 687+ );
 688+ }
 689+
 690+ // Append the player list:
 691+ $playerSelect.append( $playerList );
 692+
 693+ } else {
 694+ // No player available:
 695+ $playerSelect.append( gM( 'mwe-no-player', source.getTitle() ) )
 696+ }
 697+ } );
 698+
 699+ // Return the player select elements
 700+ return $playerSelect;
 701+ },
505702
506703 /**
 704+ * Loads sources and calls showDownloadWithSources
 705+ * @param {Object} $target jQuery target to output to
 706+ */
 707+ showDownload: function( $target ) {
 708+ var _this = this;
 709+ var embedPlayer = this.embedPlayer;
 710+ // Load the roe if available (to populate out download options:
 711+ // mw.log('f:showDownload '+ this.roe + ' ' + this.mediaElement.addedROEData);
 712+ if ( embedPlayer.roe && embedPlayer.mediaElement.addedROEData == false ) {
 713+ $target.html( gM( 'loading_txt' ) );
 714+ embedPlayer.getMvJsonUrl( this.roe, function( data ) {
 715+ embedPlayer.mediaElement.addROE( data );
 716+ _this.showDownloadWithSources( $target );
 717+ } );
 718+ } else {
 719+ _this.showDownloadWithSources( $target );
 720+ }
 721+ },
 722+
 723+ /**
 724+ * Shows the download interface with sources loaded
 725+ * @param {Object} $target jQuery target to output to
 726+ */
 727+ showDownloadWithSources : function( $target ) {
 728+ var _this = this;
 729+ var embedPlayer = this.embedPlayer;
 730+ $target.empty().append(
 731+ $j('<div />')
 732+ .css({
 733+ "color":"white"
 734+ })
 735+ );
 736+ var $mediaList = $j( '<ul />' );
 737+ var $textList = $j( '<ul />' );
 738+ $j.each( embedPlayer.mediaElement.getSources(), function( index, source ) {
 739+ if( source.getSrc() ) {
 740+ var $dl_line = $j( '<li />').append(
 741+ $j('<a />').
 742+ css({
 743+ "color" : "white"
 744+ })
 745+ .attr( 'href', source.getSrc())
 746+ .text( source.getTitle() )
 747+ );
 748+ // Add link to correct "bucket"
 749+
 750+ //Add link to time segment:
 751+ if ( source.getSrc().indexOf( '?t=' ) !== -1 ) {
 752+ $target.append( $dl_line );
 753+ } else if ( this.getMIMEType() == "text/cmml" || this.getMIMEType() == "text/x-srt" ) {
 754+ // Add link to text list
 755+ $textList.append( $dl_line );
 756+ } else {
 757+ // Add link to media list
 758+ $mediaList.append( $dl_line );
 759+ }
 760+
 761+ }
 762+ } );
 763+ if( $mediaList.find('li').length != 0 ) {
 764+ $target.append(
 765+ $j('<h2 />')
 766+ .text( gM( 'mwe-download_full' ) ),
 767+ $mediaList
 768+ )
 769+ }
 770+
 771+ if( $textList.find('li').length != 0 ) {
 772+ $target.append(
 773+ $j('<h2 />')
 774+ .text( gM( 'mwe-download_text' ) ),
 775+ $textList
 776+ )
 777+ }
 778+ },
 779+
 780+
 781+ /**
507782 * Get component
508783 *
509784 * @param {String} component Component key to grab html output
@@ -558,7 +833,7 @@
559834 'optionsMenu': {
560835 'w' : 0,
561836 'o' : function( ctrlObj ) {
562 - var o = '<div id="mv_vid_options_' + ctrlObj.embedPlayer.id + '" class="videoOptions">' +
 837+ /*var o = '<div id="mv_vid_options_' + ctrlObj.embedPlayer.id + '" class="videoOptions">' +
563838 '<div class="videoOptionsTop"></div>' +
564839 '<div class="videoOptionsBox">' +
565840 '<div class="block">' +
@@ -578,6 +853,7 @@
579854 '<div class="videoOptionsBot"></div>' +
580855 '</div><!--videoOptions-->';
581856 return o;
 857+ */
582858 }
583859 },
584860
@@ -614,7 +890,11 @@
615891 .append(
616892 $j('<span />')
617893 .addClass( 'ui-icon ui-icon-wrench' )
618 - )
 894+ )
 895+ // Options binding:
 896+ .menu( {
 897+ 'content' : ctrlObj.getOptionsMenu(),
 898+ } );
619899 }
620900 },
621901
@@ -631,6 +911,10 @@
632912 $j( '<span />' )
633913 .addClass( "ui-icon ui-icon-arrow-4-diag" )
634914 )
 915+ // Fullscreen binding:
 916+ .buttonHover().click( function() {
 917+ ctrlObj.embedPlayer.fullscreen();
 918+ } );
635919 }
636920 },
637921
@@ -654,7 +938,7 @@
655939 /**
656940 * The closed captions button
657941 */
658 - 'timed_text': {
 942+ 'timedText': {
659943 'w': 28,
660944 'o': function( ctrlObj ) {
661945 return $j( '<div />' )
@@ -664,6 +948,10 @@
665949 $j( '<span />' )
666950 .addClass( "ui-icon ui-icon-comment" )
667951 )
 952+ // Captions binding:
 953+ .buttonHover().click( function() {
 954+ ctrlObj.embedPlayer.showTextInterface();
 955+ } );
668956 }
669957 },
670958
@@ -725,15 +1013,76 @@
7261014
7271015 }
7281016 },
729 - /*
 1017+
 1018+ /**
7301019 * The playhead component
7311020 */
7321021 'playHead': {
7331022 'w':0, // special case (takes up remaining space)
7341023 'o':function( ctrlObj ) {
735 - return $j( '<div />' )
736 - .addClass ( "play_head" )
737 - .css( "width", parseInt( ctrlObj.available_width - 20 ) + 'px' )
 1024+ var embedPlayer = ctrlObj.embedPlayer;
 1025+ var $playHead = $j( '<div />' )
 1026+ .addClass ( "play_head" )
 1027+ .css( "width", parseInt( ctrlObj.available_width - 20 ) + 'px' )
 1028+ // Playhead binding
 1029+ .slider( {
 1030+ range: "min",
 1031+ value: 0,
 1032+ min: 0,
 1033+ max: 1000,
 1034+ start: function( event, ui ) {
 1035+ var id = ( embedPlayer.pc != null ) ? embedPlayer.pc.pp.id:embedPlayer.id;
 1036+ embedPlayer.userSlide = true;
 1037+ $j( id + ' .play-btn-large' ).fadeOut( 'fast' );
 1038+ // If playlist always start at 0
 1039+ embedPlayer.start_time_sec = ( embedPlayer.instanceOf == 'mvPlayList' ) ? 0:
 1040+ mw.npt2seconds( embedPlayer.getTimeRange().split( '/' )[0] );
 1041+ },
 1042+ slide: function( event, ui ) {
 1043+ var perc = ui.value / 1000;
 1044+ embedPlayer.jump_time = mw.seconds2npt( parseFloat( parseFloat( embedPlayer.getDuration() ) * perc ) + embedPlayer.start_time_sec );
 1045+ // mw.log('perc:' + perc + ' * ' + embedPlayer.getDuration() + ' jt:'+ this.jump_time);
 1046+ if ( _this.longTimeDisp ) {
 1047+ embedPlayer.setStatus( gM( 'mwe-seek_to', embedPlayer.jump_time ) );
 1048+ } else {
 1049+ embedPlayer.setStatus( embedPlayer.jump_time );
 1050+ }
 1051+ // Update the thumbnail / frame
 1052+ if ( embedPlayer.isPlaying == false ) {
 1053+ embedPlayer.updateThumbPerc( perc );
 1054+ }
 1055+ },
 1056+ change:function( event, ui ) {
 1057+ // Only run the onChange event if done by a user slide
 1058+ // (otherwise it runs times it should not)
 1059+ if ( embedPlayer.userSlide ) {
 1060+ embedPlayer.userSlide = false;
 1061+ embedPlayer.seeking = true;
 1062+ // Stop the monitor timer (if we can)
 1063+ embedPlayer.stopMonitor();
 1064+
 1065+ var perc = ui.value / 1000;
 1066+ // set seek time (in case we have to do a url seek)
 1067+ embedPlayer.seek_time_sec = mw.npt2seconds( embedPlayer.jump_time, true );
 1068+ mw.log( 'do jump to: ' + embedPlayer.jump_time + ' perc:' + perc + ' sts:' + embedPlayer.seek_time_sec );
 1069+ embedPlayer.setStatus( gM( 'mwe-seeking' ) );
 1070+ embedPlayer.doSeek( perc );
 1071+ }
 1072+ }
 1073+ } );
 1074+
 1075+ // Up the z-index of the default status indicator:
 1076+ $playHead.find( 'ui-slider-handle' ).css( 'z-index', 4 );
 1077+ $playHead.find( '.ui-slider-range' ).addClass( 'ui-corner-all' ).css( 'z-index', 2 );
 1078+
 1079+ // Add buffer html:
 1080+ $playHead.append(
 1081+ $j('<div />')
 1082+ .addClass( "ui-slider-range ui-slider-range-min ui-widget-header")
 1083+ .addClass( "ui-state-highlight ui-corner-all mw_buffer")
 1084+ );
 1085+
 1086+ return $playHead;
7381087 }
7391088 }
7401089 }
Index: branches/js2-work/phase3/js/mwEmbed/skins/common/common.css
@@ -477,4 +477,10 @@
478478 width: 12px;
479479 margin-top: -6px !important;
480480 margin-left: 3px !important;
 481+}
 482+mw-buffer{
 483+ width:0px;
 484+ height:100%;
 485+ z-index:1;
 486+ top:0px;
481487 }
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js
@@ -11,7 +11,7 @@
1212 playerClass: 'k-player',
1313
1414 // Display time string length
15 - long_time_disp: false,
 15+ longTimeDisp: false,
1616
1717 // Options are handled internally
1818 external_options: false,
@@ -19,13 +19,11 @@
2020 // Volume control layout is horizontal
2121 volume_layout: 'horizontal',
2222
23 - // Menu items for the kskin:
24 - menu_items:[
25 - 'playerSelect',
26 - 'download',
27 - 'share',
28 - 'credits'
29 - ],
 23+ // Skin "kskin" is specific for wikimedia we have an
 24+ // api Title key so the "credits" menu item can be showed.
 25+ supportedMenuItems: {
 26+ 'credits': true
 27+ },
3028
3129 // Extends base components with kskin specific options:
3230 components: {
@@ -89,17 +87,17 @@
9088 .addClass( 'k-menu-bar' );
9189
9290 // Output menu item containers:
93 - for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
94 - var mk = ctrlObj.menu_items[i];
 91+ for ( i = 0; i < ctrlObj.optionMenuItems.length; i++ ) {
 92+ var menuItem = ctrlObj.optionMenuItems[ i ];
9593 $menuBar.append(
9694 $j( '<li />')
9795 // Add the menu item class:
98 - .addClass( 'k-' + mk + '-btn' )
99 - .attr( 'rel', mk )
 96+ .addClass( 'k-' + menuItem + '-btn' )
 97+ .attr( 'rel', menuItem )
10098 .append(
10199 $j( '<a />' )
102100 .attr( {
103 - 'title' : gM( 'mwe-' + mk ),
 101+ 'title' : gM( 'mwe-' + menuItem ),
104102 'href' : '#'
105103 })
106104 )
@@ -115,10 +113,10 @@
116114 'width' : ( ctrlObj.getOverlayWidth() - 75 ),
117115 'height' : ( ctrlObj.getOverlayHeight() - ctrlObj.getControlBarHeight() )
118116 })
119 - for ( i = 0; i < ctrlObj.menu_items.length; i++ ) {
 117+ for ( i = 0; i < ctrlObj.optionMenuItems.length; i++ ) {
120118 $menuScreens.append(
121119 $j( '<div />' )
122 - .addClass( 'menu-screen menu-' + ctrlObj.menu_items[i] )
 120+ .addClass( 'menu-screen menu-' + ctrlObj.optionMenuItems[i] )
123121 );
124122 }
125123
@@ -229,8 +227,8 @@
230228 $playerTarget.find( '.k-menu' ).hide();
231229
232230 // Add menu-items bindings:
233 - for ( i = 0; i < _this.menu_items.length ; i++ ) {
234 - $playerTarget.find( '.k-' + _this.menu_items[i] + '-btn' ).click( function() {
 231+ for ( i = 0; i < _this.optionMenuItems.length ; i++ ) {
 232+ $playerTarget.find( '.k-' + _this.optionMenuItems[ i ] + '-btn' ).click( function( ) {
235233 var mk = $j( this ).attr( 'rel' );
236234 // hide menu items
237235 $targetItem = $playerTarget.find( '.menu-' + mk );
@@ -246,27 +244,9 @@
247245 return false;
248246 } );
249247 }
250 - },
 248+ },
251249
252250 /**
253 - * Shows a selected menu_item
254 - *
255 - * @param {String} menu_itme Menu item key to display
256 - */
257 - showMenuItem:function( menu_item ) {
258 - var embedPlayer = this.embedPlayer;
259 - //handle special k-skin specific display;
260 - if( menu_item == 'credits'){
261 - this.showCredits();
262 - }else{
263 - // Call the base embedPlayer "show{Item}"
264 - this.embedPlayer['show' + menu_item.charAt( 0 ).toUpperCase() + menu_item.substring( 1 )](
265 - embedPlayer.$interface.find( '.menu-' + menu_item )
266 - );
267 - }
268 - },
269 -
270 - /**
271251 * Show the credit screen (presently specific to kaltura skin )
272252 */
273253 showCredits: function() {
@@ -290,7 +270,7 @@
291271 .attr({
292272 'title': gM('mwe-kaltura-platform-title')
293273 })
294 - .click( function(){
 274+ .click( function( ) {
295275 window.location = 'http://kaltura.com';
296276 })
297277 );
@@ -321,7 +301,7 @@
322302 // Get the image info
323303 var request = {
324304 'prop' : 'imageinfo',
325 - 'titles': fileTitle,
 305+ 'titles' : fileTitle,
326306 'iiprop' : 'url'
327307 };
328308 var articleUrl = '';
@@ -332,12 +312,12 @@
333313 // Check properites for "missing"
334314 if( imageProps.imageinfo && imageProps.imageinfo[0] && imageProps.imageinfo[0].descriptionurl ){
335315 // Found page
336 - $target.find('.credits_box').html(
 316+ $target.find( '.credits_box' ).html(
337317 _this.doCreditLine( imageProps.imageinfo[0].descriptionurl )
338318 );
339319 }else{
340320 // missing page descriptionurl
341 - $target.find('.credits_box').text(
 321+ $target.find( '.credits_box' ).text(
342322 'Error: title key: ' + embedPlayer.apiTitleKey + ' not found'
343323 );
344324 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/loader.js
@@ -16,14 +16,14 @@
1717 });
1818
1919 // TimedText module
20 -mw.addModuleLoader( 'TimedText', function( callback ){
21 - mw.load( [ '$j.fn.menu', 'mw.TimedText' ], function(){
 20+mw.addModuleLoader( 'TimedText', function( callback ) {
 21+ mw.load( [ '$j.fn.menu', 'mw.TimedText' ], function() {
2222 callback( 'TimedText' );
2323 } );
2424 });
2525
2626 // TimedText editor:
27 -mw.addModuleLoader( 'TimedText.Edit', function( callback ){
 27+mw.addModuleLoader( 'TimedText.Edit', function( callback ) {
2828 mw.load([
2929 [
3030 '$j.ui',
@@ -35,7 +35,7 @@
3636 '$j.ui.dialog',
3737 '$j.ui.tabs'
3838 ]
39 - ], function( ){
 39+ ], function( ) {
4040 callback( 'TimedText.Edit' );
4141 });
4242 });
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/jquery.menu/jquery.menu.js
@@ -18,20 +18,44 @@
1919 (function($) {
2020
2121
22 -$.fn.menu = function( options ){
 22+/**
 23+* Utility line item ( li ) from text string function
 24+*
 25+* @param {String} string Text to display for the menu item
 26+* @param {String} icon jQuery UI icon key displayed to the left of the menu item
 27+* @param {Function} callback Function called once the line item is selected
 28+*/
 29+$.getLineItem = function( string, icon , callback) {
 30+ var $li = $j( '<li>' ).append(
 31+ $j('<a>')
 32+ .attr('href', '#')
 33+ .click( callback )
 34+ )
 35+ if( icon ) {
 36+ $li.find( 'a' ).append(
 37+ $j('<span style="float:left;"></span>')
 38+ .addClass( 'ui-icon ui-icon-' + icon )
 39+ )
 40+ }
 41+ $li.find( 'a' ).append( $j('<span>').text( string ) );
 42+ //mw.log(' li html: ' + $j('<div>').append( $li ).html() );
 43+ return $li;
 44+};
 45+
 46+$.fn.menu = function( options ) {
2347 var caller = this;
2448 var options = options;
25 - if( ! caller.m ){
 49+ if( ! caller.m ) {
2650 caller.m = new Menu(caller, options);
2751 allUIMenus.push( caller.m );
2852
2953
3054 //Set up bindings:
3155 $(this)
32 - .mousedown(function(){
 56+ .mousedown(function() {
3357 if (!caller.m.menuOpen) { caller.m.showLoading(); };
3458 })
35 - .click(function(){
 59+ .click(function() {
3660 if (caller.m.menuOpen == false) {
3761 caller.m.showMenu();
3862 }else {
@@ -42,15 +66,14 @@
4367 }
4468
4569 //Check for autoShow menu option
46 - if( options.autoShow ){
 70+ if( options.autoShow ) {
4771 // ( handle async build out)
48 - setTimeout(function(){
 72+ setTimeout(function() {
4973 caller.m.showLoading();
5074 caller.m.showMenu();
5175 }, 0 );
52 - }
 76+ }
5377
54 -
5578 //Else process the request:
5679 if( options == 'show' )
5780 caller.m.showMenu();
@@ -58,14 +81,14 @@
5982 return this;
6083 };
6184
62 -function Menu(caller, options){
 85+function Menu(caller, options) {
6386 var menu = this;
6487 var caller = $(caller);
6588
6689 mw.log( 'target container: ' + options.targetMenuContainer );
6790
6891 var callerClassList = 'fg-menu-container ui-widget ui-widget-content ui-corner-all';
69 - if( options.targetMenuContainer ){
 92+ if( options.targetMenuContainer ) {
7093 var container = $( options.targetMenuContainer ).addClass( callerClassList ).html( options.content );
7194 }else{
7295 var container = $('<div>').addClass( callerClassList ).html( options.content );
@@ -109,13 +132,13 @@
110133 nextCrumbLink: 'ui-icon-carat-1-e'
111134 }, options);
112135
113 - var killAllMenus = function(){
114 - $.each(allUIMenus, function(i){
 136+ var killAllMenus = function() {
 137+ $.each(allUIMenus, function(i) {
115138 if (allUIMenus[i].menuOpen) { allUIMenus[i].kill(); };
116139 });
117140 };
118141
119 - this.kill = function(){
 142+ this.kill = function() {
120143 caller
121144 .removeClass(options.loadingState)
122145 .removeClass('fg-menu-open')
@@ -131,18 +154,18 @@
132155 $(document).unbind('keydown');
133156 };
134157
135 - this.showLoading = function(){
 158+ this.showLoading = function() {
136159 caller.addClass(options.loadingState);
137160 };
138161
139 - this.showMenu = function(){
 162+ this.showMenu = function() {
140163 mw.log('$j.menu:: show menu' );
141164 killAllMenus();
142165 if (!menu.menuExists) { menu.create() };
143166 caller
144167 .addClass('fg-menu-open')
145168 .addClass(options.callerOnState);
146 - container.parent().show().click(function(){
 169+ container.parent().show().click(function() {
147170 menu.kill();
148171 return false;
149172 });
@@ -152,7 +175,7 @@
153176 $(document).click(killAllMenus);
154177
155178 // assign key events
156 - $(document).keydown(function(event){
 179+ $(document).keydown(function(event) {
157180 var e;
158181 if (event.which !="") { e = event.which; }
159182 else if (event.charCode != "") { e = event.charCode; }
@@ -197,7 +220,7 @@
198221 }
199222 else if (menuType == 'ipod') {
200223 $(event.target).trigger('click');
201 - setTimeout(function(){
 224+ setTimeout(function() {
202225 $(event.target).next().find('a:eq(0)').trigger('mouseover');
203226 }, options.crossSpeed);
204227 };
@@ -224,7 +247,7 @@
225248 case 13: // enter
226249 if ($(event.target).is('.fg-menu-indicator') && menuType == 'ipod') {
227250 $(event.target).trigger('click');
228 - setTimeout(function(){
 251+ setTimeout(function() {
229252 $(event.target).next().find('a:eq(0)').trigger('mouseover');
230253 }, options.crossSpeed);
231254 };
@@ -233,7 +256,7 @@
234257 });
235258 };
236259
237 - this.create = function(){
 260+ this.create = function() {
238261 container.css({ width: options.width }).appendTo('body').find('ul:first').not('.fg-menu-breadcrumb').addClass('fg-menu');
239262 container.find('ul, li a').addClass('ui-corner-all');
240263
@@ -249,7 +272,7 @@
250273 else { menu.drilldown(container, options); }
251274 }
252275 else {
253 - container.find('a').click(function(){
 276+ container.find('a').click(function() {
254277 menu.chooseItem(this);
255278 return false;
256279 });
@@ -258,12 +281,12 @@
259282 if (options.linkHover) {
260283 var allLinks = container.find('.fg-menu li a');
261284 allLinks.hover(
262 - function(){
 285+ function() {
263286 var menuitem = $(this);
264287 $('.'+options.linkHover).removeClass(options.linkHover).blur().parent().removeAttr('id');
265288 $(this).addClass(options.linkHover).focus().parent().attr('id','active-menuitem');
266289 },
267 - function(){
 290+ function() {
268291 $(this).removeClass(options.linkHover).blur().parent().removeAttr('id');
269292 }
270293 );
@@ -271,12 +294,12 @@
272295
273296 if (options.linkHoverSecondary) {
274297 container.find('.fg-menu li').hover(
275 - function(){
 298+ function() {
276299 $(this).siblings('li').removeClass(options.linkHoverSecondary);
277300 if (options.flyOutOnState) { $(this).siblings('li').find('a').removeClass(options.flyOutOnState); }
278301 $(this).addClass(options.linkHoverSecondary);
279302 },
280 - function(){ $(this).removeClass(options.linkHoverSecondary); }
 303+ function() { $(this).removeClass(options.linkHoverSecondary); }
281304 );
282305 };
283306
@@ -284,7 +307,7 @@
285308 menu.menuExists = true;
286309 };
287310
288 - this.chooseItem = function(item){
 311+ this.chooseItem = function(item) {
289312 menu.kill();
290313 if( options.selectItemCallback )
291314 options.selectItemCallback( item );
@@ -294,12 +317,12 @@
295318 Menu.prototype.flyout = function(container, options) {
296319 var menu = this;
297320
298 - this.resetFlyoutMenu = function(){
 321+ this.resetFlyoutMenu = function() {
299322 var allLists = container.find('ul ul');
300323 allLists.removeClass('ui-widget-content').hide();
301324 };
302325
303 - container.addClass('fg-menu-flyout').find('li:has(ul)').each(function(){
 326+ container.addClass('fg-menu-flyout').find('li:has(ul)').each(function() {
304327 var linkWidth = container.width();
305328 var showTimer, hideTimer;
306329 var allSubLists = $(this).find('ul');
@@ -310,33 +333,33 @@
311334 '<span>' + $(this).find('a:eq(0)').html() +
312335 '</span><span class="ui-icon '+options.nextMenuLink+'"></span>')
313336 .hover(
314 - function(){
 337+ function() {
315338 clearTimeout(hideTimer);
316339 var subList = $(this).next();
317340 if (!fitVertical(subList, $(this).offset().top)) { subList.css({ top: 'auto', bottom: 0 }); };
318341 if (!fitHorizontal(subList, $(this).offset().left + 100)) { subList.css({ left: 'auto', right: linkWidth, 'z-index': 1005 }); };
319 - showTimer = setTimeout(function(){
 342+ showTimer = setTimeout(function() {
320343 subList.addClass('ui-widget-content').show(options.showSpeed).attr('aria-expanded', 'true');
321344 }, 300);
322345 },
323 - function(){
 346+ function() {
324347 clearTimeout(showTimer);
325348 var subList = $(this).next();
326 - hideTimer = setTimeout(function(){
 349+ hideTimer = setTimeout(function() {
327350 subList.removeClass('ui-widget-content').hide(options.showSpeed).attr('aria-expanded', 'false');
328351 }, 400);
329352 }
330353 );
331354
332355 $(this).find('ul a').hover(
333 - function(){
 356+ function() {
334357 clearTimeout(hideTimer);
335358 if ($(this).parents('ul').prev().is('a.fg-menu-indicator')) {
336359 $(this).parents('ul').prev().addClass(options.flyOutOnState);
337360 }
338361 },
339 - function(){
340 - hideTimer = setTimeout(function(){
 362+ function() {
 363+ hideTimer = setTimeout(function() {
341364 allSubLists.hide(options.showSpeed);
342365 container.find(options.flyOutOnState).removeClass(options.flyOutOnState);
343366 }, 500);
@@ -344,7 +367,7 @@
345368 );
346369 });
347370
348 - container.find('a').click(function(){
 371+ container.find('a').click(function() {
349372 menu.chooseItem(this);
350373 return false;
351374 });
@@ -368,19 +391,19 @@
369392 else { breadcrumb.addClass('fg-menu-header').prependTo(container); };
370393 breadcrumb.append(crumbDefaultHeader);
371394
372 - var checkMenuHeight = function(el){
 395+ var checkMenuHeight = function(el) {
373396 if (el.height() > options.maxHeight) { el.addClass('fg-menu-scroll') };
374397 el.css({
375398 height: options.maxHeight-30
376399 });
377400 };
378401
379 - var resetChildMenu = function(el){ el.removeClass('fg-menu-scroll').removeClass('fg-menu-current').height('auto'); };
 402+ var resetChildMenu = function(el) { el.removeClass('fg-menu-scroll').removeClass('fg-menu-current').height('auto'); };
380403
381 - this.resetDrilldownMenu = function(){
 404+ this.resetDrilldownMenu = function() {
382405 $('.fg-menu-current').removeClass('fg-menu-current');
383 - topList.animate({ left: 0 }, options.crossSpeed, function(){
384 - $(this).find('ul').each(function(){
 406+ topList.animate({ left: 0 }, options.crossSpeed, function() {
 407+ $(this).find('ul').each(function() {
385408 $(this).hide();
386409 resetChildMenu($(this));
387410 });
@@ -401,13 +424,13 @@
402425 .hide();
403426 checkMenuHeight(topList);
404427
405 - topList.find('a').each(function(){
 428+ topList.find('a').each(function() {
406429 // if the link opens a child menu:
407430 if ($(this).next().is('ul')) {
408431 $(this)
409432 .addClass('fg-menu-indicator')
410 - .each(function(){ $(this).html('<span>' + $(this).html() + '</span><span class="ui-icon '+options.nextMenuLink+'"></span>'); })
411 - .click(function(){ // ----- show the next menu
 433+ .each(function() { $(this).html('<span>' + $(this).html() + '</span><span class="ui-icon '+options.nextMenuLink+'"></span>'); })
 434+ .click(function() { // ----- show the next menu
412435 var nextList = $(this).next();
413436 var parentUl = $(this).parents('ul:eq(0)');
414437 var parentLeft = (parentUl.is('.fg-menu-content')) ? 0 : parseFloat(topList.css('left'));
@@ -420,7 +443,7 @@
421444 topList.animate({ left: nextLeftVal }, options.crossSpeed);
422445 nextList.show().addClass('fg-menu-current').attr('aria-expanded', 'true');
423446
424 - var setPrevMenu = function(backlink){
 447+ var setPrevMenu = function(backlink) {
425448 var b = backlink;
426449 var c = $('.fg-menu-current');
427450 var prevList = c.parents('ul:eq(0)');
@@ -437,10 +460,10 @@
438461 footer.show();
439462 $('<a href="#"><span class="ui-icon ui-icon-triangle-1-w"></span> <span>Back</span></a>')
440463 .appendTo(footer)
441 - .click(function(){ // ----- show the previous menu
 464+ .click(function() { // ----- show the previous menu
442465 var b = $(this);
443466 var prevLeftVal = parseFloat(topList.css('left')) + container.width();
444 - topList.animate({ left: prevLeftVal }, options.crossSpeed, function(){
 467+ topList.animate({ left: prevLeftVal }, options.crossSpeed, function() {
445468 setPrevMenu(b);
446469 });
447470 return false;
@@ -449,9 +472,9 @@
450473 }
451474 // or initialize top breadcrumb
452475 else {
453 - if (breadcrumb.find('li').size() == 1){
 476+ if (breadcrumb.find('li').size() == 1) {
454477 breadcrumb.empty().append(firstCrumb);
455 - firstCrumb.find('a').click(function(){
 478+ firstCrumb.find('a').click(function() {
456479 menu.resetDrilldownMenu();
457480 return false;
458481 });
@@ -461,13 +484,13 @@
462485 var newCrumb = $('<li class="fg-menu-current-crumb"><a href="javascript://" class="fg-menu-crumb">'+crumbText+'</a></li>');
463486 newCrumb
464487 .appendTo(breadcrumb)
465 - .find('a').click(function(){
466 - if ($(this).parent().is('.fg-menu-current-crumb')){
 488+ .find('a').click(function() {
 489+ if ($(this).parent().is('.fg-menu-current-crumb')) {
467490 menu.chooseItem(this);
468491 }
469492 else {
470493 var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * 180;
471 - topList.animate({ left: newLeftVal }, options.crossSpeed, function(){
 494+ topList.animate({ left: newLeftVal }, options.crossSpeed, function() {
472495 setPrevMenu();
473496 });
474497
@@ -484,7 +507,7 @@
485508 }
486509 // if the link is a leaf node (doesn't open a child menu)
487510 else {
488 - $(this).click(function(){
 511+ $(this).click(function() {
489512 menu.chooseItem(this);
490513 return false;
491514 });
@@ -520,7 +543,7 @@
521544
522545 var helper = $( '<div class="positionHelper">' );
523546 // Hard code width heigh of button if unset ( crazy IE )
524 - if( isNaN( dims.refW ) || isNaN( dims.refH ) ){
 547+ if( isNaN( dims.refW ) || isNaN( dims.refH ) ) {
525548 dims.refH = 16;
526549 dims.refW = 23;
527550 }
@@ -604,28 +627,28 @@
605628
606629 function sortBigToSmall(a, b) { return b - a; };
607630
608 -jQuery.fn.getTotalWidth = function(){
 631+jQuery.fn.getTotalWidth = function() {
609632 return $(this).width() + parseInt($(this).css('paddingRight')) + parseInt($(this).css('paddingLeft')) + parseInt($(this).css('borderRightWidth')) + parseInt($(this).css('borderLeftWidth'));
610633 };
611634
612 -jQuery.fn.getTotalHeight = function(){
 635+jQuery.fn.getTotalHeight = function() {
613636 return $(this).height() + parseInt($(this).css('paddingTop')) + parseInt($(this).css('paddingBottom')) + parseInt($(this).css('borderTopWidth')) + parseInt($(this).css('borderBottomWidth'));
614637 };
615638
616 -function getScrollTop(){
 639+function getScrollTop() {
617640 return self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
618641 };
619642
620 -function getScrollLeft(){
 643+function getScrollLeft() {
621644 return self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
622645 };
623646
624 -function getWindowHeight(){
 647+function getWindowHeight() {
625648 var de = document.documentElement;
626649 return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
627650 };
628651
629 -function getWindowWidth(){
 652+function getWindowWidth() {
630653 var de = document.documentElement;
631654 return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
632655 };
@@ -635,12 +658,12 @@
636659 el = element to position, required
637660 leftOffset / topOffset = optional parameter if the offset cannot be calculated (i.e., if the object is in the DOM but is set to display: 'none') */
638661
639 -function fitHorizontal(el, leftOffset){
 662+function fitHorizontal(el, leftOffset) {
640663 var leftVal = parseInt(leftOffset) || $(el).offset().left;
641664 return (leftVal + $(el).width() <= getWindowWidth() + getScrollLeft() && leftVal - getScrollLeft() >= 0);
642665 };
643666
644 -function fitVertical(el, topOffset){
 667+function fitVertical(el, topOffset) {
645668 var topVal = parseInt(topOffset) || $(el).offset().top;
646669 return (topVal + $(el).height() <= getWindowHeight() + getScrollTop() && topVal - getScrollTop() >= 0);
647670 };
@@ -671,7 +694,7 @@
672695 * 08.01.2008 - fixed font-size calculation for IE
673696 --------------------------------------------------------------------*/
674697
675 -Number.prototype.pxToEm = String.prototype.pxToEm = function(settings){
 698+Number.prototype.pxToEm = String.prototype.pxToEm = function(settings) {
676699 //set defaults
677700 settings = jQuery.extend({
678701 scope: 'body',
@@ -680,7 +703,7 @@
681704
682705 var pxVal = (this == '') ? 0 : parseFloat(this);
683706 var scopeVal;
684 - var getWindowWidth = function(){
 707+ var getWindowWidth = function() {
685708 var de = document.documentElement;
686709 return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
687710 };
@@ -691,7 +714,7 @@
692715 to get an accurate em value. */
693716
694717 if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) {
695 - var calcFontSize = function(){
 718+ var calcFontSize = function() {
696719 return (parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16;
697720 };
698721 scopeVal = calcFontSize();
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -134,7 +134,7 @@
135135 * @constructor
136136 * @param {Object} embedPlayer Host player for timedText interfaces
137137 */
138 - init: function( embedPlayer, options ){
 138+ init: function( embedPlayer, options ) {
139139 var _this = this;
140140 mw.log("TimedText: init() ")
141141 this.embedPlayer = embedPlayer;
@@ -147,7 +147,7 @@
148148 this.textSourceSetupFlag = false;
149149
150150 //Set default langauge via wgUserLanguage if set
151 - if( typeof wgUserLanguage != 'undefined'){
 151+ if( typeof wgUserLanguage != 'undefined') {
152152 this.config.userLanugage = wgUserLanguage;
153153 }
154154
@@ -158,11 +158,11 @@
159159 }
160160
161161 // Set up embedPlayer hooks:
162 - embedPlayer.addHook( 'monitor', function(){
 162+ embedPlayer.addHook( 'monitor', function() {
163163 _this.monitor();
164164 } )
165165
166 - embedPlayer.addHook( 'play', function(){
 166+ embedPlayer.addHook( 'play', function() {
167167 // Will load and setup timedText sources (if not loaded already loaded )
168168 _this.setupTextSources();
169169 } );
@@ -174,16 +174,16 @@
175175 * auto-selects a source based on the user language
176176 * @param {Function} callback Function to be called once text sources are setup.
177177 */
178 - setupTextSources: function( callback ){
 178+ setupTextSources: function( callback ) {
179179 var _this = this;
180 - if( this.textSourceSetupFlag ){
181 - if( callback ){
 180+ if( this.textSourceSetupFlag ) {
 181+ if( callback ) {
182182 callback();
183183 }
184184 return ;
185185 }
186186 // Load textSources
187 - _this.loadTextSources( function(){
 187+ _this.loadTextSources( function() {
188188
189189 // Enable a default source and issue a request to "load it"
190190 _this.autoSelectSource();
@@ -205,7 +205,7 @@
206206 * @param {Object} target to display the menu
207207 * @param {Boolean} autoShow If the menu should be displayed
208208 */
209 - bindMenu: function( target , autoShow){
 209+ bindMenu: function( target , autoShow) {
210210 var _this = this;
211211 mw.log( "TimedText:bindMenu:" + target );
212212 _this.menuTarget = target;
@@ -214,7 +214,7 @@
215215 // Else bind and show the menu
216216 // We already have a loader in embedPlayer so the delay of
217217 // setupTextSources is already taken into account
218 - _this.setupTextSources( function(){
 218+ _this.setupTextSources( function() {
219219 // NOTE: Button target should be an option or config
220220 $menuButton.unbind().menu( {
221221 'content' : _this.getMainMenu(),
@@ -229,7 +229,7 @@
230230 /**
231231 * Monitor video time and update timed text filed[s]
232232 */
233 - monitor: function( ){
 233+ monitor: function( ) {
234234 //mw.log(" timed Text monitor: " + this.enabledSources.length );
235235 embedPlayer = this.embedPlayer;
236236 // Setup local reference to currentTime:
@@ -249,20 +249,20 @@
250250 * or from a timedTextProviders
251251 * @param {Function} callback Function to call once text sources are loaded
252252 */
253 - loadTextSources: function( callback ){
 253+ loadTextSources: function( callback ) {
254254 var _this = this;
255255 this.textSources = [ ];
256256 // Get local reference to all timed text sources: ( text/xml, text/x-srt etc )
257257 var inlineSources = this.embedPlayer.mediaElement.getSources( 'text' );
258258 // Add all the sources to textSources
259 - for( var i = 0 ; i < inlineSources.length ; i++ ){
 259+ for( var i = 0 ; i < inlineSources.length ; i++ ) {
260260 // make a new textSource:
261261 var source = new TextSource( inlineSources[i] );
262262 this.textSources.push( source );
263263 }
264264
265265 //If there are no inline sources check timedTextProviders & apiTitleKey
266 - if( !this.embedPlayer.apiTitleKey ){
 266+ if( !this.embedPlayer.apiTitleKey ) {
267267 //no other sources just issue the callback:
268268 callback();
269269 return ;
@@ -272,7 +272,7 @@
273273 var provider_id = ( this.embedPlayer.apiProvider ) ? this.embedPlayer.apiProvider : 'local';
274274 var api_url = mw.getApiProviderURL( provider_id );
275275 var assetKey = this.embedPlayer.apiTitleKey;
276 - if( !api_url || !assetKey ){
 276+ if( !api_url || !assetKey ) {
277277 mw.log("Error: loading source without apiProvider or apiTitleKey");
278278 return ;
279279 }
@@ -284,8 +284,8 @@
285285 } );
286286
287287 // Load the textProvider sources
288 - this.textProvider.loadSources( assetKey, function( textSources ){
289 - for( var i in textSources ){
 288+ this.textProvider.loadSources( assetKey, function( textSources ) {
 289+ for( var i in textSources ) {
290290 var textSource = textSources[ i ];
291291 // Try to insert the itext source:
292292 var textElm = document.createElement( 'itext' );
@@ -315,9 +315,9 @@
316316 * Playback method overlays support ( have to put subtitles bellow video )
317317 *
318318 */
319 - getLayoutMode: function(){
 319+ getLayoutMode: function() {
320320 // Re-map "ontop" to "below" if player does not support
321 - if( this.config.layout == 'ontop' && !this.embedPlayer.supports['overlays'] ){
 321+ if( this.config.layout == 'ontop' && !this.embedPlayer.supports['overlays'] ) {
322322 this.config.layout = 'below';
323323 }
324324 return this.config.layout;
@@ -329,32 +329,32 @@
330330 * NOTE: presently this selects a "single" source.
331331 * In the future we could support multiple "enabled sources"
332332 */
333 - autoSelectSource: function(){
 333+ autoSelectSource: function() {
334334 this.enabledSources = [];
335335
336336 // Check if any source matches our "local"
337 - for( var i in this.textSources ){
 337+ for( var i in this.textSources ) {
338338 var source = this.textSources[ i ];
339339 if( this.config.userLanugage &&
340 - this.config.userLanugage == source.lang.toLowerCase() ){
 340+ this.config.userLanugage == source.lang.toLowerCase() ) {
341341 // Check for category if available
342342 this.enabledSources.push( source );
343343 return ;
344344 }
345345 }
346346 // If no userLang, source try enabling English:
347 - if( this.enabledSources.length == 0 ){
348 - for( var i in this.textSources ){
 347+ if( this.enabledSources.length == 0 ) {
 348+ for( var i in this.textSources ) {
349349 var source = this.textSources[ i ];
350 - if( source.lang.toLowerCase() == 'en' ){
 350+ if( source.lang.toLowerCase() == 'en' ) {
351351 this.enabledSources.push( source );
352352 return ;
353353 }
354354 }
355355 }
356356 // If still no source try the first source we get;
357 - if( this.enabledSources.length == 0 ){
358 - for( var i in this.textSources ){
 357+ if( this.enabledSources.length == 0 ) {
 358+ for( var i in this.textSources ) {
359359 var source = this.textSources[ i ];
360360 this.enabledSources.push( source );
361361 return ;
@@ -366,8 +366,8 @@
367367 * Issue a request to load all enabled Sources
368368 * Should be called anytime enabled Source list is updatd
369369 */
370 - loadEnabledSources: function(){
371 - for(var i in this.enabledSources ){
 370+ loadEnabledSources: function() {
 371+ for(var i in this.enabledSources ) {
372372 var enabledSource = this.enabledSources[ i ];
373373 if( ! enabledSource.loaded )
374374 enabledSource.load();
@@ -379,7 +379,7 @@
380380 *
381381 * @param {Element} item Item selected
382382 */
383 - selectMenuItem: function( item ){
 383+ selectMenuItem: function( item ) {
384384 mw.log("selectMenuItem: " + $j( item ).find('a').attr('class') );
385385 },
386386
@@ -390,14 +390,14 @@
391391 * false if source is off
392392 * @type {Boolean}
393393 */
394 - isSourceEnabled: function( source ){
395 - for(var i in this.enabledSources ){
 394+ isSourceEnabled: function( source ) {
 395+ for(var i in this.enabledSources ) {
396396 var enabledSource = this.enabledSources[i];
397 - if( source.id ){
 397+ if( source.id ) {
398398 if( source.id == enabledSource.id )
399399 return true;
400400 }
401 - if( source.lang ){
 401+ if( source.lang ) {
402402 if( source.lang == enabledSource.lang )
403403 return true;
404404 }
@@ -407,8 +407,8 @@
408408 /*
409409 * Get a source object by language, returns "false" if not found
410410 */
411 - getSourceByLanguage: function ( langKey ){
412 - for(var i in this.textSources){
 411+ getSourceByLanguage: function ( langKey ) {
 412+ for(var i in this.textSources) {
413413 var source = this.textSources[ i ];
414414 if( source.lang == langKey )
415415 return source;
@@ -434,25 +434,25 @@
435435 * [ All videos ]
436436 * [ Chapters ] seek to chapter
437437 */
438 - getMainMenu: function(){
 438+ getMainMenu: function() {
439439 var _this = this;
440440
441441
442442 // Build the source list menu item:
443443 $menu = $j( '<ul>' );
444444 // Chouse text menu item ( if there are sources)
445 - if( _this.textSources.length != 0 ){
 445+ if( _this.textSources.length != 0 ) {
446446 $menu.append(
447 - _this.getLi( gM( 'mwe-chose-text'), 'comment' ).append(
 447+ $j.getLineItem( gM( 'mwe-chose-text'), 'comment' ).append(
448448 _this.getLanguageMenu()
449449 ),
450450 // Layout Menu option
451 - _this.getLi( gM( 'mwe-layout' ), 'image' ).append(
 451+ $j.getLineItem( gM( 'mwe-layout' ), 'image' ).append(
452452 _this.getLayoutMenu()
453453 )
454454
455455 // Search Menu option
456 - //_this.getLi( gM('mwe-search'), 'search')
 456+ //$j.getLineItem( gM('mwe-search'), 'search')
457457 );
458458 }
459459 // Put in the "Make Transcript" link
@@ -469,13 +469,13 @@
470470 *
471471 * @param {String} mode Mode or page to display ( to differentiate between edit vs new transcript)
472472 */
473 - showTimedTextEditUI: function( mode ){
 473+ showTimedTextEditUI: function( mode ) {
474474 var _this = this;
475475 // Show a loader:
476476 mw.addLoaderDialog( gM( 'mwe-loading-text-edit' ));
477477 // Load the timedText edit interface
478 - mw.load( 'TimedText.Edit', function(){
479 - if( ! _this.editText ){
 478+ mw.load( 'TimedText.Edit', function() {
 479+ if( ! _this.editText ) {
480480 _this.editText = new mw.TimedTextEdit( _this );
481481 }
482482 // Close the loader:
@@ -494,9 +494,9 @@
495495 /**
496496 * Get the add text menu item:
497497 */
498 - getLiAddText: function(){
 498+ getLiAddText: function() {
499499 var _this = this;
500 - return _this.getLi( gM( 'mwe-add-timed-text'), 'script', function(){
 500+ return $j.getLineItem( gM( 'mwe-add-timed-text'), 'script', function() {
501501 _this.showTimedTextEditUI( 'add' );
502502 } )
503503 },
@@ -505,61 +505,38 @@
506506 * Get line item (li) from source object
507507 * @param {Object} source Source to get menu line item from
508508 */
509 - getLiSource: function( source ){
 509+ getLiSource: function( source ) {
510510 var _this = this;
511511 //See if the source is currently "on"
512512 var source_icon = ( this.isSourceEnabled( source ) )? 'bullet' : 'radio-on';
513513
514 - if( source.title ){
515 - return this.getLi( source.title, source_icon, function(){
 514+ if( source.title ) {
 515+ return $j.getLineItem( source.title, source_icon, function() {
516516 mw.log(" call selectTextSource");
517517 _this.selectTextSource( source );
518518 });
519519 }
520520
521 - if( source.lang ){
 521+ if( source.lang ) {
522522 var langKey = source.lang.toLowerCase();
523523 _this.getLanguageName ( langKey );
524 - return this.getLi(
 524+ return $j.getLineItem(
525525 gM('mwe-key-language', [langKey, unescape( mw.languages[ source.lang ] ) ] ),
526526 source_icon,
527 - function(){
 527+ function() {
528528 mw.log(" call selectTextSource");
529529 _this.selectTextSource( source );
530530 }
531531 );
532532 }
533 - },
 533+ },
534534
535535 /**
536 - * Get line item ( li ) from text string
537 - * @param {String} string Text to display for the menu item
538 - * @param {String} icon jQuery UI icon key displayed to the left of the menu item
539 - * @param {Function} callback Function called once the line item is selected
540 - */
541 - getLi: function( string, icon , callback){
542 - var $li = $j( '<li>' ).append(
543 - $j('<a>')
544 - .attr('href', '#')
545 - .click( callback )
546 - )
547 - if( icon ){
548 - $li.find( 'a' ).append(
549 - $j('<span style="float:left;"></span>')
550 - .addClass( 'ui-icon ui-icon-' + icon )
551 - )
552 - }
553 - $li.find( 'a' ).append( $j('<span>').text( string ) );
554 - //mw.log(' li html: ' + $j('<div>').append( $li ).html() );
555 - return $li;
556 - },
557 -
558 - /**
559536 * Get lagnuage name from language key
560537 * @param {String} lang_key Language key
561538 */
562 - getLanguageName: function( lang_key ){
563 - if( mw.languages[ lang_key ]){
 539+ getLanguageName: function( lang_key ) {
 540+ if( mw.languages[ lang_key ]) {
564541 return mw.languages[ lang_key ];
565542 }
566543 return false
@@ -570,7 +547,7 @@
571548 * @return {Object}
572549 * The jquery menu dom object
573550 */
574 - getLayoutMenu: function(){
 551+ getLayoutMenu: function() {
575552 var _this = this;
576553 var layoutOptions = [ ];
577554
@@ -583,13 +560,13 @@
584561 layoutOptions.push( 'off' );
585562
586563 $ul = $j('<ul>');
587 - $j.each( layoutOptions, function( na, layoutMode ){
 564+ $j.each( layoutOptions, function( na, layoutMode ) {
588565 var icon = ( _this.config.layout == layoutMode ) ? 'bullet' : 'radio-on';
589566 $ul.append(
590 - _this.getLi(
 567+ $j.getLineItem(
591568 gM( 'mwe-layout-' + layoutMode),
592569 icon,
593 - function(){
 570+ function() {
594571 _this.selectLayout( layoutMode );
595572 } )
596573 )
@@ -601,9 +578,9 @@
602579 * Select a new layout
603580 * @param {Object} layoutMode The selected layout mode
604581 */
605 - selectLayout: function( layoutMode ){
 582+ selectLayout: function( layoutMode ) {
606583 var _this = this;
607 - if( layoutMode != _this.config.layout ){
 584+ if( layoutMode != _this.config.layout ) {
608585 // Update the config and redraw layout
609586 _this.config.layout = layoutMode;
610587
@@ -618,7 +595,7 @@
619596 /**
620597 * Updates the timed text layout ( should be called when config.layout changes )
621598 */
622 - updateLayout: function(){
 599+ updateLayout: function() {
623600 var $playerTarget = this.embedPlayer.$interface;
624601 $playerTarget.find('.itext').remove();
625602 this.refreshDisplay();
@@ -629,7 +606,7 @@
630607 *
631608 * @param {Object} source Source object selected
632609 */
633 - selectTextSource: function( source ){
 610+ selectTextSource: function( source ) {
634611 var _this = this;
635612 mw.log(" select source: " + source.lang );
636613
@@ -652,7 +629,7 @@
653630 $playerTarget.find('.itext').text( gM('mwe-loading-text') );
654631 }
655632 // Load the text:
656 - source.load( function(){
 633+ source.load( function() {
657634 // Refresh the interface:
658635 _this.refreshDisplay();
659636 })
@@ -661,11 +638,11 @@
662639 /**
663640 * Refresh the display, updates the timedText layout, menu, and text display
664641 */
665 - refreshDisplay: function(){
 642+ refreshDisplay: function() {
666643 // Empty out previous text to force an interface update:
667644 this.prevText = [];
668645 // Refresh the Menu (if it has a target to refresh)
669 - if( this.menuTarget ){
 646+ if( this.menuTarget ) {
670647 this.bindMenu( this.menuTarget, false )
671648 }
672649 // Issues a "monitor" command to update the timed text for the new layout
@@ -676,7 +653,7 @@
677654 * Builds the language source list menu
678655 * checks all text sources for category and language key attribute
679656 */
680 - getLanguageMenu: function(){
 657+ getLanguageMenu: function() {
681658 var _this = this;
682659
683660 // See if we have categories to worry about:
@@ -686,10 +663,10 @@
687664 var sourcesWithoutCategory = [ ];
688665 for( var i in this.textSources ) {
689666 var source = this.textSources[ i ];
690 - if( source.category ){
 667+ if( source.category ) {
691668 var catKey = source.category ;
692669 // Init Category menu item if it does not already exist:
693 - if( !catSourceList[ catKey ] ){
 670+ if( !catSourceList[ catKey ] ) {
694671 // Set up catList pointer:
695672 catSourceList[ catKey ] = [ ]
696673 }
@@ -703,24 +680,24 @@
704681 }
705682 var $langMenu = $j('<ul>');
706683 // Check if we have multiple categories ( if not just list them under the parent menu item)
707 - if( catSourceList.length > 1 ){
708 - for(var catKey in catSourceList){
 684+ if( catSourceList.length > 1 ) {
 685+ for(var catKey in catSourceList) {
709686 $catChildren = $j('<ul>');
710 - for(var i in catSourceList[ catKey ]){
 687+ for(var i in catSourceList[ catKey ]) {
711688 $catChildren.append(
712689 catSourceList[ catKey ][i]
713690 )
714691 }
715692 // Append a cat menu item for each category list
716693 $langMenu.append(
717 - _this.getLi( gM( 'mwe-textcat-' + catKey.toLowerCase() ) ).append(
 694+ $j.getLineItem( gM( 'mwe-textcat-' + catKey.toLowerCase() ) ).append(
718695 $catChildren
719696 )
720697 );
721698 }
722699 } else {
723 - for(var catKey in catSourceList){
724 - for(var i in catSourceList[ catKey ]){
 700+ for(var catKey in catSourceList) {
 701+ for(var i in catSourceList[ catKey ]) {
725702 $langMenu.append(
726703 catSourceList[ catKey ][i]
727704 )
@@ -728,7 +705,7 @@
729706 }
730707 }
731708
732 - for(var i in sourcesWithoutCategory){
 709+ for(var i in sourcesWithoutCategory) {
733710 $langMenu.append( sourcesWithoutCategory[i] )
734711 }
735712
@@ -744,7 +721,7 @@
745722 * Updates a source display in the interface for a given time
746723 * @param {Object} source Source to update
747724 */
748 - updateSourceDisplay: function ( source, time ){
 725+ updateSourceDisplay: function ( source, time ) {
749726 // Get the source text for the requested time:
750727 var text = source.getTimedText( time );
751728
@@ -757,7 +734,7 @@
758735 var $playerTarget = this.embedPlayer.$interface;
759736 var $textTarget = $playerTarget.find( '.itext_' + source.category + ' span' );
760737 // If we are missing the target add it:
761 - if( $textTarget.length == 0){
 738+ if( $textTarget.length == 0) {
762739 this.addItextDiv( source.category )
763740 // Re-grab the textTarget:
764741 $textTarget = $playerTarget.find( '.itext_' + source.category + ' span' );
@@ -765,11 +742,11 @@
766743
767744
768745 // If text is "false" fade out the subtitle:
769 - if( text === false ){
 746+ if( text === false ) {
770747 $textTarget.fadeOut('fast');
771748 }else{
772749 // Fade in the target if not visible
773 - if( ! $textTarget.is(':visible') ){
 750+ if( ! $textTarget.is(':visible') ) {
774751 $textTarget.fadeIn('fast');
775752 }
776753 // Update text ( use "html" instead of "text" so that parsers can swap in html for formating
@@ -784,7 +761,7 @@
785762 /**
786763 * Add an itext div to the embedPlayer
787764 */
788 - addItextDiv: function( category ){
 765+ addItextDiv: function( category ) {
789766 mw.log(" addItextDiv: " + category )
790767 // Get the relative positioned player class from the ctrlBuilder:
791768 var $playerTarget = this.embedPlayer.$interface;
@@ -794,7 +771,7 @@
795772
796773 // Setup the display text div:
797774 var layoutMode = this.getLayoutMode();
798 - if( layoutMode == 'ontop' ){
 775+ if( layoutMode == 'ontop' ) {
799776 $playerTarget.append(
800777 $j('<div>').addClass( 'itext' + ' ' + 'itext_' + category )
801778 .css( {
@@ -816,7 +793,7 @@
817794 this.embedPlayer.$interface.animate({
818795 'height': this.embedPlayer.height + this.embedPlayer.ctrlBuilder.height
819796 })
820 - }else if ( layoutMode == 'below'){
 797+ }else if ( layoutMode == 'below') {
821798 // Append before controls:
822799 $playerTarget.find( '.control-bar' ).before(
823800 $j('<div>').addClass( 'itext' + ' ' + 'itext_' + category )
@@ -852,7 +829,7 @@
853830 * @param {Object} source Source object to extend
854831 * @param {Object} {Optional} textProvider The text provider interface ( to load source from api )
855832 */
856 - TextSource = function( source , textProvider){
 833+ TextSource = function( source , textProvider) {
857834 return this.init( source, textProvider );
858835 }
859836 TextSource.prototype = {
@@ -872,16 +849,16 @@
873850 * @constructor Inherits mediaSource from embedPlayer
874851 * @param {source} Base source element
875852 */
876 - init: function( source , textProvider){
877 - for( var i in source){
 853+ init: function( source , textProvider) {
 854+ for( var i in source) {
878855 this[i] = source[i];
879856 }
880857 // Set default category to subtitle if unset:
881 - if( ! this.category ){
 858+ if( ! this.category ) {
882859 this.category = 'SUB';
883860 }
884861 //Set the textProvider if provided
885 - if( textProvider ){
 862+ if( textProvider ) {
886863 this.textProvider = textProvider;
887864 }
888865 },
@@ -890,17 +867,17 @@
891868 * Function to load and parse the source text
892869 * @param {Function} callback Function called once text source is loaded
893870 */
894 - load: function( callback ){
 871+ load: function( callback ) {
895872 var _this = this;
896873
897874 //check if its already loaded:
898 - if( _this.loaded ){
899 - if( callback ){
 875+ if( _this.loaded ) {
 876+ if( callback ) {
900877 callback();
901878 }
902879 }
903880 // Set parser handler:
904 - switch( this.getMIMEType() ){
 881+ switch( this.getMIMEType() ) {
905882 //Special mediaWiki srt format ( support wiki-text in srt's )
906883 case 'text/mw-srt':
907884 var handler = parseMwSrt;
@@ -915,23 +892,23 @@
916893 var hanlder = null;
917894 break;
918895 }
919 - if( !handler ){
 896+ if( !handler ) {
920897 mw.log("Error: no handler for type: " + this.getMIMEType() );
921898 return ;
922899 }
923900 // Try to load src via src attr:
924 - if( this.getSrc() ){
 901+ if( this.getSrc() ) {
925902 // Issue the direct load request ( if we can )
926 - if ( !mw.isLocalDomain( this.getSrc() ) ){
 903+ if ( !mw.isLocalDomain( this.getSrc() ) ) {
927904 mw.log("Error: cant load crossDomain src:" + this.getSrc() )
928905 return ;
929906 }
930 - $j.get( this.getSrc(), function( data ){
 907+ $j.get( this.getSrc(), function( data ) {
931908 // Parse and load captions:
932909 _this.captions = handler( data );
933910 // Update the loaded state:
934911 _this.loaded = true;
935 - if( callback ){
 912+ if( callback ) {
936913 callback();
937914 }
938915 }, 'text' );
@@ -939,12 +916,12 @@
940917 }
941918
942919 // Try to load src via textProvider:
943 - if( this.textProvider && this.titleKey ){
944 - this.textProvider.loadTitleKey( this.titleKey, function( data ){
945 - if( data ){
 920+ if( this.textProvider && this.titleKey ) {
 921+ this.textProvider.loadTitleKey( this.titleKey, function( data ) {
 922+ if( data ) {
946923 _this.captions = handler( data );
947924 }
948 - if( callback ){
 925+ if( callback ) {
949926 callback();
950927 }
951928 return ;
@@ -957,21 +934,21 @@
958935 *
959936 * @param {String} time Time in seconds
960937 */
961 - getTimedText: function ( time ){
 938+ getTimedText: function ( time ) {
962939 var prevCaption = this.captions[ this.prevIndex ];
963940
964941 // Setup the startIndex:
965 - if( prevCaption && time >= prevCaption.start ){
 942+ if( prevCaption && time >= prevCaption.start ) {
966943 var startIndex = this.prevIndex;
967944 }else{
968945 //If a backwards seek start searching at the start:
969946 var startIndex = 0;
970947 }
971948 // Start looking for the text via time, return first match:
972 - for( var i = startIndex ; i < this.captions.length; i ++ ){
 949+ for( var i = startIndex ; i < this.captions.length; i ++ ) {
973950 caption = this.captions[ i ];
974951 if( time >= caption.start &&
975 - time <= caption.end ){
 952+ time <= caption.end ) {
976953 this.prevIndex = i;
977954 return caption.content;
978955 }
@@ -984,12 +961,12 @@
985962 * parse mediaWiki html srt
986963 * @param {Object} data XML data string to be parsed
987964 */
988 - function parseMwSrt( data ){
 965+ function parseMwSrt( data ) {
989966 var captions = [ ];
990967 var curentCap = [];
991968 var parseNextAsTime = false;
992969 // Optimize: we could use javascript strings functions instead of jQuery XML parsing:
993 - $j( '<div>' + data + '</div>' ).find('p').each( function(){
 970+ $j( '<div>' + data + '</div>' ).find('p').each( function() {
994971 currentPtext = $j(this).html();
995972 //mw.log( 'pText: ' + currentPtext );
996973
@@ -1012,7 +989,7 @@
1013990 return 'next';
1014991 }
1015992 // Else check for multi-line match:
1016 - if( parseInt( currentPtext ) == currentPtext ){
 993+ if( parseInt( currentPtext ) == currentPtext ) {
1017994 if( curentCap.length != 0) {
1018995 captions.push( curentCap );
1019996 }
@@ -1037,12 +1014,12 @@
10381015 return 'next';
10391016 }
10401017 //Else content for the curentCap
1041 - if( currentPtext != '<br>' ){
 1018+ if( currentPtext != '<br>' ) {
10421019 curentCap['content'] += currentPtext;
10431020 }
10441021 });
10451022 //Push last subtitle:
1046 - if( curentCap.length != 0){
 1023+ if( curentCap.length != 0) {
10471024 captions.push( curentCap );
10481025 }
10491026 return captions;
@@ -1107,7 +1084,7 @@
11081085 * CMML parser handle
11091086 * @param {Mixed} data String or XML tree of CMML data to be parsed
11101087 */
1111 - function parseCMML( data ){
 1088+ function parseCMML( data ) {
11121089 var captions = [ ];
11131090 $j( data ).find( 'clip' ).each( function( inx, clip ) {
11141091 var content, start, end;
@@ -1140,11 +1117,11 @@
11411118 *
11421119
11431120 // Will add a base class once we are serving more than just mediaWiki "commons"
1144 - mw.BaseTextProvider = function(){
 1121+ mw.BaseTextProvider = function() {
11451122 return this.init();
11461123 }
11471124 mw.BaseTextProvider.prototype = {
1148 - init: function(){
 1125+ init: function() {
11491126
11501127 }
11511128 }
@@ -1157,7 +1134,7 @@
11581135 'embedPlayer'
11591136 ];
11601137
1161 - mw.MediaWikiTextProvider = function( options ){
 1138+ mw.MediaWikiTextProvider = function( options ) {
11621139 this.init( options )
11631140 }
11641141 mw.MediaWikiTextProvider.prototype = {
@@ -1172,8 +1149,8 @@
11731150 * @constructor
11741151 * @param {Object} options Set of options for the provider
11751152 */
1176 - init: function( options ){
1177 - for(var i in default_textProvider_attr){
 1153+ init: function( options ) {
 1154+ for(var i in default_textProvider_attr) {
11781155 var attr = default_textProvider_attr[ i ];
11791156 if( options[ attr ] )
11801157 this[ attr ] = options[ attr ];
@@ -1185,12 +1162,12 @@
11861163 * Loads a single text source by titleKey
11871164 * @param {titleKey}
11881165 */
1189 - loadTitleKey: function( titleKey, callback ){
 1166+ loadTitleKey: function( titleKey, callback ) {
11901167 var request = {
11911168 'action': 'parse',
11921169 'page': titleKey
11931170 };
1194 - mw.getJSON( this.api_url, request, function( data ){
 1171+ mw.getJSON( this.api_url, request, function( data ) {
11951172 if ( data && data.parse && data.parse.text['*'] ) {
11961173 callback( data.parse.text['*'] );
11971174 return;
@@ -1205,11 +1182,11 @@
12061183 *
12071184 * @param {String} assetKey For mediaWiki the assetKey is the "wiki title"
12081185 */
1209 - loadSources: function( assetKey, callback ){
 1186+ loadSources: function( assetKey, callback ) {
12101187 var request = {};
12111188 var _this = this;
1212 - this.getSourcePages( assetKey, function( sourcePages ){
1213 - if( ! sourcePages.query.allpages ){
 1189+ this.getSourcePages( assetKey, function( sourcePages ) {
 1190+ if( ! sourcePages.query.allpages ) {
12141191 //Check if a shared asset
12151192 mw.log( 'no subtitle pages found');
12161193 callback();
@@ -1225,7 +1202,7 @@
12261203 * @param {String} titleKey Title to get subtitles for
12271204 * @param {Function} callback Function to call once NS subs are grabbed
12281205 */
1229 - getSourcePages: function( titleKey, callback ){
 1206+ getSourcePages: function( titleKey, callback ) {
12301207 var _this = this;
12311208 var request = {
12321209 'list' : 'allpages',
@@ -1268,7 +1245,7 @@
12691246
12701247 //NOTE: we hard code the mw-srt type
12711248 // ( This is because mediaWiki srt files can have wiki-text and parsed as such )
1272 - if( extension == 'srt' ){
 1249+ if( extension == 'srt' ) {
12731250 extension = 'mw-srt';
12741251 }
12751252
@@ -1288,7 +1265,7 @@
12891266 /**
12901267 * Return the namespace (if not encoded on the page return default 102 )
12911268 */
1292 - getTimedTextNS: function(){
 1269+ getTimedTextNS: function() {
12931270 if( this.timed_text_NS )
12941271 return this.timed_text_NS;
12951272 if ( typeof wgNamespaceIds != 'undefined' && wgNamespaceIds['timedtext'] ) {
@@ -1303,15 +1280,15 @@
13041281 /**
13051282 * Get the Canonical timed text namespace text
13061283 */
1307 - getCanonicalTimedTextNS: function(){
 1284+ getCanonicalTimedTextNS: function() {
13081285 return 'TimedText';
13091286 },
13101287
13111288 /**
13121289 * Check if the language is supported
13131290 */
1314 - isSuportedLang: function( lang_key ){
1315 - if( mw.languages[ lang_key ]){
 1291+ isSuportedLang: function( lang_key ) {
 1292+ if( mw.languages[ lang_key ]) {
13161293 return true;
13171294 }
13181295 return false;
@@ -1332,17 +1309,17 @@
13331310 *
13341311 * @param {Object} options Options for the timed text menu
13351312 */
1336 - $.fn.timedText = function ( action, target ){
 1313+ $.fn.timedText = function ( action, target ) {
13371314 if( !target )
13381315 options = action;
13391316 if( typeof options == 'undefined' )
13401317 options = {};
13411318
1342 - $j( this.selector ).each(function(){
 1319+ $j( this.selector ).each(function() {
13431320 var embedPlayer = $j(this).get(0);
13441321
13451322 // Setup timed text for the given player:
1346 - if( ! embedPlayer.timedText ){
 1323+ if( ! embedPlayer.timedText ) {
13471324 embedPlayer.timedText = new mw.TimedText( embedPlayer, options);
13481325 }
13491326
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js
@@ -28,7 +28,7 @@
2929 "mwe-upload-text-done-uploading" : "Done uploading"
3030 } );
3131
32 -mw.TimedTextEdit = function( parentTimedText ){
 32+mw.TimedTextEdit = function( parentTimedText ) {
3333 return this.init( parentTimedText );
3434 }
3535 mw.TimedTextEdit.prototype = {
@@ -55,14 +55,14 @@
5656 * @constructor
5757 * @param {Object} parentTimedText The parent TimedText object that called the editor
5858 */
59 - init: function( parentTimedText ){
 59+ init: function( parentTimedText ) {
6060 this.parentTimedText = parentTimedText;
6161 },
6262
6363 /**
6464 * Show the editor UI
6565 */
66 - showUI: function(){
 66+ showUI: function() {
6767 // Setup the parent container:
6868 this.createDialogContainer();
6969
@@ -73,7 +73,7 @@
7474 /**
7575 * Setup the dialog layout: s
7676 */
77 - initDialog: function(){
 77+ initDialog: function() {
7878 var _this =this;
7979 _this.createTabs();
8080 },
@@ -81,12 +81,12 @@
8282 /**
8383 * Creates interface tabs from the textEditStages
8484 */
85 - createTabs: function(){
 85+ createTabs: function() {
8686 var _this = this;
8787 $tabContainer = $j( '<div />' )
8888 .attr( 'id', "TimedTextEdit-tabs" )
8989 .append( '<ul />' );
90 - for(var edit_stage_id in this.textEditStages){
 90+ for(var edit_stage_id in this.textEditStages) {
9191 var editStage = this.textEditStages[ edit_stage_id ];
9292 // Append the menu item:
9393 $tabContainer.find('ul').append(
@@ -118,7 +118,7 @@
119119 $j( _this.target_container ).append( $tabContainer );
120120
121121 //Create all the "interfaces"
122 - for(var edit_stage_id in this.textEditStages){
 122+ for(var edit_stage_id in this.textEditStages) {
123123 _this.createInterface( edit_stage_id )
124124 }
125125
@@ -130,7 +130,7 @@
131131 });
132132
133133 },
134 - selectTab: function( tab_id ){
 134+ selectTab: function( tab_id ) {
135135 mw.log('sel: ' + tab_id);
136136 },
137137
@@ -139,9 +139,9 @@
140140 * @return the jquery interface
141141 * @type {Object}
142142 */
143 - createInterface: function( edit_stage_id){
 143+ createInterface: function( edit_stage_id) {
144144 $target = $j('#tab-' + edit_stage_id);
145 - if( this[edit_stage_id + 'Interface']){
 145+ if( this[edit_stage_id + 'Interface']) {
146146 this[ edit_stage_id + 'Interface']( $target );
147147 }else{
148148 $target.append( ' interface under development' );
@@ -151,7 +151,7 @@
152152 * Builds out and binds the upload interface to a given target
153153 * @param {Object} $target jQuery target for the upload interface
154154 */
155 - uploadInterface: function( $target ){
 155+ uploadInterface: function( $target ) {
156156 var _this = this;
157157 // Check if user has XHR file upload support & we are on the target wiki
158158
@@ -214,9 +214,9 @@
215215 'maxlength' : "10",
216216 'size' :"3"
217217 } )
218 - .change(function(){
 218+ .change(function() {
219219 var langKey = $j(this).val();
220 - if( mw.languages[ langKey ] ){
 220+ if( mw.languages[ langKey ] ) {
221221 $buttonTarget.find('.btnText').text(
222222 unescape( mw.languages[ langKey ] )
223223 );
@@ -269,7 +269,7 @@
270270
271271 // Update the preview text area:
272272 var file = $j( '#timed-text-file-upload' ).get(0).files[0];
273 - if( file.fileSize > 1048576 ){
 273+ if( file.fileSize > 1048576 ) {
274274 $j( '#timed-text-file-preview' ).text( 'Error the file you selected is too lage');
275275 return ;
276276 }
@@ -281,7 +281,7 @@
282282 var langKey = $j(this).val().split( '.' );
283283 var extension = langKey.pop();
284284 langKey = langKey.pop();
285 - if( mw.languages[ langKey ] ){
 285+ if( mw.languages[ langKey ] ) {
286286 $buttonTarget.find('.btnText').text(
287287 unescape( mw.languages[ langKey ] )
288288 );
@@ -304,7 +304,7 @@
305305 } )
306306 .unbind()
307307 .buttonHover()
308 - .click( function(){
 308+ .click( function() {
309309 _this.uploadTextFile();
310310 })
311311 );
@@ -313,7 +313,7 @@
314314 /**
315315 * Uploads the text content
316316 */
317 - uploadTextFile: function(){
 317+ uploadTextFile: function() {
318318 // Put a dialog ontop
319319 mw.addLoaderDialog( gM( 'mwe-uploading-text') );
320320
@@ -325,7 +325,7 @@
326326 targetTitleKey = 'TimedText:' + targetTitleKey + '.' + $j('#timed-text-langKey-input').val() + '.srt';
327327
328328 // Get a token
329 - mw.getToken( targetTitleKey, function( token ){
 329+ mw.getToken( targetTitleKey, function( token ) {
330330 mw.log("got token: " + token);
331331 var request = {
332332 'action' : 'edit',
@@ -333,17 +333,17 @@
334334 'text' : $j('#timed-text-file-preview').val(),
335335 'token': token
336336 };
337 - mw.getJSON( request, function( data ){
 337+ mw.getJSON( request, function( data ) {
338338 //Close the loader dialog:
339339 mw.closeLoaderDialog();
340340
341 - if( data.edit && data.edit.result == 'Success' ){
 341+ if( data.edit && data.edit.result == 'Success' ) {
342342 var buttons = { };
343 - buttons[ gM("mwe-upload-text-another")] = function(){
 343+ buttons[ gM("mwe-upload-text-another")] = function() {
344344 // just close the current dialog:
345345 $j( this ).dialog('close');
346346 }
347 - buttons[ gM( "mwe-upload-text-done-uploading" ) ] = function(){
 347+ buttons[ gM( "mwe-upload-text-done-uploading" ) ] = function() {
348348 window.location.reload();
349349 }
350350 //Edit success
@@ -374,7 +374,7 @@
375375 *
376376 * ~ what really a lot of time is putting this ~into~ the dom ~
377377 */
378 - getLanguageList: function(){
 378+ getLanguageList: function() {
379379 var _this = this;
380380 var $langMenu = $j( '<ul>' );
381381 // Loop through all supported languages:
@@ -382,9 +382,9 @@
383383 var language = mw.languages [ langKey ];
384384 var source_icon = 'radio-on';
385385 //check if the key is in the _this.parentTimedText source array
386 - for( var i in _this.parentTimedText.textSources ){
 386+ for( var i in _this.parentTimedText.textSources ) {
387387 var pSource = _this.parentTimedText.textSources[i];
388 - if( pSource.lang == langKey){
 388+ if( pSource.lang == langKey) {
389389 source_icon = 'bullet';
390390 }
391391 }
@@ -395,11 +395,11 @@
396396 }
397397 return $langMenu;
398398 },
399 - getLangMenuItem: function( langKey , source_icon){
 399+ getLangMenuItem: function( langKey , source_icon) {
400400 return this.parentTimedText.getLi(
401401 langKey + ' - ' + unescape( mw.languages[ langKey ] ),
402402 source_icon,
403 - function(){
 403+ function() {
404404 mw.log( "Selected: " + langKey );
405405 // Update the input box text
406406 $j('#timed-text-langKey-input').val( langKey );
@@ -410,7 +410,7 @@
411411 /**
412412 * Creates the interface dialog container
413413 */
414 - createDialogContainer: function(){
 414+ createDialogContainer: function() {
415415 var _this = this;
416416 //Setup the target container:
417417 _this.target_container = '#timedTextEdit_target';
@@ -453,7 +453,7 @@
454454
455455 },
456456
457 - onCancelClipEdit: function(){
 457+ onCancelClipEdit: function() {
458458 var _this = this;
459459 // Cancel edit
460460 $j( _this.target_container ).dialog( 'close' );
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/remotes/RemoteMwTimedText.js
@@ -11,7 +11,7 @@
1212 "mwe-language-no-subtitles-for-clip": "No $1 subtitles where found for clip: $2"
1313 });
1414
15 -RemoteMwTimedText = function( options ){
 15+RemoteMwTimedText = function( options ) {
1616 return this.init( options );
1717 }
1818 mw_default_remote_text_options = [
@@ -23,36 +23,36 @@
2424 RemoteMwTimedText.prototype = {
2525
2626 init: function( options ) {
27 - for(var i in mw_default_remote_text_options){
 27+ for(var i in mw_default_remote_text_options) {
2828 var opt = mw_default_remote_text_options[i]
29 - if( options[ opt ] ){
 29+ if( options[ opt ] ) {
3030 this[ opt ] = options[ opt ];
3131 }
3232 }
3333 },
34 - updateUI: function(){
 34+ updateUI: function() {
3535 // Check page type
36 - if( this.action == 'view' ){
 36+ if( this.action == 'view' ) {
3737 this.showViewUI();
3838 }else{
3939 //restore
4040 }
4141 },
42 - showViewUI: function(){
 42+ showViewUI: function() {
4343 var _this = this;
4444 var fileTitleKey = this.title.split('.');
4545 this.extension = fileTitleKey.pop();
4646 this.langKey = fileTitleKey.pop();
4747 this.fileTitleKey = fileTitleKey.join('.');
4848
49 - this.getTitleResource( this.fileTitleKey, function( resource ){
 49+ this.getTitleResource( this.fileTitleKey, function( resource ) {
5050 _this.embedViewUI( resource );
5151 });
5252 },
53 - embedViewUI: function( resource ){
 53+ embedViewUI: function( resource ) {
5454 var _this = this;
5555 // Load the player module:
56 - mw.load( 'EmbedPlayer', function(){
 56+ mw.load( 'EmbedPlayer', function() {
5757 // Add the embed code: ( jquery wrapping of "video" fails )
5858 $j( _this.target ).append(
5959 $j( '<div class="videoLoading">').html(
@@ -73,9 +73,9 @@
7474 /*
7575 * embeds a player with the current language key pre selected
7676 */
77 - embedPlayerLang: function(){
 77+ embedPlayerLang: function() {
7878 var _this = this;
79 - if( wgArticlePath ){
 79+ if( wgArticlePath ) {
8080 var $fileLink = $j('<div>').append(
8181 $j('<a>').attr({
8282 'href' : wgArticlePath.replace( '$1', 'File:' + _this.fileTitleKey)
@@ -85,7 +85,7 @@
8686 }
8787
8888 // Rewrite the player (any video tags on the page)
89 - $j('#timed-text-player-embed').embedPlayer( function(){
 89+ $j('#timed-text-player-embed').embedPlayer( function() {
9090 //Select the timed text for the page:
9191
9292 //remove the loader
@@ -94,7 +94,7 @@
9595 var player = $j('#timed-text-player-embed').get(0);
9696
9797
98 - if( !player.timedText ){
 98+ if( !player.timedText ) {
9999 mw.log("Error: no timedText method on embedPlayer" );
100100 return ;
101101 }
@@ -102,11 +102,11 @@
103103 player.timedText.config.userLanugage = this.langKey;
104104
105105 // Make sure the timed text sources are loaded:
106 - player.timedText.setupTextSources( function(){
 106+ player.timedText.setupTextSources( function() {
107107
108108 var source = player.timedText.getSourceByLanguage( _this.langKey );
109109 var pageMsgKey = 'mwe-language-subtitles-for-clip';
110 - if( ! source ){
 110+ if( ! source ) {
111111 pageMsgKey = "mwe-language-no-subtitles-for-clip"
112112 }
113113 // Add the page msg to the top
@@ -117,7 +117,7 @@
118118 )
119119 );
120120 // Select the language if possible:
121 - if( source ){
 121+ if( source ) {
122122 player.timedText.selectTextSource( source );
123123 }
124124 // Un-hide the player
@@ -131,7 +131,7 @@
132132 * @param {String} fileTitle Title of media asset to embed
133133 * @param {Function} {Optional} callback Function to call once asset is embedded
134134 */
135 - getTitleResource: function( fileTitle, callback ){
 135+ getTitleResource: function( fileTitle, callback ) {
136136 var _this = this;
137137 // Get all the embed details:
138138 var request = {
@@ -144,7 +144,7 @@
145145 // (only works for commons right now)
146146 mw.getJSON( request, function( data ) {
147147 // Check for "page not found"
148 - if( data.query.pages['-1'] ){
 148+ if( data.query.pages['-1'] ) {
149149 //restore content:
150150 $j(_this.target).html( _this.orgBody );
151151 return ;
@@ -176,7 +176,7 @@
177177 /**
178178 * Get the embed code from response resource and sends it a callback
179179 */
180 - getResource: function( page ){
 180+ getResource: function( page ) {
181181 return {
182182 'apiTitleKey' : page.title.replace(/File:/ig, '' ),
183183 'link' : page.imageinfo[0].descriptionurl,
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.FirefoggGUI.js
@@ -71,7 +71,7 @@
7272 /**
7373 * Setup firefoggGUI jquery binding
7474 */
75 -( function( $ ){
 75+( function( $ ) {
7676 $.fn.firefoggGUI = function( options ) {
7777 if ( !options )
7878 options = { };
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -126,10 +126,10 @@
127127 // Enabled providers can be keyword 'all' or an array of enabled content provider keys
128128 'enabled_providers': 'all',
129129
130 - // Enalbed license types can any set of
 130+ // Enabled license types can any set of
131131 // 'pd' (public domain), 'by' ( attribution ) , 'sa' (share alike ),
132132 // 'nd' ( no derivatives )
133 - // 'nc' ( non-comercial ), 'all' ( all found licenses are "ok")
 133+ // 'nc' ( non-commercial ), 'all' ( all found licenses are "ok")
134134 'enabled_licenses' : ['pd', 'by', 'sa' ],
135135
136136 // Set a default provider
@@ -156,7 +156,7 @@
157157 }
158158 }
159159
160 - $.addMediaWizard = function( options ){
 160+ $.addMediaWizard = function( options ) {
161161 $.fn.addMediaWizard ( options, function( amwObj ) {
162162 // Do the add-media-wizard display
163163 amwObj.createUI();
@@ -429,7 +429,7 @@
430430 _this.enabled_providers = 'all';
431431
432432 // Set the current_provider from default_provider
433 - if( this.default_provider && this.content_providers[ this.default_provider ] ){
 433+ if( this.default_provider && this.content_providers[ this.default_provider ] ) {
434434 this.current_provider = this.default_provider;
435435 }
436436
@@ -561,7 +561,7 @@
562562 getLicenseFromUrl: function( license_url ) {
563563 // Get the license key:
564564 var licenseKey = this.getLicenseKeyFromUrl( license_url );
565 - if( licenseKey ){
 565+ if( licenseKey ) {
566566 // Return the license object:
567567 return this.getLicenseFromKey( licenseKey , license_url );
568568 }
@@ -578,10 +578,10 @@
579579 * @parma {String} license_url License url to get key from
580580 * @return mixed license key or false if not found.
581581 */
582 - getLicenseKeyFromUrl: function( license_url ){
 582+ getLicenseKeyFromUrl: function( license_url ) {
583583 // Check for some pre-defined us gov url:
584584 if ( license_url == 'http://www.usa.gov/copyright.shtml' ||
585 - license_url == 'http://creativecommons.org/licenses/publicdomain' ){
 585+ license_url == 'http://creativecommons.org/licenses/publicdomain' ) {
586586 return 'pd';
587587 }
588588 // First do a direct lookup check:
@@ -611,7 +611,7 @@
612612 return false;
613613 var licenseSet = licenseKey.split( '-' );
614614 for ( var i = 0; i < licenseSet.length; i++ ) {
615 - if( $j.inArray( licenseSet[i], this.enabled_licenses ) == -1){
 615+ if( $j.inArray( licenseSet[i], this.enabled_licenses ) == -1) {
616616 return false;
617617 }
618618 }
@@ -664,7 +664,7 @@
665665
666666 // Setup the parent container (if not already created)
667667 mw.log(" looking for: " + _this.target_container);
668 - if( !_this.target_container || $j( _this.target_container ).length == 0 ){
 668+ if( !_this.target_container || $j( _this.target_container ).length == 0 ) {
669669 this.createDialogContainer();
670670 }else{
671671 // Empty out the target
@@ -914,7 +914,7 @@
915915 text: gM( 'mwe-media_search' ) })
916916 .addClass( 'rsd_search_button' )
917917 .buttonHover()
918 - .click(function (){
 918+ .click(function () {
919919 _this.updateResults( _this.current_provider, true );
920920 return false;
921921 });
@@ -978,7 +978,7 @@
979979 if ( this.content_providers['upload'].enabled) {
980980 $uploadButton = $j.button( { icon_id: 'disk', text: gM( 'mwe-upload_tab' ) })
981981 .addClass("rsd_upload_button")
982 - .click(function(){
 982+ .click(function() {
983983 _this.current_provider = 'upload';
984984 _this.updateUploadResults( );
985985 return false;
@@ -1502,7 +1502,7 @@
15031503 /**
15041504 * Show failure
15051505 */
1506 - showFailure : function( resultStatus ){
 1506+ showFailure : function( resultStatus ) {
15071507 //only one type of resultStatus right now:
15081508 if( resultStatus == 'timeout' )
15091509 $j( '#tab-' + this.current_provider ).text(
@@ -1748,8 +1748,8 @@
17491749 */
17501750 getMediaType: function( resource ) {
17511751 var types = [ 'image', 'audio', 'video'];
1752 - for( var i=0; i < types.length ; i++ ){
1753 - if ( resource.mime.indexOf( types[i] ) !== -1){
 1752+ for( var i=0; i < types.length ; i++ ) {
 1753+ if ( resource.mime.indexOf( types[i] ) !== -1) {
17541754 return types[i];
17551755 }
17561756 }
@@ -1993,7 +1993,7 @@
19941994
19951995 // Add extra space at the top if the embed player is less than 90px high
19961996 // bug 22189
1997 - if( $j('#embed_vid').get(0).getPlayerHeight() < 90 ){
 1997+ if( $j('#embed_vid').get(0).getPlayerHeight() < 90 ) {
19981998 $j( '#clip_edit_disp' ).prepend(
19991999 $j( '<span />' )
20002000 .css({
@@ -2186,7 +2186,7 @@
21872187 );
21882188
21892189 // Update video tag (if a video)
2190 - if ( resource.mime.indexOf( 'video/' ) !== -1 ){
 2190+ if ( resource.mime.indexOf( 'video/' ) !== -1 ) {
21912191 var target_rewrite_id = $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid';
21922192 $j('#' + target_rewrite_id ).embedPlayer();
21932193 }
@@ -2223,7 +2223,7 @@
22242224 mw.log( "do import asset:" + _this.import_url_mode );
22252225 // check import mode:
22262226 if ( _this.import_url_mode == 'api' ) {
2227 - _this.doApiImport( resource, function(){
 2227+ _this.doApiImport( resource, function() {
22282228 $j( '#rsd_resource_import' ).remove();
22292229 _this.clipEdit.updateInsertControlActions();
22302230 callback
@@ -2249,7 +2249,7 @@
22502250 /**
22512251 * Get the resource Import interface
22522252 */
2253 - getResourceImportInterface: function( resource, description ){
 2253+ getResourceImportInterface: function( resource, description ) {
22542254 var _this = this;
22552255 var $rsdResourceImport = $j('<div />')
22562256 .attr( 'id', 'rsd_resource_import' )
@@ -2386,7 +2386,7 @@
23872387 * Get Template Description wikitext
23882388 * @pram {Object} resource Resource source for description
23892389 */
2390 - getTemplateDescription: function( resource ){
 2390+ getTemplateDescription: function( resource ) {
23912391 // setup the resource description from resource description:
23922392 // FIXME: i18n, namespace
23932393 var description = '{{Information ' + "\n";
@@ -2441,7 +2441,7 @@
24422442 mw.getJSON( mw.getLocalApiUrl(), request, function( data ) {
24432443 if ( data.query.pages ) {
24442444 for ( var i in data.query.pages ) {
2445 - if( i == '-1' ){
 2445+ if( i == '-1' ) {
24462446 callback( false );
24472447 return ;
24482448 }
@@ -2521,7 +2521,7 @@
25222522
25232523 // If status is missing show import UI
25242524 if ( status === 'missing' ) {
2525 - _this.showImportUI( resource, function(){
 2525+ _this.showImportUI( resource, function() {
25262526 // Once the image is imported re-issue the showPreview request:
25272527 _this.showPreview( resource );
25282528 } );
@@ -2588,8 +2588,8 @@
25892589 _this.target_title,
25902590 function( phtml ) {
25912591 $j( '#rsd_preview_display' ).html( phtml );
2592 - if( mw.documentHasPlayerTags() ){
2593 - mw.load( 'EmbedPlayer', function(){
 2592+ if( mw.documentHasPlayerTags() ) {
 2593+ mw.load( 'EmbedPlayer', function() {
25942594 // Update the display of video tag items (if any)
25952595 $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer();
25962596 });
@@ -2665,7 +2665,7 @@
26662666 *
26672667 * @param {Object} resource Resource to be inserted into the output targets
26682668 */
2669 - insertResourceToOutput: function( resource ){
 2669+ insertResourceToOutput: function( resource ) {
26702670 var _this = this;
26712671 var embed_code = _this.getEmbedCode( resource );
26722672 $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } );
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/jquery.simpleUploadForm.js
@@ -137,7 +137,7 @@
138138
139139 // Set up the binding per the config
140140 if ( options.enable_fogg ) {
141 - mw.load( 'AddMedia.firefogg', function(){
 141+ mw.load( 'AddMedia.firefogg', function() {
142142 $j( "#wpUploadFile" ).firefogg( {
143143 // An api url (we won't submit directly to action of the form)
144144 'api_url' : options.api_target,
@@ -151,13 +151,13 @@
152152 warn_target: "#wpDestFile-warning"
153153 } );
154154 },
155 - 'onsubmit_cb' : function( ){
 155+ 'onsubmit_cb' : function( ) {
156156 // Update with basic info template:
157157 // TODO: it would be nice to have a template generator class
158158 var desc = $j('#wpUploadDescription').val();
159159
160160 // Update the template if the user does not already have template code:
161 - if( desc.indexOf('{{Information') == -1){
 161+ if( desc.indexOf('{{Information') == -1) {
162162 $j('#wpUploadDescription').val(
163163 '== {{int:filedesc}} ==' + "\n" +
164164 '{{Information' + "\n" +
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -68,9 +68,9 @@
6969 /**
7070 * Setup upload jQuery binding
7171 */
72 -( function( $ ){
 72+( function( $ ) {
7373 $.fn.uploadHandler = function( options ) {
74 - if ( !options ){
 74+ if ( !options ) {
7575 options = { };
7676 }
7777
@@ -133,7 +133,7 @@
134134 $j.extend( this, default_bui_options, options );
135135
136136 // Set a api_url if unset
137 - if( !this.api_url ){
 137+ if( !this.api_url ) {
138138 this.api_url = mw.getLocalApiUrl();
139139 }
140140 // Setup the UploadInterface handler
@@ -189,7 +189,7 @@
190190 }
191191
192192 // Call the onsubmit_cb option if set:
193 - if( this.onsubmit_cb && typeof this.onsubmit_cb == 'function' ){
 193+ if( this.onsubmit_cb && typeof this.onsubmit_cb == 'function' ) {
194194 this.onsubmit_cb();
195195 }
196196
@@ -319,7 +319,7 @@
320320 //
321321 mw.log("remapFormToApi:: " + this.api_url + ' form: ' + this.form);
322322
323 - if ( !this.api_url ){
 323+ if ( !this.api_url ) {
324324 mw.log( 'Error: no api url target' );
325325 return false;
326326 }
@@ -328,12 +328,12 @@
329329 // Set the form action
330330 try{
331331 $form.attr('action', _this.api_url);
332 - }catch(e){
 332+ }catch(e) {
333333 mw.log("IE for some reason error's out when you change the action")
334334 }
335335
336336 // Add API action
337 - if ( $form.find( "[name='action']" ).length == 0 ){
 337+ if ( $form.find( "[name='action']" ).length == 0 ) {
338338 $form.append(
339339 $j('<input />')
340340 .attr({
@@ -345,7 +345,7 @@
346346 }
347347
348348 // Add JSON response format
349 - if ( $form.find( "[name='format']" ).length == 0 ){
 349+ if ( $form.find( "[name='format']" ).length == 0 ) {
350350 $form.append(
351351 $j( '<input />' )
352352 .attr({
@@ -670,13 +670,13 @@
671671 * @return {String}
672672 * value of wpUploadDescription
673673 */
674 - getUploadDescription: function(){
 674+ getUploadDescription: function() {
675675 //Special case of upload.js commons hack:
676676 var comment_value = $j( '#wpUploadDescription' ).val();
677 - if( comment_value == '' ){
 677+ if( comment_value == '' ) {
678678 comment_value = $j( "[name='wpUploadDescription']").val();
679679 }
680 -
 680+ mw.log( 'getUploadDescription:: base:' + comment_value + ' ucr:' + this.useCopyrightUpload );
681681 // Set license, copyStatus, source if available ( generally not available SpecialUpload needs some refactoring )
682682 if ( this.useCopyrightUpload ) {
683683 var license = ( $j("[name='wpLicense']").length ) ? $j("[name='wpLicense']").val() : '';
@@ -686,8 +686,8 @@
687687 // Run the JS equivalent of SpecialUpload.php getInitialPageText
688688 comment_value = this.getCommentText( comment_value, license, copyStatus, source );
689689 }
690 -
691 - return comment_value;
 690+ mw.log( 'getCommentText:: new val:' + comment_value );
 691+ return comment_value;
692692 },
693693
694694 /**
@@ -700,7 +700,7 @@
701701 * @param {String} copyStatus the copyright status field
702702 * @param {String} source The source filed
703703 */
704 - getCommentText: function( comment, license, copyStatus, source ){
 704+ getCommentText: function( comment, license, copyStatus, source ) {
705705 var licensetxt = '';
706706 if ( license != '' ) {
707707 licensetxt = '== ' + gM( 'license-header' ) + " ==\n" + '{{' + license + '}}' + "\n";
@@ -1011,11 +1011,11 @@
10121012 mw.log( 'doDestCheck::' + _this.selector );
10131013
10141014 // Set up option defaults
1015 - if ( !options.warn_target ){
 1015+ if ( !options.warn_target ) {
10161016 options.warn_target = '#wpDestFile-warning';
10171017 }
10181018
1019 - if( ! options.api_url ){
 1019+ if( ! options.api_url ) {
10201020 options.api_url = mw.getLocalApiUrl();
10211021 }
10221022
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js
@@ -271,7 +271,7 @@
272272 var result = data[ result_id ];
273273
274274 // Skip the resource if the license is not compatible
275 - if( result.license_url && ! _this.rsd.checkCompatibleLicense( result.license_url ) ){
 275+ if( result.license_url && ! _this.rsd.checkCompatibleLicense( result.license_url ) ) {
276276 continue;
277277 }
278278
@@ -305,7 +305,7 @@
306306 */
307307 getImageObj: function( resource, size, callback ) {
308308 var _this = this;
309 - this.getSerachLib( resource.content_provider_id, function( searchLib ){
 309+ this.getSerachLib( resource.content_provider_id, function( searchLib ) {
310310 searchLib.getImageObj( resource, size, callback );
311311 });
312312 },
@@ -314,9 +314,9 @@
315315 * Get extra resource info via a library specific callback
316316 * NOTE: this info should be included in the original kaltura search results
317317 */
318 - addResourceInfoCallback: function( resource, callback ){
 318+ addResourceInfoCallback: function( resource, callback ) {
319319 mw.log('Kaltura: addResourceInfoCallback');
320 - this.getSerachLib( resource.content_provider_id, function( searchLib ){
 320+ this.getSerachLib( resource.content_provider_id, function( searchLib ) {
321321 searchLib.addResourceInfoCallback( resource, callback );
322322 });
323323 },
@@ -327,16 +327,16 @@
328328 * @param {Function} callback Function to call once provider search lib is loaded
329329 * callback is passed the search object
330330 */
331 - getSerachLib: function( provider_id, callback ){
 331+ getSerachLib: function( provider_id, callback ) {
332332 var _this = this;
333333 // Check if we already have the library loaded:
334 - if( this.searchLibs[ provider_id ] ){
 334+ if( this.searchLibs[ provider_id ] ) {
335335 callback ( this.searchLibs[ provider_id ] );
336336 return ;
337337 }
338338 // Else load the provider lib:
339339 var provider = this.rsd.content_providers [ provider_id ];
340 - mw.load( provider.lib + 'Search', function(){
 340+ mw.load( provider.lib + 'Search', function() {
341341 //Set up the search lib options
342342 var options = {
343343 'provider': provider,
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -261,7 +261,7 @@
262262
263263
264264 this.num_results++;
265 - // for(var i in this.resultsObj[page_id]){
 265+ // for(var i in this.resultsObj[page_id]) {
266266 // mw.log('added: '+ i +' '+ this.resultsObj[page_id][i]);
267267 // }
268268 }
@@ -310,7 +310,7 @@
311311 mw.getJSON( this.provider.api_url, request, function( data ) {
312312 var imObj = { };
313313 for ( var page_id in data.query.pages ) {
314 - if( page_id == -1 ){
 314+ if( page_id == -1 ) {
315315 mw.log( 'Error: missing page for title: ' + resource.titleKey )
316316 continue;
317317 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js
@@ -87,7 +87,7 @@
8888 /**
8989 * getProviderResults abstract method
9090 */
91 - getProviderResults: function( searchQuery , calback){
 91+ getProviderResults: function( searchQuery , calback) {
9292 mw.log( 'Error: getProviderResults not set by provider' );
9393 callback( 'error-provider' );
9494 },
@@ -158,7 +158,7 @@
159159 * @param {XML Node} the xml result node
160160 * @param {attr} the name attribute we are maping to the resource object
161161 */
162 - mapAttributeToResource: function( resource, item, attr ){
 162+ mapAttributeToResource: function( resource, item, attr ) {
163163 var selector = rsd_default_rss_item_mapping[ attr ].split( '@' );
164164 var flag_multiple = ( selector[0].substr( 0, 1 ) == '.' ) ? true : false;
165165 if ( flag_multiple ) {
@@ -228,14 +228,14 @@
229229 }
230230
231231 options.style = '';
232 - if( options.height ){
 232+ if( options.height ) {
233233 options.style += 'height:' + parseInt( options.height ) + 'px;';
234234 }
235 - if( options.width ){
 235+ if( options.width ) {
236236 options.style += 'width:' + parseInt( options.width ) + 'px;';
237237 }
238238
239 - if ( resource.mime.indexOf( 'image/' ) != -1 ){
 239+ if ( resource.mime.indexOf( 'image/' ) != -1 ) {
240240 outHtml = this.getImageEmbedHTML( resource, options );
241241 }
242242
@@ -252,7 +252,7 @@
253253 'type="' + mw.escapeQuotesHTML( resource.mime ) + '" ';
254254
255255 // Add the api title key if avaliable:
256 - if( resource.titleKey ){
 256+ if( resource.titleKey ) {
257257 'apiTitleKey="' + mw.escapeQuotesHTML( resource.titleKey ) + '" ';
258258 }
259259
@@ -266,7 +266,7 @@
267267 }
268268
269269 // Return the output. Wrap with a description div if insert_description is on.
270 - if( outHtml != ''){
 270+ if( outHtml != '') {
271271 return ( options['insert_description'] ) ?
272272 this.wrapHtmlDesc(resource, options, outHtml) :
273273 outHtml;
@@ -329,10 +329,10 @@
330330 'src' : resource.edit_url,
331331 'style' : options.style
332332 });
333 - if( options['id'] ){
 333+ if( options['id'] ) {
334334 $img.attr( 'id', options['id'] );
335335 }
336 - if ( resource.crop == null ){
 336+ if ( resource.crop == null ) {
337337 return $j('<div />').append( $img ).html();
338338 }
339339 // Else do crop output:
@@ -490,7 +490,7 @@
491491 * @parma {Object} resource Resource to update title on.
492492 */
493493 updateTargetResourceTitle:function( resource ) {
494 - if( resource.titleKey ){
 494+ if( resource.titleKey ) {
495495 resource.target_resource_title = resource.titleKey.replace( /^(File:|Image:)/ , '' ).replace(':', '');
496496 resource.target_resource_title = this.provider.resource_prefix + resource.target_resource_title;
497497 }
@@ -499,7 +499,7 @@
500500 /**
501501 * Utily to convert from mime type to extension
502502 */
503 - getMimeExtension: function( mime ){
 503+ getMimeExtension: function( mime ) {
504504 if( mime == 'video/ogg' || mime == 'application/ogg' )
505505 return 'ogv';
506506 if( mime == 'audio/ogg' )
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js
@@ -76,7 +76,7 @@
7777
7878 // Skip the resource if the license is not compatible
7979 // ( archive.org does not let us filter the license on search )
80 - if( ! _this.rsd.checkCompatibleLicense( resource.licenseurl ) ){
 80+ if( ! _this.rsd.checkCompatibleLicense( resource.licenseurl ) ) {
8181 continue;
8282 }
8383
@@ -138,14 +138,14 @@
139139 var attributes = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
140140
141141 // Add height width if we have it:
142 - if( resource.width ){
 142+ if( resource.width ) {
143143 attributes += ' width="'+ parseInt( resource.width ) + '"';
144144 }
145 - if( resource.height ){
 145+ if( resource.height ) {
146146 attributes += ' height="' + parseInt( resource.height ) + '"';
147147 }
148148 // Add the src
149 - if( !resource.src ){
 149+ if( !resource.src ) {
150150 mw.log("Error: resource missing src");
151151 }else{
152152 attributes += ' src="' + resource.src + '"';
@@ -160,7 +160,7 @@
161161 if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' ) {
162162 return '<video poster="' + resource.poster + '" ' + attributes +
163163 ' type="video/ogg"></video>';
164 - }else if( resource.mime == 'audio/ogg' ){
 164+ }else if( resource.mime == 'audio/ogg' ) {
165165 return '<audio ' + attributes + ' type="audio/ogg" ></audio>';
166166 }
167167 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/metavidSearch.js
@@ -49,7 +49,7 @@
5050 $j.getJSON( url + '&cb=?&cb_inx=1', request, function( data ) {
5151 mw.log( 'mvSearch: got data response::' );
5252 var xmldata = ( data && data['pay_load'] ) ? mw.parseXML( data['pay_load'] ) : false;
53 - if( !xmldata ){
 53+ if( !xmldata ) {
5454 // XML Error or No results:
5555 _this.resultsObj = {};
5656 _this.loading = 0;
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/flickrSearch.js
@@ -97,7 +97,7 @@
9898 *
9999 * @param {Object} flickrResource Fliker response resource
100100 */
101 - getResourceObject: function( flickrResource ){
 101+ getResourceObject: function( flickrResource ) {
102102 var _this = this;
103103 var resource = {
104104 'titleKey' : flickrResource.title + '.jpg',
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js
@@ -36,7 +36,7 @@
3737 */
3838
3939 //Setup the addMediaWizard module
40 - mw.addModuleLoader( 'AddMedia.addMediaWizard', function( callback ){
 40+ mw.addModuleLoader( 'AddMedia.addMediaWizard', function( callback ) {
4141 // Load all the required libs:
4242 var request = [
4343 [ 'mw.RemoteSearchDriver',
@@ -75,7 +75,7 @@
7676 * Upload interface loader:
7777 */
7878
79 - mw.addModuleLoader( 'AddMedia.UploadHandler', function( callback ){
 79+ mw.addModuleLoader( 'AddMedia.UploadHandler', function( callback ) {
8080 mw.load( baseUploadlibs , function() {
8181 callback( 'AddMedia.BaseUploadHandler' );
8282 });
@@ -91,7 +91,7 @@
9292 var mwBaseFirefoggReq = baseUploadlibs.slice( 0 )
9393 mwBaseFirefoggReq[0].push('mw.Firefogg');
9494
95 - mw.addModuleLoader( 'AddMedia.firefogg', function( callback ){
 95+ mw.addModuleLoader( 'AddMedia.firefogg', function( callback ) {
9696
9797 //Load firefogg libs
9898 mw.load( mwBaseFirefoggReq, function() {
@@ -99,7 +99,7 @@
100100 });
101101 } );
102102
103 - mw.addModuleLoader( 'AddMedia.FirefoggGUI', function( callback ){
 103+ mw.addModuleLoader( 'AddMedia.FirefoggGUI', function( callback ) {
104104 // Clone the array:
105105 var request = mwBaseFirefoggReq.slice( 0 ) ;
106106
@@ -117,7 +117,7 @@
118118 });
119119 } );
120120
121 - mw.addModuleLoader( 'AddMedia.firefoggRender', function( callback ){
 121+ mw.addModuleLoader( 'AddMedia.firefoggRender', function( callback ) {
122122 mw.load( [
123123 'mw.UploadHandler',
124124 'mw.UploadInterface',
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js
@@ -18,8 +18,8 @@
1919 * Base UploadInterface object
2020 */
2121 mw.UploadInterface = {
22 - factory : function( interfaceType ){
23 - switch( interfaceType ){
 22+ factory : function( interfaceType ) {
 23+ switch( interfaceType ) {
2424 case 'iframe':
2525 return new mw.iframeInterface( );
2626 break;
@@ -43,7 +43,7 @@
4444 // we are currently only managing one, so this is okay... for now.
4545 uploadBeginTime: null,
4646
47 - setup: function( options ){
 47+ setup: function( options ) {
4848 var _this = this;
4949
5050 // Start the "upload" time
@@ -59,7 +59,7 @@
6060 $j( '<div />')
6161 .attr( 'id', "upProgressDialog" )
6262 );
63 - if( typeof options == 'undefined' || !options.title ){
 63+ if( typeof options == 'undefined' || !options.title ) {
6464 options.title = gM('mwe-upload-in-progress');
6565 }
6666 $j( '#upProgressDialog' ).dialog( {
@@ -168,7 +168,7 @@
169169 * Set the dialog to loading
170170 * @param optional loadingText text to set dialog to.
171171 */
172 - setLoading: function( loadingText ){
 172+ setLoading: function( loadingText ) {
173173 this.action_done = false;
174174 //Update the progress dialog (no bar without XHR request)
175175 $j( '#upProgressDialog' ).loadingSpinner();
@@ -206,7 +206,7 @@
207207 /**
208208 * Set the dialog to "done"
209209 */
210 - close: function(){
 210+ close: function() {
211211 this.action_done = true;
212212 $j( '#upProgressDialog' ).dialog( 'destroy' ).remove();
213213 },
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js
@@ -97,7 +97,7 @@
9898 /**
9999 * Setup firefogg jquery binding
100100 */
101 -( function( $ ){
 101+( function( $ ) {
102102 $.fn.firefogg = function( options ) {
103103 if ( !options )
104104 options = { };
@@ -121,20 +121,25 @@
122122 return this.init( options );
123123 };
124124 mw.Firefogg.prototype = { // extends mw.BaseUploadHandler
 125+ // Minnium version of firefogg allowed
125126 min_firefogg_version: '1.1.0',
126 - default_encoder_settings: { // NOTE: allow the server to set these
 127+
 128+ // The default encoder seetings
 129+ // NOTE: should be mw.getConfig based
 130+ default_encoder_settings: {
127131 'maxSize' : '400',
128132 'videoBitrate' : '544',
129133 'audioBitrate' : '96',
130134 'noUpscaling' : true
131135 },
132 - // lazy initialised, use getFirefogg()
 136+
 137+ // Lazy initialised, use getFirefogg()
133138 have_firefogg: null,
134139
135 - // lazy initialised, use getEncoderSettings()
 140+ // Lazy initialised, use getEncoderSettings()
136141 current_encoder_settings: null,
137142
138 - // lazy initialised, use getSourceFileInfo()
 143+ // Lazy initialised, use getSourceFileInfo()
139144 sourceFileInfo: null,
140145
141146 // Valid ogg extensions
@@ -299,7 +304,7 @@
300305
301306
302307 // Set up the click handler for the "save local file" button
303 - if( _this.target_btn_save_local_file ){
 308+ if( _this.target_btn_save_local_file ) {
304309 $j( _this.target_btn_save_local_file )
305310 .unbind()
306311 .click( function() {
@@ -311,7 +316,7 @@
312317 /**
313318 * Show the install firefogg msg
314319 */
315 - showInstallFirefog: function(){
 320+ showInstallFirefog: function() {
316321 var _this = this;
317322
318323 var upMsg = ( _this.form_type == 'upload' ) ?
@@ -329,7 +334,7 @@
330335 }
331336
332337 // Add the upload msg if we are "uploading"
333 - if ( _this.form_type == 'upload' ){
 338+ if ( _this.form_type == 'upload' ) {
334339 $j( _this.target_use_latest_firefox )
335340 .prepend( upMsg );
336341 }
@@ -341,7 +346,7 @@
342347
343348 // Otherwise show the "install Firefogg" message
344349 var firefoggUrl = _this.getFirefoggInstallUrl();
345 - if( firefoggUrl ){
 350+ if( firefoggUrl ) {
346351
347352 // Add the target please install in not present:
348353 if ( !this.target_please_install ) {
@@ -424,7 +429,7 @@
425430 // If uploading and firefogg is on show warning
426431 if ( this.form_type == 'upload'
427432 && typeof console != 'undefined'
428 - && console.firebug ){
 433+ && console.firebug ) {
429434 $j( this.selector ).after(
430435 $j( '<div />' )
431436 .addClass( 'ui-state-error ui-corner-all' )
@@ -474,7 +479,7 @@
475480
476481 // Set the initial button html:
477482 var buttonHtml = '';
478 - if( _this.show_preview == true ){
 483+ if( _this.show_preview == true ) {
479484 buttonHtml = $j.btnHtml( gM( 'fogg-hidepreview' ), 'fogg_preview', 'triangle-1-s' );
480485 } else {
481486 buttonHtml = $j.btnHtml( gM( 'fogg-preview' ), 'fogg_preview', 'triangle-1-e' );
@@ -553,7 +558,7 @@
554559
555560 function seekToEnd() {
556561 var v = $j( '#fogg_preview_vid' ).get( 0 );
557 - if( v ){
 562+ if( v ) {
558563 // Seek to near the end of the clip ( arbitrary -.4 seconds from end )
559564 v.currentTime = v.duration - 0.4;
560565 }
@@ -904,9 +909,9 @@
905910 var data = $j( this.form ).serializeArray();
906911 this.formData = {};
907912 for ( var i = 0; i < data.length; i++ ) {
908 - if ( data[i]['name'] ){
 913+ if ( data[i]['name'] ) {
909914 // Special case of upload.js commons hack:
910 - if( data[i]['name'] == 'wpUploadDescription' ){
 915+ if( data[i]['name'] == 'wpUploadDescription' ) {
911916 this.formData[ 'comment' ] = data[i]['value'];
912917 }else{
913918 this.formData[ data[i]['name'] ] = data[i]['value'];
@@ -940,10 +945,10 @@
941946 /**
942947 * Internal function called once the token and form data is avaliable
943948 */
944 - doUploadWithFormData: function(){
 949+ doUploadWithFormData: function() {
945950 var _this = this;
946951 // We can do a chunk upload
947 - if( _this.upload_mode == 'post' && _this.enable_chunks ){
 952+ if( _this.upload_mode == 'post' && _this.enable_chunks ) {
948953 _this.doChunkUpload();
949954 } else if ( _this.upload_mode == 'post' ) {
950955 // Encode and then do a post upload
@@ -997,7 +1002,7 @@
9981003 *
9991004 * @param {Object} options Options
10001005 */
1001 - getUploadApiRequest: function( options ){
 1006+ getUploadApiRequest: function( options ) {
10021007 var _this = this;
10031008 var request = {
10041009 'action': 'upload',
@@ -1005,19 +1010,19 @@
10061011 'filename': _this.formData['filename'],
10071012 'comment': _this.formData['comment']
10081013 };
1009 - if( options && options.enable_chunks == true ){
 1014+ if( options && options.enable_chunks == true ) {
10101015 request[ 'enablechunks' ] = 'true';
10111016 }
10121017
1013 - if ( _this.editToken ){
 1018+ if ( _this.editToken ) {
10141019 request['token'] = this.editToken;
10151020 }
10161021
1017 - if ( _this.formData['watch'] ){
 1022+ if ( _this.formData['watch'] ) {
10181023 request['watch'] = _this.formData['watch'];
10191024 }
10201025
1021 - if ( _this.formData['ignorewarnings'] ){
 1026+ if ( _this.formData['ignorewarnings'] ) {
10221027 request['ignorewarnings'] = _this.formData['ignorewarnings'];
10231028 }
10241029
@@ -1058,7 +1063,7 @@
10591064 var encoderSettings = this.getEncoderSettings();
10601065
10611066 // Check if encoderSettings passthrough is on ( then skip the encode )
1062 - if( encoderSettings['passthrough'] == true){
 1067+ if( encoderSettings['passthrough'] == true) {
10631068 // Firefogg requires an encode request to setup a the file to be uploaded.
10641069 _this.fogg.encode( JSON.stringify( { 'passthrough' : true } ) );
10651070 doneCallback();
@@ -1139,7 +1144,7 @@
11401145 }
11411146
11421147 //Check for success:
1143 - if( apiResult && _this.isApiSuccess( apiResult ) ){
 1148+ if( apiResult && _this.isApiSuccess( apiResult ) ) {
11441149 if( _this.processApiResult ( apiResult ) ) {
11451150 return true;
11461151 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js
@@ -43,7 +43,7 @@
4444 '<param value="opaque" name="wmode"/>'+
4545 '</object>'
4646 )
47 - setTimeout(function(){
 47+ setTimeout(function() {
4848 _this.postEmbedJS();
4949 }, 50);
5050 },
@@ -55,7 +55,7 @@
5656 var _this = this;
5757 this.getPlayerElement();
5858 //alert( this.playerElement );
59 - if( this.playerElement && this.playerElement.insertMedia){
 59+ if( this.playerElement && this.playerElement.insertMedia) {
6060 // Add KDP listeners
6161
6262 //this.playerElement.addJsListener("doPlay","kdpDoOnPlay");
@@ -79,7 +79,7 @@
8080 }else{
8181 // Keep trying to get the html:
8282 //mw.log('insert media: not defiend:' + typeof this.playerElement.insertMedia );
83 - setTimeout( function(){
 83+ setTimeout( function() {
8484 _this.postEmbedJS();
8585 }, 25);
8686 }
@@ -93,9 +93,9 @@
9494 * @param {String} flash binding name
9595 * @param {String} function callback name
9696 */
97 - bindPlayerFunction:function( bName, fName ){
 97+ bindPlayerFunction:function( bName, fName ) {
9898 var cbid = fName + '_cb_' + this.id.replace(' ', '_');
99 - eval( 'window[ \'' + cbid +'\' ] = function(){$j(\'#' + this.id + '\').get(0).'+ fName +'();}' );
 99+ eval( 'window[ \'' + cbid +'\' ] = function() {$j(\'#' + this.id + '\').get(0).'+ fName +'();}' );
100100 this.playerElement.addJsListener( bName , cbid);
101101 },
102102
@@ -103,7 +103,7 @@
104104 * on Pause callback from the kaltura flash player
105105 * calls parent_pause to update the interface
106106 */
107 - onPause:function(){
 107+ onPause:function() {
108108 this.parent_pause();
109109 },
110110
@@ -129,13 +129,13 @@
130130 /**
131131 * Issues a seek to the playerElement
132132 */
133 - doSeek:function( prec ){
 133+ doSeek:function( prec ) {
134134 var _this = this;
135 - if( this.playerElement ){
 135+ if( this.playerElement ) {
136136 var seek_time = prec * this.getDuration();
137137 this.playerElement.dispatchKdpEvent('doSeek', seek_time);
138138 // Kdp is missing seek done callback
139 - setTimeout(function(){
 139+ setTimeout(function() {
140140 _this.seeking= false;
141141 },500);
142142 }
@@ -154,7 +154,7 @@
155155 * Monitors playback updating the current Time
156156 */
157157 monitor:function() {
158 - if( this.playerElement && this.playerElement.getMediaSeekTime ){
 158+ if( this.playerElement && this.playerElement.getMediaSeekTime ) {
159159 this.currentTime = this.playerElement.getMediaSeekTime();
160160 }
161161 this.parent_monitor();
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -57,12 +57,12 @@
5858 *
5959 * NOTE: this function can be part of setup can run prior to jQuery being ready
6060 */
61 -mw.documentHasPlayerTags = function(){
 61+mw.documentHasPlayerTags = function() {
6262 var rewriteTags = mw.getConfig( 'rewritePlayerTags' );
63 - if( rewriteTags ){
 63+ if( rewriteTags ) {
6464 var jtags = rewriteTags.split( ',' );
6565 for ( var i = 0; i < jtags.length; i++ ) {
66 - if( document.getElementsByTagName( jtags[i] )[0] ){
 66+ if( document.getElementsByTagName( jtags[i] )[0] ) {
6767 return true;
6868 }
6969 }
@@ -76,10 +76,10 @@
7777 * We use mw.addDOMReadyHook instead of mw.ready so that
7878 * player interfaces are ready once mw.ready is called.
7979 */
80 -mw.addDOMReadyHook( function(){
 80+mw.addDOMReadyHook( function() {
8181 if( mw.documentHasPlayerTags() ) {
8282 // Add the setup hook since we have player tags
83 - mw.addSetupHook( function( callback ){
 83+ mw.addSetupHook( function( callback ) {
8484 // Load the embedPlayer module ( then run queued hooks )
8585 mw.load( 'EmbedPlayer', function ( ) {
8686 // Rewrite the rewritePlayerTags with the
@@ -98,7 +98,7 @@
9999 /**
100100 * Add the module loader function:
101101 */
102 -mw.addModuleLoader( 'EmbedPlayer', function( callback ){
 102+mw.addModuleLoader( 'EmbedPlayer', function( callback ) {
103103 var _this = this;
104104
105105 // Set module specific class videonojs to loading:
@@ -126,25 +126,25 @@
127127 var addTimedTextReqFlag = false;
128128
129129 // Merge in the timed text libs
130 - if( mw.getConfig( 'textInterface' ) == 'always' ){
 130+ if( mw.getConfig( 'textInterface' ) == 'always' ) {
131131 addTimedTextReqFlag = true;
132132 }
133133
134134 // Get the class of all embed video elements
135135 // to add the skin to the load request
136 - $j( mw.getConfig( 'rewritePlayerTags' ) ).each( function(){
 136+ $j( mw.getConfig( 'rewritePlayerTags' ) ).each( function() {
137137 var playerElement = this;
138138 var cName = $j( playerElement ).attr( 'class' );
139 - for( var n=0; n < mw.valid_skins.length ; n++ ){
 139+ for( var n=0; n < mw.valid_skins.length ; n++ ) {
140140 // Get any other skins that we need to load
141141 // That way skin js can be part of the single script-loader request:
142 - if( cName.indexOf( mw.valid_skins[ n ] ) !== -1){
 142+ if( cName.indexOf( mw.valid_skins[ n ] ) !== -1) {
143143 dependencyRequest[0].push( mw.valid_skins[n] + 'Config' );
144144 }
145145 }
146146 // If add timed text flag not already set check for itext, and sources
147 - if( !addTimedTextReqFlag ){
148 - if( $j( playerElement ).find( 'itext' ).length != 0 ){
 147+ if( !addTimedTextReqFlag ) {
 148+ if( $j( playerElement ).find( 'itext' ).length != 0 ) {
149149 // Has an itext child include timed text request
150150 addTimedTextReqFlag = true;
151151 // break out of the loop
@@ -162,23 +162,23 @@
163163 } );
164164
165165 // Add timed text items if flag set.
166 - if( addTimedTextReqFlag ){
 166+ if( addTimedTextReqFlag ) {
167167 dependencyRequest[0].push( 'mw.TimedText' )
168168 }
169169
170170 // Add PNG fix code needed:
171 - if ( $j.browser.msie || $j.browser.version < 7 ){
 171+ if ( $j.browser.msie || $j.browser.version < 7 ) {
172172 dependencyRequest[0].push( '$j.fn.pngFix' );
173173 }
174174
175175 // Do short detection, to avoid extra player library request in ~most~ cases.
176176 //( If browser is firefox include native, if browser is IE include java )
177 - if( $j.browser.msie ){
 177+ if( $j.browser.msie ) {
178178 dependencyRequest[0].push( 'javaEmbed' )
179179 }
180180
181181 // Safari gets slower load since we have to detect ogg support
182 - if( typeof HTMLVideoElement == 'object' && !$j.browser.safari ){
 182+ if( typeof HTMLVideoElement == 'object' && !$j.browser.safari ) {
183183 dependencyRequest[0].push( 'nativeEmbed' )
184184 }
185185
@@ -186,7 +186,7 @@
187187 // Load the video libs:
188188 mw.load( dependencyRequest, function() {
189189 // Setup userConfig
190 - mw.setupUserConfig( function(){
 190+ mw.setupUserConfig( function() {
191191 // Remove no video html elements:
192192 $j( '.videonojs' ).remove();
193193
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/omtkEmbed.js
@@ -34,7 +34,7 @@
3535 '</object>'
3636 )
3737 // omtk needs to fire an onReady event.
38 - setTimeout( function(){
 38+ setTimeout( function() {
3939 _this.postEmbedJS();
4040 }, 2000 );
4141 return embed_code;
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -148,9 +148,6 @@
149149 // If serving an ogg_chop segment use this to offset the presentation time
150150 // ( for some plugins that use ogg page time rather than presentation time )
151151 "startOffset" : 0,
152 -
153 - //If we should display the play button
154 - "play_button" : true,
155152
156153 // Thumbnail (same as poster)
157154 "thumbnail" : null,
@@ -227,7 +224,7 @@
228225 * @param {Object} attributes Attributes to apply to embed players
229226 * @param {Function} callback Function to call once embeding is done
230227 */
231 - $.embedPlayers = function( attributes, callback){
 228+ $.embedPlayers = function( attributes, callback) {
232229 $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer( attributes, callback );
233230 }
234231
@@ -245,7 +242,7 @@
246243 * @param [ Optional ] {Function} callback Function to be called once video interfaces are ready
247244 *
248245 */
249 - $.fn.embedPlayer = function( attributes, callback ){
 246+ $.fn.embedPlayer = function( attributes, callback ) {
250247 mw.log('fn:embedPlayer on: ' + this.selector);
251248 var player_select = this.selector;
252249 //Handle optional include of attributes argument:
@@ -262,16 +259,16 @@
263260
264261 // IE not working well with jQuery selector on "VIDEO", "AUDIO" etc.
265262 var ie_safe_selector = coma = '';
266 - if( $j.browser.msie ){
 263+ if( $j.browser.msie ) {
267264 var selectors = player_select.split(',');
268 - for( var i=0; i < selectors.length; i++){
 265+ for( var i=0; i < selectors.length; i++ ) {
269266 if( selectors[i] == 'video' ||
270267 selectors[i] == 'playlist' ||
271268 selectors[i] == 'audio'
272 - ){
273 - $j( document.getElementsByTagName( selectors[i] )).each(function(){
274 - mw.playerManager.addElement(this, attributes );
275 - });
 269+ ) {
 270+ $j( document.getElementsByTagName( selectors[ i ] )).each( function( ) {
 271+ mw.playerManager.addElement( this, attributes );
 272+ } );
276273 }else{
277274 ie_safe_selector += coma + selectors[i];
278275 coma = ',';
@@ -279,9 +276,9 @@
280277 }
281278 player_select = ie_safe_selector;
282279 }
283 - if( player_select != ''){
 280+ if( player_select != '') {
284281 // Add each selected element to the player manager:
285 - $j( player_select ).each( function(na, playerElement){
 282+ $j( player_select ).each( function(na, playerElement) {
286283 mw.playerManager.addElement( playerElement, attributes);
287284 } );
288285 }
@@ -326,7 +323,7 @@
327324 /**
328325 * get the list of players
329326 */
330 - getPlayerList: function( ){
 327+ getPlayerList: function( ) {
331328 return this.playerList;
332329 },
333330
@@ -340,7 +337,9 @@
341338 * @param {Object} [Optional] attributes Extra attributes to apply to the player interface
342339 */
343340 addElement: function( element, attributes ) {
344 - var _this = this;
 341+ var _this = this;
 342+
 343+ // Assign id if unset
345344 var element_id = $j( element ).attr( "id" );
346345 if ( element_id == '' ) {
347346 element_id = 'v' + this.playerList.length;
@@ -352,43 +351,19 @@
353352 // Add the element id to playerList
354353 this.playerList.push( element_id );
355354
356 - // Check for class based player skin ( could have been loaded before in 'EmbedPlayer' loader module )
 355+ // Check for class based player skin
357356 var skinClassRequest = [ ];
358357 var className = $j( element ).attr( 'class' );
359 - for( var n=0; n < mw.valid_skins.length ; n++ ){
360 - if( className && className.indexOf( mw.valid_skins[ n ] ) !== -1){
 358+ for( var n=0; n < mw.valid_skins.length ; n++ ) {
 359+ if( className && className.indexOf( mw.valid_skins[ n ] ) !== -1) {
361360 skinClassRequest.push( mw.valid_skins[n] + 'Config' );
362361 }
363 - }
364 -
365 - // Firefox gives 300x150 css values OR -1 if video has not loaded metadata yet:
366 - // We check that and delay swapping in the player interface
367 - var waitForMeta = (
368 - (
369 - (
370 - $j(element).attr('width') == -1 &&
371 - $j(element).attr('height') == -1
372 - )
373 - ||
374 - // Google Chrome gives 0 width height for unloaded media
375 - (
376 - $j(element).attr('width') == 0 &&
377 - $j(element).attr('height') == 0
378 - )
379 - ||
380 - // Strange firefox default width height ( should wait for "real" metadata )
381 - ( this.height == 150 && this.width == 300 )
382 - )
383 - &&
384 - // If media has video/audio "sources" wait for meta:
385 - (
386 - $j(element).attr('src') ||
387 - $j(element).find("source[src]").filter('[type^=video],[type^=audio]').length != 0
388 - )
389 - ) ? true : false;
 362+ }
390363
391364 // Load any skins we need then swap in the interface
392 - mw.load( skinClassRequest, function(){
 365+ mw.load( skinClassRequest, function() {
 366+ var waitForMeta = _this.waitForMetaCheck( element );
 367+
393368 switch( element.tagName.toLowerCase() ) {
394369 case 'playlist':
395370 // Make sure we have the necessary playlist libs loaded:
@@ -411,7 +386,7 @@
412387 var ranPlayerSwapFlag = false;
413388
414389 // Local callback to runPlayer swap once element has metadata
415 - function runPlayerSwap(){
 390+ function runPlayerSwap() {
416391 if( ranPlayerSwapFlag )
417392 return ;
418393 mw.log("runPlayerSwap::" + $j( element ).attr('id') );
@@ -422,8 +397,8 @@
423398 $j( '#' + $j( element ).attr('id') ).get(0).checkPlayerSources();
424399 }
425400
426 - if( waitForMeta ){
427 - mw.log(" WaitForMeta ( video missing height, width or duration )" );
 401+ if( waitForMeta ) {
 402+ mw.log(' WaitForMeta ( video missing height (' + $j( element ).attr('height') + '), width (' + $j( element ).attr('width') + ') or duration' );
428403 element.removeEventListener( "loadedmetadata", runPlayerSwap, true );
429404 element.addEventListener( "loadedmetadata", runPlayerSwap, true );
430405 // Time-out of 5 seconds ( maybe still playable but no timely metadata )
@@ -436,6 +411,54 @@
437412 });
438413 },
439414
 415+ /**
 416+ * Check for bogus resolutions of the media asset that has not loaded.
 417+ * @return
 418+ * true if the resolution is "likely" to be updated
 419+ * by waiting for metadata
 420+ * false if the resolution has been set via an attribute or is already loaded
 421+ */
 422+ waitForMetaCheck: function( element ){
 423+ var waitForMeta = false;
 424+ var width = $j( element ).css( 'width' );
 425+ var height = $j( element ).css( 'height' );
 426+
 427+ // Css video defaults:
 428+ if( $j( element ).css( 'width' ) == '300px'
 429+ && $j( element ).css( 'height' ) == '150px'
 430+ ){
 431+ waitForMeta = true;
 432+ }else{
 433+ // css width height attribute has been set on the element return false
 434+ return false;
 435+ }
 436+ //Firefox ~ sometimes ~ gives -1 for unloaded media
 437+ if ( $j(element).attr('width') == -1 || $j(element).attr('height') == -1 ){
 438+ waitForMeta = true;
 439+ }
 440+ // Google Chrome / safari gives 0 width height for unloaded media
 441+ if( $j(element).attr('width') == 0 || $j(element).attr('height') == 0 ){
 442+ waitForMeta = true;
 443+ }
 444+ // Firefox default width height is ~sometimes~ 150 / 300
 445+ if( this.height == 150 && this.width == 300 ){
 446+ waitForMeta = true;
 447+ }
 448+ // Make sure we have a src attribute or source child
 449+ // ( i.e not a video tag to be dynamically populated or looked up from xml resource description )
 450+ if( waitForMeta
 451+ && (
 452+ $j(element).attr('src') ||
 453+ $j(element).find("source[src]").filter('[type^=video],[type^=audio]').length != 0
 454+ )
 455+ ){
 456+ return true;
 457+ }
 458+
 459+ // Element is not likely to update its resolution:
 460+ return false;
 461+ },
 462+
440463 /**
441464 * swapEmbedPlayerElement
442465 *
@@ -493,7 +516,7 @@
494517 }
495518 } else {
496519 // Continue checking the playerList
497 - setTimeout( function(){
 520+ setTimeout( function() {
498521 _this.waitPlayersReadyCallback();
499522 }, 10 );
500523 }
@@ -576,9 +599,9 @@
577600 }
578601 }
579602
580 - if ( $j( element ).attr( 'type' ) ){
 603+ if ( $j( element ).attr( 'type' ) ) {
581604 this.mime_type = $j( element ).attr( 'type' );
582 - }else if ( $j( element ).attr( 'content-type' ) ){
 605+ }else if ( $j( element ).attr( 'content-type' ) ) {
583606 this.mime_type = $j( element ).attr( 'content-type' );
584607 }else{
585608 this.mime_type = this.detectType( this.src );
@@ -586,7 +609,7 @@
587610
588611
589612 // Check for parent elements ( supplies categories in "itext" )
590 - if( $j( element ).parent().attr('category') ){
 613+ if( $j( element ).parent().attr('category') ) {
591614 this.category = $j( element ).parent().attr('category');
592615 }
593616
@@ -615,11 +638,11 @@
616639 // if we have time we can use:
617640 if ( this.URLTimeEncoding ) {
618641 // make sure its a valid start time / end time (else set default)
619 - if ( !mw.npt2seconds( start_npt ) ){
 642+ if ( !mw.npt2seconds( start_npt ) ) {
620643 start_npt = this.start_npt;
621644 }
622645
623 - if ( !mw.npt2seconds( end_npt ) ){
 646+ if ( !mw.npt2seconds( end_npt ) ) {
624647 end_npt = this.end_npt;
625648 }
626649
@@ -681,7 +704,7 @@
682705 return this.title;
683706
684707 // Return a Title based on mime type:
685 - switch( this.mime_type ){
 708+ switch( this.mime_type ) {
686709 case 'video/h264' :
687710 return gM( 'mwe-video-h264' );
688711 break;
@@ -785,7 +808,7 @@
786809 * @param {element} video_element <video> element used for initialization.
787810 * @constructor
788811 */
789 -function mediaElement( element ){
 812+function mediaElement( element ) {
790813 this.init( element );
791814 };
792815
@@ -842,7 +865,7 @@
843866 this.thumbnail = mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg' ;
844867
845868 // Process the video_element as a source element:
846 - if ( $j( video_element ).attr( "src" ) ){
 869+ if ( $j( video_element ).attr( "src" ) ) {
847870 this.tryAddSource( video_element );
848871 }
849872
@@ -889,7 +912,7 @@
890913 * @return mediaSource elements.
891914 * @type Array
892915 */
893 - getSources: function( mime_filter ){
 916+ getSources: function( mime_filter ) {
894917 if ( !mime_filter )
895918 return this.sources;
896919 // apply mime filter:
@@ -993,7 +1016,7 @@
9941017 }
9951018 }
9961019 // Select first source
997 - if ( !this.selected_source ){
 1020+ if ( !this.selected_source ) {
9981021 mw.log( 'set via first source:' + playable_sources[0] );
9991022 this.selected_source = playable_sources[0];
10001023 return true;
@@ -1028,7 +1051,7 @@
10291052 /**
10301053 * Checks if media is a playable type
10311054 */
1032 - isPlayableType:function( mime_type ){
 1055+ isPlayableType:function( mime_type ) {
10331056 if ( mw.EmbedTypes.players.defaultPlayer( mime_type ) ) {
10341057 return true;
10351058 } else {
@@ -1191,7 +1214,7 @@
11921215
11931216 // Setup the player Interface from supported attributes:
11941217 for ( var attr in default_video_attributes ) {
1195 - if ( customAttributes[ attr ] ){
 1218+ if ( customAttributes[ attr ] ) {
11961219 this[ attr ] = customAttributes[ attr ];
11971220 } else if ( element.getAttribute( attr ) ) {
11981221 this[ attr ] = element.getAttribute( attr );
@@ -1214,7 +1237,7 @@
12151238 }
12161239
12171240 // Set the default skin if unset:
1218 - if ( !this.skinName ){
 1241+ if ( !this.skinName ) {
12191242 this.skinName = mw.getConfig( 'skinName' );
12201243 }
12211244
@@ -1250,11 +1273,11 @@
12511274
12521275 // Setup the local "ROE" src pointer if added as media source
12531276 // also see: http://dev.w3.org/html5/spec/Overview.html#the-source-element
1254 - $j.each(this.mediaElement.getSources( 'text/xml'), function( inx, source ){
1255 - if( source.codecs ){
 1277+ $j.each(this.mediaElement.getSources( 'text/xml'), function( inx, source ) {
 1278+ if( source.codecs ) {
12561279 var codec_set = source.codecs.split(',');
1257 - for( var i = 0; i < codec_set.length; i++ ){
1258 - if( codec_set[i] == 'roe' ){
 1280+ for( var i = 0; i < codec_set.length; i++ ) {
 1281+ if( codec_set[i] == 'roe' ) {
12591282 _this.roe = source.src;
12601283 }
12611284 }
@@ -1274,23 +1297,23 @@
12751298 *
12761299 * @param {Element} element Source element to grab size from
12771300 */
1278 - setPlayerSize:function( element ){
 1301+ setPlayerSize: function( element ) {
12791302 this['height'] = parseInt( $j(element).css( 'height' ).replace( 'px' , '' ) );
12801303 this['width'] = parseInt( $j(element).css( 'width' ).replace( 'px' , '' ) );
12811304
1282 - if( !this['height'] && !this['width'] ){
 1305+ if( !this['height'] && !this['width'] ) {
12831306 this['height'] = parseInt( $j(element).attr( 'height' ) );
12841307 this['width'] = parseInt( $j(element).attr( 'width' ) );
12851308 }
12861309
12871310 // Use default aspect ration to get height or width ( if rewriting a non-audio player )
1288 - if( element.tagName.toLowerCase() != 'audio' ){
1289 - if( this['height'] && !this['width'] && this.videoAspect ){
 1311+ if( element.tagName.toLowerCase() != 'audio' ) {
 1312+ if( this['height'] && !this['width'] && this.videoAspect ) {
12901313 var aspect = this.videoAspect.split( ':' );
12911314 this['width'] = parseInt( this.height * ( aspect[0] / aspect[1] ) );
12921315 }
12931316
1294 - if( this['width'] && !this['height'] && this.videoAspect ){
 1317+ if( this['width'] && !this['height'] && this.videoAspect ) {
12951318 var aspect = this.videoAspect.split( ':' );
12961319 this['height'] = parseInt( this.width * ( aspect[1] / aspect[0] ) );
12971320 }
@@ -1305,11 +1328,11 @@
13061329 // Check for firefox defaults
13071330 // Note: ideally firefox would not do random guesses at css values
13081331 ( (this.height == 150 || this.height == 64 ) && this.width == 300 )
1309 - ){
 1332+ ) {
13101333 var defaultSize = mw.getConfig( 'video_size' ).split( 'x' );
13111334 this['width'] = defaultSize[0];
13121335 // Special height default for audio tag ( if not set )
1313 - if( element.tagName.toLowerCase() == 'audio' ){
 1336+ if( element.tagName.toLowerCase() == 'audio' ) {
13141337 this['height'] = 0;
13151338 }else{
13161339 this['height'] = defaultSize[1];
@@ -1323,7 +1346,7 @@
13241347 *
13251348 * @return {Number} pixle height of the video
13261349 */
1327 - getPlayerWidth: function(){
 1350+ getPlayerWidth: function() {
13281351 return parseInt( this.width );
13291352 },
13301353
@@ -1332,7 +1355,7 @@
13331356 *
13341357 * @return {Number} pixle height of the video
13351358 */
1336 - getPlayerHeight: function(){
 1359+ getPlayerHeight: function() {
13371360 return parseInt( this.height );
13381361 },
13391362
@@ -1349,7 +1372,7 @@
13501373 if ( this.roe && this.mediaElement.getPlayableSources().length == 0 ) {
13511374 mw.log( 'checkPlayerSources: loading external data' );
13521375 this.loading_external_data = true;
1353 - this.getMvJsonUrl( this.roe, function( data ){
 1376+ this.getMvJsonUrl( this.roe, function( data ) {
13541377 // Continue
13551378 _this.mediaElement.addROE( data );
13561379 mw.log( 'added_roe::' + _this.mediaElement.sources.length );
@@ -1372,8 +1395,8 @@
13731396 *
13741397 * @param roe_url to be updated
13751398 */
1376 - getMvJsonUrl : function( roe_url , callback){
1377 - if ( mw.isLocalDomain( roe_url ) ){
 1399+ getMvJsonUrl : function( roe_url , callback) {
 1400+ if ( mw.isLocalDomain( roe_url ) ) {
13781401 $j.get( roe_url, callback );
13791402 } else {
13801403 roe_url = mw.replaceUrlParams(roe_url, {
@@ -1390,10 +1413,10 @@
13911414 *
13921415 * Note we check for text sources outside of
13931416 */
1394 - isTimedTextSupported: function(){
 1417+ isTimedTextSupported: function() {
13951418 // Check for timed text sources or api/ roe url
13961419 if ( ( this.roe || this.apiTitleKey ||
1397 - this.mediaElement.textSourceExists() ) ){
 1420+ this.mediaElement.textSourceExists() ) ) {
13981421 return true;
13991422 } else {
14001423 return false;
@@ -1406,12 +1429,12 @@
14071430 *
14081431 * @param {Function} callback Function to call once timed text check is done
14091432 */
1410 - checkForTimedText: function( ){
 1433+ checkForTimedText: function( ) {
14111434 var _this = this;
14121435 mw.log( 'checkForTimedText: ' + this.id );
14131436 // Check for timedText support
1414 - if( this.isTimedTextSupported() ){
1415 - mw.load( 'TimedText', function(){
 1437+ if( this.isTimedTextSupported() ) {
 1438+ mw.load( 'TimedText', function() {
14161439 $j( '#' + _this.id ).timedText();
14171440 _this.setupSourcePlayer();
14181441 });
@@ -1428,12 +1451,12 @@
14291452 *
14301453 * Sets load error if no source is playable
14311454 */
1432 - setupSourcePlayer: function(){
 1455+ setupSourcePlayer: function() {
14331456 mw.log("setupSourcePlayer: " + this.id );
14341457 // Autoseletct the media source
14351458 this.mediaElement.autoSelectSource();
14361459 // Auto select player based on default order
1437 - if ( !this.mediaElement.selected_source ){
 1460+ if ( !this.mediaElement.selected_source ) {
14381461 // check for parent clip:
14391462 if ( typeof this.pc != 'undefined' ) {
14401463 mw.log( 'no sources, type:' + this.type + ' check for html' );
@@ -1499,7 +1522,7 @@
15001523 var playerInterface = window[ _this.selected_player.library + 'Embed' ];
15011524
15021525 for ( var method in playerInterface ) {
1503 - if ( _this[method] && !_this['parent_' + method] ){
 1526+ if ( _this[method] && !_this['parent_' + method] ) {
15041527 _this['parent_' + method] = _this[method];
15051528 }
15061529 _this[ method ] = playerInterface[method];
@@ -1524,7 +1547,7 @@
15251548 var _this = this;
15261549 if ( this.selected_player.id != player.id ) {
15271550 this.selected_player = player;
1528 - this.inheritEmbedPlayer( function(){
 1551+ this.inheritEmbedPlayer( function() {
15291552 // Update the controls for the new selected player
15301553 _this.refreshControls();
15311554 });
@@ -1536,8 +1559,8 @@
15371560 *
15381561 * @return start_npt and end_npt time if present
15391562 */
1540 - getTimeRange: function(){
1541 - var end_time = (this.ctrlBuilder.long_time_disp)? '/' + mw.seconds2npt( this.getDuration() ) : '';
 1563+ getTimeRange: function() {
 1564+ var end_time = (this.ctrlBuilder.longTimeDisp)? '/' + mw.seconds2npt( this.getDuration() ) : '';
15421565 var default_time_range = '0:00:00' + end_time;
15431566 if ( !this.mediaElement )
15441567 return default_time_range;
@@ -1590,7 +1613,7 @@
15911614 this.updatePlayHead( percent );
15921615 }
15931616 // Do play request in 100ms ( give the dom time to swap out the embed player )
1594 - setTimeout( function(){
 1617+ setTimeout( function() {
15951618 _this.play()
15961619 }, 100 );
15971620 },
@@ -1716,14 +1739,14 @@
17171740 this.thumbnail_disp = true;
17181741
17191742 // make sure we are not in preview mode( no end clip actions in preview mode)
1720 - if ( this.preview_mode ){
 1743+ if ( this.preview_mode ) {
17211744 return ;
17221745 }
17231746
17241747 // Call the ctrlBuilder end event::
17251748
17261749 //if kalturaAttribution and k-skin show the "credits" screen:
1727 - if( this.ctrlBuilder.showCredits ){
 1750+ if( this.ctrlBuilder.showCredits ) {
17281751 this.ctrlBuilder.showCredits();
17291752 return ;
17301753 }
@@ -1785,7 +1808,7 @@
17861809 )
17871810 // now load roe if run the showNextPrevLinks
17881811 if ( this.roe && this.mediaElement.addedROEData == false ) {
1789 - this.getMvJsonUrl( this.roe, function( data ){
 1812+ this.getMvJsonUrl( this.roe, function( data ) {
17901813 _this.mediaElement.addROE( data );
17911814 _this.getNextPrevLinks();
17921815 } );
@@ -1945,7 +1968,7 @@
19461969 .html( html )
19471970 //Do bindings:
19481971 .children( '.playtimerequest' )
1949 - .click( function(){
 1972+ .click( function() {
19501973 _this.stop();
19511974 _this.updateVideoTimeReq( time_req );
19521975 _this.play();
@@ -1990,7 +2013,7 @@
19912014
19922015 var _this = this;
19932016 //make sure we have interface_wrap
1994 - if( $j( this ).parent('.interface_wrap').length == 0 ){
 2017+ if( $j( this ).parent('.interface_wrap').length == 0 ) {
19952018 // Select "player"
19962019 $j( this )
19972020 .wrap(
@@ -2244,7 +2267,7 @@
22452268 })
22462269 );
22472270
2248 - if ( this.play_button == true && this.controls == true ){
 2271+ if ( this.controls == true ) {
22492272 $thumb.append(
22502273 this.ctrlBuilder.getComponent( 'playButtonLarge' )
22512274 );
@@ -2293,19 +2316,6 @@
22942317 },
22952318
22962319 /**
2297 - * Display the options div
2298 - * NOTE: should move to skins "showShare" , "showTextInterface" etc.
2299 - */
2300 - doOptionsHTML:function() {
2301 - var pos = this.$interface.find( '.options-btn' ).offset();
2302 - pos['top'] = pos['top'] + 24;
2303 - pos['left'] = pos['left'] -124;
2304 - // mw.log('pos of options button: t:'+pos['top']+' l:'+ pos['left']);
2305 - $j( '#mv_vid_options_' + this.id ).css( pos ).toggle();
2306 - return;
2307 - },
2308 -
2309 - /**
23102320 * Follows a linkback. Loads the ROE xml if no linkback is found
23112321 */
23122322 doLinkBack: function() {
@@ -2326,72 +2336,7 @@
23272337 }
23282338 }
23292339 },
2330 -
2331 - /**
2332 - * Show the "share" msg
2333 - *
2334 - * TODO share should be enabled via <embed> tag usage to be compatible
2335 - * with sites social networking sites that allow <embed> tags but not js
2336 - *
2337 - * @param {Object} $target Target jQuery object to set share html
2338 - */
2339 - showShare:function( $target ) {
2340 - var embed_code = this.getEmbeddingHTML();
2341 - var _this = this;
2342 - $target.empty();
2343 - $shareList = $j( '<ul />' );
23442340
2345 - $shareList
2346 - .append(
2347 - $j('<li />')
2348 - .append(
2349 - $j('<a />')
2350 - .attr('href', '#')
2351 - .addClass( 'active' )
2352 - .text(
2353 - gM( 'mwe-embed_site_or_blog' )
2354 - )
2355 - )
2356 - )
2357 -
2358 - $target.append(
2359 - $j( '<h2 />' )
2360 - .text( gM( 'mwe-share_this_video' ) )
2361 - .append(
2362 - $shareList
2363 - )
2364 - );
2365 -
2366 - $target.append(
2367 - $j('<div />')
2368 - .addClass( 'source_wrap' )
2369 - .html(
2370 - $j( '<textarea />' )
2371 - .html( embed_code )
2372 - .click( function() {
2373 - $j( this ).select();
2374 - })
2375 - ),
2376 -
2377 - $j('<button />')
2378 - .addClass( 'ui-state-default ui-corner-all copycode' )
2379 - .text( gM( 'mwe-copy-code' ) )
2380 - .click(function() {
2381 - $target.find( 'textarea' ).focus().select();
2382 - // Copy the text if supported:
2383 - if ( document.selection ) {
2384 - CopiedTxt = document.selection.createRange();
2385 - CopiedTxt.execCommand( "Copy" );
2386 - }
2387 - } ),
2388 -
2389 - $j('<div />')
2390 - .addClass( "ui-state-highlight ui-corner-all" )
2391 - .html(
2392 - gM( 'mwe-read_before_embed' )
2393 - )
2394 - );
2395 - },
23962341
23972342 /**
23982343 * Loads the text interface library and show the text interface near the player.
@@ -2428,7 +2373,7 @@
24292374 } ).hide()
24302375 );
24312376 // Load text interface ( if not already loaded )
2432 - mw.load( 'TimedText', function(){
 2377+ mw.load( 'TimedText', function() {
24332378 $j( '#' + _this.id ).timedText( 'showMenu', '#timedTextMenu_' + _this.id );
24342379 });
24352380 }
@@ -2443,235 +2388,9 @@
24442389 this.textInterface.close();
24452390 }
24462391 },
2447 -
2448 - /**
2449 - * Generic function to display custom HTML inside the mwEmbedPlayer
2450 - * Should call the closeDisplayedHTML function to close the
2451 - * display of the custom HTML and restore the regular player display.
2452 - *
2453 - * NOTE: this should be moved to the ctrlBuilder
2454 - *
2455 - * @param {String} html_code code for the selection list.
2456 - */
2457 - displayOverlay: function( html_code ) {
2458 - var _this = this;
24592392
2460 - if ( !this.supports['overlays'] ){
2461 - this.stop();
2462 - }
24632393
2464 -
2465 - // Put select list on-top
2466 - // make sure the parent is relatively positioned:
2467 - $j( '#' + this.id ).css( 'position', 'relative' );
2468 -
2469 -
2470 - var fade_in = true;
2471 - if ( $j( '#blackbg_' + this.id ).length != 0 ){
2472 - fade_in = false;
2473 - $j( '#blackbg_' + this.id ).remove();
2474 - }
2475 - $closeButton = $j('<span />')
2476 - .text( gM('mwe-close_btn') )
2477 - .css({
2478 - 'float' : 'right',
2479 - 'color' : '#FFF',
2480 - 'cursor' : 'pointer',
2481 - 'background' : '#111',
2482 - 'margin-right': '10px',
2483 - 'text-decoration' : 'underline'
2484 - })
2485 - .click(function(){
2486 - _this.ctrlBuilder.closeMenuOverlay();
2487 - })
2488 -
2489 -
2490 - $overlayMenu = $j('<div />')
2491 - .attr({
2492 - 'id' : 'blackbg_' + this.id
2493 - })
2494 - .addClass( 'videoComplete' )
2495 - .css({
2496 - 'height' : this.ctrlBuilder.getOverlayHeight(),
2497 - 'width' : this.ctrlBuilder.getOverlayWidth()
2498 - })
2499 - .append(
2500 - $closeButton,
2501 - $j('<div />')
2502 - .addClass('videoOptionsComplete')
2503 - )
2504 - this.$interface.prepend( $overlayMenu );
2505 - if ( fade_in )
2506 - $j( '#blackbg_' + this.id ).fadeIn( "slow" );
2507 - else
2508 - $j( '#blackbg_' + this.id ).show();
2509 - return false; // onclick action return false
2510 - },
2511 -
25122394 /**
2513 - * Shows the Player Select interface
2514 - *
2515 - * NOTE: this should be switched over to jQuery style DOM construction
2516 - *
2517 - * @param {Object} $target jQuery target for output
2518 - */
2519 - showPlayerSelect: function( $target ) {
2520 - mw.log('showPlayerSelect');
2521 - if( ! $target ){
2522 - $target = this.$interface.find( '.videoOptionsComplete' )
2523 - }
2524 - // Get id (in case where we have a parent container)
2525 - var _this = this;
2526 -
2527 - $target
2528 - .empty()
2529 - .append(
2530 - $j( '<h2 />' )
2531 - .text( gM( 'mwe-chose_player' ) )
2532 - );
2533 -
2534 - var _this = this;
2535 - $j.each( this.mediaElement.getPlayableSources(), function( source_id, source ) {
2536 - var playable = mw.EmbedTypes.players.defaultPlayer( source.getMIMEType() );
2537 -
2538 - var is_selected = ( source == _this.mediaElement.selected_source );
2539 -
2540 - $target.append(
2541 - $j( '<h2 />' )
2542 - .text( source.getTitle() )
2543 - );
2544 -
2545 - if ( playable ) {
2546 - $playerList = $j('<ul />');
2547 - // output the player select code:
2548 - var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
2549 -
2550 - for ( var i = 0; i < supporting_players.length ; i++ ) {
2551 - var $playerLink = $j( '<a />')
2552 - .attr({
2553 - 'href' : '#',
2554 - 'rel' : 'sel_source',
2555 - 'id' : 'sc_' + source_id + '_' + supporting_players[i].id
2556 - })
2557 - .text( supporting_players[i].getName() );
2558 -
2559 - if ( _this.selected_player.id == supporting_players[i].id && is_selected ) {
2560 - $playerLink
2561 - .addClass('active' );
2562 - }
2563 - $playerList.append(
2564 - $j( '<li />' ).append(
2565 - $playerLink
2566 - )
2567 - );
2568 - }
2569 -
2570 - // Append the player list:
2571 - $target.append( $playerList );
2572 -
2573 - } else {
2574 - // No player avaliable:
2575 - $target.append( gM( 'mwe-no-player', source.getTitle() ) )
2576 - }
2577 - } );
2578 -
2579 - // Set up the click bindings:
2580 - $target.find( "[rel='sel_source']" ).each( function() {
2581 - $j( this ).click( function() {
2582 - var iparts = $j( this ).attr( 'id' ).replace(/sc_/ , '' ).split( '_' );
2583 - var source_id = iparts[0];
2584 - var default_player_id = iparts[1];
2585 - mw.log( 'source id: ' + source_id + ' player id: ' + default_player_id );
2586 -
2587 - _this.ctrlBuilder.closeMenuOverlay();
2588 - _this.mediaElement.selectSource( source_id );
2589 -
2590 - mw.EmbedTypes.players.setPlayerPreference( default_player_id,
2591 - _this.mediaElement.sources[ source_id ].getMIMEType() );
2592 -
2593 - // Issue a stop
2594 - _this.stop();
2595 -
2596 - // Don't follow the empty # link:
2597 - return false;
2598 - } );
2599 - } );
2600 - },
2601 -
2602 - /**
2603 - * Loads sources and calls showDownloadWithSources
2604 - * @param {Object} $target jQuery target to output to
2605 - */
2606 - showDownload:function( $target ) {
2607 - var _this = this;
2608 - // Load the roe if available (to populate out download options:
2609 - // mw.log('f:showDownload '+ this.roe + ' ' + this.mediaElement.addedROEData);
2610 - if ( this.roe && this.mediaElement.addedROEData == false ) {
2611 - var _this = this;
2612 - $target.html( gM( 'loading_txt' ) );
2613 - this.getMvJsonUrl( this.roe, function( data ) {
2614 - _this.mediaElement.addROE( data );
2615 - _this.showDownloadWithSources( $target );
2616 - } );
2617 - } else {
2618 - _this.showDownloadWithSources( $target );
2619 - }
2620 - },
2621 -
2622 - /**
2623 - * Shows the download interface with sources loaded
2624 - * @param {Object} $target jQuery target to output to
2625 - */
2626 - showDownloadWithSources : function( $target ) {
2627 - var _this = this;
2628 - $target.empty().append(
2629 - $j('<div />')
2630 - .css({
2631 - "color":"white"
2632 - })
2633 - );
2634 - var $mediaList = $j( '<ul />' );
2635 - var $textList = $j( '<ul />' );
2636 - $j.each( _this.mediaElement.getSources(), function( index, source ) {
2637 - if( source.getSrc() ){
2638 - var $dl_line = $j( '<li />').append(
2639 - $j('<a />').
2640 - css({
2641 - "color" : "white"
2642 - })
2643 - .attr( 'href', source.getSrc())
2644 - .text( source.getTitle() )
2645 - );
2646 - //Add link to time segment:
2647 - if ( source.getSrc().indexOf( '?t=' ) !== -1 ) {
2648 - $target.append( $dl_line );
2649 - } else if ( this.getMIMEType() == "text/cmml" || this.getMIMEType() == "text/x-srt" ) {
2650 - // Add link to text list
2651 - $textList.append( $dl_line );
2652 - } else {
2653 - // Add link to media list
2654 - $mediaList.append( $dl_line );
2655 - }
2656 -
2657 - }
2658 - } );
2659 - if( $mediaList.find('li').length != 0 ){
2660 - $target.append(
2661 - $j('<h2 />')
2662 - .text( gM( 'mwe-download_full' ) ),
2663 - $mediaList
2664 - )
2665 - }
2666 -
2667 - if( $textList.find('li').length != 0 ){
2668 - $target.append(
2669 - $j('<h2 />')
2670 - .text( gM( 'mwe-download_text' ) ),
2671 - $textList
2672 - )
2673 - }
2674 - },
2675 - /**
26762395 * Base Embed Controls
26772396 */
26782397
@@ -2718,7 +2437,7 @@
27192438 .attr( 'title', gM( 'mwe-pause_clip' ) );
27202439
27212440 // Do play tracking if enabled
2722 - if( mw.getConfig( 'playTracking' ) ){
 2441+ if( mw.getConfig( 'playTracking' ) ) {
27232442 this.doPlayTracking();
27242443 }
27252444
@@ -2892,15 +2611,15 @@
28932612 * Checks if we are monitoring play requests
28942613 * presently this function is mediaWiki api specific.
28952614 */
2896 - doPlayTracking: function(){
 2615+ doPlayTracking: function() {
28972616 var playTrackingRate = mw.getConfig( 'playTrackingRate' );
28982617 // Math.floor ( Math.random() * playTrackingRate ) == 0
2899 - if( true ){
 2618+ if( true ) {
29002619 mw.getJSON( {
29012620 'action' : 'playtracking',
29022621 'filename' : this.apiTitleKey,
29032622 'client' : this.selected_player.library + ' && ' + navigator.userAgent
2904 - }, function( data ){
 2623+ }, function( data ) {
29052624 mw.log( 'done logging play request' );
29062625 } );
29072626 }
@@ -2918,19 +2637,19 @@
29192638 if ( parseInt( this.startOffset ) != 0 ) {
29202639 // If start offset include that calculation
29212640 this.updatePlayHead( ( this.currentTime - this.startOffset ) / this.duration );
2922 - var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + parseFloat( this.duration ) ) : '';
 2641+ var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( parseFloat( this.startOffset ) + parseFloat( this.duration ) ) : '';
29232642 this.setStatus( mw.seconds2npt( this.currentTime ) + et );
29242643 } else {
29252644 this.updatePlayHead( this.currentTime / this.duration );
2926 - // Only include the end time if long_time_disp is enabled:
2927 - var et = ( this.ctrlBuilder.long_time_disp ) ? '/' + mw.seconds2npt( this.duration ) : '';
 2645+ // Only include the end time if longTimeDisp is enabled:
 2646+ var et = ( this.ctrlBuilder.longTimeDisp ) ? '/' + mw.seconds2npt( this.duration ) : '';
29282647 this.setStatus( mw.seconds2npt( this.currentTime ) + et );
29292648 }
29302649 }
29312650 // Check if we are "done"
2932 - var end_presentation_time = ( this.startOffset ) ? ( this.startOffset + this.duration ) : this.duration;
2933 - if ( this.currentTime > end_presentation_time ) {
2934 - mw.log( "should run clip done :: " + this.currentTime + ' > ' + end_presentation_time );
 2651+ var endPresentationTime = ( this.startOffset ) ? ( this.startOffset + this.duration ) : this.duration;
 2652+ if ( this.currentTime > endPresentationTime ) {
 2653+ mw.log( "should run clip done :: " + this.currentTime + ' > ' + endPresentationTime );
29352654 this.onClipDone();
29362655 }
29372656 } else {
@@ -2971,7 +2690,7 @@
29722691 * Stop the playback monitor
29732692 */
29742693 stopMonitor:function() {
2975 - if ( this.monitorTimerId != 0 ){
 2694+ if ( this.monitorTimerId != 0 ) {
29762695 clearInterval( this.monitorTimerId );
29772696 this.monitorTimerId = 0;
29782697 }
@@ -3147,7 +2866,7 @@
31482867 * false if mime type is unsupported
31492868 */
31502869 supportsMIMEType: function( type ) {
3151 - for ( var i = 0; i < this.supported_types.length; i++ ){
 2870+ for ( var i = 0; i < this.supported_types.length; i++ ) {
31522871 if ( this.supported_types[i] == type )
31532872 return true;
31542873 }
@@ -3430,7 +3149,7 @@
34313150 var uniqueMimesOnly = $j.browser.opera || $j.browser.safari;
34323151 // Opera will switch off javaEnabled in preferences if java can't be found.
34333152 // And it doesn't register an application/x-java-applet mime type like Mozilla does.
3434 - if ( javaEnabled ){
 3153+ if ( javaEnabled ) {
34353154 this.players.addPlayer( cortadoPlayer );
34363155 }
34373156
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js
@@ -83,7 +83,7 @@
8484 /**
8585 * Get the applet location
8686 */
87 - getAppletLocation: function(){
 87+ getAppletLocation: function() {
8888 var mediaSrc = this.getSrc()
8989 if ( mediaSrc.indexOf( '://' ) != -1 & !mw.isLocalDomain( mediaSrc ) ) {
9090 if ( window.cortadoDomainLocations[ mw.parseUri( mediaSrc ).host ] ) {
@@ -200,7 +200,7 @@
201201 play: function() {
202202 this.getPlayerElement();
203203 this.parent_play();
204 - if ( this.playerElement && this.playerElement.play ){
 204+ if ( this.playerElement && this.playerElement.play ) {
205205 this.playerElement.play();
206206 }
207207 },
@@ -214,7 +214,7 @@
215215 // Update the interface
216216 this.parent_pause();
217217 // Call the pause function if it exists:
218 - if ( this.playerElement && this.playerElement.pause ){
 218+ if ( this.playerElement && this.playerElement.pause ) {
219219 this.playerElement.pause();
220220 }
221221 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/htmlEmbed.js
@@ -79,7 +79,7 @@
8080 *
8181 * @param {Float} perc Pecentage to seek into the virtual player
8282 */
83 - doSeek:function( perc ){
 83+ doSeek:function( perc ) {
8484 this.pauseTime = perc * this.getDuration();
8585 this.play();
8686 },
@@ -90,7 +90,7 @@
9191 * @param {Float} perc Pecentage to seek into the virtual player
9292 * @param {Function} callback Function called once time has been updated
9393 */
94 - setCurrentTime:function( perc, callback ){
 94+ setCurrentTime:function( perc, callback ) {
9595 this.pauseTime = perc * this.getDuration();
9696 if( callback )
9797 callback();
@@ -246,10 +246,10 @@
247247 * Get the media duration
248248 */
249249 getDuration:function() {
250 - if( !this.duration ){
251 - if( this.pc.dur ){
 250+ if( !this.duration ) {
 251+ if( this.pc.dur ) {
252252 this.duration = this.pc.dur;
253 - }else if( pcHtmlEmbedDefaults.dur ){
 253+ }else if( pcHtmlEmbedDefaults.dur ) {
254254 this.duration = pcHtmlEmbedDefaults.dur ;
255255 }
256256 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/vlcEmbed.js
@@ -63,7 +63,7 @@
6464 // give VLC 150ms to initialize before we start playback
6565 // @@todo should be able to do this as an ready event
6666 this.waitForVlcCount = 0;
67 - setTimeout( function(){
 67+ setTimeout( function() {
6868 _this.postEmbedJS();
6969 }, 150 );
7070 },
@@ -94,14 +94,14 @@
9595 } else {
9696 mw.log( "error:cannot play at the moment !" );
9797 }
98 - setTimeout( function(){
 98+ setTimeout( function() {
9999 _this.monitor();
100100 }, 100 );
101101 } else {
102102 mw.log( 'postEmbedJS: vlc not ready' );
103103 this.waitForVlcCount++;
104104 if ( this.waitForVlcCount < 10 ) {
105 - setTimeout( function(){
 105+ setTimeout( function() {
106106 _this.postEmbedJS();
107107 }, 100 );
108108 } else {
@@ -209,7 +209,7 @@
210210 // current media is now playing
211211 this.onPlay();
212212 }
213 - else if ( this.playerElement.input.state == 4 ){
 213+ else if ( this.playerElement.input.state == 4 ) {
214214 // current media is now paused
215215 this.onPause();
216216 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -60,7 +60,7 @@
6161 )
6262 mw.log( "Embed code: " + $j( this ).html() )
6363
64 - setTimeout( function(){
 64+ setTimeout( function() {
6565 _this.postEmbedJS();
6666 }, 150 );
6767 },
@@ -78,12 +78,12 @@
7979 var vid = $j( this.playerElement ).get(0);
8080
8181 // Bind events to local js methods:
82 - vid.addEventListener( 'canplaythrough', function(){ _this.canplaythrough }, true);
83 - vid.addEventListener( 'loadedmetadata', function(){ _this.onloadedmetadata() }, true);
84 - vid.addEventListener( 'progress', function( e ){ _this.onprogress( e ) }, true);
85 - vid.addEventListener( 'ended', function(){ _this.onended() }, true);
86 - vid.addEventListener( 'seeking', function(){ _this.onseeking() }, true);
87 - vid.addEventListener( 'seeked', function(){ _this.onseeked() }, true);
 82+ vid.addEventListener( 'canplaythrough', function() { _this.canplaythrough }, true);
 83+ vid.addEventListener( 'loadedmetadata', function() { _this.onloadedmetadata() }, true);
 84+ vid.addEventListener( 'progress', function( e ) { _this.onprogress( e ) }, true);
 85+ vid.addEventListener( 'ended', function() { _this.onended() }, true);
 86+ vid.addEventListener( 'seeking', function() { _this.onseeking() }, true);
 87+ vid.addEventListener( 'seeked', function() { _this.onseeked() }, true);
8888
8989 // Check for load flag
9090 if ( this.onlyLoadFlag ) {
@@ -92,7 +92,7 @@
9393 // Issue play request
9494 this.playerElement.play();
9595 }
96 - setTimeout( function(){
 96+ setTimeout( function() {
9797 _this.monitor();
9898 }, 100 );
9999
@@ -103,7 +103,7 @@
104104 if ( this.grab_count == 20 ) {
105105 mw.log( 'Could not get vid object after 20 tries re-run: getEmbedObj() ?' ) ;
106106 } else {
107 - setTimeout( function(){
 107+ setTimeout( function() {
108108 _this.postEmbedJS();
109109 }, 200 );
110110 }
@@ -202,7 +202,7 @@
203203 * @param {Float} position Position in seconds
204204 * @param {Function} callback Function to call once seeking completes
205205 */
206 - doSeekedCallback : function( position, callback ){
 206+ doSeekedCallback : function( position, callback ) {
207207 var _this = this;
208208 this.getPlayerElement();
209209 var once = function( event ) {
@@ -390,7 +390,7 @@
391391 }
392392
393393 //Fire "onLoaded" flags if set
394 - if( typeof this.onLoadedCallback == 'function' ){
 394+ if( typeof this.onLoadedCallback == 'function' ) {
395395 this.onLoadedCallback();
396396 }
397397 },
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/loader.js
@@ -18,12 +18,12 @@
1919 'mw.Firefogg',
2020 'mw.FirefoggRender',
2121 'mw.BaseUploadInterface'
22 - ], function(){
 22+ ], function() {
2323 callback( 'FirefoggRender' );
2424 });
2525 });
2626
27 -mw.addModuleLoader( 'Sequencer', function( callback ){
 27+mw.addModuleLoader( 'Sequencer', function( callback ) {
2828 //Get sequencer style sheet
2929 mw.getStyleSheet( mw.getMwEmbedPath() + 'modules/Sequencer/css/mv_sequence.css' );
3030 // Make sure we have the required mwEmbed libs:
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.FirefoggRender.js
@@ -72,7 +72,7 @@
7373 $j.extend(this.renderOptions, default_render_options, options['render_options']);
7474
7575 // If no height width provided use target DOM width/height
76 - if( !this.renderOptions.width && !this.renderOptions.height ){
 76+ if( !this.renderOptions.width && !this.renderOptions.height ) {
7777 this.renderOptions.width = $j(this.player_target).width();
7878 this.renderOptions.height = $j(this.player_target).height();
7979 }
@@ -131,7 +131,7 @@
132132 // add audio if we had any:
133133
134134 // issue a load request on the player:
135 - this.player.load(function(){
 135+ this.player.load(function() {
136136 $j( this.target_timeStatus ).val( "player ready" );
137137 //now issue the save video as call
138138 _this.fogg.saveVideoAs();
@@ -142,7 +142,7 @@
143143 /**
144144 * Do the next frame in the render target
145145 */
146 - doNextFrame: function(){
 146+ doNextFrame: function() {
147147 var _this = this;
148148 // internal function to handle updates:
149149 $j( _this.target_timeStatus ).val( " on " + ( Math.round( _this.render_time * 10 ) / 10 ) + " of " +
@@ -186,7 +186,7 @@
187187 var rstatus = _this.fogg.renderstatus()
188188 $j( _this.target_timeStatus ).val( rstatus );
189189 if ( rstatus != 'done' && rstatus != 'rendering failed' ) {
190 - setTimeout( function(){
 190+ setTimeout( function() {
191191 _this.updateStatus();
192192 }, 100 );
193193 } else {
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.Sequencer.js
@@ -58,7 +58,7 @@
5959 /*
6060 * Setup the sequencer jQuery binding:
6161 */
62 -( function( $ ){
 62+( function( $ ) {
6363 $.fn.sequencer = function( options, callback ) {
6464 // Debugger
6565 options['target_sequence_container'] = this.selector;
@@ -279,7 +279,7 @@
280280
281281 $j('#' + this.plObj_id ).embedPlayer();
282282
283 - setTimeout( function(){
 283+ setTimeout( function() {
284284 _this.checkReadyPlObj()
285285 }, 25 );
286286 },
@@ -481,8 +481,8 @@
482482 // & from seq obj to sequencer
483483 this.plObj.pSeq = this;
484484
485 - if ( this.plObj ){
486 - if ( ! this.plObj.loading ){
 485+ if ( this.plObj ) {
 486+ if ( ! this.plObj.loading ) {
487487 this.plReadyInit();
488488 return ;
489489 }
@@ -494,7 +494,7 @@
495495 mw.log( 'error playlist never ready' );
496496 } else {
497497 this.plReadyTimeout++;
498 - setTimeout( function(){
 498+ setTimeout( function() {
499499 _this.checkReadyPlObj();
500500 }, 25 );
501501 }
@@ -521,7 +521,7 @@
522522 this.sequenceEditToken = $j( 'input[wpEditToken]' ).val();
523523
524524 // Update the buttons for no Api url (local editor)
525 - if( !this.getLocalApiUrl() ){
 525+ if( !this.getLocalApiUrl() ) {
526526 _this.updateSeqSaveButtons();
527527 }
528528
@@ -542,9 +542,9 @@
543543 $j.ajax({
544544 type: "GET",
545545 url: token_url + _this.plObj.mTitle,
546 - success:function(data){
 546+ success:function(data) {
547547 var pageElm = data.getElementsByTagName('page')[0];
548 - if( $j(pageElm).attr('edittoken') ){
 548+ if( $j(pageElm).attr('edittoken') ) {
549549 _this.sequenceEditToken = $j(pageElm).attr('edittoken');
550550 }
551551
@@ -554,9 +554,9 @@
555555 /*$j.ajax({
556556 type:"GET",
557557 url: token_url + _this.plObj.mTalk,
558 - success:function(data){
 558+ success:function(data) {
559559 var pageElm = data.getElementsByTagName('page')[0];
560 - if( $j(pageElm).attr('edittoken') ){
 560+ if( $j(pageElm).attr('edittoken') ) {
561561 _this.clipboardEditToken = $j(pageElm).attr('edittoken');
562562 }
563563 }
@@ -1490,7 +1490,7 @@
14911491 clip_desc += '<br>end time: ' + new_end;
14921492 // also shift all the other clips (after the current)
14931493 // mw.log("track_inx: " + track_inx + ' clip inx:'+clip_inx);
1494 - // $j('#container_track_'+track_inx+' > .mv_clip_drag :gt('+clip_inx+')').each(function(){
 1494+ // $j('#container_track_'+track_inx+' > .mv_clip_drag :gt('+clip_inx+')').each(function() {
14951495 $j( '#container_track_' + track_inx + ' > :gt(' + clip_inx + ')' ).each( function() {
14961496 var move_id_parts = this.id.split( '_' );
14971497 var move_clip = _this.plObj.tracks[move_id_parts[1]].clips[move_id_parts[3]];
@@ -1543,7 +1543,7 @@
15441544 var out='';
15451545 //output time-desc every 50pixles and jump links every 10 pixles
15461546 var n=0;
1547 - for(i=0;i<pixle_length;i+=10){
 1547+ for(i=0;i<pixle_length;i+=10) {
15481548 out+='<div onclick="'+this.instance_name+'.jt('+i*this.timeline_scale+');"' +
15491549 ' style="z-index:2;position:absolute;left:'+i+'px;width:10px;height:20px;top:0px;"></div>';
15501550 if(n==0)
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/playlistEmbed.js
@@ -32,7 +32,7 @@
3333 /**
3434 * put the embed player into the container
3535 */
36 - doEmbedPlayer: function(){
 36+ doEmbedPlayer: function() {
3737 var _this = this;
3838 // Set "loading" here:
3939 $j(this).text( gM( 'mwe-loading_plugin' ) );
@@ -46,7 +46,7 @@
4747 /**
4848 * Get the thumbnail html
4949 */
50 - getThumbnailHTML: function(){
 50+ getThumbnailHTML: function() {
5151 return 'thumb html';
5252 },
5353 /**
@@ -60,7 +60,7 @@
6161 /**
6262 * Get all the "clips" in a given range from currentTime
6363 */
64 - getClipsInRange: function( range ){
 64+ getClipsInRange: function( range ) {
6565
6666 }
6767 }
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js
@@ -181,7 +181,7 @@
182182 }
183183 this.cur_clip.embed.showShare( embed_code );
184184 },
185 - isTimedTextSupported: function(){
 185+ isTimedTextSupported: function() {
186186 return false;
187187 },
188188 checkForTextSource: function() {
@@ -196,7 +196,7 @@
197197 // import methods from the plObj to this
198198 for ( var method in plObj ) {
199199 // js parent preservation for local overwritten methods
200 - if ( this[method] && !this[ 'parent_' + method ] ){
 200+ if ( this[method] && !this[ 'parent_' + method ] ) {
201201 this[ 'parent_' + method ] = this[ method ];
202202 }
203203 this[method] = plObj[method];
@@ -262,7 +262,7 @@
263263 this.doWhenClipLoadDone();
264264 } else {
265265 mw.log( "only " + _this.clip_ready_count + " clips done, scheduling callback:" );
266 - setTimeout( function(){
 266+ setTimeout( function() {
267267 _this.doWhenParseDone()
268268 }, 100 );
269269 }
@@ -306,7 +306,7 @@
307307 // determine the type / first is it m3u or xml?
308308 var _this = this;
309309 this.src = mw.absoluteUrl( this.src );
310 - if ( mw.isLocalDomain( this.src ) ){
 310+ if ( mw.isLocalDomain( this.src ) ) {
311311 $j.get( this.src, function( data ) {
312312 _this.data = data;
313313 _this.getSourceType();
@@ -323,7 +323,7 @@
324324 });
325325 }
326326 },
327 - getSrc: function(){
 327+ getSrc: function() {
328328 return this.src;
329329 },
330330 getSourceType:function() {
@@ -431,7 +431,7 @@
432432 var _this = this;
433433
434434 //Check for playlist player sources:
435 - this.checkPlayerSources(function(){
 435+ this.checkPlayerSources(function() {
436436 _this.buildPlayerUI();
437437 });
438438 },
@@ -439,11 +439,11 @@
440440 /**
441441 * Build out the player interface ( assumes checkPlayerSources has been run )
442442 */
443 - buildPlayerUI: function(){
 443+ buildPlayerUI: function() {
444444 var _this = this;
445445 mw.log('pl:buildPlayer');
446446 // Make sure we have interface_wrap
447 - if( $j( this ).parent('.interface_wrap').length == 0 ){
 447+ if( $j( this ).parent('.interface_wrap').length == 0 ) {
448448 // Select "player"
449449 $j( this )
450450 // Add interface control class:
@@ -639,7 +639,7 @@
640640 * this won't work so well with time range loading for smil (need to work on that)
641641 */
642642 loadFutureClips:function() {
643 - /*if( this.cur_clip.embed.bufferedPercent == 1){
 643+ /*if( this.cur_clip.embed.bufferedPercent == 1) {
644644 //set the buffer to the currentTime - duration
645645 var curBuffredTime = this.cur_clip.getDuration() - this.cur_clip.embed.currentTime;
646646
@@ -647,20 +647,20 @@
648648 curBuffredTime = 0;
649649
650650 mw.log( "curBuffredTime:: " + curBuffredTime );
651 - if( curBuffredTime < this.playlist_buffer_time ){
 651+ if( curBuffredTime < this.playlist_buffer_time ) {
652652 mw.log(" we only have " + curBuffredTime + ' buffed but we need: ' + this.playlist_buffer_time);
653653
654 - for(var inx = this.cur_clip.order + 1; inx < this.default_track.clips.length; inx++ ){
 654+ for(var inx = this.cur_clip.order + 1; inx < this.default_track.clips.length; inx++ ) {
655655 var cClip = this.default_track.getClip( inx );
656656
657657 //check if the clip is already loaded (add its duration)
658 - if( cClip.embed.bufferedPercent == 1){
 658+ if( cClip.embed.bufferedPercent == 1) {
659659 curBuffredTime += cClip.embed.getDuration();
660660 }
661661 //check if we still have to load a resource:
662 - if( curBuffredTime < this.playlist_buffer_time ){
 662+ if( curBuffredTime < this.playlist_buffer_time ) {
663663 //issue the load request
664 - if( cClip.embed.networkState==0 ){
 664+ if( cClip.embed.networkState==0 ) {
665665 cClip.embed.load();
666666 }
667667 break; //check back next time
@@ -715,9 +715,9 @@
716716 this.cur_clip = new_clip;
717717 $j( '#clipDesc_' + this.cur_clip.id ).show();
718718 // Update the playhead:
719 - if( this.controls ){
 719+ if( this.controls ) {
720720 // Check if we have into_perc
721 - if( into_perc ){
 721+ if( into_perc ) {
722722 var clip_time = this.cur_clip.dur_offset + ( into_perc * this.cur_clip.getDuration() );
723723 }else{
724724 var clip_time = this.cur_clip.dur_offset;
@@ -835,7 +835,7 @@
836836
837837 this.updateUIPauseState();
838838 },
839 - updateUIPauseState:function(){
 839+ updateUIPauseState:function() {
840840 var _this = this;
841841 // Copied from embedPlayer.pause ( in the refactor this is not needed )
842842 // update the ctrl "paused state"
@@ -915,7 +915,7 @@
916916 *
917917 * @returns the relative offsets of the current clip (given the playlist time)
918918 */
919 - updateClipByTime: function(){
 919+ updateClipByTime: function() {
920920 var _this = this;
921921 var prevClip = null;
922922 //set the current percent done:
@@ -954,7 +954,7 @@
955955 updateBufferStatus: function() {
956956 // Update the buffer status for all current clip
957957 /*mw.log(' update: '+ this.cur_clip.embed.id + ' to ' + (this.cur_clip.embed.bufferedPercent * 100) );
958 - if( this.cur_clip.embed && this.cur_clip.embed.bufferedPercent ){
 958+ if( this.cur_clip.embed && this.cur_clip.embed.bufferedPercent ) {
959959 $j('#cl_status_' + this.cur_clip.embed.id ).find('.mw_buffer').css({
960960 'width': ( this.cur_clip.embed.bufferedPercent * 100) + '%'
961961 })
@@ -974,7 +974,7 @@
975975 var cur_pixle = 0;
976976 // set up _this
977977 //remove any old cl_status
978 - _this.$interface.find( '.play_head' ).find('.cl_status').remove();
 978+ _this.$interface.find( '.play_head' ).find( '.cl_status' ).remove();
979979 // mw.log("do play head total dur: "+pl_duration );
980980 $j.each( this.default_track.clips, function( i, clip ) {
981981 // (use getSoloDuration to not include transitions and such)
@@ -993,7 +993,8 @@
994994 barHtml += 'filter:alpha(opacity=40);' +
995995 '-moz-opacity:.40;">';
996996
997 - barHtml += _this.ctrlBuilder.getBufferHtml();
 997+ barHtml += '<div class="ui-slider-range ui-slider-range-min ui-widget-header ' +
 998+ 'ui-state-highlight ui-corner-all mw_buffer" />';
998999
9991000 barHtml += '</div>';
10001001
@@ -1046,14 +1047,14 @@
10471048 else
10481049 this.default_track.clips[ clip_inx ][ trans_type ].run_transition();
10491050 },
1050 - getPlayerWidth: function(){
 1051+ getPlayerWidth: function() {
10511052 var player = $j( this ).get( 0 );
10521053 if ( typeof player != 'undefined' && player['offsetWidth'] )
10531054 return player.offsetWidth;
10541055 else
10551056 return parseInt( this.width );
10561057 },
1057 - getPlayerHeight: function(){
 1058+ getPlayerHeight: function() {
10581059 var player = $j( this ).get( 0 );
10591060 if ( typeof player != 'undefined' && player['offsetHeight'] )
10601061 return player.offsetHeight;
@@ -1114,7 +1115,7 @@
11151116 // if in sequence mode hide controls / embed links
11161117 // init_pl_embed.play_button=false;
11171118 // init_pl_embed.controls=true;
1118 - // if(this.pp.sequencer=='true'){
 1119+ // if(this.pp.sequencer=='true') {
11191120 init_pl_embed.linkback = null;
11201121
11211122 if( this.durationHint )
@@ -1144,11 +1145,11 @@
11451146 this.pp.refresh();
11461147 /*var base_src = this.src.substr(0,this.src.indexOf('?'));
11471148 mw.log("delta:"+ delta);
1148 - if(side=='start'){
 1149+ if(side=='start') {
11491150 //since we adjust start invert the delta:
11501151 var startOffset =parseInt(this.embed.startOffset/1000)+parseInt(delta*-1);
11511152 this.src = base_src +'?t='+ mw.seconds2npt(startOffset) +'/'+ this.embed.end_ntp;
1152 - }else if(side=='end'){
 1153+ }else if(side=='end') {
11531154 //put back into seconds for adjustment:
11541155 var end_offset = parseInt(this.embed.startOffset/1000) + parseInt(this.embed.duration/1000) + parseInt(delta);
11551156 this.src = base_src +'?t='+ this.embed.start_ntp +'/'+ mw.seconds2npt(end_offset);
@@ -1174,7 +1175,7 @@
11751176 },
11761177 // output the detail view:
11771178 // @@todo
1178 - /*getDetail:function(){
 1179+ /*getDetail:function() {
11791180 //mw.log('get detail:' + this.pp.title);
11801181 var th=Math.round( this.layout.clip_desc * this.pp.height );
11811182 var tw=Math.round( th * this.layout.clip_aspect );
@@ -1191,7 +1192,7 @@
11921193 $j(this.embed).css({ 'position':"absolute",'top':"0px", 'left':"0px"});
11931194
11941195 //mw.log('append child to:#clipDesc_'+this.id);
1195 - if($j('#clipDesc_'+this.id).get(0)){
 1196+ if($j('#clipDesc_'+this.id).get(0)) {
11961197 $j('#clipDesc_'+this.id).get(0).appendChild(this.embed);
11971198
11981199 $j('#clipDesc_'+this.id).append(''+
@@ -1511,7 +1512,7 @@
15121513 // status updates are handled by children clips ... playlist mostly manages smil actions
15131514 this.doSmilActions();
15141515
1515 - setTimeout( function(){
 1516+ setTimeout( function() {
15161517 _this.monitor();
15171518 }, 250);
15181519 }
@@ -1551,7 +1552,7 @@
15521553 * @param {string} tid the transition type [transIn|transOut]
15531554 * @param {function} callback the callback function passed onto doUPdate
15541555 */
1555 -mw.PlayList.prototype.procTranType = function( tid, callback){
 1556+mw.PlayList.prototype.procTranType = function( tid, callback) {
15561557 // Setup local clip pointer:
15571558 var _clip = this.cur_clip;
15581559
@@ -1570,12 +1571,12 @@
15711572 tObj.animation_state = 0;
15721573 tObj.run_transition();
15731574 /*if ( this.userSlide || this.paused ) {
1574 - if ( tid == 'transIn' ){
 1575+ if ( tid == 'transIn' ) {
15751576 mvTransLib.doUpdate( tObj,
15761577 ( _clip.embed.currentTime / tObj.dur ),
15771578 callback );
15781579 }
1579 - if ( tid == 'transOut' ){
 1580+ if ( tid == 'transOut' ) {
15801581 mvTransLib.doUpdate( tObj,
15811582 ( ( _clip.embed.currentTime - ( _clip.dur - tObj.dur ) ) / tObj.dur ),
15821583 callback );
@@ -1831,7 +1832,7 @@
18321833
18331834 // }else{
18341835 // relay on currentTime update grabs (every 250ms or so) (ie for images)
1835 - // if(this.prev_curtime!=this.pClip.embed.currentTime){
 1836+ // if(this.prev_curtime!=this.pClip.embed.currentTime) {
18361837 // this.prev_curtime = this.pClip.embed.currentTime;
18371838 // this.interValCount=0;
18381839 // }
@@ -1845,11 +1846,11 @@
18461847 this.animation_state = 1;
18471848 }
18481849
1849 - if( this.transAttrType=='transIn' ){
 1850+ if( this.transAttrType=='transIn' ) {
18501851 var percentage = ( this.pClip.embed.currentTime / this.dur ) ;
18511852 }
18521853
1853 - if( this.transAttrType=='transOut' ){
 1854+ if( this.transAttrType=='transOut' ) {
18541855 var percentage = ( this.pClip.embed.currentTime -
18551856 (this.pClip.dur - this.dur)
18561857 )
@@ -1867,8 +1868,8 @@
18681869 }
18691870
18701871 // run the animation ( animation_state == 1 && not "paused")
1871 - if( !this.pClip.pp.paused ){
1872 - setTimeout( function(){
 1872+ if( !this.pClip.pp.paused ) {
 1873+ setTimeout( function() {
18731874 _this.run_transition();
18741875 }, MV_ANIMATION_CB_RATE);
18751876 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/remotes/RemoteMwSequencer.js
@@ -10,7 +10,7 @@
1111 "mwe-sequence-create-one" : "start a sequence"
1212 });
1313
14 -RemoteMwSequencer = function( options ){
 14+RemoteMwSequencer = function( options ) {
1515 return this.init( options );
1616 };
1717 RemoteMwSequencer.prototype = {
@@ -24,9 +24,9 @@
2525 this.target = ( options.target )? options.target : this.target;
2626 },
2727
28 - updateUI: function(){
 28+ updateUI: function() {
2929 // Check page type
30 - if( this.action == 'view' ){
 30+ if( this.action == 'view' ) {
3131 this.showViewUI();
3232 }
3333 },
@@ -34,8 +34,8 @@
3535 * Check page for sequence
3636 * if not present give link to "create" one.
3737 */
38 - showViewUI: function(){
39 - if( wgArticleId == 0 ){
 38+ showViewUI: function() {
 39+ if( wgArticleId == 0 ) {
4040 $startLink = $j('<div>').append(
4141 $j('<a>')
4242 .text( gM('mwe-sequence-create-one') )
@@ -44,9 +44,9 @@
4545 $j( this.target ).html(
4646 gM("mwe-no-sequence-create", [this.title, $startLink.html() ])
4747 );
48 - $j('#mwe-sequence-create').click(function(){
 48+ $j('#mwe-sequence-create').click(function() {
4949 $j('body').append( '<div id="seqcontainer" style="position:absolute;top:5px;bottom:10px;left:10px;right:10px;" />' );
50 - mw.load( 'Sequencer', function(){
 50+ mw.load( 'Sequencer', function() {
5151 $j('#seqcontainer').sequencer({
5252 'amw_conf':{
5353 'enabled_providers':['wiki_commons']
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/loader.js
@@ -5,7 +5,7 @@
66 "JSON" : "modules/ApiProxy/json2.js"
77 } );
88
9 -mw.addModuleLoader( 'ApiProxy', function( callback ){
 9+mw.addModuleLoader( 'ApiProxy', function( callback ) {
1010 mw.load( [
1111 'mw.ApiProxy',
1212 'JSON'
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/NestedCallbackIframe.html
@@ -4,7 +4,7 @@
55 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66 <title>Simple nested iframe callback page</title>
77 <script type="text/javascript">
8 -window.onload = function (){
 8+window.onload = function () {
99 //call the nested callback in top most frame:
1010 top.mw.ApiProxy.nested( window.location.href.split("#")[1] || false );
1111 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -124,7 +124,7 @@
125125
126126 // Special callback to frameProxyOk flag
127127 // (only used to quickly test the proxy connection)
128 - if ( resultObject.state == 'ok' ){
 128+ if ( resultObject.state == 'ok' ) {
129129 return ;
130130 }
131131
@@ -138,30 +138,30 @@
139139 *
140140 * @param {Function} callback Function to host the
141141 */
142 - $.browseFile = function( options ){
 142+ $.browseFile = function( options ) {
143143
144144 // Set frame proxy ok state flag:
145145 frameProxyOk = false;
146146
147 - if( ! options ){
 147+ if( ! options ) {
148148 options = {};
149149 }
150150
151 - if( ! options.target ){
 151+ if( ! options.target ) {
152152 mw.log( "Error: no target for file browse iframe" ) ;
153153 return false;
154154 }
155 - if( ! options.api_url ){
 155+ if( ! options.api_url ) {
156156 mw.log( "Error: no api url to target" );
157157 return false;
158158 }
159159 //update the current apiUrl:
160160 currentApiUrl = options.api_url;
161161
162 - if( ! options.width ){
 162+ if( ! options.width ) {
163163 options.width = 270;
164164 }
165 - if( ! options.height ){
 165+ if( ! options.height ) {
166166 options.height = 27;
167167 }
168168 var iFrameName = ( options.iframeName ) ? options.iframeName : 'fileBrowse_' + $j('iframe').length;
@@ -200,21 +200,21 @@
201201 };
202202
203203 // Setup the proxy callback to display the upload unhide the iframe upload form
204 - proxyCallback = function( iframeData ){
 204+ proxyCallback = function( iframeData ) {
205205 // proccess fileBrowse callbacks::
206206
207207 // check for basic status "ok"
208 - if( iframeData['status'] == 'ok' ){
 208+ if( iframeData['status'] == 'ok' ) {
209209 // Hide the loading spinner
210210 $j( options.target ).find('.loading_spinner').fadeOut('fast');
211211 mw.log("iframe ready callback");
212212 $j( '#' + iFrameName ).fadeIn( 'fast' );
213213 }
214214 // else check for event
215 - if( iframeData['event'] ){
216 - switch( iframeData['event'] ){
 215+ if( iframeData['event'] ) {
 216+ switch( iframeData['event'] ) {
217217 case 'selectFileCb':
218 - if( options.selectFileCb ){
 218+ if( options.selectFileCb ) {
219219 options.selectFileCb( iframeData['fileName'] );
220220 }
221221 break;
@@ -233,7 +233,7 @@
234234 $.server = function() {
235235 var proxyConfig = mw.getConfig( 'apiProxyConfig' );
236236 // Validate the server request:
237 - if( !validateIframeRequest( proxyConfig ) ){
 237+ if( !validateIframeRequest( proxyConfig ) ) {
238238 mw.log( "Not a valid iframe request");
239239 return false;
240240 }
@@ -252,7 +252,7 @@
253253 /**
254254 * Get the client frame path ( within mwEmbed )
255255 */
256 - function getClientFrame(){
 256+ function getClientFrame() {
257257 return mw.getMwEmbedPath() + 'modules/ApiProxy/NestedCallbackIframe.html';
258258 }
259259
@@ -265,9 +265,9 @@
266266 * ( there is no cost if they do already have the gadget on )
267267 */
268268 var gadgetWithJS = 'withJS=MediaWiki:Gadget-mwEmbed.js';
269 - function getServerFrame( apiUrl ){
 269+ function getServerFrame( apiUrl ) {
270270 // Set to local scope currentApiUrl if unset by argument
271 - if( !apiUrl){
 271+ if( !apiUrl) {
272272 apiUrl = currentApiUrl;
273273 }
274274 var parsedUrl = mw.parseUri( apiUrl );
@@ -276,9 +276,9 @@
277277 /**
278278 * Same as getServerFrame but for browse file interface
279279 */
280 - function getServerBrowseFileFrame( apiUrl ){
 280+ function getServerBrowseFileFrame( apiUrl ) {
281281 // Set to local scope currentApiUrl if unset by argument
282 - if( !apiUrl){
 282+ if( !apiUrl) {
283283 apiUrl = currentApiUrl;
284284 }
285285 var parsedUrl = mw.parseUri( apiUrl );
@@ -335,7 +335,7 @@
336336 * checks master_blacklist
337337 * checks master_whitelist
338338 */
339 - function validateIframeRequest( proxyConfig ){
 339+ function validateIframeRequest( proxyConfig ) {
340340 var clientRequest = false;
341341
342342
@@ -369,7 +369,7 @@
370370 * Check if a domain is allowed.
371371 * @param {Object} clientFrame
372372 */
373 - function isAllowedClientFrame( clientFrame ){
 373+ function isAllowedClientFrame( clientFrame ) {
374374 var clientDomain = mw.parseUri( clientFrame ).host ;
375375 // Get the proxy config
376376 var proxyConfig = mw.getConfig( 'apiProxyConfig' );
@@ -399,7 +399,7 @@
400400 * Get the client request from the document hash
401401 * @return {Object} the object result of parsing the document anchor msg
402402 */
403 - function getClientRequest(){
 403+ function getClientRequest() {
404404 // Read the anchor data package from the requesting url
405405 var hashMsg = unescape( mw.parseUri( document.URL ).anchor );
406406 try {
@@ -455,10 +455,10 @@
456456 * serverHandleRequest handle a given request from the client
457457 * maps the request to serverBrowseFile or serverApiRequest
458458 */
459 - function serverHandleRequest(){
 459+ function serverHandleRequest() {
460460 var clientRequest = getClientRequest();
461461 // Process request type
462 - if( clientRequest['browseFile'] ){
 462+ if( clientRequest['browseFile'] ) {
463463 serverBrowseFile();
464464 return true;
465465 }
@@ -490,11 +490,11 @@
491491 *
492492 * Sets the page content to browser file
493493 */
494 - function serverBrowseFile( ){
 494+ function serverBrowseFile( ) {
495495 // Get the proxy config
496496 var proxyConfig = mw.getConfig( 'apiProxyConfig' );
497497 //check for fw ( file width )
498 - if( ! proxyConfig.fileWidth ){
 498+ if( ! proxyConfig.fileWidth ) {
499499 proxyConfig.fileWidth = 130;
500500 }
501501 //Build a form with bindings similar to uploadPage.js ( but only the browse button )
@@ -526,7 +526,7 @@
527527 // load the mw.upload library with iframe interface (similar to uploadPage.js)
528528
529529 // If wgEnableFirefogg is not boolean false, set to true
530 - if ( typeof wgEnableFirefogg == 'undefined' ){
 530+ if ( typeof wgEnableFirefogg == 'undefined' ) {
531531 wgEnableFirefogg = true;
532532 }
533533
@@ -536,7 +536,7 @@
537537 'interface_type' : 'iframe',
538538
539539 // Set the select file callback to update clientFrame
540 - 'selectFileCb' : function( fileName ){
 540+ 'selectFileCb' : function( fileName ) {
541541 sendClientMsg( {
542542 'event': 'selectFileCb',
543543 'fileName' : fileName
@@ -544,14 +544,14 @@
545545 }
546546 }
547547
548 - if( wgEnableFirefogg ){
549 - mw.load( 'AddMedia.firefogg', function(){
 548+ if( wgEnableFirefogg ) {
 549+ mw.load( 'AddMedia.firefogg', function() {
550550 $j( '#wpUploadFile' ).firefogg( uploadConfig );
551551 // Update status
552552 sendClientMsg( {'status':'ok'} );
553553 });
554554 } else {
555 - mw.load( 'AddMedia.UploadHandler', function(){
 555+ mw.load( 'AddMedia.UploadHandler', function() {
556556 $j( 'mw-upload-form' ).uploadHandler( uploadConfig );
557557 sendClientMsg( {'status':'ok'} );
558558 });
@@ -569,7 +569,7 @@
570570 var clientFrame = getClientRequest()['clientFrame'];
571571
572572 // Double check that the client is an approved domain before outputing the iframe
573 - if( ! isAllowedClientFrame ( clientFrame ) ){
 573+ if( ! isAllowedClientFrame ( clientFrame ) ) {
574574 mw.log( "cant send msg to " + clientFrame );
575575 return false;
576576 }
@@ -589,7 +589,7 @@
590590 // After the nested frame is done loading schedule its removal
591591 $j( '#' + nestName ).get( 0 ).onload = function() {
592592 // Use a settimeout to give time for client frame to propagate update.
593 - setTimeout( function(){
 593+ setTimeout( function() {
594594 $j('#' + nestName ).remove();
595595 }, 10 );
596596 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/index.html
@@ -60,7 +60,7 @@
6161 $(this).ColorPickerSetColor(this.value);
6262 }
6363 })
64 -.bind('keyup', function(){
 64+.bind('keyup', function() {
6565 $(this).ColorPickerSetColor(this.value);
6666 });
6767 </pre>
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/colorpicker.js
@@ -17,7 +17,7 @@
1818 defaults = {
1919 eventName: 'click',
2020 onShow: function () {},
21 - onBeforeShow: function(){},
 21+ onBeforeShow: function() {},
2222 onHide: function () {},
2323 onChange: function () {},
2424 onSubmit: function () {},
@@ -458,7 +458,7 @@
459459 } else {
460460 return this;
461461 }
462 - return this.each(function(){
 462+ return this.each(function() {
463463 if ($(this).data('colorpickerId')) {
464464 var cal = $('#' + $(this).data('colorpickerId'));
465465 cal.data('colorpicker').color = col;
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/layout.js
@@ -1,4 +1,4 @@
2 -(function($){
 2+(function($) {
33 var initLayout = function() {
44 var hash = window.location.hash.replace('#', '');
55 var currentTab = $('ul.navigationTabs a')
@@ -31,7 +31,7 @@
3232 $(this).ColorPickerSetColor(this.value);
3333 }
3434 })
35 - .bind('keyup', function(){
 35+ .bind('keyup', function() {
3636 $(this).ColorPickerSetColor(this.value);
3737 });
3838 $('#colorSelector').ColorPicker({
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/utils.js
@@ -175,7 +175,7 @@
176176 {
177177 func(nodeEl);
178178 nodeEl = nodeEl.firstChild;
179 - while(nodeEl){
 179+ while(nodeEl) {
180180 EYE.traverseDOM(nodeEl, func);
181181 nodeEl = nodeEl.nextSibling;
182182 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/colorpicker/js/eye.js
@@ -4,14 +4,14 @@
55 * Author: Stefan Petre www.eyecon.ro
66 *
77 */
8 -(function($){
 8+(function($) {
99 var EYE = window.EYE = function() {
1010 var _registered = {
1111 init: []
1212 };
1313 return {
1414 init: function() {
15 - $.each(_registered.init, function(nr, fn){
 15+ $.each(_registered.init, function(nr, fn) {
1616 fn.call();
1717 });
1818 },
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/pixastic-editor/editor.js
@@ -164,7 +164,7 @@
165165 var undoRatio = canvasWidth / canvasHeight;
166166
167167 for (var i=undoImages.length-1;i>=0;i--) {
168 - (function(){
 168+ (function() {
169169 var canvas = document.createElement("canvas");
170170 $j(canvas)
171171 .addClass("undo-canvas-small")
@@ -199,8 +199,8 @@
200200 $link = $j("<a href='#'></a>", doc)
201201 .addClass("undo-link")
202202 .appendTo($listCtr)
203 - .mouseover(function(){ $j(this).addClass("hover") })
204 - .mouseout(function(){ $j(this).removeClass("hover") });
 203+ .mouseover(function() { $j(this).addClass("hover") })
 204+ .mouseout(function() { $j(this).removeClass("hover") });
205205 $j(canvas).appendTo($link);
206206
207207 var displayShowing;
@@ -389,8 +389,8 @@
390390 .click(function() {
391391 enableTab(tab.id);
392392 })
393 - .mouseover(function(){ $j(this).addClass("hover") })
394 - .mouseout(function(){ $j(this).removeClass("hover") });
 393+ .mouseover(function() { $j(this).addClass("hover") })
 394+ .mouseout(function() { $j(this).removeClass("hover") });
395395
396396 $j("#main-bar", doc).append($tabElement);
397397
@@ -479,7 +479,7 @@
480480 for (var k=0;k<action.controls.length;k++) {
481481 var control = action.controls[k];
482482 if (typeof control.defaultValue != "function") {
483 - (function(){
 483+ (function() {
484484 var defVal = control.defaultValue;
485485 control.defaultValue = function() {
486486 return defVal;
@@ -707,14 +707,14 @@
708708 height : "100%",
709709 zIndex : "11"
710710 });
711 - $frame.load(function(){
 711+ $frame.load(function() {
712712 doc = $frame.get(0).contentDocument;
713713
714714 buildEditor();
715715 callback();
716716 $frame.show();
717717 hideLoadingScreen();
718 - setTimeout(function(){
 718+ setTimeout(function() {
719719 updateDisplayCanvas();
720720 },10);
721721 });
@@ -827,8 +827,8 @@
828828 .css("left", "-9999px")
829829 .css("top", "-9999px")
830830 .appendTo("body")
831 - .load(function(){onload(this);})
832 - .error(function(){
 831+ .load(function() {onload(this);})
 832+ .error(function() {
833833 throw new Error("Could not load temporary copy image. Is provided image valid?");
834834 unload();
835835 })
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/pixastic-lib/pixastic-editor/editor.js
@@ -164,7 +164,7 @@
165165 var undoRatio = canvasWidth / canvasHeight;
166166
167167 for (var i=undoImages.length-1;i>=0;i--) {
168 - (function(){
 168+ (function() {
169169 var canvas = document.createElement("canvas");
170170 $j(canvas)
171171 .addClass("undo-canvas-small")
@@ -199,8 +199,8 @@
200200 $link = $j("<a href='#'></a>", doc)
201201 .addClass("undo-link")
202202 .appendTo($listCtr)
203 - .mouseover(function(){ $j(this).addClass("hover") })
204 - .mouseout(function(){ $j(this).removeClass("hover") });
 203+ .mouseover(function() { $j(this).addClass("hover") })
 204+ .mouseout(function() { $j(this).removeClass("hover") });
205205 $j(canvas).appendTo($link);
206206
207207 var displayShowing;
@@ -389,8 +389,8 @@
390390 .click(function() {
391391 enableTab(tab.id);
392392 })
393 - .mouseover(function(){ $j(this).addClass("hover") })
394 - .mouseout(function(){ $j(this).removeClass("hover") });
 393+ .mouseover(function() { $j(this).addClass("hover") })
 394+ .mouseout(function() { $j(this).removeClass("hover") });
395395
396396 $j("#main-bar", doc).append($tabElement);
397397
@@ -479,7 +479,7 @@
480480 for (var k=0;k<action.controls.length;k++) {
481481 var control = action.controls[k];
482482 if (typeof control.defaultValue != "function") {
483 - (function(){
 483+ (function() {
484484 var defVal = control.defaultValue;
485485 control.defaultValue = function() {
486486 return defVal;
@@ -707,14 +707,14 @@
708708 height : "100%",
709709 zIndex : "11"
710710 });
711 - $frame.load(function(){
 711+ $frame.load(function() {
712712 doc = $frame.get(0).contentDocument;
713713
714714 buildEditor();
715715 callback();
716716 $frame.show();
717717 hideLoadingScreen();
718 - setTimeout(function(){
 718+ setTimeout(function() {
719719 updateDisplayCanvas();
720720 },10);
721721 });
@@ -827,8 +827,8 @@
828828 .css("left", "-9999px")
829829 .css("top", "-9999px")
830830 .appendTo("body")
831 - .load(function(){onload(this);})
832 - .error(function(){
 831+ .load(function() {onload(this);})
 832+ .error(function() {
833833 throw new Error("Could not load temporary copy image. Is provided image valid?");
834834 unload();
835835 })
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/mw.ClipEdit.js
@@ -115,7 +115,7 @@
116116 *
117117 * Clip edit profile is either "sequence" or "clip"
118118 */
119 - showControlEdit: function(){
 119+ showControlEdit: function() {
120120 mw.log( 'showControlEdit' );
121121 if ( this.profile == 'sequence' ) {
122122 this.showEditTypesMenu();
@@ -139,7 +139,7 @@
140140 /**
141141 * Get the mediatype for the current resource
142142 */
143 - getMediaType: function (){
 143+ getMediaType: function () {
144144 if( this.media_type )
145145 return this.media_type;
146146 // If media type was not supplied detect for resource if possible:
@@ -761,7 +761,7 @@
762762 );
763763
764764 // Make sure the default is reflected:
765 - if ( ! _this.resource.layout ){
 765+ if ( ! _this.resource.layout ) {
766766 _this.resource.layout = 'right';
767767 }
768768
@@ -974,7 +974,7 @@
975975 /**
976976 * Bind the Crop once the library $j.Jcrop is ready:
977977 */
978 - bindCrop: function(){
 978+ bindCrop: function() {
979979 var _this = this;
980980 $j( '.mw_crop_msg_load' ).hide();
981981 $j( '.mw_reset_crop,.mw_apply_crop' ).show();
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -68,8 +68,8 @@
6969 * @param {String} value Value of configuration name
7070 */
7171 mw.setConfig = function ( name, value ) {
72 - if( typeof name == 'object' ){
73 - for( var i in name ){
 72+ if( typeof name == 'object' ) {
 73+ for( var i in name ) {
7474 mw.setConfig( i, name[ i ] );
7575 }
7676 }
@@ -85,14 +85,14 @@
8686 * @param [Mixed] value Set configuration name to value
8787 */
8888 mw.setDefaultConfig = function( name, value ) {
89 - if( typeof name == 'object' ){
90 - for( var i in name ){
 89+ if( typeof name == 'object' ) {
 90+ for( var i in name ) {
9191 mw.setDefaultConfig( i, name[ i ] );
9292 }
9393 return ;
9494 }
9595 // Name is a string update the config directly
96 - if( ! mwConfig[ name ] ){
 96+ if( ! mwConfig[ name ] ) {
9797 mwConfig[ name ] = value;
9898 }
9999 }
@@ -104,7 +104,7 @@
105105 * @return {Mixed} value of configuration key
106106 * returns "false" if key not found
107107 */
108 - mw.getConfig = function ( name ){
 108+ mw.getConfig = function ( name ) {
109109 if( mwConfig[ name ] )
110110 return mwConfig[ name ];
111111 return false;
@@ -125,18 +125,18 @@
126126 * @parma {Function} callback Function to be called once userPrefrences are loaded
127127 */
128128 var setupUserConfigFlag = false;
129 - mw.setupUserConfig = function( callback ){
130 - if( setupUserConfigFlag ){
 129+ mw.setupUserConfig = function( callback ) {
 130+ if( setupUserConfigFlag ) {
131131 if( callback )
132132 callback();
133133 }
134134 // Do Setup user config:
135 - mw.load( [ '$j.cookie', 'JSON' ], function(){
136 - if( $j.cookie( 'mwUserConfig' ) ){
 135+ mw.load( [ '$j.cookie', 'JSON' ], function() {
 136+ if( $j.cookie( 'mwUserConfig' ) ) {
137137 mwUserConfig = JSON.parse( $j.cookie( 'mwUserConfig' ) );
138138 }
139139 mw.log( 'mw: ' + $j.cookie( 'mwUserConfig' ) );
140 - for(var i in mwUserConfig ){
 140+ for(var i in mwUserConfig ) {
141141 mw.log( 'i: ' + i + ' ' + mwUserConfig[ i ] ) ;
142142 }
143143 //debugger;
@@ -154,8 +154,8 @@
155155 * @param {String} name Name of user configuration value
156156 * @param {String} value Value of configuration name
157157 */
158 - mw.setUserConfig = function ( name, value, cookieOptions ){
159 - if( ! setupUserConfigFlag ){
 158+ mw.setUserConfig = function ( name, value, cookieOptions ) {
 159+ if( ! setupUserConfigFlag ) {
160160 mw.log( "Error: userConfig not setup" );
161161 return false;
162162 }
@@ -174,7 +174,7 @@
175175 * value of the configuration name
176176 * false if the configuration name could not be found
177177 */
178 - mw.getUserConfig = function ( name ){
 178+ mw.getUserConfig = function ( name ) {
179179 if( mwUserConfig[ name ] )
180180 return mwUserConfig[ name ];
181181 return false;
@@ -247,13 +247,13 @@
248248 // Replace Values
249249 if ( typeof args == 'object' || typeof args == 'array' ) {
250250 for ( var v =0; v < args.length; v++ ) {
251 - if( typeof args[v] == 'undefined' ){
 251+ if( typeof args[v] == 'undefined' ) {
252252 continue;
253253 }
254254 var replaceValue = args[ v ];
255255
256256 // Convert number if applicable
257 - if( parseInt( replaceValue ) == replaceValue ){
 257+ if( parseInt( replaceValue ) == replaceValue ) {
258258 replaceValue = mw.lang.convertNumber( replaceValue );
259259 }
260260
@@ -261,7 +261,7 @@
262262 var rep = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' );
263263
264264 // Check if we got passed in a jQuery object:
265 - if( typeof args[v]['html'] == 'function' ){
 265+ if( typeof args[v]['html'] == 'function' ) {
266266 message = message.replace( rep, $j('<div />').append( replaceValue ).html() );
267267 }else{
268268 // Assume replaceValue string
@@ -270,7 +270,7 @@
271271 }
272272 } else if ( typeof args == 'string' || typeof args == 'number' ) {
273273 // Convert number if applicable
274 - if( parseInt( args ) == args ){
 274+ if( parseInt( args ) == args ) {
275275 args = mw.lang.convertNumber( args );
276276 }
277277 message = message.replace( /\$1/g, args );
@@ -322,7 +322,7 @@
323323 // ( gRuleSet is loaded from script-loader to contains local ruleset )
324324 var rs = gRuleSet[ 'PLURAL' ];
325325
326 - if( tObj.arg && tObj.param && mw.lang.convertPlural){
 326+ if( tObj.arg && tObj.param && mw.lang.convertPlural) {
327327 // Check if we have forms to replace
328328 if ( tObj.param.length == 0 ) {
329329 return '';
@@ -335,7 +335,7 @@
336336
337337 }
338338 // Could not proccess plural return first form or nothing
339 - if( tObj.param[0] ){
 339+ if( tObj.param[0] ) {
340340 return tObj.param[0];
341341 }
342342 return '';
@@ -374,11 +374,11 @@
375375 var transformTable = mw.lang.digitTransformTable;
376376
377377 // Check if the "restore" to latin number flag is set:
378 - if( typeInt ){
 378+ if( typeInt ) {
379379 if( parseInt( number ) == number )
380380 return number;
381381 var tmp = [];
382 - for( var i in transformTable ){
 382+ for( var i in transformTable ) {
383383 tmp[ transformTable[ i ] ] = i;
384384 }
385385 transformTable = tmp;
@@ -386,8 +386,8 @@
387387
388388 var numberString = '' + number;
389389 var convertedNumber = '';
390 - for( var i =0; i < numberString.length; i++){
391 - if( transformTable[ numberString[i] ] ){
 390+ for( var i =0; i < numberString.length; i++) {
 391+ if( transformTable[ numberString[i] ] ) {
392392 convertedNumber += transformTable[ numberString[i] ];
393393 }else{
394394 convertedNumber += numberString[i];
@@ -401,10 +401,10 @@
402402 * @param {String} langKey Language key to be checked
403403 * @return true if valid language, false if not
404404 */
405 - mw.isValidLang = function( langKey ){
 405+ mw.isValidLang = function( langKey ) {
406406 var langList = mw.getConfig( 'languageCodeList');
407 - for(var i =0; i < langList.length; i++){
408 - if( langList[i] == langKey ){
 407+ for(var i =0; i < langList.length; i++) {
 408+ if( langList[i] == langKey ) {
409409 return true;
410410 }
411411 }
@@ -421,12 +421,12 @@
422422 var ammessages = '';
423423 if ( typeof msgSet == 'object' ) {
424424 for ( var i in msgSet ) {
425 - if( !messageCache[ i ] ){
 425+ if( !messageCache[ i ] ) {
426426 ammessages += msgSet[i] + '|';
427427 }
428428 }
429429 } else if ( typeof msgSet == 'string' ) {
430 - if( !messageCache[ i ] ){
 430+ if( !messageCache[ i ] ) {
431431 ammessages += msgSet;
432432 }
433433 }
@@ -701,24 +701,24 @@
702702 *
703703 * NOTE: should be integrated with the parser
704704 */
705 - getTemplateVars: function(){
 705+ getTemplateVars: function() {
706706 //mw.log('matching against: ' + wikiText);
707707 templateVars = new Array();
708708 var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi);
709709
710710 // Clean up results:
711 - for(var i=0; i < tempVars.length; i++){
 711+ for(var i=0; i < tempVars.length; i++) {
712712 //match
713713 var tvar = tempVars[i].replace('{{{','').replace('}}}','');
714714
715715 // Strip anything after a |
716 - if(tvar.indexOf('|') != -1){
 716+ if(tvar.indexOf('|') != -1) {
717717 tvar = tvar.substr(0, tvar.indexOf('|'));
718718 }
719719
720720 // Check for duplicates:
721721 var do_add=true;
722 - for(var j=0; j < templateVars.length; j++){
 722+ for(var j=0; j < templateVars.length; j++) {
723723 if( templateVars[j] == tvar)
724724 do_add=false;
725725 }
@@ -758,7 +758,7 @@
759759 * @return {Object} parserObj returns a parser object that has methods for getting at
760760 * things you would want
761761 */
762 - mw.parser = function( wikiText, options){
 762+ mw.parser = function( wikiText, options) {
763763 // return the parserObj
764764 return new parseObj( wikiText, options ) ;
765765 }
@@ -784,7 +784,7 @@
785785 *
786786 * @param {Object} targetObj Interface Object to add hook system to.
787787 */
788 - mw.addHookSystem = function( targetObj ){
 788+ mw.addHookSystem = function( targetObj ) {
789789 // Setup the target object hook holder:
790790 targetObj[ 'hooks' ] = { };
791791
@@ -796,7 +796,7 @@
797797 * @param {String} hookName Name of hook to be added
798798 * @param {Function} hookFunction Function to be called at hook time
799799 */
800 - targetObj.addHook = function( hookName, hookFunction ){
 800+ targetObj.addHook = function( hookName, hookFunction ) {
801801 if( ! this.hooks[ hookName ] )
802802 this.hooks[ hookName ] = [ ];
803803 this.hooks[ hookName ].push( hookFunction )
@@ -812,10 +812,10 @@
813813 * true interface should continue function execution
814814 * false interface should stop or return from method
815815 */
816 - targetObj.runHook = function( hookName ){
817 - if( this.hooks[ hookName ] ){
818 - for( var i in this.hooks[ hookName ]){
819 - if( typeof( this.hooks[ hookName ][ i ] ) == 'function'){
 816+ targetObj.runHook = function( hookName ) {
 817+ if( this.hooks[ hookName ] ) {
 818+ for( var i in this.hooks[ hookName ]) {
 819+ if( typeof( this.hooks[ hookName ][ i ] ) == 'function') {
820820 return this.hooks[ hookName ][ i ]( this );
821821 }
822822 }
@@ -879,17 +879,17 @@
880880 *
881881 * @param {Function} callback Function called once loading is complete
882882 */
883 - load: function( loadRequest, callback ){
 883+ load: function( loadRequest, callback ) {
884884 // Check for empty loadRequest ( directly return the callback )
885 - if( mw.isEmpty( loadRequest ) ){
 885+ if( mw.isEmpty( loadRequest ) ) {
886886 mw.log( 'Empty load request: ' + loadRequest );
887887 callback( loadRequest );
888888 return ;
889889 }
890890
891891 // Check if its a multi-part request:
892 - if( typeof loadRequest == 'object' ){
893 - if( loadRequest.length > 1 ){
 892+ if( typeof loadRequest == 'object' ) {
 893+ if( loadRequest.length > 1 ) {
894894 this.loadMany ( loadRequest, callback );
895895 return ;
896896 }else{
@@ -901,7 +901,7 @@
902902 // Check for the module name loader function
903903 if( this.moduleLoaders[ loadRequest ] &&
904904 typeof ( this.moduleLoaders[ loadRequest ] ) == 'function'
905 - ){
 905+ ) {
906906 mw.log("mw.load: loadModule:" + loadRequest );
907907 // Run the module with the parent callback
908908 this.moduleLoaders[ loadRequest ]( callback );
@@ -909,7 +909,7 @@
910910 }
911911
912912 // Check for javascript class
913 - if( this.getClassPath( loadRequest ) ){
 913+ if( this.getClassPath( loadRequest ) ) {
914914 mw.log('mw.load: loadClass: ' + loadRequest );
915915 this.loadClass( loadRequest, callback );
916916 return ;
@@ -917,7 +917,7 @@
918918
919919 // Try loading as a "file" or via ScriptLoader
920920 if( loadRequest ) {
921 - if( loadRequest.indexOf( '.js' ) == -1 && !mw.getScriptLoaderPath() ){
 921+ if( loadRequest.indexOf( '.js' ) == -1 && !mw.getScriptLoaderPath() ) {
922922 mw.log( 'Error: are you sure ' + loadRequest + ' is a file ( is it missing a class path? ) ' );
923923 }
924924 mw.getScript( loadRequest, callback );
@@ -941,16 +941,16 @@
942942 var loadStates = { };
943943
944944 // Check if we can load via the "script-loader" ( mwEmbed was included via scriptLoader )
945 - if( mw.getScriptLoaderPath() ){
 945+ if( mw.getScriptLoaderPath() ) {
946946 loadStates = this.getGroupLoadState( loadSet );
947 - if( mw.isEmpty( loadStates ) ){
 947+ if( mw.isEmpty( loadStates ) ) {
948948 mw.log( 'loadMany:all classes already loaded');
949949 callback();
950950 return ;
951951 }
952952 }else{
953953 // Check if its a dependency set ( nested objects )
954 - if( typeof loadSet [ 0 ] == 'object' ){
 954+ if( typeof loadSet [ 0 ] == 'object' ) {
955955 _this.dependencyChainCallFlag[loadSet] = false;
956956 //Load sets of classes ( to preserver order for some browsers )
957957 _this.loadDependencyChain( loadSet, callback );
@@ -958,7 +958,7 @@
959959 }
960960
961961 // Set the initial load state for every item in the loadSet
962 - for( var i = 0; i < loadSet.length ; i++ ){
 962+ for( var i = 0; i < loadSet.length ; i++ ) {
963963 var loadName = loadSet[ i ];
964964 loadStates[ loadName ] = 0;
965965 }
@@ -968,19 +968,19 @@
969969 mw.log("mw.load: LoadMany:: " + loadSet );
970970
971971 // Issue the load request check check loadStates to see if we are "done"
972 - for( var loadName in loadStates ){
 972+ for( var loadName in loadStates ) {
973973 //mw.log("loadMany: load: " + loadName );
974 - this.load( loadName, function ( loadName ){
 974+ this.load( loadName, function ( loadName ) {
975975 loadStates[ loadName ] = 1;
976976 //mw.log( loadName + ' finished of: ' + JSON.stringify( loadStates ) );
977977 //Check if all load request states are set 1
978978 var loadDone = true;
979 - for( var j in loadStates ){
 979+ for( var j in loadStates ) {
980980 if( loadStates[ j ] === 0 )
981981 loadDone = false;
982982 }
983983 // Run the parent scope callback for "loadMany"
984 - if( loadDone ){
 984+ if( loadDone ) {
985985 callback( loadName );
986986 }
987987 } );
@@ -999,13 +999,13 @@
10001000 * @return {Object}
10011001 * grouped loadSet
10021002 */
1003 - getGroupLoadState: function( loadSet ){
 1003+ getGroupLoadState: function( loadSet ) {
10041004 var groupedLoadSet = [];
10051005 var loadStates = { };
10061006 // Merge load set into new groupedLoadSet
1007 - if( typeof loadSet[0] == 'object' ){
1008 - for( var i = 0; i < loadSet.length ; i++ ){
1009 - for( var j = 0; j < loadSet[i].length ; j++ ){
 1007+ if( typeof loadSet[0] == 'object' ) {
 1008+ for( var i = 0; i < loadSet.length ; i++ ) {
 1009+ for( var j = 0; j < loadSet[i].length ; j++ ) {
10101010 // Make sure we have not already included it:
10111011 groupedLoadSet.push( loadSet[i][j] );
10121012 }
@@ -1022,18 +1022,18 @@
10231023 var loadName = groupedLoadSet[ i ];
10241024 if( this.getClassPath( loadName ) ) {
10251025 // Only add to group request if not already set:
1026 - if ( !mw.isset( loadName ) ){
 1026+ if ( !mw.isset( loadName ) ) {
10271027 groupClassKey += coma + loadName
10281028 coma = ',';
10291029 }
10301030 // Issue a request for any dependent style sheets ( won't load if already present )
1031 - if( typeof this.stylePaths[ loadName ] != 'undefined' ){
 1031+ if( typeof this.stylePaths[ loadName ] != 'undefined' ) {
10321032 mw.getStyleSheet( mw.getMwEmbedPath() + this.stylePaths[ loadName ] );
10331033 }
10341034
10351035 }else if( this.moduleLoaders[ loadName ] ) {
10361036 // Module loaders break up grouped script requests ( add the current groupClassKey )
1037 - if( groupClassKey != '' ){
 1037+ if( groupClassKey != '' ) {
10381038 loadStates[ groupClassKey ] = 0;
10391039 groupClassKey = coma = '';
10401040 }
@@ -1043,7 +1043,7 @@
10441044 }
10451045
10461046 // Add groupClassKey if set:
1047 - if( groupClassKey != '' ){
 1047+ if( groupClassKey != '' ) {
10481048 loadStates [ groupClassKey ] = 0;
10491049 }
10501050
@@ -1059,7 +1059,7 @@
10601060 */
10611061 dependencyChainCallFlag: { },
10621062
1063 - loadDependencyChain: function( loadChain, callback ){
 1063+ loadDependencyChain: function( loadChain, callback ) {
10641064 var _this = this;
10651065 // Load with dependency checks
10661066 var callSet = loadChain.shift();
@@ -1070,7 +1070,7 @@
10711071 // NOTE: IE is playing tricks with me
10721072 // Need to figure out why this callback gets called twice
10731073 // and remove this flag
1074 - if( _this.dependencyChainCallFlag[ callSet ] == callback ){
 1074+ if( _this.dependencyChainCallFlag[ callSet ] == callback ) {
10751075 mw.log("... already called this callback for " + callSet );
10761076 return ;
10771077 }
@@ -1087,10 +1087,10 @@
10881088 * @param {String} className Name of class to load
10891089 * @param {Function} callback Function to run once class is loaded
10901090 */
1091 - loadClass: function( className , callback){
 1091+ loadClass: function( className , callback) {
10921092 var _this = this;
10931093 // Make sure the class is not already defined:
1094 - if ( mw.isset( className ) ){
 1094+ if ( mw.isset( className ) ) {
10951095 mw.log( 'Class ( ' + className + ' ) already defined ' );
10961096 callback( className );
10971097 return ;
@@ -1100,7 +1100,7 @@
11011101 var scriptRequest = null;
11021102
11031103 // If the scriptloader is enabled use the className as the scriptRequest:
1104 - if( mw.getScriptLoaderPath() ){
 1104+ if( mw.getScriptLoaderPath() ) {
11051105 // replace $j with j since php strips the $ from the request class
11061106 scriptRequest = className;
11071107 }else{
@@ -1108,19 +1108,19 @@
11091109 var baseClassPath = this.getClassPath( className );
11101110 // Add the mwEmbed path if not a root path or a full url
11111111 if( baseClassPath.indexOf( '/' ) !== 0 &&
1112 - baseClassPath.indexOf('://') === -1 ){
 1112+ baseClassPath.indexOf('://') === -1 ) {
11131113 scriptRequest = mw.getMwEmbedPath() + baseClassPath;
11141114 }else{
11151115 scriptRequest = baseClassPath;
11161116 }
1117 - if( ! scriptRequest ){
 1117+ if( ! scriptRequest ) {
11181118 mw.log( "Could not get url for class " + className );
11191119 return ;
11201120 }
11211121 }
11221122
11231123 // Check for any associated style sheets that should be loaded
1124 - if( typeof this.stylePaths[ className ] != 'undefined' ){
 1124+ if( typeof this.stylePaths[ className ] != 'undefined' ) {
11251125 mw.getStyleSheet( mw.getMwEmbedPath() + this.stylePaths[ className ] );
11261126 }
11271127
@@ -1134,7 +1134,7 @@
11351135 mw.getScript( scriptRequest, function( scriptRequest ) {
11361136 // Debug output
11371137 if(! mw.isset( className )
1138 - && mwLoadDoneCB[ className ] != 'done' ){
 1138+ && mwLoadDoneCB[ className ] != 'done' ) {
11391139 mw.log( 'Possible Error: ' + className +' not set in time, or not defined in:' + "\n" + _this.getClassPath( className ) );
11401140 }
11411141 // Call load done (incase the script did not include a loadDone callback )
@@ -1149,9 +1149,9 @@
11501150 * ( not all browsers support onLoad script attribute )
11511151 * In the case of a "class" we can pull the javascript state until its ready
11521152 */
1153 - if( !mw.getScriptLoaderPath() ){
1154 - setTimeout( function(){
1155 - mw.waitForObject( className, function( className ){
 1153+ if( !mw.getScriptLoaderPath() ) {
 1154+ setTimeout( function() {
 1155+ mw.waitForObject( className, function( className ) {
11561156 // Once object is ready run loadDone
11571157 mw.loadDone( className );
11581158 } );
@@ -1166,7 +1166,7 @@
11671167 * @param {Function} moduleLoader Function that
11681168 * loads dependencies for a module
11691169 */
1170 - addModuleLoader: function( name, moduleLoader ){
 1170+ addModuleLoader: function( name, moduleLoader ) {
11711171 this.moduleLoaders [ name ] = moduleLoader;
11721172 },
11731173
@@ -1179,11 +1179,11 @@
11801180 * classSet must be strict JSON to allow the
11811181 * php scriptLoader to parse the file paths.
11821182 */
1183 - addClassFilePaths: function( classSet ){
 1183+ addClassFilePaths: function( classSet ) {
11841184 var prefix = ( mw.getConfig( 'loaderContext' ) )?
11851185 mw.getConfig( 'loaderContext' ): '';
11861186
1187 - for( var i in classSet ){
 1187+ for( var i in classSet ) {
11881188 this.classPaths[ i ] = prefix + classSet[ i ];
11891189 }
11901190 },
@@ -1192,7 +1192,7 @@
11931193 * Get a class path forom a className
11941194 * if no class found return false
11951195 */
1196 - getClassPath: function( className ){
 1196+ getClassPath: function( className ) {
11971197 if( this.classPaths[ className ] )
11981198 return this.classPaths[ className ]
11991199 return false;
@@ -1206,8 +1206,8 @@
12071207 *
12081208 * @param {Object} sheetSet ClassKey : sheet location key value paris
12091209 */
1210 - addClassStyleSheets: function( sheetSet ){
1211 - for(var i in sheetSet ){
 1210+ addClassStyleSheets: function( sheetSet ) {
 1211+ for(var i in sheetSet ) {
12121212 this.stylePaths[ i ] = sheetSet[ i ];
12131213 }
12141214 }
@@ -1219,16 +1219,16 @@
12201220 */
12211221 mw.loadDone = function( requestName ) {
12221222 //mw.log( "LoadDone: " + requestName + ' run callback ');
1223 - if( !mwLoadDoneCB[ requestName ] ){
 1223+ if( !mwLoadDoneCB[ requestName ] ) {
12241224 return true;
12251225 }
1226 - while( mwLoadDoneCB[ requestName ].length ){
 1226+ while( mwLoadDoneCB[ requestName ].length ) {
12271227 if( typeof mwLoadDoneCB[ requestName ] != 'object' )
12281228 {
12291229 break;
12301230 }
12311231 var func = mwLoadDoneCB[ requestName ].pop();
1232 - if( typeof func == 'function' ){
 1232+ if( typeof func == 'function' ) {
12331233 func( requestName );
12341234 }else{
12351235 mw.log('mwLoadDoneCB: Error non callback function on stack');
@@ -1243,13 +1243,13 @@
12441244 * @param {String} requestName Name of class or request set
12451245 * @param {Function} callback Function called once requestName is ready
12461246 */
1247 - mw.setLoadDoneCB = function( requestName, callback ){
 1247+ mw.setLoadDoneCB = function( requestName, callback ) {
12481248 // If the requestName is already done loading just callback
1249 - if( mwLoadDoneCB[ requestName ] == 'done' ){
 1249+ if( mwLoadDoneCB[ requestName ] == 'done' ) {
12501250 callback( requestName )
12511251 }
12521252 // Setup the function queue if unset
1253 - if( ! mwLoadDoneCB[ requestName ] ){
 1253+ if( ! mwLoadDoneCB[ requestName ] ) {
12541254 mwLoadDoneCB[ requestName ] = [];
12551255 }
12561256 mwLoadDoneCB[ requestName ].push( callback );
@@ -1263,7 +1263,7 @@
12641264 /**
12651265 * Load Object entry point: Loads a requested set of javascript
12661266 */
1267 - mw.load = function( loadRequest, callback ){
 1267+ mw.load = function( loadRequest, callback ) {
12681268 return mw.loader.load( loadRequest, callback );
12691269 }
12701270
@@ -1271,7 +1271,7 @@
12721272 /**
12731273 * Add module entry point: Adds a module to the mwLoader object
12741274 */
1275 - mw.addModuleLoader = function ( name, loaderFunction ){
 1275+ mw.addModuleLoader = function ( name, loaderFunction ) {
12761276 return mw.loader.addModuleLoader( name, loaderFunction );
12771277 }
12781278
@@ -1290,7 +1290,7 @@
12911291 /**
12921292 * Add Class Style Sheet entry point:
12931293 */
1294 - mw.addClassStyleSheets = function( sheetSet ){
 1294+ mw.addClassStyleSheets = function( sheetSet ) {
12951295 return mw.loader.addClassStyleSheets( sheetSet );
12961296 }
12971297
@@ -1315,9 +1315,9 @@
13161316 * {Boolean} false if no page found
13171317 * {String} text of wiki page
13181318 */
1319 - mw.getTitleText = function( apiUrl, title, callback ){
 1319+ mw.getTitleText = function( apiUrl, title, callback ) {
13201320 // Check if optional apiURL was not included
1321 - if( !callback ){
 1321+ if( !callback ) {
13221322 title = apiUrl;
13231323 callback = title;
13241324 apiUrl = mw.getLocalApiUrl();
@@ -1329,13 +1329,13 @@
13301330 'rvprop' : 'content'
13311331 };
13321332 mw.getJSON( apiUrl , request, function( data ) {
1333 - if( !data || !data.query || !data.query.pages ){
 1333+ if( !data || !data.query || !data.query.pages ) {
13341334 callback( false );
13351335 }
13361336 var pages = data.query.pages;
1337 - for(var i in pages){
 1337+ for(var i in pages) {
13381338 page = pages[ i ];
1339 - if( page[ 'revisions' ] && page[ 'revisions' ][0]['*'] ){
 1339+ if( page[ 'revisions' ] && page[ 'revisions' ][0]['*'] ) {
13401340 callback( page[ 'revisions' ][0]['*'] );
13411341 }
13421342 }
@@ -1363,7 +1363,7 @@
13641364 * @param {Mixed} callbcak
13651365 *
13661366 */
1367 - mw.getJSON = function( arg1, arg2, arg3 ){
 1367+ mw.getJSON = function( arg1, arg2, arg3 ) {
13681368 // Set up the url
13691369 var url = false;
13701370 url = ( typeof arg1 == 'string' ) ? arg1 : mw.getLocalApiUrl();
@@ -1371,40 +1371,40 @@
13721372 // Set up the data:
13731373 var data = null;
13741374 data = ( typeof arg1 == 'object' ) ? arg1 : null;
1375 - if( !data && typeof arg2 == 'object' ){
 1375+ if( !data && typeof arg2 == 'object' ) {
13761376 data = arg2;
13771377 }
13781378
13791379 // Setup the callback
13801380 var callback = false;
13811381 callback = ( typeof arg2 == 'function') ? arg2 : false;
1382 - if( ! callback && ( typeof arg3 == 'function') ){
 1382+ if( ! callback && ( typeof arg3 == 'function') ) {
13831383 callback = arg3;
13841384 }
13851385
13861386 // Make sure we got a url:
1387 - if( !url ){
 1387+ if( !url ) {
13881388 mw.log( 'Error: no api url for api request' );
13891389 return false;
13901390 }
13911391
13921392 // Add default action if unset:
1393 - if( !data['action'] ){
 1393+ if( !data['action'] ) {
13941394 data['action'] = 'query';
13951395 }
13961396
13971397 // Add default format if not set:
1398 - if( !data['format'] ){
 1398+ if( !data['format'] ) {
13991399 data['format'] = 'json';
14001400 }
14011401
14021402 mw.log("run getJSON: " + mw.replaceUrlParams( url, data ) );
14031403 // Check if the request requires a "post" (that does not work with callbacks cross domain)
1404 - if( mw.checkRequestPost( data ) ){
 1404+ if( mw.checkRequestPost( data ) ) {
14051405 // Check if we need to setup a proxy
1406 - if( ! mw.isLocalDomain( url ) ){
 1406+ if( ! mw.isLocalDomain( url ) ) {
14071407 // Load the proxy and issue the request
1408 - mw.load( 'ApiProxy', function(){
 1408+ mw.load( 'ApiProxy', function() {
14091409 mw.ApiProxy.doRequest( url, data, callback );
14101410 });
14111411 }else{
@@ -1414,8 +1414,8 @@
14151415 return ;
14161416 }
14171417 // If cross domain setup a callback:
1418 - if( ! mw.isLocalDomain( url ) ){
1419 - if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){
 1418+ if( ! mw.isLocalDomain( url ) ) {
 1419+ if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ) {
14201420 // jQuery specific: ( second ? is replaced with the callback )
14211421 url += ( url.indexOf('?') == -1 ) ? '?callback=?' : '&callback=?';
14221422 }
@@ -1431,14 +1431,14 @@
14321432 * true if the request requires a post request
14331433 * false if the request does not
14341434 */
1435 - mw.checkRequestPost = function ( data ){
1436 - if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){
 1435+ mw.checkRequestPost = function ( data ) {
 1436+ if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ) {
14371437 return true;
14381438 }
1439 - if( data['prop'] == 'info' && data['intoken'] ){
 1439+ if( data['prop'] == 'info' && data['intoken'] ) {
14401440 return true;
14411441 }
1442 - if( data['meta'] == 'userinfo' ){
 1442+ if( data['meta'] == 'userinfo' ) {
14431443 return true;
14441444 }
14451445 return false;
@@ -1455,7 +1455,7 @@
14561456 */
14571457 mw.isLocalDomain = function( url ) {
14581458 if( mw.parseUri( document.URL ).host == mw.parseUri( url ).host ||
1459 - url.indexOf( '://' ) == -1 ){
 1459+ url.indexOf( '://' ) == -1 ) {
14601460 return true;
14611461 }
14621462 return false;
@@ -1470,7 +1470,7 @@
14711471 */
14721472 mw.getToken = function( api_url, title, callback ) {
14731473 // Make the api_url be optional:
1474 - if( typeof title == 'function' ){
 1474+ if( typeof title == 'function' ) {
14751475 callback = title;
14761476 title = api_url;
14771477 api_url = mw.getLocalApiUrl();
@@ -1514,7 +1514,7 @@
15151515 /*mw.status = function( status )
15161516
15171517
1518 - var Status = function(){
 1518+ var Status = function() {
15191519
15201520 }*/
15211521
@@ -1616,27 +1616,27 @@
16171617 * number of times waitForObject has been called
16181618 */
16191619 var waitTime = 1200; // About 30 seconds
1620 - mw.waitForObject = function( objectName, callback, _callNumber){
 1620+ mw.waitForObject = function( objectName, callback, _callNumber) {
16211621 //mw.log( 'waitForObject: ' + objectName + ' cn: ' + _callNumber);
16221622
16231623 // Increment callNumber:
1624 - if( !_callNumber ){
 1624+ if( !_callNumber ) {
16251625 _callNumber = 1;
16261626 } else {
16271627 _callNumber++;
16281628 }
16291629
1630 - if( _callNumber > waitTime ){
 1630+ if( _callNumber > waitTime ) {
16311631 mw.log( "Error: waiting for object: " + objectName + ' timeout ' );
16321632 callback( false );
16331633 return ;
16341634 }
16351635
16361636 // If the object is defined ( or we are done loading from a callback )
1637 - if ( mw.isset( objectName ) || mwLoadDoneCB[ objectName ] == 'done' ){
 1637+ if ( mw.isset( objectName ) || mwLoadDoneCB[ objectName ] == 'done' ) {
16381638 callback( objectName )
16391639 }else{
1640 - setTimeout( function( ){
 1640+ setTimeout( function( ) {
16411641 mw.waitForObject( objectName, callback, _callNumber);
16421642 }, 25);
16431643 }
@@ -1648,7 +1648,7 @@
16491649 * @param {Object} object Object to be checked
16501650 */
16511651 mw.isEmpty = function( object ) {
1652 - if( typeof object == 'string' ){
 1652+ if( typeof object == 'string' ) {
16531653 if( object == '' ) return true;
16541654 // Non empty string:
16551655 return false;
@@ -1656,12 +1656,12 @@
16571657
16581658 // If an array check length:
16591659 if( Object.prototype.toString.call( object ) === "[object Array]"
1660 - && object.length == 0 ){
 1660+ && object.length == 0 ) {
16611661 return true;
16621662 }
16631663
16641664 // Else check as an object:
1665 - for( var i in object ){ return false; }
 1665+ for( var i in object ) { return false; }
16661666
16671667 // Else object is empty:
16681668 return true;
@@ -1690,7 +1690,7 @@
16911691 /*
16921692
16931693 var log_elm = document.getElementById('mv_js_log');
1694 - if(!log_elm){
 1694+ if(!log_elm) {
16951695 document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML +
16961696 '<div style="position:absolute;z-index:500;bottom:0px;left:0px;right:0px;height:200px;">'+
16971697 '<textarea id="mv_js_log" cols="120" rows="12"></textarea>'+
@@ -1698,7 +1698,7 @@
16991699
17001700 var log_elm = document.getElementById('mv_js_log');
17011701 }
1702 - if(log_elm){
 1702+ if(log_elm) {
17031703 log_elm.value+=string+"\n";
17041704 }
17051705 */
@@ -1735,15 +1735,15 @@
17361736 *
17371737 * @param {Function} callback Function to run once DOM and jQuery are ready
17381738 */
1739 - mw.ready = function( callback ){
1740 - if( mwReadyFlag === false ){
 1739+ mw.ready = function( callback ) {
 1740+ if( mwReadyFlag === false ) {
17411741
17421742 // Add the callbcak to the onLoad function stack
17431743 mwOnLoadFunctions.push ( callback );
17441744
17451745 // Set the mwSetup flag. So that onLoad functions can
17461746 // be called once mwEmbed interfaces are setup.
1747 - if( !mwDomReadyFlag ){
 1747+ if( !mwDomReadyFlag ) {
17481748 //mw.log( 'set config flag' );
17491749 mw.setConfig( 'runSetupMwEmbed', true );
17501750 }else{
@@ -1761,9 +1761,9 @@
17621762 /**
17631763 * Runs all the queued functions
17641764 */
1765 - mw.runReadyHooks = function ( ){
 1765+ mw.runReadyHooks = function ( ) {
17661766 // Run all the queued functions:
1767 - while( mwOnLoadFunctions.length ){
 1767+ while( mwOnLoadFunctions.length ) {
17681768 mwOnLoadFunctions.pop()();
17691769 }
17701770
@@ -1781,7 +1781,7 @@
17821782 * @param {String} scriptRequest The requested path or classNames for the scriptLoader
17831783 * @param {Function} callback Function to call once script is loaded
17841784 */
1785 - mw.getScript = function( scriptRequest, callback ){
 1785+ mw.getScript = function( scriptRequest, callback ) {
17861786
17871787 // Set the base url based scriptLoader availability & type of scriptRequest
17881788 // ( presently script loader only handles "classes" not relative urls:
@@ -1807,7 +1807,7 @@
18081808 // If jQuery is available and debug is off load the scirpt via jQuery
18091809 //( will use XHR if on same domain )
18101810 if( mw.isset( 'window.jQuery' ) && mw.getConfig( 'debug' ) === false ) {
1811 - $j.getScript( url, function(){
 1811+ $j.getScript( url, function() {
18121812 if( callback )
18131813 callback( scriptRequest );
18141814 });
@@ -1825,9 +1825,9 @@
18261826 script.setAttribute( 'src', url );
18271827
18281828 // Attach handlers ( if using script loader it issues onDone callback as well )
1829 - script.onload = script.onreadystatechange = function(){
 1829+ script.onload = script.onreadystatechange = function() {
18301830 if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
1831 - if( callback ){
 1831+ if( callback ) {
18321832 callback( scriptRequest );
18331833 }
18341834 }
@@ -1838,10 +1838,8 @@
18391839 }
18401840
18411841 /**
1842 - * "Get" a style sheet.
 1842+ * Get a style sheet and append the style sheet to the DOM
18431843 *
1844 - * Appends a style sheet to the DOM is called "getStyleSheet" to mirror wraping of jqueries getScript
1845 - *
18461844 * @param {Mixed}
18471845 * {Array} url List of urls to be loaded
18481846 * {String} url Url of the style sheet to be loaded
@@ -1862,21 +1860,21 @@
18631861
18641862 // Check if style sheet is already included:
18651863 var foundSheet = false;
1866 - $j( 'link' ).each( function(){
 1864+ $j( 'link' ).each( function() {
18671865 var currentSheet = $j( this) .attr( 'href' );
18681866 var sheetParts = currentSheet.split('?');
18691867 var urlParts = url.split('?');
18701868 //if the base url's match check the parameters:
1871 - if( sheetParts[0] == urlParts[0] && sheetParts[1]){
 1869+ if( sheetParts[0] == urlParts[0] && sheetParts[1]) {
18721870 //mw.log(" sheet compare: " + sheetParts[1].split( '&' ).sort().join('') + ' != ' + urlParts[1].split('&').sort().join(''));
18731871 //Check if url params match ( sort to do string compare )
18741872 if( sheetParts[1].split( '&' ).sort().join('') ==
1875 - urlParts[1].split('&').sort().join('') ){
 1873+ urlParts[1].split('&').sort().join('') ) {
18761874 foundSheet = true;
18771875 }
18781876 }
18791877 } );
1880 - if( foundSheet ){
 1878+ if( foundSheet ) {
18811879 mw.log( 'skiped sheet: ' + url);
18821880 return ;
18831881 }
@@ -1898,8 +1896,8 @@
18991897 * local wiki api if no apiProvider is set
19001898 * false if no local wiki api found
19011899 */
1902 - mw.getApiProviderURL = function( provider_id ){
1903 - if( mw.getConfig( provider_id + '_apiurl') ){
 1900+ mw.getApiProviderURL = function( provider_id ) {
 1901+ if( mw.getConfig( provider_id + '_apiurl') ) {
19041902 return mw.getConfig( provider_id + '_apiurl');
19051903 }
19061904 return mw.getLocalApiUrl();
@@ -1944,12 +1942,12 @@
19451943 }
19461944
19471945 // Script-loader has jsScriptLoader name when local:
1948 - if( src.indexOf( 'jsScriptLoader.php' ) !== -1 ){
 1946+ if( src.indexOf( 'jsScriptLoader.php' ) !== -1 ) {
19491947 mwpath = src.substr( 0, src.indexOf( 'jsScriptLoader.php' ) );
19501948 }
19511949
19521950 // Error out if we could not get the path:
1953 - if( ! mwpath ){
 1951+ if( ! mwpath ) {
19541952 mw.log( "Error could not get mwEmbed path " );
19551953 return ;
19561954 }
@@ -2069,7 +2067,7 @@
20702068 &&
20712069 src.indexOf( 'mwEmbed' ) !== -1
20722070 )
2073 - ){
 2071+ ) {
20742072 mwEmbedSrc = src;
20752073 return mwEmbedSrc;
20762074 }
@@ -2138,7 +2136,7 @@
21392137 }
21402138
21412139 // Merge new params:
2142 - for( var key in newParams ){
 2140+ for( var key in newParams ) {
21432141 parsedUrl.queryKey[ key ] = newParams[ key ];
21442142 }
21452143
@@ -2205,14 +2203,14 @@
22062204 return src;
22072205
22082206 // Get parent Url location the context URL
2209 - if( contextUrl){
 2207+ if( contextUrl) {
22102208 var parsedUrl = mw.parseUri( contextUrl );
22112209 } else {
22122210 var parsedUrl = mw.parseUri( document.URL );
22132211 }
22142212
22152213 // Check for leading slash:
2216 - if( src.indexOf( '/' ) === 0 ){
 2214+ if( src.indexOf( '/' ) === 0 ) {
22172215 return parsedUrl.protocol + '://' + parsedUrl.authority + src;
22182216 }else{
22192217 return parsedUrl.protocol + '://' + parsedUrl.authority + parsedUrl.directory + src;
@@ -2271,7 +2269,7 @@
22722270 try{
22732271 xmldata.loadXML( str );
22742272 return xmldata;
2275 - } catch (e){
 2273+ } catch (e) {
22762274 mw.log( 'XML parse ERROR: ' + e.message );
22772275 return false;
22782276 }
@@ -2320,7 +2318,7 @@
23212319 mw.log( 'mw:setupMwEmbed :: ' + mw.getMwEmbedSrc() );
23222320
23232321 // Set the User language
2324 - if( typeof wgUserLanguage != 'undefined' && mw.isValidLang( wgUserLanguage) ){
 2322+ if( typeof wgUserLanguage != 'undefined' && mw.isValidLang( wgUserLanguage) ) {
23252323 mw.setConfig( 'userLanguage', wgUserLanguage )
23262324 }else{
23272325 // Grab it from the included url
@@ -2331,7 +2329,7 @@
23322330 }
23332331
23342332 // Make sure we have jQuery:
2335 - mw.load( 'window.jQuery', function(){
 2333+ mw.load( 'window.jQuery', function() {
23362334 if ( !window['$j'] ) {
23372335 window['$j'] = jQuery.noConflict();
23382336 }
@@ -2339,7 +2337,7 @@
23402338
23412339 // Only load jquery ui theme sheet if ui-widget does not exist.
23422340 // NOTE: disabled as style sheets are cross domain and it behaves differently across browsers
2343 - //if( ! mw.styleRuleExists( 'ui-widget' ) ){
 2341+ //if( ! mw.styleRuleExists( 'ui-widget' ) ) {
23442342 mw.getStyleSheet( mw.getConfig( 'jquery_skin_path' ) + 'jquery-ui-1.7.1.custom.css' );
23452343 //}
23462344
@@ -2361,8 +2359,8 @@
23622360
23632361 // Run all the setup function hooks
23642362 // Once complete we can run .ready queued functions
2365 - function runSetupFunctions(){
2366 - if( mwSetupFunctions.length ){
 2363+ function runSetupFunctions() {
 2364+ if( mwSetupFunctions.length ) {
23672365 mwSetupFunctions.pop()( function() {
23682366 runSetupFunctions();
23692367 } );
@@ -2381,28 +2379,28 @@
23822380 * Note if using a scriptLoader all the loaders and localization converters
23832381 * are included automatically.
23842382 */
2385 - mw.moduleLoaderCheck = function( callback ){
 2383+ mw.moduleLoaderCheck = function( callback ) {
23862384 mw.log( 'doLoaderCheck::' );
23872385 // Check if we are using scriptloader ( handles loader include automatically )
2388 - if( mw.getScriptLoaderPath() ){
 2386+ if( mw.getScriptLoaderPath() ) {
23892387 // Do a async call to callback in cases where DOM is ready before we get to
23902388 // loader config code in the same file.
2391 - setTimeout(function(){
 2389+ setTimeout(function() {
23922390 callback();
23932391 }, 1000);
23942392 return ;
23952393 }
23962394 // Add the Core loader to the request
2397 - mw.load( 'loader.js', function(){
 2395+ mw.load( 'loader.js', function() {
23982396 // Load all the "loaders" of the enabled modules:
23992397 var loaderRequest = [];
24002398 var enabledModules = mw.getConfig( 'enabledModules' );
2401 - for(var i=0; i < enabledModules.length; i++ ){
 2399+ for(var i=0; i < enabledModules.length; i++ ) {
24022400 loaderRequest.push( 'modules/' + enabledModules[ i ] + '/loader.js' );
24032401 };
24042402
24052403 // Add the language ( if set )
2406 - if( mw.getConfig( 'userLanguage' ) ){
 2404+ if( mw.getConfig( 'userLanguage' ) ) {
24072405 var langCode = mw.getConfig( 'userLanguage' );
24082406 // Upper case the first letter:
24092407 langCode = langCode.substr(0,1).toUpperCase() + langCode.substr( 1, langCode.length );
@@ -2411,7 +2409,7 @@
24122410 }
24132411
24142412 mw.setConfig('loaderContext', '' );
2415 - mw.load( loaderRequest, function(){
 2413+ mw.load( loaderRequest, function() {
24162414 mw.log( 'Done moduleLoaderCheck request' );
24172415 // Set the mwModuleLoaderCheckFlag flag to true
24182416 mwModuleLoaderCheckFlag = true;
@@ -2444,13 +2442,13 @@
24452443 rules = document.styleSheets[i].cssRules
24462444 else if (document.styleSheets[0].rules)
24472445 rules = document.styleSheets[i].rules
2448 - for(var j=0 ; j < rules.length ; j++ ){
 2446+ for(var j=0 ; j < rules.length ; j++ ) {
24492447 var rule = rules[j].selectorText;
24502448 if( rule && rule.indexOf( styleRule ) != -1 ) {
24512449 return true;
24522450 }
24532451 }
2454 - }catch ( e ){
 2452+ }catch ( e ) {
24552453 mw.log( 'Error: cant check rule on cross domain style sheet:' + document.styleSheets[i].href );
24562454 }
24572455 }
@@ -2490,7 +2488,7 @@
24912489 * Will check configuration and issue a mw.setupMwEmbed call if needed
24922490 */
24932491 mw.domReady = function ( ) {
2494 - if( mwDomReadyFlag ){
 2492+ if( mwDomReadyFlag ) {
24952493 return ;
24962494 }
24972495 mw.log( 'run:domReady:: ' + document.getElementsByTagName('video').length );
@@ -2513,7 +2511,7 @@
25142512 }
25152513
25162514 // Check for queued functions that use mw interfaces:
2517 - if ( mwOnLoadFunctions.length ){
 2515+ if ( mwOnLoadFunctions.length ) {
25182516 mw.setupMwEmbed();
25192517 return ;
25202518 }
@@ -2537,10 +2535,10 @@
25382536 var minVersionParts = minVersion.split('.')
25392537 var clientVersionParts = clientVersion.split('.');
25402538 for( var i =0; i < minVersionParts.length; i++ ) {
2541 - if( parseInt( clientVersionParts[i] ) > parseInt( minVersionParts[i] ) ){
 2539+ if( parseInt( clientVersionParts[i] ) > parseInt( minVersionParts[i] ) ) {
25422540 return true;
25432541 }
2544 - if( parseInt( clientVersionParts[i] ) < parseInt( minVersionParts[i] ) ){
 2542+ if( parseInt( clientVersionParts[i] ) < parseInt( minVersionParts[i] ) ) {
25452543 return false;
25462544 }
25472545 }
@@ -2620,11 +2618,11 @@
26212619 .attr('href', '#')
26222620 .addClass( 'ui-state-default ui-corner-all ui-icon_link' );
26232621 // Add css if set:
2624 - if( options.css ){
 2622+ if( options.css ) {
26252623 $btn.css( options.css )
26262624 }
26272625
2628 - if( options['class'] ){
 2626+ if( options['class'] ) {
26292627 $btn.addClass( options['class'] )
26302628 }
26312629
@@ -2723,7 +2721,7 @@
27242722 var ie = /*@cc_on!@*/false;
27252723 if (/webkit/.test(u)) {
27262724 // safari
2727 - timeout = setTimeout(function(){
 2725+ timeout = setTimeout(function() {
27282726 if ( document.readyState == "loaded" ||
27292727 document.readyState == "complete" ) {
27302728 i();
@@ -2734,7 +2732,7 @@
27352733 } else if ((/mozilla/.test(u) && !/(compatible)/.test(u)) ||
27362734 (/opera/.test(u))) {
27372735 // opera/moz
2738 - document.addEventListener("DOMContentLoaded",i,false);
 2736+ document.addEventListener("DOMContentLoaded", i, false);
27392737 } else if ( ie ) {
27402738 // IE
27412739 (function ( ) {
@@ -2755,7 +2753,7 @@
27562754 // As a backup check if "body" is not null ( for dynamic inserts )
27572755 // ( mw.domReady ignores multiple ready calls )
27582756 var mwCheckBody = function( ) {
2759 - if( document.getElementsByTagName( 'body' )[0] ){
 2757+ if( document.getElementsByTagName( 'body' )[0] ) {
27602758 mw.domReady();
27612759 }else{
27622760 setTimeout( function( ) {

Status & tagging log