r69413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69412‎ | r69413 | r69414 >
Date:00:15, 16 July 2010
Author:dale
Status:deferred
Tags:
Comment:
some fixes to the sequencer playback
fix to sequencer widget set in and out points
Modified paths:
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/css/mw.style.SequenceEdit.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.style.SmilLayout.css (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js
@@ -378,8 +378,28 @@
379379 }
380380 return $node.data('computedDuration');
381381 },
382 -
383382 /**
 383+ * Get the asset duration for a clip
 384+ * @param {element} $node the smil clip that we want to get duration for
 385+ * @param {function} callback Function to be called once asset duration is known.
 386+ */
 387+ getClipAssetDuration: function( $node, callback ){
 388+ this.smil.getBuffer().loadElement( $node );
 389+ // xxx check if the type is "video or audio" else nothing to return
 390+
 391+ var vid = $j( '#' + this.smil.getAssetId( $node ) ).get(0);
 392+ if( vid.duration ){
 393+ callback( vid.duration );
 394+ }
 395+ // Duration ready callback:
 396+ var durationReady = function(){
 397+ callback( vid.duration );
 398+ }
 399+ // else setup a load biding
 400+ vid.removeEventListener( "loadedmetadata", durationReady, true );
 401+ vid.addEventListener( "loadedmetadata", durationReady, true );
 402+ },
 403+ /**
384404 * Maps a few smil tags to smil types
385405 *
386406 * http://www.w3.org/TR/2008/REC-SMIL3-20081201/smil-structure.html#edef-body
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -113,7 +113,9 @@
114114 }
115115 },
116116
117 - drawElementThumb: function( $target, $node, relativeTime ){
 117+ drawElementThumb: function( $target, $node, relativeTime ){
 118+ // parse the time incase it came in as human input
 119+ relativeTime = this.smil.parseTime( relativeTime );
118120 switch ( this.smil.getRefType( $node )){
119121 case 'video':
120122 this.getVideoCanvasThumb($target, $node, relativeTime )
@@ -137,31 +139,46 @@
138140 // draw an audio icon in the target
139141 break;
140142 }
141 - },
 143+ },
 144+
142145 getVideoCanvasThumb: function($target, $node, relativeTime ){
143146
144 - var naturaSize = {};
145 - var drawElement = $j( '#' + this.smil.getAssetId( $node ) ).get(0);
 147+ var naturaSize = {};
 148+ var drawElement = $j( '#' + this.smil.getAssetId( $node ) ).get(0);
146149
147 - naturaSize.height = drawElement.videoHeight;
148 - naturaSize.width = drawElement.videoWidth;
149 -
150 - // Draw the thumb via canvas grab
151 - // NOTE I attempted to scale down the image using canvas but failed
152 - // xxx should revisit thumb size issue:
153 - $target.html( $j('<canvas />')
154 - .attr({
155 - height: naturaSize.height,
156 - width : naturaSize.width
157 - }).css( {
158 - height:'100%',
159 - widht:'100%'
160 - })
161 - .addClass("ui-corner-all")
162 - ).find( 'canvas')
163 - .get(0)
164 - .getContext('2d')
165 - .drawImage( drawElement, 0, 0)
 150+ var drawFrame = function(){
 151+ naturaSize.height = drawElement.videoHeight;
 152+ naturaSize.width = drawElement.videoWidth;
 153+
 154+ // Draw the thumb via canvas grab
 155+ // NOTE I attempted to scale down the image using canvas but failed
 156+ // xxx should revisit thumb size issue:
 157+ $target.html( $j('<canvas />')
 158+ .attr({
 159+ height: naturaSize.height,
 160+ width : naturaSize.width
 161+ }).css( {
 162+ height:'100%',
 163+ widht:'100%'
 164+ })
 165+ .addClass("ui-corner-all")
 166+ ).find( 'canvas')
 167+ .get(0)
 168+ .getContext('2d')
 169+ .drawImage( drawElement, 0, 0)
 170+ }
 171+
 172+ // check if relativeTime transform matches current absolute time then render directly:
 173+ var drawTime = ( relativeTime + this.smil.parseTime( $j( $node ).attr('clipBegin') ) );
 174+ if( drawElement.currentTime == drawTime ){
 175+ mw.log("getVideoCanvasThumb: Draw time:" + drawTime + " matches video time drawFrame:" +drawElement.currentTime );
 176+ drawFrame();
 177+ } else {
 178+ // check if we need to spawn a video copy for the draw request
 179+
 180+ // no match do seek
 181+ mw.log( "getVideoCanvasThumb: Draw time:" + drawTime + ' != ' + drawElement.currentTime );
 182+ }
166183 },
167184
168185 /**
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js
@@ -216,7 +216,7 @@
217217 * @param {Element} smilElement Smil video element to be transformed
218218 * @param {time} animateTime Relative time to be transformed
219219 */
220 - transformVideoForTime: function( smilElement, animateTime ){
 220+ transformVideoForTime: function( smilElement, animateTime, callback ){
221221 // Get the video element
222222 var assetId = this.smil.getAssetId( smilElement );
223223 var vid = $j ( '#' + assetId ).get( 0 );
@@ -224,7 +224,7 @@
225225 var videoSeekTime = animateTime;
226226 //Add the clipBegin if set
227227 if( $j( smilElement ).attr( 'clipBegin') &&
228 - this.smil.parseTime( $j( smilElement ).attr( 'clipBegin') ) )
 228+ this.smil.parseTime( $j( smilElement ).attr( 'clipBegin') ) )
229229 {
230230 videoSeekTime += this.smil.parseTime( $j( smilElement ).attr( 'clipBegin') );
231231 }
@@ -233,7 +233,9 @@
234234
235235 // Register a buffer ready callback
236236 this.smil.getBuffer().videoBufferSeek( smilElement, videoSeekTime, function() {
237 - //mw.log( "transformVideoForTime:: seek complete ");
 237+ //mw.log( "transformVideoForTime:: seek complete ")
 238+ if( callback )
 239+ callback();
238240 });
239241 },
240242
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.style.SmilLayout.css
@@ -4,4 +4,5 @@
55 height : 100%;
66 top : 0px;
77 left : 0px;
8 -}
\ No newline at end of file
 8+}
 9+
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
@@ -17,14 +17,14 @@
1818 // Store the actual play time
1919 smilPlayTime: 0,
2020
21 - // Flag to register the player being embedd
 21+ // Flag to register the player being embedded
