r71219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71218‎ | r71219 | r71220 >
Date:23:33, 17 August 2010
Author:dale
Status:deferred
Tags:
Comment:
* improved undo redo handling for non-change edits
* improved click selection "editTool" updates
* improved audio track display and edit
Modified paths:
  • /branches/MwEmbedStandAlone/libraries/jquery/jquery-1.4.2.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/css/mw.style.Sequencer.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/SmilPlayer.i8n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -115,7 +115,11 @@
116116
117117 drawElementThumb: function( $target, $node, relativeTime ){
118118 mw.log('SmilLayout::drawElementThumb: ' + relativeTime );
119 - // parse the time incase it came in as human input
 119+ if( $target.length == 0 ){
 120+ mw.log("Error drawElementThumb to empty target");
 121+ return ;
 122+ }
 123+ // parse the time in case it came in as human input
120124 relativeTime = this.smil.parseTime( relativeTime );
121125 switch ( this.smil.getRefType( $node )){
122126 case 'video':
@@ -125,10 +129,10 @@
126130 // xxx we could eventually use canvas as well but for now just add it at 100%
127131 $target.html(
128132 this.getSmilImgHtml( $node, {
129 - 'width' : $target.width(),
130 - 'height' : $target.height()
131 - })
132 - );
 133+ 'width' : $target.width(),
 134+ 'height' : $target.height()
 135+ })
 136+ );
133137 break;
134138 case 'cdata_html':
135139 // Scale down the html into the target width
@@ -136,8 +140,20 @@
137141 this.getSmilCDATAHtml( $node, $target.width() )
138142 )
139143 break;
140 - case 'audio':
141 - // draw an audio icon in the target
 144+ case 'audio':
 145+ var titleStr = ( $node.attr('title') )? $node.attr('title') : gM( 'mwe-sequencer-untitled-audio' )
 146+ // draw an audio icon / title the target
 147+ $target.append(
 148+ $j('<span />')
 149+ .addClass( 'ui-icon ui-icon-volume-on')
 150+ .attr('title', titleStr)
 151+ .css( 'position', 'absolute')
 152+ ,
 153+ $j('<span />')
 154+ .attr('title', titleStr)
 155+ .css({'position': 'absolute', 'left':'16px'})
 156+ .text( titleStr )
 157+ )
142158 break;
143159 }
144160 },
@@ -189,7 +205,7 @@
190206 // update the drawElement
191207 drawElement = $j( '#' + _this.smil.getPageDomId( $tmpFrameNode ) ).get(0);
192208 drawFrame( drawElement );
193 - // remove the temporary node from dom
 209+ // Remove the temporary node from dom
194210 $j( drawElement ).remove();
195211 })
196212 }
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js
@@ -17,6 +17,8 @@
1818 *
1919 */
2020
 21+mw.includeAllModuleMessages();
 22+
