r72764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72763‎ | r72764 | r72765 >
Date:22:40, 10 September 2010
Author:dale
Status:deferred
Tags:
Comment:
* improved sequence audio playback
* improved preview button with play / pause bindings
* fixed layout of inline player for play dialogs
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1132,13 +1132,13 @@
11331133 var $dialog = $j( '#mwTempLoaderDialog' ).show().dialog( options );
11341134 // center the dialog
11351135 // xxx figure out why jquery ui is messing up here
1136 - $j( '#mwTempLoaderDialog' ).parent('.ui-dialog').css({
 1136+ /*$j( '#mwTempLoaderDialog' ).parent('.ui-dialog').css({
11371137 'position' : 'absolute',
11381138 'left' : '50%',
11391139 'margin-left': -1 * $dialog.width()/2,
11401140 'top' : '50%',
11411141 'margin-top': -1 * $dialog.height()/2
1142 - });
 1142+ }); */
11431143 } );
11441144 return $j( '#mwTempLoaderDialog' );
11451145 }
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js
@@ -449,6 +449,16 @@
450450
451451 return $html;
452452 },
 453+ getTitleKey: function( smilElement ){
 454+ // check directly for the attribute:
 455+ if( $j(smilElement).attr('apititlekey') ){
 456+ return $j(smilElement).attr('apititlekey') ;
 457+ }
 458+ if( $j(smilElement).find("param[name='apiTitleKey']").length ) {
 459+ return $j(smilElement).find("param[name='apiTitleKey']").attr('value');
 460+ }
 461+ return false;
 462+ },