2222 smilPlayerEmbedded: false,
2323
2424 // Store the pause time
2525 smilPauseTime: 0,
2626
2727 // Store a playback duration
28 - smilsmilPlayEndTime: null,
 28+ smilplaySegmentEndTime: null,
2929
3030 // flag to register when video is paused to fill a buffer.
3131 pausedForBuffer: false,
@@ -85,13 +85,13 @@
8686 }
8787 // Start seek
8888 this.controlBuilder.onSeek();
89 - this.smilPlayTime = time;
 89+ this.smilPlayTime = time;
 90+ this.smilPauseTime = this.smilPlayTime;
9091 var _this = this;
9192 this.getSmil( function( smil ){
9293 smil.renderTime( time, function(){
9394 //mw.log( "setCurrentTime:: renderTime callback" );
94 - $j('#loadingSpinner_' + _this.id ).remove();
95 -
 95+ $j('#loadingSpinner_' + _this.id ).remove();
9696 _this.monitor();
9797 if( callback ){
9898 callback();
@@ -99,6 +99,24 @@
100100 } );
101101 });
102102 },
 103+ /**
 104+ * Issue a seeking request.
 105+ *
 106+ * @param {Float} percentage
 107+ */
 108+ doSeek: function( percentage ) {
 109+ mw.log( 'EmbedPlayerSmil::doSeek p: ' + percentage );
 110+ this.seeking = true;
 111+ var _this = this;
 112+ // Run the seeking hook
 113+
 114+ $j( this.embedPlayer ).trigger( 'onSeek' );
 115+ this.setCurrentTime( percentage * this.getDuration(), function(){
 116+ mw.log("EmbedPlayerSmil:: seek done");
 117+ _this.seeking = false;
 118+ _this.monitor();
 119+ })
 120+ },
