r67575 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67574‎ | r67575 | r67576 >
Date:23:37, 7 June 2010
Author:dale
Status:deferred
Tags:
Comment:
improved gallery view for mwEmbed player
fixed dialog bug
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -26,7 +26,7 @@
2727 * Adds a resource by its Title
2828 *
2929 * @param {String} title Title of the resource to be added
30 - * @param {Function} callback Function called once title resource aquired
 30+ * @param {Function} callback Function called once title resource acquired
3131 */
3232 addByTitle:function( title , callback, redirect_count ) {
3333
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -1679,7 +1679,7 @@
16801680 * @param {Function} callback Function to be called once playback-system has been inherited
16811681 */
16821682 inheritEmbedPlayer: function( callback ) {
1683 - mw.log( "inheritEmbedPlayer:duration is: " + this.getDuration() + ' p: ' + this.id);
 1683+ mw.log( "inheritEmbedPlayer:duration is: " + this.getDuration() + ' p: ' + this.id );
16841684
16851685 // Clear out any non-base embedObj methods:
16861686 if ( this.instanceOf ) {
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1115,11 +1115,12 @@
11161116 * Add a (temporary) dialog window:
11171117 * @param {String} title Title string for the dialog
11181118 * @param {String} dialogHtml String to be inserted in msg box
1119 - * @param {Mixed} buttons A button object for the dialog
1120 - * Can be 'ok' for oky button.
 1119+ * @param {Mixed} buttonOption A button object for the dialog
 1120+ * Can be a string for the close buton
11211121 */
11221122 mw.addDialog = function ( title, dialogHtml, buttons ) {
11231123 $j( '#mwTempLoaderDialog' ).remove();
 1124+
11241125 // Append the style free loader ontop:
11251126 $j( 'body' ).append(
11261127 $j('<div />')
@@ -1130,13 +1131,16 @@
11311132 .css('display', 'none')
11321133 .html( dialogHtml )
11331134 );
 1135+
11341136 // Special buttons == ok gives empty give a single "oky" -> "close"
1135 - if ( buttons == 'ok' ) {
 1137+ if ( typeof buttons == 'string' ) {
 1138+ var buttonMsg = buttons;
11361139 buttons = { };
1137 - buttons[ gM( 'mwe-ok' ) ] = function() {
1138 - $j( '#mwTempLoaderDialog' ).close();
 1140+ buttons[ buttonMsg ] = function() {
 1141+ $j( '#mwTempLoaderDialog' ).dialog( 'close' );
11391142 }
1140 - }
 1143+ }
 1144+
11411145 // Load the dialog classes
11421146 mw.load([
11431147 [
@@ -2279,17 +2283,18 @@
22802284 *
22812285 */
22822286 mw.runTriggersCallback = function( targetObject, triggerName, callback ){
2283 - // on trigger calls with many binded functions.
2284 - if( ! $j( targetObject ).data( 'events' )[ triggerName ] ) {
 2287+ // If events are not present directly run callback
 2288+ if( ! $j( targetObject ).data( 'events' ) ||
 2289+ ! $j( targetObject ).data( 'events' )[ triggerName ] ) {
22852290 callback();
2286 - }
2287 -
 2291+ }
22882292 var callbackCount = $j( targetObject ).data( 'events' )[ triggerName ].length;
22892293 if( !callbackCount ){
22902294 // No events run the callback directly
22912295 callback();
22922296 return ;
2293 - }
 2297+ }
 2298+
22942299 mw.log(" runTriggersCallback:: " + callbackCount );
22952300 var callInx = 0;
22962301 $j( targetObject ).trigger( 'checkPlayerSourcesEvent', function() {
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -12,6 +12,7 @@
1313 window.console.log( 'mwEmbed:remote:' + mwRemoteVersion );
1414 }
1515
 16+
1617 // Setup up request Params:
1718 var reqParts = urlparts[1].substring( 1 ).split( '&' );
1819 var mwReqParam = { };
@@ -26,6 +27,7 @@
2728 if( mwReqParam['debug'] ) {
2829 mwUseScriptLoader = false;
2930 }
 31+mwUseScriptLoader = true;
3032
3133 // Setup up some globals to wrap mwEmbed mw.ready and mw.setConfig functions
3234
@@ -220,9 +222,10 @@
221223 * ( front-loaded to avoid extra requests )
222224 */
223225 function mwLoadPlayer( callback ){
224 - // the jsPlayerRequest includes both javascript and style sheets for the embedPlayer
 226+
 227+ // The jsPlayerRequest includes both javascript and style sheets for the embedPlayer
225228 var jsPlayerRequest = [
226 -
 229+ 'mw.style.mwCommon',
227230 'mw.EmbedPlayer',
228231 'mw.style.EmbedPlayer',
229232 '$j.ui',
@@ -231,8 +234,10 @@
232235 '$j.cookie',
233236 'JSON',
234237 '$j.ui.slider',
235 - 'kskinConfig',
236 - 'mw.style.kskin',
 238+
 239+ 'mw.PlayerSkinKskin',
 240+ 'mw.style.PlayerSkinKskin',
 241+
237242 '$j.fn.menu',
238243 'mw.style.jquerymenu',
239244
@@ -247,11 +252,11 @@
248253 // Quick sniff use java if IE and native if firefox
249254 // ( other browsers will run detect and get on-demand )
250255 if (navigator.userAgent.indexOf("MSIE") != -1){
251 - jsPlayerRequest.push( 'mw.EmbedPlayeJava' );
 256+ jsPlayerRequest.push( 'mw.EmbedPlayerJava' );
252257 }
253258
254259 if ( navigator.userAgent && navigator.userAgent.indexOf("Firefox") != -1 ){
255 - jsPlayerRequest.push( 'mw.EmbedPlayeNative' );
 260+ jsPlayerRequest.push( 'mw.EmbedPlayerNative' );
256261 }
257262
258263 loadMwEmbed( jsPlayerRequest, function() {
@@ -268,15 +273,15 @@
269274 // Don't process empty vids
270275 if ( !vidId ){
271276 return ;
272 - }
273 -
 277+ }
274278
275279 tag_type = 'video';
276280
277281 // Check type:
278282 var pwidth = $j( '#' + vidId ).width();
279 - var $pimg = $j( '#' + vidId + ' img:first' );
280 - if( $pimg.attr('src') && $pimg.attr('src').split('/').pop() == 'play.png'){
 283+ var $pimg = $j( '#' + vidId + ' img:first' );
 284+ var imgSring = $pimg.attr('src').split('/').pop();
 285+ if( $pimg.attr('src') && imgSring == 'play.png' || imgSring == 'fileicon-ogg.png' ){
281286 tag_type = 'audio';
282287 poster_attr = '';
283288 pheight = 0;
@@ -313,6 +318,15 @@
314319 // Check if file is from commons and therefore should explicitly set apiProvider to commons:
315320 var apiProviderAttr = ( src.indexOf( 'wikipedia\/commons' ) != -1 )?'apiProvider="commons" ': '';
316321
 322+ // If in a gallery box we will be displaying the video larger in a lightbox
 323+ if( $j( '#' + vidId ).parents( '.gallerybox' ).length ){
 324+ // Update the width to 400 and keep scale
 325+ pwidth = 400;
 326+ if( pheight != 0 ) {
 327+ pheight = pwidth * ( $j( '#' + vidId ).height() / $j( '#' + vidId ).width() );
 328+ }
 329+ }
 330+
317331 if ( src ) {
318332 var html_out = '';
319333
@@ -336,19 +350,73 @@
337351 'style="width:' + pwidth + 'px;height:' + pheight + 'px;">' +
338352 '</video>';
339353 }
340 - // Set the video tag inner html and update the height
341 - $j( '#' + vidId ).after( html_out ).remove();
 354+
 355+
 356+ // If the video is part of a "gallery box" use light-box linker instead
 357+ if( $j( '#' + vidId ).parents( '.gallerybox' ).length ){
 358+ $j( '#' + vidId ).after(
 359+ $j( '<div />')
 360+ .css( {
 361+ 'width' : $pimg.attr('width' ),
 362+ 'height' :$pimg.attr( 'height' ),
 363+ 'position' : 'relative'
 364+ })
 365+ .addClass( 'k-player' )
 366+ .append(
 367+ // The poster image
 368+ $j( '<img />' )
 369+ .css( {
 370+ 'width' : '100%',
 371+ 'height' : '100%'
 372+ })
 373+ .attr( 'src', $pimg.attr('src') ),
 374+
 375+ // A play button:
 376+ $j( '<div />' )
 377+ .css( {
 378+ 'position' : 'absolute',
 379+ 'top' : ( parseInt( $pimg.attr( 'height' ) ) /2 ) -25,
 380+ 'left' : ( parseInt( $pimg.attr( 'height' ) ) /2 ) - 45
 381+ })
 382+ .addClass( 'play-btn-large' )
 383+ .buttonHover()
 384+ .click( function(){
 385+ var dialogHeight = ( $j( this ).data( 'playerHeight') == 0 )? 175 :
 386+ ( $j( this ).data( 'playerHeight') - 75 );
 387+ mw.addDialog(
 388+ decodeURIComponent( $j( this ).data( 'title' ).replace(/_/g, ' ') ),
 389+ $j( this ).data( 'embedCode' ),
 390+ gM( 'mwe-ok' )
 391+ )
 392+ // Dialog size setup is a bit strange:
 393+ .css( {
 394+ 'height' : dialogHeight + 'px'
 395+ })
 396+ .parent().css( {
 397+ // we hard code the default resolution to 400 above
 398+ 'width' : '435px',
 399+ } )
 400+ // Update the embed code to use the mwEmbed player:
 401+ $j.embedPlayers();
 402+ })
 403+ .data( 'embedCode', html_out )
 404+ .data( 'title' , apiTitleKey )
 405+ .data( 'playerHeight', pheight )
 406+ )
 407+ ).remove();
 408+
 409+ } else {
 410+ // Set the video tag inner html remove extra player
 411+ $j( '#' + vidId ).after( html_out ).remove();
 412+ $j( '#mwe_' + vidId ).embedPlayer();
 413+ }
342414
343 - // Do the actual rewrite
344 - //mw.log("rewrite: "+ vidId );
345 - $j( '#mwe_' + vidId ).embedPlayer();
346415 // Issue an async request to rewrite the next clip
347416 if ( vidIdList.length != 0 ) {
348 - setTimeout( function() {
 417+ setTimeout( function() {
349418 procVidId( vidIdList.pop() )
350419 }, 1 );
351420 }
352 -
353421 }
354422 };
355423 // Process current top item in vidIdList

Status & tagging log