453463 /**
454464 * Get the smil resource type based on nodeName and type attribute
455465 */
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
@@ -241,6 +241,7 @@
242242 // Check if we reached playSegmentEndTime and pause playback
243243 if( this.playSegmentEndTime && this.smilPlayTime >= this.playSegmentEndTime ) {
244244 mw.log("monitor:: Reached playSegmentEndTime pause playback: " + this.playSegmentEndTime );
 245+ $j( this ).trigger( 'playSegmentEnd' );
245246 this.playSegmentEndTime= null;
246247 this.pause();
247248 this.parent_monitor();
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -331,6 +331,9 @@
332332 if ( size.width ) {
333333 request['iiurlwidth'] = size.width;
334334 }
 335+ if( size.height ){
 336+ request['iiurlheight'] = size.height;
 337+ }
335338
336339 mw.getJSON( this.provider.apiUrl, request, function( data ) {
337340 var imObj = { };
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -3039,10 +3039,8 @@
30403040 // Call monitor at 250ms interval. ( use setInterval to avoid stacking monitor requests )
30413041 //mw.log("EmbedPlayer::monitor: continue?:" + !this.isStopped() + ' monitorInterval: ' + this.monitorInterval );
30423042 if( ! this.isStopped() ) {
3043 - if( !this.monitorInterval ){
3044 -
3045 - this.monitorInterval = setInterval( function(){
3046 - mw.log("monitorInterval!!");
 3043+ if( !this.monitorInterval ){
 3044+ this.monitorInterval = setInterval( function(){
30473045 if( _this.monitor ){
30483046 _this.monitor();
30493047 }
Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -55,9 +55,13 @@
5656 'mwe-sequencer-clip-transin' => 'Transition in',
5757 'mwe-sequencer-clip-transout' => 'Transition out',
5858
 59+ 'mwe-sequencer-clip-cancel-edit' => 'Cancel clip edit',
5960 'mwe-sequencer-preview' => 'Preview',
 61+ 'mwe-sequencer-preview-pause' => 'Pause preview',
 62+ 'mwe-sequencer-preview-continue' => 'Continue preview',
6063 'mwe-sequencer-apply-changes' => 'Apply changes',
6164 'mwe-sequencer-start-time' => 'Start time',
 65+ 'mwe-sequencer-asset-source' => 'Source page',
6266
6367
6468 'mwe-sequencer-loading_user_rights' => 'Loading user rights ...',
@@ -110,6 +114,7 @@
111115 'mwe-sequencer-save-no-changes' => 'There are no new edits to save',
112116 'mwe-sequencer-save-summary' => 'Please enter a short summary of changes:',
113117 'mwe-sequencer-edit_cancel' => 'Cancel sequence edit',
 118+
114119 'mwe-sequencer-saving_wait' => 'Save in progress (please wait)',
115120 'mwe-sequencer-save_done' => 'Save complete',
116121
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
@@ -167,7 +167,7 @@
168168 if( !_this.sequencer.getServer().hasLocalChanges() ){
169169 $dialog.html( gM('mwe-sequencer-save-no-changes') );
170170 var closeButton = {};
171 - closeButton[gM('mwe-ok')]= function(){ $j(this).dialog('close') };
 171+ closeButton[ gM('mwe-ok') ]= function(){ $j(this).dialog('close') };
172172 $dialog.dialog( "option", "buttons", closeButton);
173173 return ;
174174 }
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsView.js
@@ -22,14 +22,14 @@
2323 // For now just show the sequence output
2424 $viewSmilXmlDialog = mw.addDialog({
2525 'title' : gM('mwe-sequencer-menu-view-smilxml'),
26 - 'dragable': true,
27 - 'height' : 480,
28 - 'width' : 640,
29 - 'resizable': true,
30 - 'content' : $j('<div />')
 26+ 'dragable': true,
 27+ 'width' : 800,
 28+ 'height' : 600,
 29+ 'resizable': false,
 30+ 'content' : $j('<div />')
3131 .append(
3232 // Add a loading div
33 - $j('<div />')
 33+ $j('<div />')
3434 .addClass('syntaxhighlighter_loader')
3535 .loadingSpinner(),
3636
@@ -47,6 +47,7 @@
4848 // load and run the syntax highlighter:
4949 $j( $viewSmilXmlDialog.find('pre') ).syntaxHighlighter( function(){
5050 $viewSmilXmlDialog.find('.syntaxhighlighter_loader').remove();
 51+ $viewSmilXmlDialog.find('.syntaxhighlighter').css('height', '520px');
5152 $viewSmilXmlDialog.find('pre').fadeIn();
5253 });
5354
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -195,6 +195,9 @@
196196 * ref node that can be inserted into a smil xml tree
197197 */
198198 getSmilClipFromResource: function( resource, callback ){
 199+ // fist check if we
 200+
 201+
199202 var tagType = 'ref';
200203 if( resource.mime.indexOf( 'image/' ) != -1 ){
201204 tagType = 'img';
@@ -249,24 +252,37 @@
250253 })
251254 )
252255 }
 256+ }
 257+ // Check if the source asset is smaller than our target import size in both width and height:
 258+ if( resource.width < mw.getConfig( 'Sequencer.AddMediaImageWidth' )
 259+ &&
 260+ resource.height < mw.getConfig( 'Sequencer.AddMediaImageHeight' )
 261+ ) {
 262+ callback( $smilRef.get(0) );
 263+ return ;
253264 }
254 - // Make sure we have source for the asset.
255 - if( $smilRef.attr('src') ){
256 - callback( $smilRef.get(0) )
257 - } else {
258 - // the resource includes a pointer to its parent search object
259 - // from the search object grab the image object for the target resolution
260 - resource.pSobj.getImageObj(
261 - resource,
262 - {
263 - 'width' : mw.getConfig( 'Sequencer.AddMediaImageWidth' )
264 - },
265 - function( imageObj ){
266 - $smilRef.attr('src', imageObj.url )
267 - callback( $smilRef.get(0) );
268 - }
269 - )
 265+
 266+ // Get the dominate aspect ratio so we can
 267+ var targetAspect = mw.getConfig( 'Sequencer.AddMediaImageWidth' ) / mw.getConfig( 'Sequencer.AddMediaImageHeight' )
 268+ var fileAspect = resource.width / resource.height;
 269+
 270+ var requestWidth = mw.getConfig( 'Sequencer.AddMediaImageWidth' );
 271+ if( targetAspect > fileAspect ){
 272+ requestWidth = parseInt( mw.getConfig( 'Sequencer.AddMediaImageHeight' ) * fileAspect );
270273 }
 274+
 275+ // the resource includes a pointer to its parent search object
 276+ // from the search object grab the image object for the target resolution
 277+ resource.pSobj.getImageObj(
 278+ resource,
 279+ {
 280+ 'width' : requestWidth
 281+ },
 282+ function( imageObj ){
 283+ $smilRef.attr('src', imageObj.url )
 284+ callback( $smilRef.get(0) );
 285+ }
 286+ )
271287 }
272288 }
273289
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
@@ -58,7 +58,7 @@
5959 });
6060 },
6161
62 - previewClip: function( smilClip ){
 62+ previewClip: function( smilClip, donePreivewCallback ){
6363 var _this = this;
6464 // Seek and play start of smilClip
6565 var startOffset = $j( smilClip ).data('startOffset');
@@ -67,6 +67,8 @@
6868 this.getEmbedPlayer().setCurrentTime( startOffset, function(){
6969 mw.log("SequencerPlayer::Preview clip: " + startOffset + ' to ' + clipEndTime);
7070 _this.getEmbedPlayer().play( clipEndTime );
 71+ // bind end of segment action
 72+ $j( _this.sequencer.getEmbedPlayer() ).bind( 'playSegmentEnd', donePreivewCallback);
7173 })
7274 },
7375
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -149,18 +149,80 @@
150150 }
151151 },
152152 editActions: {
 153+ 'sourcePage':{
 154+ 'displayCheck': function( _this, smilElement ){
 155+ if( _this.sequencer.getSmil().getTitleKey( smilElement )
 156+ &&
 157+ _this.sequencer.getServer().isConfigured()
 158+ ){
 159+ return true;
 160+ }
 161+ return false;
 162+ },
 163+ 'icon': 'info',
 164+ 'title': gM('mwe-sequencer-asset-source'),
 165+ 'action' : function( clickButton, _this, smilElement ){
 166+ // Update the link
 167+ $j( clickButton )
 168+ .attr({
 169+ 'href': _this.sequencer.getServer().getAssetViewUrl(
 170+ $j(smilElement).find("param[name='apiTitleKey']").attr('value')
 171+ )
 172+ ,
 173+ 'target' : '_new'
 174+ })
 175+ // follow the link the link
 176+ return true;
 177+ }
 178+ },
153179 'preview' : {
154180 'icon' : 'play',
155181 'title' : gM('mwe-sequencer-preview'),
156 - 'action': function( _this, smilElement ){
157 - _this.sequencer.getPlayer().previewClip( smilElement );
 182+ 'action': function( clickButton, _this, smilElement ){
 183+ _this.sequencer.getPlayer().previewClip( smilElement, function(){
 184+ // preview done, restore original state:
 185+ $j(clickButton).replaceWith (
 186+ _this.getEditAction( smilElement, 'preview' )
 187+ )
 188+ });
158189 // xxx todo update preview button to "pause" / "play"
 190+ var doPause = function(){
 191+ $j( clickButton ).find( '.ui-icon')
 192+ .removeClass( 'ui-icon-pause' )
 193+ .addClass( 'ui-icon-play' )
 194+ $j( clickButton ).find('.btnText').text(
 195+ gM('mwe-sequencer-preview-continue')
 196+ )
 197+ _this.sequencer.getEmbedPlayer().pause();
 198+ }
 199+ var doPlay = function(){
 200+ // setup pause button:
 201+ $j( clickButton ).find( '.ui-icon')
 202+ .removeClass( 'ui-icon-play' )
 203+ .addClass( 'ui-icon-pause' )
 204+ $j( clickButton ).find('.btnText').text(
 205+ gM('mwe-sequencer-preview-pause')
 206+ )
 207+ // keep the target preview end time:
 208+ // xxx should probably refactor this.. a bit of abstraction leak here:
 209+ _this.sequencer.getEmbedPlayer().play(
 210+ _this.sequencer.getEmbedPlayer().playSegmentEndTime
 211+ );
 212+ }
 213+ $j( clickButton ).unbind().click(function(){
 214+ if( _this.sequencer.getEmbedPlayer().paused ){
 215+ doPlay();
 216+ } else {
 217+ doPause();
 218+ }
 219+ })
 220+ doPlay();
159221 }
160 - },
 222+ },
161223 'cancel' : {
162224 'icon': 'close',
163 - 'title' : gM('mwe-cancel'),
164 - 'action' : function( _this, smilElement ){
 225+ 'title' : gM('mwe-sequencer-clip-cancel-edit'),
 226+ 'action' : function(clickButton, _this, smilElement ){
165227 $j.each(
166228 _this.getToolSet(
167229 _this.sequencer.getSmil().getRefType( smilElement )
@@ -724,16 +786,21 @@
725787 });
726788
727789 // Add tab bindings
728 - $toolsContainer.tabs({
729 - select: function(event, ui) {
 790+ $toolsContainer.tabs();
 791+
 792+ // Build out global edit Actions buttons after the container
 793+ for( var editActionId in this.editActions ){
 794+ // Check if the edit action has a conditional display:
 795+ var displayEidtAction = true;
730796
 797+ if( this.editActions[ editActionId ].displayCheck ){
 798+ displayEidtAction = this.editActions[ editActionId ].displayCheck( _this, smilElement );
 799+ }
 800+ if( displayEidtAction ){
 801+ $toolsContainer.after(
 802+ this.getEditAction( smilElement, editActionId )
 803+ )
731804 }
732 - })
733 - // Build out global edit Actions buttons after the container
734 - for( var editActionId in this.editActions ){
735 - $toolsContainer.after(
736 - this.getEditAction( smilElement, editActionId )
737 - )
738805 }
739806 },
740807 getCurrentsmilElement: function(){
@@ -765,7 +832,7 @@
766833 'margin': '5px'
767834 })
768835 .click( function(){
769 - editAction.action( _this, smilElement );
 836+ return editAction.action( this, _this, smilElement );
770837 })
771838 return $actionButton;
772839 },
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
@@ -27,9 +27,16 @@
2828 // Default image duration
2929 "Sequencer.AddMediaImageDuration" : 2,
3030
31 - // Default image source width
32 - "Sequencer.AddMediaImageWidth" : 640,
 31+ // NOTE these values 800x600 are the default display
 32+ // size for assets in wikimedia commons and helps avoid server side resizes
 33+ // and gives the asset a better chance of being served from the cache
3334
 35+ // Default import image source width
 36+ "Sequencer.AddMediaImageWidth" : 800,
 37+
 38+ // Default import image source height
 39+ "Sequencer.AddMediaImageHeight" : 600,
 40+
3441 // If a asset can be directly added to the sequence by url
3542 // ( if disabled only urls that are part addMedia can be added )
3643 "Sequencer.AddAssetByUrl" : true,
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
@@ -349,6 +349,15 @@
350350 }
351351 return this.pagePathUrl.replace( '$1', 'Sequence:' + titleKey);
352352 },
 353+
 354+ getAssetViewUrl: function( titleKey ){
 355+ // Check that we have a pagePathUrl config:
 356+ if( !this.pagePathUrl ){
 357+ return false;
 358+ }
 359+ return this.pagePathUrl.replace( '$1', titleKey );
 360+ },
 361+
353362 /**
354363 * Get the sequencer 'edit' url
355364 */
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -449,19 +449,13 @@
450450 // close the dialog
451451 $j(this).dialog( 'close' ).remove();
452452 };
453 - mw.addDialog( {
 453+ var $dialog = mw.addDialog( {
454454 'title' : decodeURIComponent( apiTitleKey.replace(/_/g, ' ') ),
455455 'content' : html_out,
456 - 'buttons' : buttons
457 - })
458 - // Dialog size setup is a bit strange:
459 - .css( {
460 - 'height' : dialogHeight + 'px'
461 - })
462 - .parent().css( {
463 - // we hard code the default resolution to 400 above
464 - 'width' : '435px',
465 - } )
 456+ 'buttons' : buttons,
 457+ 'height' : dialogHeight,
 458+ 'width' : 425
 459+ })
466460
467461 // Update the embed code to use the mwEmbed player:
468462 $j( '#mwe_' + vidId ).embedPlayer( function(){

Status & tagging log