r65148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65147‎ | r65148 | r65149 >
Date:22:38, 16 April 2010
Author:dale
Status:deferred
Tags:
Comment:
added utility function mw.isMobileSafari , minor cleanup
Modified paths:
  • /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/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js
@@ -13,7 +13,7 @@
1414 'stop' : true,
1515 'timeDisplay' : true,
1616 'volumeControl' : true,
17 - 'overlay' : true,
 17+ 'overlays' : true,
1818 'fullscreen' : false
1919 },
2020
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -37,6 +37,17 @@
3838 // If fullscreen is global enabled.
3939 'enableFullscreen' : true,
4040
 41+ // If mwEmbed should use the Native player controls
 42+ // this will prevent video tag rewriting and skinning
 43+ // usefull for devices such as iPad / iPod that
 44+ // don't fully support DOM overlays or don't expose full-screen
 45+ // functionality to javascript
 46+ 'nativePlayerControls': false,
 47+
 48+ // If mwembed should use native controls on mobile safari
 49+ 'nativePlayerControlsMobileSafari' : false,
 50+
 51+
4152 // The z-index given to the player interface during full screen ( high z-index )
4253 'fullScreenIndex' : 999998,
4354
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -378,7 +378,24 @@
379379 case 'audio':
380380 // By default treat the rewrite request as "video"
381381 default:
382 - var ranPlayerSwapFlag = false;
 382+ var ranPlayerSwapFlag = false;
 383+ // Skip the video if we are using native controls
 384+ if( _this.useNativeControls( element ) ){
 385+ // Remove the player loader spiner:
 386+ $j('#loadSpiner_' + element.id ).remove();
 387+ // Unhide
 388+ $j( element ).css({
 389+ 'opacity' : 1,
 390+ 'position': null
 391+ } )
 392+ .attr('controls', 'true')
 393+ // iPad needs the video to be hidden then shown
 394+ // for control attribute update to take effect
 395+ .hide()
 396+ .show()
 397+
 398+ return ;
 399+ }
383400 // Local callback to runPlayer swap once element has metadata
384401 function runPlayerSwap() {
385402 if( ranPlayerSwapFlag ){
@@ -486,17 +503,18 @@
487504 swapPlayerElement[ method ] = playerInterface[ method ];
488505 }
489506 }
490 -
491 - // Remove the targetElement
 507+
492508 $j( targetElement ).replaceWith( swapPlayerElement );
493509
 510+
494511 // Set swapPlayerElement has height / width set and set to loading:
495512 $j( swapPlayerElement ).css( {
496513 'width' : playerInterface.width + 'px',
497514 'height' : playerInterface.height + 'px'
498 - } )
499 - //if we don't already have a loadSpiner add one:
500 - if( ! $j('#loadSpiner_' + playerInterface.id ).length ){
 515+ } );
 516+
 517+ // If we don't already have a loadSpiner add one:
 518+ if( $j('#loadSpiner_' + playerInterface.id ).length == 0 ){
501519 $j( swapPlayerElement ).append(
502520 $j('<div style="margin:auto;top:35%;position:relative;width:32px;height:32px;"/>')
503521 .loadingSpinner()
@@ -507,6 +525,25 @@
508526 },
509527
510528 /**
 529+ * Checks configuration options
 530+ *
 531+ * @param [player] Object Optional player object to check controlls attirbute
 532+ * @returns bollean true if the mwEmbed player interface should be used
 533+ * false if the mwEmbed player interace should not be used
 534+ */
 535+ useNativeControls: function( player ) {
 536+ if( mw.getConfig('nativePlayerControls') == true ) {
 537+ return true;
 538+ }
 539+ if( mw.getConfig('nativePlayerControlsMobileSafari' ) &&
 540+ mw.isMobileSafari()
 541+ ){
 542+ return true;
 543+ }
 544+ return false;
 545+ },
 546+
 547+ /**
511548 * Player ready will run the global callbacks
512549 * once players are "ready"
513550 *
@@ -2108,18 +2145,11 @@
21092146
21102147 // Set by default thumb value if not found
21112148 var posterSrc = ( this.poster ) ? this.poster :
2112 - mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg';
 2149+ mw.getConfig( 'images_path' ) + 'vid_default_thumb.jpg';
21132150
2114 - // Remove any old thumbnail items:
2115 - $j( this ).find( '.playerPoster,.loadingSpinner,.play-btn-large' ).remove();
2116 -
2117 - var dummyvid = document.createElement( "video" );
2118 - // put it all in the div container dc_id
2119 -
21202151 // Poster support is not very consistant in browsers
2121 - // use a jpg poster image:
2122 - // use a jpg thumbnail:
2123 - $j( this ).append(
 2152+ // use a jpg poster image:
 2153+ $j( this ).html(
21242154 $j( '<img />' )
21252155 .css({
21262156 'position' : 'relative',
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -43,9 +43,7 @@
4444 updateFeatureSupport: function(){
4545 // iWhatever devices appear to have a broken
4646 // dom overlay implementation of video atm. (hopefully iphone OS 4 fixes this )
47 - if ((navigator.userAgent.indexOf('iPhone') != -1) ||
48 - (navigator.userAgent.indexOf('iPod') != -1) ||
49 - (navigator.userAgent.indexOf('iPad') != -1)) {
 47+ if( mw.isMobileSafari() ) {
5048 this.supports.overlays = false;
5149 }
5250 },
@@ -66,12 +64,12 @@
6765 } )
6866 .css( {
6967 'width' : '100%',
70 - 'height' : '100%'
71 - } )
 68+ 'height' : '100%'
 69+ } )
7270 )
7371 mw.log( "Embed code: " + $j( this ).html() );
7472 // directly run postEmbedJS ( if playerElement is not avaliable it will retry )
75 - _this.postEmbedJS();
 73+ _this.postEmbedJS();
7674 },
7775
7876 /**
@@ -102,6 +100,7 @@
103101 vid.play();
104102 }
105103
 104+
106105 // Run the "hook" for any extensions that need to bind things to the actual video elemnt
107106 this.runHook( 'postEmbedJS' )
108107
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -1278,14 +1278,18 @@
12791279 mw.addLoaderDialog = function( msg_txt ) {
12801280 mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() );
12811281 }
1282 -
1283 - /*mw.status = function( status )
 1282+ /**
 1283+ * NOTE: should be moved to browser detection script
 1284+ */
 1285+ mw.isMobileSafari = function(){
 1286+ if ((navigator.userAgent.indexOf('iPhone') != -1) ||
 1287+ (navigator.userAgent.indexOf('iPod') != -1) ||
 1288+ (navigator.userAgent.indexOf('iPad') != -1)) {
 1289+ return true;
 1290+ }
 1291+ return false;
 1292+ },
12841293
1285 -
1286 - var Status = function() {
1287 -
1288 - }*/
1289 -
12901294 /**
12911295 * Add a (temporary) dialog window:
12921296 * @param {String} title Title string for the dialog

Status & tagging log