2123 /* Add the hooks needed for playback */
2224 mw.Smil = function(options) {
2325 return this.init(options);
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/SmilPlayer.i8n.php
@@ -2,5 +2,6 @@
33 $messages = array();
44
55 $messages['en'] = array(
6 - 'mwe-embedplayer-ogg-player-smilPlayer' => 'SMIL Player'
 6+ 'mwe-embedplayer-ogg-player-smilPlayer' => 'SMIL Player',
 7+ 'mwe-smilplayer-untitled-audio' => 'Untitled audio'
78 );
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
@@ -266,7 +266,7 @@
267267 .append(
268268 $j('<div />')
269269 .addClass( "ui-layout-center mwseq-edit" )
270 - .html( this.getEditTools().defaultText ),
 270+ .html( gM('mwe-sequencer-no_selected_resource') ),
271271 $j('<div />')
272272 .addClass( "ui-layout-east mwseq-player" )
273273 .text( gM('mwe-sequencer-loading-player') ),
Index: branches/MwEmbedStandAlone/modules/Sequencer/css/mw.style.Sequencer.css
@@ -22,14 +22,16 @@
2323 list-style-position: inside;
2424 cursor: hand;
2525 cursor: pointer;
26 - margin:0px;
 26+ margin-top:4px;
 27+ margin-bottom: 0px;
2728 padding: 4px;
2829 }
2930
3031 .mwe-sequencer .trackNames{
3132 background-color: #EEE;
3233 border: solid thin #999;
33 - padding:4px
 34+ padding:4px;
 35+ margin-top: 4px;
3436 }
3537
3638 .mwe-sequencer .timelineClip{
@@ -39,7 +41,6 @@
4042 border: 2px solid #555;
4143 overflow: hidden;
4244 width:120px;
43 - height:90px;
4445
4546 display: inline-block;
4647 position: relative;
Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -14,6 +14,7 @@
1515 'mwe-sequencer-loading-asset' => 'Loading asset ...',
1616
1717 'mwe-sequencer-no_selected_resource' => '<h3>No resource selected</h3> Select a clip to enable editing.',
 18+ 'mwe-sequencer-error_edit_multiple' => '<h3>Multiple resources selected</h3> Select a single clip to edit it.',
1819 'mwe-sequencer-no-sequence-start-new' => 'Empty sequence, [$1 browser for assets] to create a new sequence',
1920 'mwe-sequencer-video-track' => 'Video track',
2021 'mwe-sequencer-audio-track' => 'Audio track',
@@ -86,8 +87,7 @@
8788 'mwe-sequencer-pixle2sec' => 'pixels to seconds',
8889 'mwe-sequencer-rmclip' => 'Remove clip',
8990 'mwe-sequencer-clip_in' => 'clip in',
90 - 'mwe-sequencer-clip_out' => 'clip out',
91 - 'mwe-sequencer-error_edit_multiple' => '<h3>Multiple resources selected</h3> Select a single clip to edit it.',
 91+ 'mwe-sequencer-clip_out' => 'clip out',
9292 'mwe-sequencer-editor_options' => 'Editor options',
9393 'mwe-sequencer-editor_mode' => 'Editor mode',
9494 'mwe-sequencer-simple_editor_desc' => 'simple editor (iMovie style)',
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsEdit.js
@@ -47,7 +47,14 @@
4848 * Apply a smil xml transform state ( to support undo / redo )
4949 */
5050 registerEdit: function(){
51 - mw.log( 'ActionsEdit::registerEdit: stacksize' + this.editStack.length + ' editIndex: ' + this.editIndex );
 51+ //mw.log( 'ActionsEdit::registerEdit: stacksize' + this.editStack.length + ' editIndex: ' + this.editIndex );
 52+ // Make sure the edit is distinct from the latest in the stack:
 53+ var currentXML = this.sequencer.getSmil().getXMLString();
 54+ if( currentXML == this.editStack[ this.editStack-1 ] ){
 55+ mw.log("ActionsEdit::registerEdit on identical smil xml state ( no edit stack modification ) ")
 56+ return ;
 57+ }
 58+
5259 // Throw away any edit history after the current editIndex:
5360 if( this.editStack.length && this.editIndex > this.editStack.length ) {
5461 this.editStack = this.editStack.splice(0, this.editIndex);
@@ -56,7 +63,7 @@
5764 // @@TODO could save space to just compute the diff in JS and store that
5865 // ie: http://code.google.com/p/google-diff-match-patch/
5966 // ( instead of the full xml text with "key-pages" every 10 edits or something like that.
60 - this.editStack.push( this.sequencer.getSmil().getXMLString() );
 67+ this.editStack.push( currentXML );
6168
6269 // Update the editIndex
6370 this.editIndex = this.editStack.length - 1;
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -14,7 +14,6 @@
1515 init: function( sequencer ){
1616 this.sequencer = sequencer;
1717 },
18 - defaultText : gM('mwe-sequencer-no_selected_resource'),
1918 tools:{
2019 'trim':{
2120 'title': gM('mwe-sequencer-cliptool-trim'),
@@ -132,14 +131,16 @@
133132 // Return the trimTimeline edit widget
134133 'draw': function( _this, target, smilClip ){
135134 var smil = _this.sequencer.getSmil();
136 - // For now just have a thumbnail and a slider
137 - $j(target).append(
138 - $j('<div />')
139 - .addClass( 'trimStartThumb ui-corner-all' ),
140 - $j('<div />')
141 - .addClass( 'trimEndThumb ui-corner-all' ),
142 - $j('<div />').addClass('ui-helper-clearfix')
143 - )
 135+ // check if thumbs are supported
 136+ if( _this.sequencer.getSmil().getRefType( smilClip ) == 'video' ){
 137+ $j(target).append(
 138+ $j('<div />')
 139+ .addClass( 'trimStartThumb ui-corner-all' ),
 140+ $j('<div />')
 141+ .addClass( 'trimEndThumb ui-corner-all' ),
 142+ $j('<div />').addClass('ui-helper-clearfix')
 143+ )
 144+ }
144145
145146 // Add a trim binding:
146147 $j('#editTool_trim_clipBegin,#editTool_trim_dur').change(function(){
@@ -148,7 +149,7 @@
149150 // Update the thumbnails:
150151 _this.editWidgets.trimTimeline.update( _this, target, smilClip);
151152
152 - // get the clip full duration to build out the timeline selector
 153+ // Get the clip full duration to build out the timeline selector
153154 smil.getBody().getClipAssetDuration( smilClip, function( fullClipDuration ) {
154155
155156 var sliderToTime = function( sliderval ){
@@ -227,6 +228,7 @@
228229 // get the toolId based on what "ref type" smilClip is:
229230 switch( this.sequencer.getSmil().getRefType( smilClip ) ){
230231 case 'video':
 232+ case 'audio':
231233 toolId = 'trim';
232234 break;
233235 default:
@@ -243,7 +245,9 @@
244246 var tool = this.tools[ toolId ];
245247
246248 // Append the title:
247 - $target.empty().append(
 249+ $target.empty().append(
 250+ $j('<div />').addClass( 'editToolsContainer' )
 251+ ,
248252 $j('<h3 />' ).append(
249253 tool.title
250254 )
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
@@ -27,6 +27,6 @@
2828 "Sequencer.TimelineTrackHeight" : 100,
2929
3030 // Default timeline "audio / collapsed" size
31 - "Sequencer.TimelineColapsedTrackSize" : 30
 31+ "Sequencer.TimelineColapsedTrackSize" : 35
3232 })
3333
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -69,14 +69,18 @@
7070 var timelineHeight = mw.getConfig( 'Sequencer.TimelineTrackHeight' );
7171 var smilSequenceTracks = this.sequencer.getSmil().getBody().getSeqElements();
7272 $j.each(smilSequenceTracks, function( trackIndex, smilSequenceTrack ){
73 - if( $j( smilSequenceTrack).attr('tracktype') == 'audio' ){
74 - timelineHeight+= mw.getConfig( 'Sequencer.TimelineColapsedTrackSize')
75 - }else{
76 - timelineHeight+= mw.getConfig( 'Sequencer.TimelineTrackHeight' )
77 - }
 73+ timelineHeight+= _this.getSequenceTrackHeight( smilSequenceTrack )
7874 })
7975 return timelineHeight;
8076 },
 77+ // xxx may need to refactor to store collapsed expanded state info
 78+ getSequenceTrackHeight: function( smilSequenceTrack ){
 79+ if( $j( smilSequenceTrack).attr('tracktype') == 'audio' ){
 80+ return mw.getConfig( 'Sequencer.TimelineColapsedTrackSize')
 81+ }else{
 82+ return mw.getConfig( 'Sequencer.TimelineTrackHeight' )
 83+ }
 84+ },
8185 // Get the selected sequence track index ( for now its always zero )
8286 getSelectedTrackIndex: function(){
8387 return 0;
@@ -148,8 +152,10 @@
149153 mw.log("ADD: " + _this.getTimelineClipId( $node ) + ' to ' + $clipTrackSet.attr('id') );
150154 // Draw the node onto the timeline if the clip is not already there:
151155 var $timelineClip = $clipTrackSet.find( '#' + _this.getTimelineClipId( $node ) )
152 - if( $timelineClip.length == 0 ){
153 - $timelineClip = _this.getTimelineClip( $clipTrackSet, $node );
 156+ if( $timelineClip.length == 0 ){
 157+ $timelineClip = _this.getTimelineClip( smilSequenceTrack, $node );
 158+ // Set the index order on the clip
 159+ $timelineClip.data( 'indexOrder', $clipTrackSet.children().length );
154160 if( $previusClip ){
155161 $previusClip.after(
156162 $timelineClip
@@ -225,19 +231,16 @@
226232 */
227233 getClipTrackSet: function( trackIndex, smilSequenceTrack ){
228234 var _this = this;
229 -
230 - var trackHeight = ( $j( smilSequenceTrack).attr('tracktype') == 'audio' )?
231 - mw.getConfig( 'Sequencer.TimelineColapsedTrackSize') :
232 - mw.getConfig( 'Sequencer.TimelineTrackHeight' )
233 -
 235+
234236 return $j('<ul />')
235237 .attr( 'id', this.getTrackSetId( trackIndex ))
236238 .data( 'trackIndex', trackIndex )
237239 .addClass( 'clipTrackSet ui-corner-all' )
238 - .css( 'height', trackHeight )
 240+ .css( 'height', _this.getSequenceTrackHeight( smilSequenceTrack ) )
239241 // Add "sortable
240242 .sortable({
241243 placeholder: "clipSortTarget timelineClip ui-corner-all",
 244+ forcePlaceholderSize: true,
242245 opacity: 0.6,
243246 tolerance: 'pointer',
244247 cursor: 'move',
@@ -281,15 +284,16 @@
282285 'width' : ( ( this.timelineThumbSize.width + 16) * trackClipCount) + 'px'
283286 });
284287 },
285 - getTimelineClip: function( $clipTrackSet, $node ){
 288+ getTimelineClip: function( smilSequenceTrack, $node ){
286289 var _this = this;
 290+
287291 return $j('<li />')
288292 .attr('id', _this.getTimelineClipId( $node ) )
289293 .data( {
290 - 'smilId': $node.attr('id'),
291 - 'indexOrder' : $clipTrackSet.children().length
 294+ 'smilId': $node.attr('id'),
292295 })
293 - .addClass('timelineClip ui-corner-all')
 296+ .css( 'height', this.getSequenceTrackHeight( smilSequenceTrack) - 10 )
 297+ .addClass( 'timelineClip ui-corner-all' )
294298 .loadingSpinner()
295299 .click(function(){
296300 //Add clip to selection
@@ -451,6 +455,7 @@
452456 * Handle multiple selections based on what clips was just "cliked"
453457 */
454458 handleMultiSelect: function( clickClip ){
 459+ var _this = this;
455460 var keyBindings = this.sequencer.getKeyBindings();
456461 var $target = this.getTimelineContainer();
457462 var smil = this.sequencer.getSmil();
@@ -508,7 +513,32 @@
509514 });
510515 }
511516
512 - // xxx check if selected clip has changed hide tool edit interface
 517+ // Update the edit Tools window
 518+ var $selectedClips = _this.getTimelineContainer().find('.selectedClip');
 519+ // zero clips selected
 520+ var $toolTarget = _this.sequencer.getEditToolTarget();
 521+
 522+ //( on an edit screen update the edit screen per selection )
 523+ if( $toolTarget.find( '.editToolsContainer' ).length != 0 ){
 524+ // multiple clips selected
 525+ if( $selectedClips.length == 0 ){
 526+ // Update edit window to no selected clips
 527+ $toolTarget.empty().append(
 528+ gM( 'mwe-sequencer-no_selected_resource' ),
 529+ $j('<div />').addClass('editToolsContainer')
 530+ )
 531+ } else if( $selectedClips.length > 1 ){
 532+ $toolTarget.empty().append(
 533+ gM( 'mwe-sequencer-error_edit_multiple' ),
 534+ $j('<div />').addClass('editToolsContainer')
 535+ )
 536+ } else {
 537+ // A single clip is selected edit that clip
 538+ _this.editClip( clickClip );
 539+ }
 540+ // Register the edit tools update for undo
 541+ _this.sequencer.getActionsEdit().registerEdit();
 542+ }
513543 },
514544
515545 /**
@@ -534,6 +564,12 @@
535565 var _this = this;
536566 var smil = this.sequencer.getSmil();
537567
 568+ var clipButtonCss = {
 569+ 'position' : 'absolute',
 570+ 'bottom' : '2px',
 571+ 'padding' : '2px',
 572+ 'cursor' : 'pointer'
 573+ };
538574
539575 var $timelineClip = $j( '#' + _this.getTimelineClipId( $node ) );
540576 // Add Thumb target and remove loader
@@ -544,12 +580,9 @@
545581
546582 // Edit clip button:
547583 $j('<div />')
548 - .css({
549 - 'position' : 'absolute',
550 - 'right' : '32px',
551 - 'bottom' : '5px',
552 - 'padding' : '2px',
553 - 'cursor' : 'pointer'
 584+ .css( clipButtonCss )
 585+ .css({
 586+ 'right' : '32px'
554587 })
555588 .addClass( 'clipEditLink ui-state-default ui-corner-all' )
556589 .append(
@@ -564,12 +597,9 @@
565598
566599 // Remove clip button:
567600 $j('<div />')
568 - .css({
569 - 'position' : 'absolute',
570 - 'right' : '5px',
571 - 'bottom' : '5px',
572 - 'padding' : '2px',
573 - 'cursor' : 'pointer'
 601+ .css( clipButtonCss )
 602+ .css({
 603+ 'right' : '5px'
574604 })
575605 .addClass( 'clipRemoveLink ui-state-default ui-corner-all' )
576606 .append(
@@ -580,7 +610,7 @@
581611 .buttonHover()
582612 .click( function(){
583613 // Remove the associated clip:
584 - _this.getTimelineContainer().removeClass( 'selectedClip' );
 614+ _this.getTimelineContainer().find('.selectedClip').removeClass( 'selectedClip' );
585615 $timelineClip.addClass( 'selectedClip' );
586616 _this.removeSelectedClips();
587617 })
@@ -624,6 +654,7 @@
625655 }
626656 }, 5000);
627657 }
 658+
628659 // Buffer the asset then render it into the layout target:
629660 smil.getBuffer().bufferedSeek( $node, relativeTime, function(){
630661 // Add the seek, add to canvas and draw thumb request
@@ -653,19 +684,17 @@
654685 $j('<span />').addClass( 'ui-icon ui-icon-volume-on'),
655686 $j('<span />').text( gM( 'mwe-sequencer-audio-track' ) )
656687 )
657 - $trackNameContainer.css({
658 - 'height' : mw.getConfig( 'Sequencer.TimelineColapsedTrackSize')
659 - });
660688 } else {
661689 // for now default to "video" tracktype
662690 $trackNameTitle.append(
663691 $j('<span />').addClass( 'ui-icon ui-icon-video'),
664692 $j('<span />').text( gM( 'mwe-sequencer-video-track' ) )
665693 )
666 - $trackNameContainer.css({
667 - 'height' : mw.getConfig( 'Sequencer.TimelineTrackHeight' )
668 - });
669694 }
 695+ // Set track name height
 696+ $trackNameContainer.css({
 697+ 'height' : this.getSequenceTrackHeight( smilSequenceTrack )
 698+ });
670699
671700 // Add the track title as a title attribute
672701 if ( $j( smilSequenceTrack ).attr('title') ){
Index: branches/MwEmbedStandAlone/libraries/jquery/jquery-1.4.2.js
@@ -1820,7 +1820,7 @@
18211821
18221822 // Only trigger if we've ever bound an event for it
18231823 if ( jQuery.event.global[ type ] ) {
1824 - jQuery.each( jQuery.cache, function() {
 1824+ jQuery.each( jQuery.cache, function() {
18251825 if ( this.events && this.events[type] ) {
18261826 jQuery.event.trigger( event, data, this.handle.elem );
18271827 }

Status & tagging log