r70597 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70596‎ | r70597 | r70598 >
Date:21:17, 6 August 2010
Author:dale
Status:deferred (Comments)
Tags:
Comment:
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerMenu.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/Playlist/loader.js
@@ -6,6 +6,7 @@
77 ( function( mw ) {
88
99 mw.addResourcePaths( {
 10+ "iScroll" : "iScroll.js",
1011 "mw.Playlist" : "mw.Playlist.js",
1112 "mw.PlaylistHandlerMediaRss" : "mw.PlaylistHandlerMediaRss.js"
1213 });
@@ -28,8 +29,15 @@
2930 'Playlist.defaultType' : 'application/rss+xml'
3031 } );
3132
32 - // Module loader ( right now its just a stub for mw.MediaRss )
33 - mw.addModuleLoader( 'Playlist', [ "mw.Playlist", "mw.PlaylistHandlerMediaRss" ] );
 33+ // Module loader
 34+ mw.addModuleLoader( 'Playlist', function(){
 35+ var resourceList = ["mw.Playlist", "mw.PlaylistHandlerMediaRss" ]
 36+ // xxx should detect touch support rather than mobile safari check
 37+ if( mw.isMobileSafari() ){
 38+ resourceList.push( "iScroll" );
 39+ }
 40+ return resourceList;
 41+ });
3442
3543
3644 } )( window.mw );
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js
@@ -79,7 +79,7 @@
8080
8181 this.loadPlaylistHandler( function( playlistHandler ){
8282 mw.log("mw.Playlist::loaded playlist handler");
83 - // check if load failed or empty playlist
 83+ // Check if load failed or empty playlist
8484 if( _this.sourceHandler.getClipList().length == 0 ){
8585 $j( _this.target ).empty().text( gM('mwe-playlist-empty') )
8686 return ;
@@ -94,14 +94,21 @@
9595 .css({
9696 'float' : 'left'
9797 })
98 - ,
99 - $j( '<div />')
100 - .addClass( 'media-rss-video-list' )
 98+ ,
 99+ $j( '<div />')
 100+ .addClass( 'media-rss-video-list-wrapper' )
101101 .css({
102 - 'float' : 'right',
103 - 'overflow-y' : 'auto' ,
104 - 'overflow-x' : 'hidden'
105 - })
 102+ 'position' : 'relative',
 103+ 'z-index' : '1',
 104+ 'width': '400px',
 105+ 'height': '300px',
 106+ 'overflow' : 'auto'
 107+ })
 108+ .append(
 109+ $j( '<div />')
 110+ .addClass( 'media-rss-video-list' )
 111+ .attr('id', _this.id + '_videolist')
 112+ )
106113 .hide()
107114 );
108115
@@ -113,22 +120,27 @@
114121
115122 // Update the list height ( vertical layout )
116123 if( _this.layout == 'vertical' ){
117 - var targetListHeight = ( $j( _this.target ).height() - $j( _this.target + ' .media-rss-video-player' ).height() );
118 - mw.log( ' targetHeight: ' + $j( _this.target ).height() + ' - ' + $j( _this.target + ' .media-rss-video-player' ).height() + ' = ' + targetListHeight );
119 - $j( _this.target + ' .media-rss-video-list' ).css( {
 124+ var targetListHeight = ( $j( _this.target ).height() - $j( _this.target + ' .media-rss-video-player' ).height() );
 125+ $j( _this.target + ' .media-rss-video-list-wrapper' ).css( {
120126 'height' : targetListHeight,
121127 'width' : '100%'
122 - } ).fadeIn();
 128+ } )
123129 } else {
124130 var targetListWidth = ( $j( _this.target ).width() - $j( _this.target + ' .media-rss-video-player' ).width() );
125 - mw.log( 'targetListWidth:' + $j( _this.target ).width() + ' - pw: ' + $j( _this.target + ' .media-rss-video-player' ).width() + ' = ' + targetListWidth );
126 - $j( _this.target + ' .media-rss-video-list').css( {
 131+ $j( _this.target + ' .media-rss-video-list-wrapper').css( {
127132 'width' : targetListWidth,
128133 'height' : '100%'
129 - } )
130 - .fadeIn();
131 - }
132 - } );
 134+ } )
 135+ }
 136+ // show the video list and apply the swipe binding
 137+ $j( _this.target ).find('.media-rss-video-list-wrapper').fadeIn();
 138+ if( mw.isMobileSafari() ){
 139+ document.addEventListener('touchmove', function(e){ e.preventDefault(); });
 140+ var myScroll = iScroll( _this.id + '_videolist' );
 141+ setTimeout(function () { myScroll.refresh(); }, 0);
 142+ }
 143+
 144+ });