103121
104122 /**
105123 * Return the render target for output of smil html
@@ -123,34 +141,31 @@
124142 },
125143 /**
126144 * Smil play function
127 - * @param {float=} smilPlayEndTime Optional duration to be played before pausing playback
 145+ * @param {float=} playSegmentEndTime Optional duration to be played before pausing playback
128146 */
129 - play: function( smilPlayEndTime ){
 147+ play: function( playSegmentEndTime ){
130148 var _this = this;
131 - mw.log(" EmbedPlayerSmil::play " + _this.smilPlayTime );
 149+ mw.log(" EmbedPlayerSmil::play " + _this.smilPlayTime + ' to ' + playSegmentEndTime + ' pause time: ' + this.smilPauseTime );
132150 // Update the interface
133151 this.parent_play();
134152
135 - // Update the smilPlayEndTime flag
136 - if( ! smilPlayEndTime ){
137 - this.smilPlayEndTime = null;
 153+ // Update the playSegmentEndTime flag
 154+ if( ! playSegmentEndTime ){
 155+ this.playSegmentEndTime = null;
138156 } else {
139 - this.smilPlayEndTime = smilPlayEndTime;
 157+ this.playSegmentEndTime = playSegmentEndTime;
140158 }
141159
142160 // Make sure this.smil is ready :
143161 this.getSmil( function( smil ){
144162 // Start buffering the movie
145163 _this.smil.startBuffer();
146 -
147 - // Set start clock time:
148 - _this.clockStartTime = new Date().getTime();
149 -
150 - // Update the pause time:
151 - _this.smilPauseTime = 0;
152164
153165 // Sync with current smilPlayTime
154 - _this.clockStartTime = _this.clockStartTime -( _this.smilPlayTime * 1000 );
 166+ _this.clockStartTime = new Date().getTime() -( _this.smilPlayTime * 1000 );
 167+
 168+ // Zero out the pause time:
 169+ _this.smilPauseTime = 0;
155170
156171 // Start up monitor:
157172 _this.monitor();
@@ -180,7 +195,7 @@
181196 * Preserves the pause time across for timed playback
182197 */
183198 pause: function() {
184 - mw.log( 'EmbedPlayerSmil::pause at time' + this.smilPlayTime );
 199+ mw.log( 'EmbedPlayerSmil::pause at time:' + this.smilPlayTime );
185200 this.smilPauseTime = this.smilPlayTime;
186201
187202 // Issue pause to smil engine
@@ -204,9 +219,10 @@
205220 monitor: function(){
206221 // Get a local variable of the new target time:
207222
208 - // Check if we reached smilPlayEndTime and pause playback
209 - if( this.smilPlayEndTime && this.smilPlayTime >= this.smilPlayEndTime ) {
210 - this.smilPlayEndTime= null;
 223+ // Check if we reached playSegmentEndTime and pause playback
 224+ if( this.playSegmentEndTime && this.smilPlayTime >= this.playSegmentEndTime ) {
 225+ mw.log("monitor:: Reached playSegmentEndTime pause playback: " + this.playSegmentEndTime );
 226+ this.playSegmentEndTime= null;
211227 this.pause();
212228 this.parent_monitor();
213229 return ;
@@ -238,14 +254,17 @@
239255 if( !this.pausedForBuffer ){
240256 // Update playtime if not pausedForBuffer
241257 this.smilPlayTime = this.smilPauseTime + ( ( new Date().getTime() - this.clockStartTime ) / 1000 );
242 - /*mw.log(" update smilPlayTime: " + this.smilPauseTime + " getTime: " + new Date().getTime() +
 258+ /*
 259+ mw.log(" update smilPlayTime: " + this.smilPauseTime + " getTime: " + new Date().getTime() +
243260 ' - clockStartTime: ' + this.clockStartTime + ' = ' +
244261 ( ( new Date().getTime() - this.clockStartTime ) / 1000 ) +
245 - " \n time:" + this.smilPlayTime );*/
 262+ " \n time:" + this.smilPlayTime );
 263+ */
246264 }
247265
248 - // Done with sync delay:
 266+ // Reset the pausedForBuffer flag:
249267 this.pausedForBuffer = false;
 268+
250269 //mw.log( "Call animateTime: " + this.smilPlayTime);
251270 // Issue an animate time request with monitorDelta
252271 this.smil.animateTime( this.smilPlayTime, this.monitorRate );
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTimeline.js
@@ -348,7 +348,9 @@
349349 // Draw a clip thumb into the timeline clip target
350350 drawClipThumb: function ( $node , relativeTime ){
351351 var _this = this;
352 - var smil = this.sequenceEdit.getSmil();
 352+ var smil = this.sequenceEdit.getSmil();
 353+
 354+
353355 // Buffer the asset then render it into the layout target:
354356 smil.getBuffer().canGrabRelativeTime( $node, relativeTime, function(){
355357 var $timelineClip = $j( '#' + _this.getTimelineClipId( $node ) );
@@ -408,13 +410,22 @@
409411 )
410412 // remove loader
411413 .find('.loadingSpinner').remove();
412 - // Add thumb
413 - smil.getLayout().drawElementThumb(
414 - $j( '#' + _this.getTimelineClipId( $node ) ).find('.thumbTraget'),
415 - $node,
416 - relativeTime
417 - )
418 - })
 414+
 415+ var $thumbTarget = $j( '#' + _this.getTimelineClipId( $node ) ).find('.thumbTraget');
 416+
 417+ // Check for a "poster" image use that temporarily while we wait for the video to seek and draw
 418+ if( $node.attr('poster') ){
 419+ $thumbTarget.append(
 420+ $j('<img />')
 421+ .attr( 'src', smil.getAssetUrl( $node.attr('poster') ) )
 422+ .css('height', $thumbTarget.height() )
 423+ )
 424+ }
 425+
 426+ // Add the seek, add to canvas and draw thumb request
 427+ smil.getLayout().drawElementThumb( $thumbTarget, $node, relativeTime );
 428+
 429+ })
419430 },
420431 /**
421432 * Gets an sequence track control interface
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/css/mw.style.SequenceEdit.css
@@ -64,4 +64,12 @@
6565 border: 2px solid #F22;
6666 }
6767
 68+.mwe-sequence-edit .trimStartThumb, .trimEndThumb {
 69+ float : left;
 70+ display:block;
 71+ width : 80px;
 72+ height : 60px;
 73+ overflow: hidden;
 74+ border: 2px solid #555;
 75+}
6876
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditPlayer.js
@@ -68,6 +68,7 @@
6969 var clipEndTime = startOffset +
7070 this.sequenceEdit.getSmil().getBody().getClipDuration( smilClip );
7171 this.getEmbedPlayer().setCurrentTime( startOffset, function(){
 72+ mw.log("SequenceEditPlayer::Preview clip: " + startOffset + ' to ' + clipEndTime);
7273 _this.getEmbedPlayer().play( clipEndTime );
7374 })
7475 },
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEdit.js
@@ -97,8 +97,7 @@
9898 */
9999 drawUI: function( ){
100100 var _this = this;
101 - mw.log("SequenceEdit:: drawUI to: " + this.interfaceContainer +
102 - ' ' + this.getContainer().length);
 101+ mw.log( "SequenceEdit:: drawUI to: " + this.interfaceContainer + ' ' + this.getContainer().length );
103102
104103 // Add the ui layout
105104 this.getContainer().html(
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTools.js
@@ -46,10 +46,11 @@
4747 $j( smilClip ).attr( attributeName, mw.seconds2npt( seconds ) );
4848 // Update the clip duration :
4949 _this.sequenceEdit.getEmbedPlayer().getDuration( true );
 50+
5051 // Seek to "this clip"
5152 _this.sequenceEdit.getEmbedPlayer().setCurrentTime(
5253 $j( smilClip ).data('startOffset')
53 - );
 54+ );
5455 },
5556 getSmilVal : function( _this, smilClip, attributeName ){
5657 var smil = _this.sequenceEdit.getSmil();
@@ -69,16 +70,6 @@
7071 _this.sequenceEdit.getPlayer().previewClip( smilClip );
7172 }
7273 },
73 - /*'apply' :{
74 - 'icon' : 'check',
75 - 'title' : gM('mwe-sequenceedit-apply-changes'),
76 - 'action': function( _this, smilClip, toolId){
77 - mw.log( "editActions:: changes already applied" );
78 - _this.sequenceEdit.getEditToolTarget().html(
79 - _this.defaultText
80 - )
81 - }
82 - },*/
8374 'cancel':{
8475 'icon': 'close',
8576 'title' : gM('mwe-cancel'),
@@ -86,17 +77,137 @@
8778 var tool = _this.tools[toolId];
8879 for( var i=0; i < tool.editableAttributes.length ; i++ ){
8980 var attributeName = tool.editableAttributes[i];
90 - var $editToolInput = $j('#' + _this.getEditToolId( toolId, attributeName ) );
 81+ var $editToolInput = $j('#' + _this.getEditToolId( toolId, attributeName ) );
9182 // Restore all original attribute values
92 - smilClip.attr( attributeName, $editToolInput.data('initialValue') );
93 - // close / empty the toolWindow
 83+ smilClip.attr( attributeName, $editToolInput.data('initialValue') );
9484 }
 85+
 86+ // Update the clip duration :
 87+ _this.sequenceEdit.getEmbedPlayer().getDuration( true );
 88+
 89+ // Update the embed player
 90+ _this.sequenceEdit.getEmbedPlayer().setCurrentTime(
 91+ $j( smilClip ).data('startOffset')
 92+ );
 93+
 94+ // Close / empty the toolWindow
9595 _this.sequenceEdit.getEditToolTarget().html(
9696 _this.defaultText
9797 )
9898 }
9999 }
100100 },
 101+ editWidgets: {
 102+ 'trimTimeline':{
 103+ 'update': function( _this, target, smilClip ){
 104+ var smil = _this.sequenceEdit.getSmil();
 105+ // Update the preview thumbs
 106+ var clipBeginTime = $j('#editTool_trim_clipBegin').val();
 107+ if( !clipBeginTime ){
 108+ $j(target).find('.trimStartThumb').hide();
 109+ } else {
 110+ // Render a thumbnail for relative start time = 0
 111+ smil.getLayout().drawElementThumb(
 112+ $j(target).find('.trimStartThumb'),
 113+ smilClip,
 114+ 0
 115+ )
 116+ }
 117+ // Check the duration:
 118+ var clipDur = $j('editTool_trim_dur').val();
 119+ if( clipDur ){
 120+ // Render a thumbnail for relative start time = 0
 121+ smil.getLayout().drawElementThumb(
 122+ $j(target).find('.trimEndThumb'),
 123+ smilClip,
 124+ clipDur
 125+ );
 126+ }
 127+
 128+ mw.log( "editWidgets::trimTimeline:update:: " + clipBeginTime + ' dur: ' + clipDur);
 129+ },
 130+ // Return the trimTimeline edit widget
 131+ 'draw': function( _this, target, smilClip ){
 132+ var smil = _this.sequenceEdit.getSmil();
 133+ // For now just have a thumbnail and a slider
 134+ $j(target).append(
 135+ $j('<div />')
 136+ .addClass( 'trimStartThumb ui-corner-all' ),
 137+ $j('<div />')
 138+ .addClass( 'trimEndThumb ui-corner-all' ),
 139+ $j('<div />').addClass('ui-helper-clearfix')
 140+ )
 141+
 142+ // Add a trim binding:
 143+ $j('#editTool_trim_clipBegin,#editTool_trim_dur').change(function(){
 144+ _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 145+ })
 146+ // Update the thumbnails:
 147+ _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 148+
 149+ // get the clip full duration to build out the timeline selector
 150+ smil.getBody().getClipAssetDuration( smilClip, function( fullClipDuration ) {
 151+
 152+ var sliderToTime = function( sliderval ){
 153+ return parseInt( fullClipDuration * ( sliderval / 1000 ) );
 154+ }
 155+ var timeToSlider = function( time ){
 156+ return parseInt( ( time / fullClipDuration ) * 1000 );
 157+ }
 158+ var startSlider = timeToSlider( smil.parseTime( $j('#editTool_trim_clipBegin').val() ) );
 159+ var sliderValues = [
 160+ startSlider,
 161+ startSlider + timeToSlider( smil.parseTime( $j('#editTool_trim_dur').val() ) )
 162+ ];
 163+ // Return a trim tool binded to smilClip id update value events.
 164+ $j(target).append(
 165+ $j('<div />')
 166+ .attr( 'id', _this.sequenceEdit.id + '_trimTimeline' )
 167+ .css({
 168+ 'width': '100%',
 169+ 'margin': '5px'
 170+ })
 171+ .slider({
 172+ range: true,
 173+ min: 0,
 174+ max: 1000,
 175+ values: sliderValues,
 176+ slide: function(event, ui) {
 177+ mw.log( 'slider1: ' + ui.values[0] + ' - sldier two' + ui.values[1] + ' t: ' + sliderToTime( ui.values[0] ) + ' t2: ' + sliderToTime( ui.values[1]) );
 178+ $j('#editTool_trim_clipBegin').val(
 179+ mw.seconds2npt( sliderToTime( ui.values[0] ), true )
 180+ );
 181+ $j('#editTool_trim_dur').val(
 182+ mw.seconds2npt( sliderToTime( ui.values[1] ), true )
 183+ );
 184+ },
 185+ change: function( event, ui ) {
 186+ if( sliderValues[0] != ui.values[0] ){
 187+ var attributeChanged = 'clipBegin';
 188+ sliderIndex = 0;
 189+ } else {
 190+ var attributeChanged = 'dur';
 191+ sliderIndex = 1;
 192+ }
 193+ var attributeValue = sliderToTime( ui.values[ sliderIndex ] )
 194+ sliderValues[ sliderIndex ] = ui.values[ sliderIndex ];
 195+
 196+ // update start and end time:
 197+ _this.editableTypes['time'].update( _this, smilClip, attributeChanged, attributeValue)
 198+
 199+ // update the widget
 200+ _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 201+ }
 202+ })
 203+ );
 204+ });
 205+ // On resize event
 206+
 207+ // Fill in timeline images
 208+
 209+ }
 210+ }
 211+ },
101212 getEditToolId: function( toolId, attributeName){
102213 return 'editTool_' + toolId + '_' + attributeName;
103214 },
@@ -107,10 +218,10 @@
108219 // get the toolId based on what "ref type" smilClip is:
109220 switch( this.sequenceEdit.getSmil().getRefType( smilClip ) ){
110221 case 'video':
111 - toolId = 'trim'
 222+ toolId = 'trim';
112223 break;
113224 default:
114 - toolId = 'duration'
 225+ toolId = 'duration';
115226 break;
116227 }
117228
@@ -121,19 +232,14 @@
122233 return ;
123234 }
124235 var tool = this.tools[ toolId ];
 236+
125237 // Append the title:
126238 $target.empty().append(
127239 $j('<h3 />' ).append(
128240 tool.title
129241 )
130242 );
131 -
132 - // Build out widgets
133 - //if( tool.editWidgets ){
134 - //for( var i =0 ; i < tool.editWidgets.length ; i ++ ){
135 - //}
136 - //}
137 -
 243+
138244 // Build out the attribute list:
139245 for( var i=0; i < tool.editableAttributes.length ; i++ ){
140246 attributeName = tool.editableAttributes[i];
@@ -141,9 +247,34 @@
142248 this.getEditableAttribute( smilClip, toolId, attributeName )
143249 );
144250 }
 251+
