r109856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109855‎ | r109856 | r109857 >
Date:21:58, 23 January 2012
Author:dale
Status:ok
Tags:
Comment:
* switched loading spinner over to spinner.js ( all js much nicer solution )
* use of playerReadyFlag ( instead of "playerReady" to work around jQuery trigger restriction on isFunction for DOM methods )
* removed use of intermediary .preference local var, instead always read and write to the cookie directly
* added css rounded boarders for playhead and playhead position indicator
* added min resize for resizing fullscren players to avoid interface overflow
* fixed loaderScript restriction on associated modules, moved mw.MediaWikiPlayer.loader into its own "module"
* removed selenium test folder
Modified paths:
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.php (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/jquery.loadingSpinner.js (modified) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingDots.png (deleted) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpinner.css (deleted) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpokes.gif (deleted) (history)
  • /trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.mwEmbedUtil.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.MediaPlayers.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.processEmbedPlayers.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/kskin/PlayerSkinKskin.css (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/kskin/mw.PlayerSkinKskin.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/resources/mw.MediaWikiPlayer.loader.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/resources/mw.MediaWikiPlayerSupport.js (modified) (history)
  • /trunk/extensions/TimedMediaHandler/tests/selenium (deleted) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/TimedMediaHandler.hooks.php
@@ -50,7 +50,7 @@
5151 'embedPlayerIframeStyle'=> array_merge( $baseExtensionResource, array(
5252 'styles' => 'resources/embedPlayerIframe.css',
5353 ) ),
54 - 'ext.tmh.transcodetable' => array_merge($baseExtensionResource, array(
 54+ 'ext.tmh.transcodetable' => array_merge( $baseExtensionResource, array(
5555 'scripts' => 'resources/ext.tmh.transcodetable.js',
5656 'styles' => 'resources/transcodeTable.css',
5757 'messages'=> array(
@@ -61,13 +61,13 @@
6262 'timedmedia-reset-confirm'
6363 )
6464 ) ),
65 - "mw.MediaWikiPlayerSupport" => array_merge($baseExtensionResource, array(
 65+ "mw.MediaWikiPlayerSupport" => array_merge( $baseExtensionResource, array(
6666 'scripts' => 'resources/mw.MediaWikiPlayerSupport.js',
67 - 'loaderScripts' => 'resources/mw.MediaWikiPlayer.loader.js',
68 - 'dependencies'=> array(
69 - 'mw.Api'
70 - )
 67+ 'dependencies'=> array( 'mw.Api' )
7168 ) ),
 69+ "mw.MediaWikiPlayer.loader" => array_merge( $baseExtensionResource, array(
 70+ 'loaderScripts' => 'resources/mw.MediaWikiPlayer.loader.js',
 71+ ) ),
7272 );
7373 // Setup a hook for iframe embed handling:
7474 $wgHooks['ArticleFromTitle'][] = 'TimedMediaIframeOutput::iframeHook';
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
@@ -154,7 +154,7 @@
155155 // If the player is done loading ( does not guarantee playability )
156156 // for example if there is an error playerReady is still set to true once
157157 // no more loading is to be done
158 - 'playerReady' : false,
 158+ 'playerReadyFlag' : false,
159159
160160 // Stores the loading errors
161161 'loadError' : false,
@@ -693,7 +693,7 @@
694694 // Hide / remove track container
695695 _this.$interface.find( '.track' ).remove();
696696 // We have to re-bind hoverIntent ( has to happen in this scope )
697 - if( !this.useNativePlayerControls() && _this.controls && _this.controlBuilder.isOverlayControls() ){
 697+ if( ! _this.useNativePlayerControls() && _this.controls && _this.controlBuilder.isOverlayControls() ){
698698 _this.controlBuilder.showControlBar();
699699 _this.$interface.hoverIntent({
700700 'sensitivity': 4,
@@ -961,7 +961,7 @@
962962 }, 0);
963963
964964 // Update the playerReady flag
965 - this.playerReady = true;
 965+ this.playerReadyFlag = true;
966966 // trigger the player ready event;
967967 $(this).trigger('playerReady');
968968
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js
@@ -183,7 +183,7 @@
184184 // Set via user-preference
185185 $.each( playableSources, function( inx, source ){
186186 var mimeType =source.mimeType;
187 - if ( mw.EmbedTypes.getMediaPlayers().preference[ 'format_preference' ] == mimeType ) {
 187+ if ( $.cookie( 'EmbedPlayer.FormatPreference' ) == mimeType ) {
188188 mw.log( 'MediaElement::autoSelectSource: Set via preference: ' + source.mimeType );
189189 return setSelectedSource( source );
190190 }
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/kskin/PlayerSkinKskin.css
@@ -104,10 +104,12 @@
105105 top: 0;
106106 width: 8px;
107107 cursor: pointer;
108 - -moz-border-radius:5px 5px 5px 5px;
 108+ -moz-border-radius:5px 5px 5px 5px !important;
 109+ border-radius:5px 5px 5px 5px !important;
109110 }
110111 .k-player .ui-corner-all {
111 - -moz-border-radius:5px 5px 5px 5px;
 112+ -moz-border-radius:5px 5px 5px 5px !important;
 113+ border-radius:5px 5px 5px 5px !important;
112114 }
113115 .k-player .time-disp {
114116 border: medium none;
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/kskin/mw.PlayerSkinKskin.js
@@ -59,7 +59,6 @@
6060 'top' : '0px',
6161 'bottom' : ( ctrlObj.getHeight() + 2 ) + 'px'
6262 } );
63 -
6463 // Note safari can't display video overlays with text:
6564 // see bug https://bugs.webkit.org/show_bug.cgi?id=48379
6665
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
@@ -28,6 +28,12 @@
2929
3030 // Default control bar height
3131 height: mw.getConfig( 'EmbedPlayer.ControlsHeight' ),
 32+
 33+ // Minimal width for interface overlay:
 34+ minInterfaceWidth: 300,
 35+
 36+ // Minimal height for interface overlay:
 37+ minInterfaceHeight: 200,
3238
3339 // Default supported components is merged with embedPlayer set of supported types
3440 supportedComponents: {
@@ -69,14 +75,11 @@
7076 */
7177 init: function( embedPlayer ) {
7278 this.embedPlayer = embedPlayer;
73 -
7479 // Check for skin overrides for controlBuilder
7580 var skinClass = embedPlayer.skinName.substr(0,1).toUpperCase() + embedPlayer.skinName.substr( 1 );
7681 if ( mw['PlayerSkin' + skinClass ] ) {
77 -
78 - // Clone as to not override prototype with the skin config
79 - var _this = $.extend( true, { }, this, mw['PlayerSkin' + skinClass ] );
80 - return _this;
 82+ // Clone as to not override prototype with the skin overrides
 83+ return $.extend( true, { }, this, mw['PlayerSkin' + skinClass ] );;
8184 }
8285 // Return the controlBuilder Object:
8386 return this;
@@ -87,12 +90,6 @@
8891 * @return {Number} control bar height
8992 */
9093 getHeight: function(){
91 - // Check if the configuration was updated
92 - // Probably will break things to set control bar height config late
93 - // but try to support it anyway
94 - if( mw.getConfig( 'EmbedPlayer.ControlsHeight' ) != this.height ){
95 - this.height = mw.getConfig( 'EmbedPlayer.ControlsHeight' ) ;
96 - }
9794 return this.height;
9895 },
9996
@@ -339,9 +336,8 @@
340337 * doFullScreenPlayer to enable fullscreen mode
341338 * restoreWindowPlayer to restore window mode
342339 */
343 - toggleFullscreen: function( forceClose ) {
 340+ toggleFullscreen: function( ) {
344341 var _this = this;
345 -
346342 // Do normal in-page fullscreen handling:
347343 if( this.fullscreenMode ){
348344 this.restoreWindowPlayer();
@@ -710,14 +706,16 @@
711707 * Get minimal width for interface overlay
712708 */
713709 getOverlayWidth: function( ) {
714 - return ( this.embedPlayer.getPlayerWidth() < 300 )? 300 : this.embedPlayer.getPlayerWidth();
 710+ return ( this.embedPlayer.getPlayerWidth() < this.minInterfaceWidth ) ?
 711+ this.minInterfaceWidth : this.embedPlayer.getPlayerWidth();
715712 },
716713
717714 /**
718715 * Get minimal height for interface overlay
719716 */
720717 getOverlayHeight: function( ) {
721 - return ( this.embedPlayer.getPlayerHeight() < 200 )? 200 : this.embedPlayer.getPlayerHeight();
 718+ return ( this.embedPlayer.getPlayerHeight() < this.minInterfaceHeight )?
 719+ this.minInterfaceHeight : this.embedPlayer.getPlayerHeight();
722720 },
723721
724722 /**
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.processEmbedPlayers.js
@@ -13,7 +13,7 @@
1414 var areSelectedPlayersReady = function(){
1515 var playersLoaded = true;
1616 $(playerSelect).each(function(inx, player){
17 - if( ! $( player ).get(0).playerReady ){
 17+ if( ! $( player ).get(0).playerReadyFlag ){
1818 playersLoaded = false;
1919 return false;
2020 }
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/mw.MediaPlayers.js
@@ -15,9 +15,6 @@
1616 // The list of players supported
1717 players : null,
1818
19 - // Store per mime-type prefrences for players
20 - preference : { },
21 -
2219 // Stores the default set of players for a given mime type
2320 defaultPlayers : { },
2421
@@ -27,7 +24,6 @@
2825 */
2926 init: function() {
3027 this.players = new Array();
31 - this.loadPreferences();
3228
3329 // set up default players order for each library type
3430 this.defaultPlayers['video/x-flv'] = ['Kplayer', 'Vlc'];
@@ -61,8 +57,6 @@
6258 return ;
6359 }
6460 }
65 -
66 -
6761 // Add the player:
6862 this.players.push( player );
6963 },
@@ -116,8 +110,10 @@
117111 {
118112 // Check for prior preference for this mime type
119113 for ( var i = 0; i < mimePlayers.length; i++ ) {
120 - if ( mimePlayers[i].id == this.preference[mimeType] )
 114+ if ( mimePlayers[i].id == $.cookie( 'EmbedPlayer.PlayerPreference.' + mimeType ) ){
 115+ mw.log( "mw.MediaPlayers:: setPlayer via cookie:: " + mimeType + ' playerId: ' + mimePlayers[i].id );
121116 return mimePlayers[i];
 117+ }
122118 }
123119 // Otherwise just return the first compatible player
124120 // (it will be chosen according to the defaultPlayers list
@@ -134,8 +130,7 @@
135131 * mimeFormat Prefered format
136132 */
137133 setFormatPreference : function ( mimeFormat ) {
138 - this.preference['formatPreference'] = mimeFormat;
139 - $.cookie( 'EmbedPlayer.Preference', JSON.stringify( this.preference) );
 134+ $.cookie( 'EmbedPlayer.FormatPreference', mimeFormat );
140135 },
141136
142137 /**
@@ -152,11 +147,14 @@
153148 if ( this.players[i].id == playerId ) {
154149 selectedPlayer = this.players[i];
155150 mw.log( 'EmbedPlayer::setPlayerPreference: choosing ' + playerId + ' for ' + mimeType );
156 - this.preference[ mimeType ] = playerId;
157 - $.cookie( 'EmbedPlayer.Preference', JSON.stringify( this.preference ) );
 151+ // Update the reference cookie
 152+ $.cookie( 'EmbedPlayer.PlayerPreference.' + mimeType, playerId);
158153 break;
159154 }
160155 }
 156+ // Also update the format Preference:
 157+ this.setFormatPreference( mimeType );
 158+
161159 // Update All the player instances on the page
162160 if ( selectedPlayer ) {
163161 $('.mwEmbedPlayer').each(function(inx, playerTarget ){
@@ -168,17 +166,6 @@
169167 }
170168 });
171169 }
172 - },
173 -
174 - /**
175 - * Loads the user preference settings from a cookie
176 - */
177 - loadPreferences : function ( ) {
178 - this.preference = { };
179 - // See if we have a cookie set to a clientSupported type:
180 - if( $.cookie( 'EmbedPlayer.Preference' ) ) {
181 - this.preference = JSON.parse( $.cookie( 'EmbedPlayer.Preference' ) );
182 - }
183170 }
184171 };
185172
Index: trunk/extensions/TimedMediaHandler/resources/mw.MediaWikiPlayer.loader.js
@@ -5,5 +5,4 @@
66 $.merge( dependencySet, ['mw.MediaWikiPlayerSupport'] );
77 }
88 });
9 -
109 } )( window.mediaWiki, jQuery );
\ No newline at end of file
Index: trunk/extensions/TimedMediaHandler/resources/mw.MediaWikiPlayerSupport.js
@@ -105,7 +105,7 @@
106106 *
107107 * TODO parse the resource page template
108108 *
109 - * @parm {String} resourceHTML Resource wiki text page contents
 109+ * @param {String} resourceHTML Resource wiki text page contents
110110 */
111111 function doCreditLine( resourceHTML, articleUrl ){
112112 // Get the title string ( again a "Title" like js object could help out here. )
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery/jquery.mwEmbedUtil.js
@@ -23,7 +23,7 @@
2424
2525 /**
2626 * Shortcut to a themed button Should be depreciated for $.button
27 - * bellow
 27+ * below
2828 */
2929 $.btnHtml = function( msg, styleClass, iconId, opt ) {
3030 if ( !opt )
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.php
@@ -15,15 +15,13 @@
1616 'messageFile' => 'MwEmbedSupport.i18n.php',
1717 ),
1818 "jquery.loadingSpinner" => array(
19 - 'scripts' => 'jquery.loadingSpinner/jquery.loadingSpinner.js',
20 - 'styles' => 'jquery.loadingSpinner/loadingSpinner.css'
 19+ 'scripts' => array(
 20+ 'jquery.loadingSpinner/spinner.js',
 21+ 'jquery.loadingSpinner/jquery.loadingSpinner.js',
 22+ )
2123 ),
2224 'mw.MwEmbedSupport.style' => array(
23 - // NOTE we add the loadingSpinner.css as a work around to the resource loader register
24 - // of modules as "ready" even though only the "script" part of the module was included.
25 - 'styles'=> array( 'skins/common/MwEmbedCommonStyle.css',
26 - 'jquery.loadingSpinner/loadingSpinner.css'
27 - ),
 25+ 'styles'=> array( 'skins/common/MwEmbedCommonStyle.css' ),
2826 'skinStyles' => array(
2927 /* shared jQuery ui skin styles */
3028 'darkness' => 'skins/jquery.ui.themes/darkness/jquery-ui-1.7.2.css',
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpinner.css
@@ -1,9 +0,0 @@
2 -.loadingSpinner {
3 - background-image: url('loadingDots.png');
4 - width: 32px;
5 - height: 32px;
6 -}
7 -.absoluteOverlaySpinner {
8 - position : absolute;
9 - z-index: 3;
10 -}
\ No newline at end of file
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingSpokes.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/loadingDots.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.loadingSpinner/jquery.loadingSpinner.js
@@ -2,26 +2,50 @@
33 /**
44 * Set a given selector html to the loading spinner:
55 */
6 - $.fn.loadingSpinner = function( ) {
7 - var _this = this;
8 - if ( _this ) {
9 - $( _this ).html(
10 - $( '<div />' )
11 - .addClass( "loadingSpinner" )
12 - );
13 - var i =0;
14 - var interval = setInterval( function(){
15 - if( _this && $( _this ).find('.loadingSpinner').length ){
16 - var offset = i*32;
17 - $( _this ).find('.loadingSpinner').css('background-position','0 ' + offset + 'px');
18 - if(i >= 7) i = 0;
19 - i++;
20 - } else {
21 - clearInterval( interval );
 6+ $.fn.loadingSpinner = function( options ) {
 7+ // empty the target:
 8+ $(this).empty();
 9+
 10+ // If we have LoadingSpinner.ImageUrl use that:
 11+ if( mw.getConfig('LoadingSpinner.ImageUrl') ) {
 12+ this.each(function() {
 13+ var $this = $(this).empty();
 14+ var thisSpinner = $this.data('spinner');
 15+ if (thisSpinner) {
 16+ $this.data('spinner', null);
 17+ delete thisSpinner;
2218 }
23 - }, 70 );
 19+ if (opts !== false) {
 20+ var $loadingSpinner = $('<img />').attr("src", mw.getConfig('LoadingSpinner.ImageUrl')).load(function() {
 21+ // Set spinner position based on image dimension
 22+ $( this ).css({
 23+ 'margin-top': '-' + (this.height/2) + 'px',
 24+ 'margin-left': '-' + (this.width/2) + 'px'
 25+ });
 26+ });
 27+ thisSpinner = $this.append($loadingSpinner);
 28+ }
 29+ });
 30+ return this;
2431 }
25 - return _this;
 32+
 33+ // Else, use Spin.js
 34+ if(!options)
 35+ options = {};
 36+ options = $.extend( {'color' : '#eee', 'shadow': true }, options);
 37+ this.each(function() {
 38+ var $this = $(this).empty();
 39+ var thisSpinner = $this.data('spinner');
 40+ if (thisSpinner) {
 41+ thisSpinner.stop();
 42+ delete thisSpinner;
 43+ }
 44+ if (options !== false) {
 45+ thisSpinner = new Spinner($.extend({color: $this.css('color')}, options)).spin(this);
 46+ }
 47+ });
 48+ // correct the position:
 49+ return this;
2650 };
2751 /**
2852 * Add an absolute overlay spinner useful for cases where the
@@ -40,7 +64,8 @@
4165 var $spinner = $('<div />')
4266 .addClass('absoluteOverlaySpinner')
4367 .loadingSpinner()
44 - .css({
 68+ .css({
 69+ 'position' : 'absolute',
4570 'top' : posTop + 'px',
4671 'left' : posLeft + 'px'
4772 });
@@ -48,4 +73,5 @@
4974 return $spinner;
5075 };
5176
52 -} )( jQuery );
\ No newline at end of file
 77+} )( jQuery );
 78+

Follow-up revisions

RevisionCommit summaryAuthorDate
r109857follow up to r109856 added missing spinner.jsdale22:05, 23 January 2012

Status & tagging log