r62047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62046‎ | r62047 | r62048 >
Date:20:44, 5 February 2010
Author:dale
Status:deferred
Tags:
Comment:
* some refactored dom build-out for showPlayerSelect
* some IE fixes
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -175,15 +175,16 @@
176176 // Add recommend firefox if we have non-native playback:
177177 if ( _this.doNativeWarningCheck() ) {
178178 $j( '#dc_' + embedPlayer.id ).hover(
179 - function() {
 179+ function() {
180180 if ( $j( '#gnp_' + embedPlayer.id ).length == 0 ) {
181181 var toppos = ( embedPlayer.instanceOf == 'mvPlayList' ) ? 25 : 10;
 182+
182183 $j( this ).append(
183184 $j('<div />')
184185 .attr({
185 - 'id': "gnp_" + embedPlayer.id,
 186+ 'id': "gnp_" + embedPlayer.id
186187 })
187 - .addClass('ui-state-highlight ui-corner-all')
 188+ .addClass( 'ui-state-highlight ui-corner-all' )
188189 .css({
189190 'position':'absolute',
190191 'display':'none',
@@ -193,13 +194,22 @@
194195 'left' : '10px',
195196 'right' : '10px'
196197 })
197 - .html( gM( 'mwe-for_best_experience' ) ),
198 - $j('<br />'),
199 - $j('<input />')
 198+ .html( gM( 'mwe-for_best_experience' ) )
 199+ );
 200+ $target_warning = $j( '#gnp_' + embedPlayer.id );
 201+
 202+ $target_warning.append(
 203+ $j('<br />')
 204+ );
 205+
 206+
 207+ $target_warning.append(
 208+ $j( '<input />' )
200209 .attr({
201210 'id' : 'ffwarn_' + embedPlayer.id,
202 - })
203 - .text( gM( 'mwe-do_not_warn_again' ) )
 211+ 'type' : "checkbox",
 212+ 'name' : 'ffwarn_' + embedPlayer.id
 213+ })
204214 .click( function() {
205215 if ( $j( this ).is( ':checked' ) ) {
206216 // Set up a cookie for 7 days:
@@ -211,12 +221,18 @@
212222 mw.setConfig( 'show_player_warning', true );
213223 $j.cookie( 'show_player_warning', true );
214224 }
215 - } )
 225+ } )
216226 );
217 - }
 227+ $target_warning.append(
 228+ $j('<span />')
 229+ .text( gM( 'mwe-do_not_warn_again' ) )
 230+ )
 231+ }
 232+
218233 // Only show the warning if cookie and config are true
219 - if ( mw.getConfig( 'show_player_warning' ) === true )
 234+ if ( mw.getConfig( 'show_player_warning' ) === true ){
220235 $j( '#gnp_' + embedPlayer.id ).fadeIn( 'slow' );
 236+ }