145252 // output a float divider:
146253 $target.append( $j('<div />').addClass('ui-helper-clearfix') );
147254
 255+ // Build out widgets
 256+ if( tool.editWidgets ){
 257+ for( var i =0 ; i < tool.editWidgets.length ; i ++ ){
 258+ var editWidgetId = tool.editWidgets[i];
 259+ if( ! this.editWidgets[editWidgetId] ){
 260+ mw.log("Error: not recogonized widget: " + editWidgetId);
 261+ continue;
 262+ }
 263+ // Append a target for the edit widget:
 264+ $target.append(
 265+ $j('<div />')
 266+ .attr('id', 'editWidgets_' + editWidgetId)
 267+ );
 268+ // Draw the binded widget:
 269+ this.editWidgets[editWidgetId].draw(
 270+ this,
 271+ $j( '#editWidgets_' + editWidgetId ),
 272+ smilClip
 273+ )
 274+ // Output a float divider:
 275+ $target.append( $j('<div />').addClass( 'ui-helper-clearfix' ) );
 276+ }
 277+ }
 278+
148279 // Build out edit Actions buttons
149280 for( var i=0; i < tool.editActions.length ; i++){
150281 var editActionId = tool.editActions[i];
@@ -178,14 +309,14 @@
179310 mw.log("Error: editableAttributes : " + attributeName + ' not found');
180311 return;
181312 }
182 - var _this = this;
 313+ var _this = this;