133145
134146
135147 });
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -111,7 +111,7 @@
112112 * mwEmbed player is setup before any other mw.ready calls
113113 */
114114 mw.addSetupHook( function( callback ) {
115 - mw.log( 'Document::' + mw.documentHasPlayerTags() );
 115+ mw.log( 'EmbedPlayer:: Document::' + mw.documentHasPlayerTags() );
116116 if( mw.documentHasPlayerTags() ) {
117117 var rewriteElementCount = 0;
118118
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -436,11 +436,10 @@
437437 // Update the list of dependent libraries for the player
438438 // ( allows extensions to add to the dependency list )
439439 mw.embedPlayerUpdateLibraryRequest( playerElement, playerDependencyRequest );
440 -
 440+
441441 // Load any skins we need then swap in the interface
442 - mw.load( playerDependencyRequest, function() {
443 - var waitForMeta = true;
444 -
 442+ mw.load( playerDependencyRequest, function() {
 443+ var waitForMeta = true;
445444 // Be sure to "stop" the target ( sometimes firefox keeps playing the video even
446445 // though its been removed from the DOM )
447446 if( playerElement.pause ){
@@ -498,7 +497,7 @@
499498 playerElement.removeEventListener( "loadedmetadata", runPlayerSwap, true );
500499 playerElement.addEventListener( "loadedmetadata", runPlayerSwap, true );
501500
502 - // Time-out of 5 seconds ( maybe still playable but no timely metadata )
 501+ // Time-out of 5 seconds ( maybe still playable but no timely metadata )
503502 setTimeout( runPlayerSwap, 5000 );
504503 return ;
505504 } else {
@@ -1033,7 +1032,6 @@
10341033 if ( $j( videoElement ).attr( "src" ) ) {
10351034 _this.tryAddSource( videoElement );
10361035 }
1037 -
10381036 // Process elements source children
10391037 $j( videoElement ).find( 'source,track' ).each( function( ) {
10401038 _this.tryAddSource( this );
@@ -1128,7 +1126,7 @@
11291127 * Selects the default source via cookie preference, default marked, or by id order
11301128 */
11311129 autoSelectSource: function() {
1132 - mw.log( 'EmbedPlayer::mediaElement::autoSelectSource:' + this.id);
 1130+ mw.log( 'EmbedPlayer::mediaElement::autoSelectSource:' );
11331131 // Select the default source
11341132 var playableSources = this.getPlayableSources();
11351133 var flash_flag = ogg_flag = false;
@@ -1614,7 +1612,7 @@
16151613 // Scope the end of check for player sources so it can be called in a callback
16161614 var finishCheckPlayerSources = function(){
16171615 // Run embedPlayer sources hook
1618 - mw.runTriggersCallback( _this, 'checkPlayerSourcesEvent', function(){
 1616+ mw.runTriggersCallback( _this, 'checkPlayerSourcesEvent', function(){
16191617 _this.checkForTimedText();
16201618 })
16211619 }
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -77,7 +77,7 @@
7878 if( ! this.remoteSearchDriver ){
7979 // set the tool target to loading
8080 mw.load( 'AddMedia.addMediaWizard', function(){
81 - this.remoteSearchDriver = new mw.RemoteSearchDriver({
 81+ _this.remoteSearchDriver = new mw.RemoteSearchDriver({
8282 'target_container' : _this.sequencer.getEditToolTarget(),
8383 'target_search_input' : _this.sequencer.getMenuTarget().find('input.searchMedia'),
8484 'displaySearchInput': false,
@@ -95,11 +95,22 @@
9696 });
9797 } else {
9898 this.remoteSearchDriver.createUI()
 99+ }
 100+ },
 101+ /**
 102+ * Get the resource object from a provided asset
 103+ */
 104+ getResourceFromAsset: function( asset ){
 105+ var _this = this;
 106+ if( ! $j( asset ).attr('id') ){
 107+ mw.log( "Error getResourceFromAsset:: missing asset id" + $j( asset ).attr('id') );
 108+ return false;
99109 }
100 -
101 - },
 110+ return _this.remoteSearchDriver.getResourceFromId( $j( asset ).attr('id') );
 111+ },
 112+
102113 /**
103 - * add search results drab binding so they can be dragged into the sequencer
 114+ * Add search results drab binding so they can be dragged into the sequencer
104115 */
105116 addSearchResultsDrag: function(){
106117 var _this = this;
@@ -107,7 +118,11 @@
108119 this.sequencer.getEditToolTarget()
109120 .find(".rsd_res_item")
110121 .draggable({
111 - connectToSortable: '#' + _this.sequencer.getTimeline().getTracksContainer().find('.clipTrackSet').attr('id'),
 122+ connectToSortable: $j( _this.sequencer.getTimeline().getTracksContainer().find('.clipTrackSet') ),
 123+ start: function( event, ui ){
 124+ // give the target timeline some extra space:
 125+ _this.sequencer.getTimeline().expandTrackSetSize();
 126+ },
112127 helper: function() {
113128 // Append a li to the sortable list
114129 return $j( this )
@@ -118,22 +133,61 @@
119134 })
120135 .get( 0 );
121136 },
122 - revert: 'invalid'
 137+ revert: 'invalid'
123138 });
124139 },
125 -
 140+ insertAssetDialog: function( assetElement, sequenceTrack, order ){
 141+ this.insertResourceDialog(
 142+ this.getResourceFromAsset( assetElement ),
 143+ sequenceTrack,
 144+ order
 145+ );
 146+ },
126147 /**
127148 * Create an insert resource dialog, expose basic in-out points or / duration
128 - *
 149+ * xxx todo if resource needs to be imported run import dialog from remoteResourceDrive
129150 * buttons include insert at end or insert after current
130151 */
131 - insertResourceDialog: function( resource ){
 152+ insertResourceDialog: function( resource, sequenceTrack, order ){
132153 var buttons = {};
133 - // insert after last selected clip ( or at end )
 154+ var cat = resource;
 155+ debugger;
 156+ // Get an xml smil ref pointer: ( per the supplied content type )
 157+ var smilRef = this.getSmilRefFromResource( resource );
 158+
 159+ // Build out the resource dialog content:
 160+ var $content =
 161+ $j('<div />').append(
 162+ $j('<div />')
 163+ .addClass( 'sequencerEditTools' )
 164+ .css({
 165+ 'width' : '50%',
 166+ 'height' : '100%',
 167+ 'overflow': 'auto',
 168+ 'position' : 'absolute',
 169+ 'top' : '0px',
 170+ 'left': '0px'
 171+ }),
 172+
 173+ $j('<div />')
 174+ .css({
 175+ 'position' : 'absolute'
 176+ 'top' : '0px',
 177+ 'right': '0px',
 178+ 'width' : '50%',
 179+ 'height' : '100%'
 180+ })
 181+ .append(
 182+ // the div
 183+ )
 184+ )
 185+ // Build out the edit tools
 186+ $content.find( '.sequencerEditTools' )
 187+
 188+ // Insert after last selected clip ( or at end )
134189 buttons[ gM('mwe-sequencer-insert') ] = function() {
135 - mw.log("insert resource into sequence");
136 - var cat = resource;
137 - debugger;
 190+ // call a function that inserts into smil and timeline ( getTimeline() )
 191+ alert(' insert resource')
138192 }
139193 // cancel
140194 buttons[ gM('mwe-cancel') ] = function(){
@@ -144,13 +198,15 @@
145199 'title' : gM('mwe-sequencer-insert-resource'),
146200 'dragable' : true,
147201 'height' : 480,
148 - 'width' : 640,
 202+ 'width' : 800,
149203 'resizable' : true,
150 - 'content' : function(){
151 - // add the resource on-top and trim
152 - },
 204+ 'content' : resourceEdit.getUi()
153205 'buttons' : buttons
154206 });
 207+ },
 208+
 209+ getSmilRefFromResource: function( resource ){
 210+
155211 }
156212 }
157213
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -66,7 +66,7 @@
6767 'preview' : {
6868 'icon' : 'play',
6969 'title' : gM('mwe-sequencer-preview'),
70 - 'action': function( _this, smilClip, toolId){
 70+ 'action': function( _this, smilClip, toolId ){
7171 _this.sequencer.getPlayer().previewClip( smilClip );
7272 }
7373 },
@@ -218,9 +218,10 @@
219219 getEditToolId: function( toolId, attributeName){
220220 return 'editTool_' + toolId + '_' + attributeName;
221221 },
222 - drawClipEditTool: function( smilClip ){
223 - $target = this.sequencer.getEditToolTarget();
224 -
 222+
 223+
 224+ drawClipEditTools: function( $target, smilClip){
 225+
225226 var toolId = '';
226227 // get the toolId based on what "ref type" smilClip is:
227228 switch( this.sequencer.getSmil().getRefType( smilClip ) ){
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerMenu.js
@@ -103,11 +103,10 @@
104104 var $menuTarget = this.sequencer.getMenuTarget();
105105 // empty and disable select for menu items
106106 $menuTarget.empty().disableSelection();
107 -
108107
109108 for( var menuKey in this.menuConfig ){
110109 // Create a function to preserve menuKey binding scope
111 - function drawTopMenu( menuKey ){
 110+ function drawTopMenu( menuKey ){
112111 // Add the menu target
113112 $menuTarget
114113 .append(
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -179,27 +179,32 @@
180180 }
181181 })
182182 },
 183+
 184+ getTrackSetId:function( trackIndex ){
 185+ return this.sequencer.getId() + '_clipTrackSet_' + trackIndex;
 186+ },
183187 /**
184188 * get and add a clip track set to the dom:
185189 */
186190 getClipTrackSet: function( trackIndex ){
187191 var _this = this;
188 - var clipTrackSetId = this.sequencer.getId() + '_clipTrackSet_' + trackIndex;
189192
190193 return $j('<ul />')
191 - .attr('id', clipTrackSetId)
 194+ .attr('id', this.getTrackSetId( trackIndex ))
 195+ .data('trackIndex', trackIndex)
192196 .addClass('clipTrackSet ui-corner-all')
193197 // Add "sortable
194198 .sortable({
195199 placeholder: "clipSortTarget timelineClip ui-corner-all",
196200 opacity: 0.6,
 201+ tolerance: 'pointer',
197202 cursor: 'move',
198203 helper: function( event, helper ){
199204 // xxxx might need some fixes for multi-track
200205 var $selected = _this.getTimelineContainer().find( '.selectedClip' )
201206 if ( $selected.length === 0 || $selected.length == 1) {
202207 return $j( helper );
203 - }
 208+ }
204209 return $j('<ul />')
205210 .css({
206211 'width' : (_this.timelineThumbSize.width + 16) * $selected.length
@@ -208,11 +213,32 @@
209214 },
210215 scroll: true,
211216 update: function( event, ui ) {
212 - // Update the html dom
213 - //_this.handleReorder( ui.item );
 217+ // Check if the movedClip was a timeline clip ( else generate timeline clip )
 218+ if( ! $j( ui.item ).hasClass( 'timelineClip' ) ){
 219+ // likely an asset dragged from add-media-wizard
 220+ // ( future would be cool to support desktop file drag and drop )
 221+ _this.handleDropAsset( ui.item );
 222+ } else {
 223+ // Update the html dom
 224+ _this.handleReorder( ui.item );
 225+ }
214226 }
215227 })
216228 },
 229+ // expand the track size by clip length + 1
 230+ expandTrackSetSize: function ( trackIndex ){
 231+ var trackClipCount = this.getTimelineContainer().find( '.clipTrackSet' ).children().length;
 232+ //mw.log("SequencerTimeline::expandTrackSetSize: " + this.timelineThumbSize.width + ' tcc: ' + trackClipCount + ' ::' + ( ( this.timelineThumbSize.width + 16) * (trackClipCount + 2) ) );
 233+ this.getTracksContainer().find('.clipTrackSet').css({
 234+ 'width' : ( (this.timelineThumbSize.width + 16) * (trackClipCount + 2 ) ) + 'px'
 235+ });
 236+ },
 237+ restoreTrackSetSize: function ( trackIndex ){
 238+ var trackClipCount = this.getTimelineContainer().find( '.clipTrackSet' ).children().length;
 239+ this.getTracksContainer().find('.clipTrackSet').css({
 240+ 'width' : ( ( this.timelineThumbSize.width + 16) * trackClipCount) + 'px'
 241+ });
 242+ },
217243 getTimelineClip: function( $clipTrackSet, $node ){
218244 var _this = this;
219245 return $j('<li />')
@@ -232,9 +258,10 @@
233259 editClip: function( selectedClip ){
234260 var smil = this.sequencer.getSmil();
235261 // get the smil element for the edit tool:
236 - var smilClip = smil.$dom.find('#' + $j( selectedClip ).data('smilId') );
237 - this.sequencer.getEditTools().drawClipEditTool( smilClip );
238 - },
 262+ var smilClip = smil.$dom.find('#' + $j( selectedClip ).data('smilId') );
 263+ var toolTarget = this.sequencer.getEditToolTarget();
 264+ this.sequencer.getEditTools().drawClipEditTools( toolTarget, previewTarget, smilClip );
 265+ },
239266
240267 /**
241268 * Remove selected clips and update the smil player
@@ -257,11 +284,21 @@
258285 this.sequencer.getActionsEdit().registerEdit();
259286 },
260287
 288+ /**
 289+ * handles assets dropped into the timeline
 290+ */
 291+ handleDropAsset: function( asset ){
 292+ // Get the newAsset resource object
 293+ var clipIndex = $j( asset ).index();
 294+ var trackIndex = $j( asset ).parent().data('trackIndex);
 295+ this.sequencer.getAddMedia().insertAssetDialog( asset, trackIndex, clipIndex );
 296+ },
 297+
261298 handleReorder: function ( movedClip ){
262299 var _this = this;
263300 var smil = this.sequencer.getSmil();
264 - var movedIndex = null;
265 -
 301+ var movedIndex = null;
 302+
266303 var clipIndex = $j( movedClip ).index();
267304 var $movedSmileNode = smil.$dom.find( '#' + $j( movedClip ).data('smilId') );
268305 var $seqParent = $movedSmileNode.parent();

Comments

#Comment by Mdale (talk | contribs)   21:20, 6 August 2010

sorry accidental omitted commit msg:

  • added import resource stubs to addMedia for sequencer.

Status & tagging log