221237 },
222238 function() {
223239 $j( '#gnp_' + embedPlayer.id ).fadeOut( 'slow' );
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -45,6 +45,7 @@
4646 "mwe-credits" : "Credits",
4747 "mwe-clip_linkback" : "Clip source page",
4848 "mwe-chose_player" : "Choose video player",
 49+ "mwe-no-player" : "No player available for $1",
4950 "mwe-share_this_video" : "Share this video",
5051 "mwe-video_credits" : "Video credits",
5152 "mwe-menu_btn" : "Menu",
@@ -2247,7 +2248,7 @@
22482249 .css({
22492250 'position' : 'relative',
22502251 'width' : this.getPlayerWidth() + 'px',
2251 - 'height' : this.getPlayerHeight() + 'px',
 2252+ 'height' : this.getPlayerHeight() + 'px'
22522253 })
22532254 .attr({
22542255 'id' : 'img_thumb_' + this.id,
@@ -2533,42 +2534,58 @@
25342535 }
25352536 // Get id (in case where we have a parent container)
25362537 var _this = this;
2537 - var o = '';
2538 - o += '<h2>' + gM( 'mwe-chose_player' ) + '</h2>';
 2538+
 2539+ $target
 2540+ .empty()
 2541+ .append(
 2542+ $j( '<h2 />' )
 2543+ .text( gM( 'mwe-chose_player' ) )
 2544+ );
 2545+
25392546 var _this = this;
25402547 $j.each( this.mediaElement.getPlayableSources(), function( source_id, source ) {
25412548 var playable = mw.EmbedTypes.players.defaultPlayer( source.getMIMEType() );
25422549
25432550 var is_selected = ( source == _this.mediaElement.selected_source );
25442551
2545 - o += '<h2>' + source.getTitle() + '</h2>';
 2552+ $target.append(
 2553+ $j( '<h2 />' )
 2554+ .text( source.getTitle() )
 2555+ );
25462556
25472557 if ( playable ) {
2548 - o += '<ul>';
 2558+ $playerList = $j('<ul />');
25492559 // output the player select code:
25502560 var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
25512561
2552 - for ( var i = 0; i < supporting_players.length ; i++ ) {
 2562+ for ( var i = 0; i < supporting_players.length ; i++ ) {
 2563+ var $playerLink = $j( '<a />')
 2564+ .attr({
 2565+ 'href' : '#',
 2566+ 'rel' : 'sel_source',
 2567+ 'id' : 'sc_' + source_id + '_' + supporting_players[i].id
 2568+ })
 2569+ .text( supporting_players[i].getName() );
 2570+
25532571 if ( _this.selected_player.id == supporting_players[i].id && is_selected ) {
2554 - o += '<li>' +
2555 - '<a href="#" class="active" rel="sel_source" id="sc_' + source_id + '_' + supporting_players[i].id + '">' +
2556 - supporting_players[i].getName() +
2557 - '</a>' +
2558 - '</li>';
2559 - } else {
2560 - o += '<li>' +
2561 - '<a href="#" rel="sel_source" id="sc_' + source_id + '_' + supporting_players[i].id + '">' +
2562 - supporting_players[i].getName() +
2563 - '</a>' +
2564 - '</li>';
 2572+ $playerLink
 2573+ .addClass('active' );
25652574 }
 2575+ $playerList.append(
 2576+ $j( '<li />' ).append(
 2577+ $playerLink
 2578+ )
 2579+ );
25662580 }
2567 - o += '</ul>';
 2581+
 2582+ // Append the player list:
 2583+ $target.append( $playerList );
 2584+
25682585 } else {
2569 - o += source.getTitle() + ' - no player available';
 2586+ // No player avaliable:
 2587+ $target.append( gM( 'mwe-no-player', source.getTitle() ) )
25702588 }
2571 - } );
2572 - $target.html( o );
 2589+ } );
25732590
25742591 // Set up the click bindings:
25752592 $target.find( "[rel='sel_source']" ).each( function() {
@@ -2621,7 +2638,7 @@
26222639 $target.append(
26232640 $j('<div />')
26242641 .css({
2625 - "color":"white",
 2642+ "color":"white"
26262643 })
26272644 );
26282645 var $mediaList = $j( '<ul />' );
@@ -2631,7 +2648,7 @@
26322649 var $dl_line = $j( '<li />').append(
26332650 $j('<a />').
26342651 css({
2635 - "color" : "white",
 2652+ "color" : "white"
26362653 })
26372654 .attr( 'href', source.getSrc())
26382655 .text( source.getTitle() )
@@ -2711,6 +2728,11 @@
27122729 } )
27132730 .attr( 'title', gM( 'mwe-pause_clip' ) );
27142731
 2732+ // Do play tracking if enabled
 2733+ if( mw.getConfig( 'playTracking' ) ){
 2734+ this.doPlayTracking();
 2735+ }
 2736+
27152737 //Run play hook:
27162738 this.runHook( 'play' );
27172739 },
@@ -2799,7 +2821,7 @@
28002822 * Base Embed mute
28012823 *
28022824 * Handles interface updates for toggling mute.
2803 - * Plug-in / player interface must handle updateing the actual media player
 2825+ * Plug-in / player interface must handle the actual media player update
28042826 */
28052827 toggleMute:function() {
28062828 if ( this.muted ) {
@@ -2816,6 +2838,7 @@
28172839
28182840 /**
28192841 * Abstract Update volumen Method must be overided by plug-in / player interface
 2842+ * @param {float} prec Percet of full volume
28202843 */
28212844 updateVolumen:function( perc ) {
28222845 mw.log( 'update volume not supported with current playback type' );
@@ -2876,6 +2899,23 @@
28772900 return this.thumbnail_disp;
28782901 },
28792902
 2903+ /**
 2904+ * Checks if we are monitoring play requests
 2905+ * presently this function is mediaWiki api specific.
 2906+ */
 2907+ doPlayTracking: function(){
 2908+ var playTrackingRate = mw.getConfig( 'playTrackingRate' );
 2909+ // Math.floor ( Math.random() * playTrackingRate ) == 0
 2910+ if( true ){
 2911+ mw.getJSON( {
 2912+ 'action' : 'playtracking',
 2913+ 'filename' : this.apiTitleKey,
 2914+ 'client' : this.selected_player.library + ' && ' + navigator.userAgent
 2915+ }, function( data ){
 2916+ mw.log( 'done logging play request' );
 2917+ } );
 2918+ }
 2919+ },
28802920
28812921 /**
28822922 * Monitor playback and update interface components.
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -1009,7 +1009,7 @@
10101010 * Groups the loadSet into a single sequential array
10111011 *
10121012 * Groups the scriptRequest where possible:
1013 - * Modules include "loader code" so they are seperated
 1013+ * Modules include "loader code" so they are separated
10141014 * into pre-condition code to be run for subsequent requests
10151015 *
10161016 * @param {Object} loadSet Loadset to return grouped
@@ -2250,7 +2250,7 @@
22512251 re = new RegExp("\\n","g");
22522252 text = text.replace(re,"\\n");
22532253 return escapeQuotesHTML(text);
2254 - }
 2254+ };
22552255
22562256 /**
22572257 * Escape an HTML text string
@@ -2268,7 +2268,7 @@
22692269 re = new RegExp('>',"g");
22702270 text = text.replace(re,"&gt;");
22712271 return text;
2272 - }
 2272+ };
22732273
22742274 /**
22752275 * Takes in a string returns an xml dom object

Status & tagging log