183314 var editAttribute = this.editableAttributes[ attributeName ];
184315 var editType = editAttribute.type;
185316
186317 var initialValue = _this.editableTypes[ editType ].getSmilVal(
187 - _this,
188 - smilClip,
189 - attributeName
 318+ _this,
 319+ smilClip,
 320+ attributeName
190321 );
191322 return $j( '<div />' )
192323 .css({
@@ -196,15 +327,16 @@
197328 'padding' : '2px',
198329 'margin' : '5px'
199330 })
 331+ .addClass('ui-corner-all')
200332 .append(
201333 $j('<span />')
202334 .css('margin', '5px')
203335 .text( editAttribute.title ),
204336
205 - $j('<input />')
 337+ $j('<input />')
206338 .attr( {
207339 'id' : _this.getEditToolId( toolId, attributeName),
208 - 'size': 5
 340+ 'size': 6
209341 })
210342 .data('initialValue', initialValue )
211343 .sequenceEditInput( _this.sequenceEdit )
@@ -216,41 +348,11 @@
217349 smilClip,
218350 attributeName,
219351 $j( this ).val()
220 - );
 352+ );
 353+ // widgets can bind directly to this change action.
221354 })
222355 );
223 - },
224 -
225 - /*drawTrimClipTool: function( clipNode ){
226 - $target = this.sequenceEdit.getToolTarget();
227 - $target.empty().append(
228 - $j('<div />')
229 - .addClass("toolTarget")
230 - .append(
231 - $j('<h3 />').text(
232 -
233 - ),
234 - // Width of the container images thumbs set-in-out
235 -
236 - $j('<div />')
237 - .addClass("ui-helper-clearfix"),
238 - // Start time and end time text:
239 - $j( '<div />' )
240 - .css({
241 - 'float': 'left',
242 - 'width': '200px',
243 - 'background-color': '#AAA'
244 - })
245 - .append(
246 - $j('<span />')
247 - .text( gM('mwe-sequenceedit-start-time') ),
248 - $j('<input />')
249 - .attr('size', 5)
250 - )
251 - )
252 - )
253 - )
254 - }*/
 356+ }
255357 }
256358
257359 } )( window.mw );
\ No newline at end of file

Status & tagging log