r69135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69134‎ | r69135 | r69136 >
Date:09:22, 7 July 2010
Author:dale
Status:deferred
Tags:
Comment:
stubs for clip edit
Modified paths:
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/SequenceEdit.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditKeyBindings.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 (added) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SequenceEdit/loader.js
@@ -11,6 +11,7 @@
1212 "mw.SequenceEditPlayer" : "mw.SequenceEditPlayer.js",
1313 "mw.SequenceEditTimeline" : "mw.SequenceEditTimeline.js",
1414 "mw.SequenceEditKeyBindings" : "mw.SequenceEditKeyBindings.js",
 15+ "mw.SequenceEditTools" : "mw.SequenceEditTools.js",
1516
1617 "mw.FirefoggRender" : "mw.FirefoggRender.js",
1718 "$j.fn.layout" : "ui.layout/ui.layout-1.2.0.js",
@@ -38,14 +39,16 @@
3940 // Make sure we have the required mwEmbed libs:
4041 return [
4142 [ // Load the EmbedPlayer Module ( includes lots of dependent classes )
42 - 'EmbedPlayer'
 43+ 'EmbedPlayer',
 44+ 'mw.SequenceEdit'
4345 ],
4446 [
4547 '$j.contextMenu',
46 - 'mw.SequenceEdit',
 48+
4749 'mw.SequenceEditPlayer',
4850 'mw.SequenceEditTimeline',
4951 'mw.SequenceEditKeyBindings',
 52+ 'mw.SequenceEditTools',
5053
5154 'mw.style.SequenceEdit'
5255 ],
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/SequenceEdit.i18n.php
@@ -11,10 +11,18 @@
1212 'mwe-sequenceedit-loading_timeline' => 'Loading timeline ...',
1313 'mwe-sequenceedit-loading_player' => 'Loading player...',
1414 'mwe-sequenceedit-loading_edit' => 'Loading edit...',
 15+ 'mwe-sequenceedit-no_selected_resource' => '<h3>No resource selected</h3> Select a clip to enable editing.',
1516 'mwe-sequenceedit-no-sequence-start-new' => 'Empty sequence, [$1 browser for assets] to create a new sequence',
1617 'mwe-sequenceedit-video-track' => 'Video track',
1718 'mwe-sequenceedit-audio-track' => 'Audio track',
1819
 20+ 'mwe-sequenceedit-trim-clip' => 'Trim clip',
 21+ 'mwe-sequenceedit-preview' => 'Preview',
 22+ 'mwe-sequenceedit-apply-changes' => 'Apply changes',
 23+
 24+ 'mwe-sequenceedit-start-time' => 'Start time',
 25+ 'mwe-sequenceedit-clip-duration' => 'Clip duration',
 26+
1927 'mwe-sequenceedit-transition_in' => 'Transition in',
2028 'mwe-sequenceedit-transition_out' => 'Transition out',
2129 'mwe-sequenceedit-effects' => 'Effects stack',
@@ -29,7 +37,7 @@
3038 'mwe-sequenceedit-menu_options' => 'Options',
3139 'mwe-sequenceedit-loading_user_rights' => 'Loading user rights ...',
3240 'mwe-sequenceedit-no_edit_permissions' => 'You do not have permissions to save changes to this sequence',
33 - 'mwe-sequenceedit-edit_clip' => 'Edit clip',
 41+
3442 'mwe-sequenceedit-edit_save' => 'Save sequence changes',
3543 'mwe-sequenceedit-saving_wait' => 'Save in progress (please wait)',
3644 'mwe-sequenceedit-save_done' => 'Save complete',
@@ -44,8 +52,7 @@
4553 'mwe-sequenceedit-pixle2sec' => 'pixels to seconds',
4654 'mwe-sequenceedit-rmclip' => 'Remove clip',
4755 'mwe-sequenceedit-clip_in' => 'clip in',
48 - 'mwe-sequenceedit-clip_out' => 'clip out',
49 - 'mwe-sequenceedit-no_selected_resource' => '<h3>No resource selected</h3> Select a clip to enable editing.',
 56+ 'mwe-sequenceedit-clip_out' => 'clip out',
5057 'mwe-sequenceedit-error_edit_multiple' => '<h3>Multiple resources selected</h3> Select a single clip to edit it.',
5158 'mwe-sequenceedit-editor_options' => 'Editor options',
5259 'mwe-sequenceedit-editor_mode' => 'Editor mode',
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditKeyBindings.js
@@ -2,6 +2,22 @@
33 * Stores the key bindings
44 */
55
 6+/**
 7+ * jQuery helper for input focus binding
 8+ */
 9+( function( $ ) {
 10+ $.fn.sequenceEditInput = function( sequenceEdit ) {
 11+ $j(this)
 12+ .focus( function(){
 13+ sequenceEdit.getKeyBindings().onFocus();
 14+ })
 15+ .blur( function(){
 16+ sequenceEdit.getKeyBindings().onBlur();
 17+ })
 18+ return this;
 19+ }
 20+} )( jQuery );
 21+
622 mw.SequenceEditKeyBindings = function( sequenceEdit ) {
723 return this.init( sequenceEdit );
824 };
@@ -24,7 +40,7 @@
2541 switch( eventType ){
2642 case 'copy':
2743 this.copyEvent = callback;
28 - break;
 44+ break;
2945 case 'cut':
3046 this.cutEvent = callback;
3147 break;
@@ -40,11 +56,11 @@
4157 }
4258 return this;
4359 },
44 - onInputFocus: function( ){
45 - _this.inputFocus = true;
 60+ onFocus: function( ){
 61+ this.inputFocus = true;
4662 },
47 - onInputBlur: function(){
48 - _this.inputFocus = false;
 63+ onBlur: function(){
 64+ this.inputFocus = false;
4965 },
5066 setupKeyBindigs: function(){
5167 var _this = this;
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTimeline.js
@@ -199,7 +199,9 @@
200200 },
201201 // calls the edit interface passing in the selected clip:
202202 editClip: function( selectedClip ){
203 -
 203+ // get the smil element for the edit tool:
 204+ var smilClip = this.sequenceEdit.getSmil().$dom.find('#' + $j( selectedClip ).data('smilId') );
 205+ this.sequenceEdit.getEditTools().drawClipEditTool(smilClip, 'trim');
204206 },
205207
206208 /**
@@ -217,12 +219,13 @@
218220 });
219221 // Invalidate / update embedPlayer duration:
220222 this.sequenceEdit.getEmbedPlayer().getDuration( true );
221 - }
 223+ }
222224 },
223225 /**
224226 * Remove selected clips and update the smil player
225227 */
226 - removeSelectedClips: function( ){
 228+ removeSelectedClips: function( ){
 229+ var smil = this.sequenceEdit.getSmil();
227230 // modify the smil.dom and rebuild
228231 this.getTimelineContainer().find( '.selectedClip' ).each(function( inx, selectedClip ){
229232 // Remove from smil dom:
@@ -452,11 +455,7 @@
453456 }
454457 return $j( sequenceNode ).data('id');
455458 }
456 -}
 459+}
457460
458461
459 -
460 -
461 -
462 -
463462 } )( window.mw );
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditPlayer.js
@@ -60,6 +60,22 @@
6161
6262 },
6363
 64+ previewSmilClip: function(){
 65+ // Set the borders to 'red' to indicate preview
 66+ this.sequenceEdit.getContainer().find( '.mwseq-player' )
 67+ .css('border', 'solid thin red');
 68+
 69+ // Get a special target of this subsmil node:
 70+
 71+ },
 72+
 73+ closePreivew: function(){
 74+ // restore border
 75+ this.sequenceEdit.getContainer().find( '.mwseq-player' )
 76+ .css({'border': null});
 77+ },
 78+
 79+
6480 resizePlayer: function(){
6581 mw.log("SequenceEditPlayer:: resizePlayer: " + $j('#' + this.getSmilPlayerId() ).length );
6682 $j('#' + this.getSmilPlayerId() ).get(0)
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEdit.js
@@ -68,8 +68,9 @@
6969 this[optionName] = mw_sequenceedit_default_options[ optionName ]
7070 }
7171 }
72 - // For style properties assgin top level mwe-sequence-edit class
73 - this.getContainer().addClass('mwe-sequence-edit');
 72+ // For style properties assign top level mwe-sequence-edit class
 73+ this.getContainer()
 74+ .addClass('mwe-sequence-edit');
7475 },
7576
7677 // Return the container id for the sequence
@@ -116,7 +117,7 @@
117118
118119 });
119120
120 - // Add deafult clip edit
 121+ // Add default clip edit
121122
122123 },
123124 getPlayer: function(){
@@ -135,17 +136,25 @@
136137 return this.smil;
137138 },
138139 getTimeline: function(){
139 - if( ! this.timeline ){
 140+ if( !this.timeline ){
140141 this.timeline = new mw.SequenceEditTimeline( this );
141142 }
142143 return this.timeline;
143144 },
 145+ getEditTools: function(){
 146+ if( !this.editTools ){
 147+ this.editTools = new mw.SequenceEditTools( this );
 148+ }
 149+ return this.editTools;
 150+ },
 151+
144152 getKeyBindings:function(){
145153 if( ! this.keyBindings ){
146154 this.keyBindings = new mw.SequenceEditKeyBindings( this );
147155 }
148156 return this.keyBindings;
149157 },
 158+
150159 // Apply the resizable layout bindings and default sizes
151160 applyLayoutBindings: function(){
152161 var _this = this;
@@ -200,7 +209,7 @@
201210 .append(
202211 $j('<div />')
203212 .addClass( "ui-layout-center mwseq-edit" )
204 - .text( gM('mwe-sequenceedit-loading_edit') ),
 213+ .html( this.getEditTools().defaultText ),
205214 $j('<div />')
206215 .addClass( "ui-layout-east mwseq-player" )
207216 .text( gM('mwe-sequenceedit-loading_player') ),
@@ -210,7 +219,9 @@
211220 )
212221 ).children();
213222 },
214 -
 223+ getEditToolTarget: function(){
 224+ return this.getContainer().find( '.mwseq-edit' );
 225+ },
215226 getContainer: function(){
216227 return $j( this.interfaceContainer );
217228 }
Index: branches/MwEmbedStandAlone/modules/SequenceEdit/mw.SequenceEditTools.js
@@ -0,0 +1,232 @@
 2+/**
 3+ * Handles the "tools" window top level component driver
 4+ */
 5+
 6+//Wrap in mw closure to avoid global leakage
 7+( function( mw ) {
 8+
 9+mw.SequenceEditTools = function( sequenceEdit ) {
 10+ return this.init( sequenceEdit );
 11+};
 12+
 13+// Set up the mvSequencer object
 14+mw.SequenceEditTools.prototype = {
 15+ init: function( sequenceEdit ){
 16+ this.sequenceEdit = sequenceEdit;
 17+ },
 18+ defaultText : gM('mwe-sequenceedit-no_selected_resource'),
 19+ tools:{
 20+ 'trim':{
 21+ 'title': gM('mwe-sequenceedit-trim-clip'),
 22+ 'editWidgets' : [ 'trimTimeline' ],
 23+ 'editableAttributes' : ['clipBegin','dur' ],
 24+ 'editActions' : ['preview', 'apply', 'cancel']
 25+ }
 26+ },
 27+ editableAttributes:{
 28+ 'clipBegin':{
 29+ 'type': 'time',
 30+ 'title' : gM('mwe-sequenceedit-start-time' ),
 31+ },
 32+ 'dur' :{
 33+ 'type': 'time',
 34+ 'title' : gM('mwe-sequenceedit-clip-duration' ),
 35+ }
 36+ },
 37+ editableTypes: {
 38+ 'time' : {
 39+ update : function( _this, smilClip, attributeName, value){
 40+ // Validate time
 41+ var seconds = _this.sequenceEdit.getSmil().parseTime( value );
 42+ $j( smilClip ).attr( attributeName, mw.seconds2npt( seconds ) )
 43+ },
 44+ getSmilVal : function( _this, smilClip, attributeName ){
 45+ var smil = _this.sequenceEdit.getSmil();
 46+ return mw.seconds2npt(
 47+ smil.parseTime(
 48+ $j( smilClip ).attr( attributeName )
 49+ )
 50+ );
 51+ }
 52+ }
 53+ },
 54+ editActions: {
 55+ 'preview' : {
 56+ 'icon' : 'play',
 57+ 'title' : gM('mwe-sequenceedit-preview'),
 58+ 'action': function( _this, smilClip, toolId){
 59+ //_this.sequenceEdit.getPlayer().previewClip( smilClip );
 60+ }
 61+ },
 62+ 'apply' :{
 63+ 'icon' : 'check',
 64+ 'title' : gM('mwe-sequenceedit-apply-changes'),
 65+ 'action': function( _this, smilClip, toolId){
 66+ mw.log( "editActions:: changes already applied" );
 67+ _this.sequenceEdit.getEditToolTarget().html(
 68+ _this.defaultText
 69+ )
 70+ }
 71+ },
 72+ 'cancel':{
 73+ 'icon': 'close',
 74+ 'title' : gM('mwe-cancel'),
 75+ 'action' : function( _this, smilClip, toolId){
 76+ var tool = _this.tools[toolId];
 77+ for( var i=0; i < tool.editableAttributes.length ; i++ ){
 78+ var attributeName = tool.editableAttributes[i];
 79+ var $editToolInput = $j('#' + _this.getEditToolId( toolId, attributeName ) );
 80+ // Restore all original attribute values
 81+ smilClip.attr( attributeName, $editToolInput.data('initialValue') );
 82+ // close / empty the toolWindow
 83+ }
 84+ _this.sequenceEdit.getEditToolTarget().html(
 85+ _this.defaultText
 86+ )
 87+ }
 88+ }
 89+ },
 90+ getEditToolId: function( toolId, attributeName){
 91+ return 'editTool_' + toolId + '_' + attributeName;
 92+ },
 93+ drawClipEditTool: function( smilClip, toolId ){
 94+ $target = this.sequenceEdit.getEditToolTarget();
 95+
 96+ // Make sure the toolid exists
 97+ if( !this.tools[ toolId ] ){
 98+ mw.log("Error: tool " + toolId + ' not found');
 99+ return ;
 100+ }
 101+ var tool = this.tools[ toolId ];
 102+ // Append the title:
 103+ $target.empty().append(
 104+ $j('<h3 />' ).append(
 105+ tool.title
 106+ )
 107+ );
 108+
 109+ // Build out widgets
 110+ //for( var i =0 ; i < tool.editWidgets.length ; i ++ ){
 111+ //}
 112+
 113+ // Build out the attritube list:
 114+ for( var i=0; i < tool.editableAttributes.length ; i++ ){
 115+ attributeName = tool.editableAttributes[i];
 116+ $target.append(
 117+ this.getEditableAttribute( smilClip, toolId, attributeName )
 118+ );
 119+ }
 120+ // output a float divider:
 121+ $target.append( $j('<div />').addClass('ui-helper-clearfix') );
 122+
 123+ // Build out edit Actions buttons
 124+ for( var i=0; i < tool.editActions.length ; i++){
 125+ var editActionId = tool.editActions[i];
 126+ $target.append(
 127+ this.getEditAction( smilClip, toolId, editActionId )
 128+ )
 129+ }
 130+ },
 131+ getEditAction: function( smilClip, toolId, editActionId ){
 132+
 133+ if(! this.editActions[ editActionId ]){
 134+ mw.log("Error: getEditAction: " + editActionId + ' not found ');
 135+ return ;
 136+ }
 137+ var _this = this;
 138+ var editAction = this.editActions[ editActionId ];
 139+ $actionButton = $j.button({
 140+ icon_id: editAction.icon,
 141+ text: editAction.title
 142+ })
 143+ .css({
 144+ 'float': 'left',
 145+ 'margin': '5px'
 146+ })
 147+ .buttonHover()
 148+ .click( function(){
 149+ editAction.action( _this, smilClip, toolId );
 150+ })
 151+ return $actionButton;
 152+ },
 153+ getEditableAttribute: function( smilClip, toolId, attributeName ){
 154+ if( ! this.editableAttributes[ attributeName ] ){
 155+ mw.log("Error: editableAttributes : " + attributeName + ' not found');
 156+ return;
 157+ }
 158+ var _this = this;
 159+ var editAttribute = this.editableAttributes[ attributeName ];
 160+ var editType = editAttribute.type;
 161+
 162+ var initialValue = _this.editableTypes[ editType ].getSmilVal(
 163+ _this,
 164+ smilClip,
 165+ attributeName
 166+ );
 167+ return $j( '<div />' )
 168+ .css({
 169+ 'float': 'left',
 170+ 'width': '150px',
 171+ 'border': 'solid thin #999',
 172+ 'background-color': '#EEE',
 173+ 'padding' : '2px',
 174+ 'margin' : '5px'
 175+ })
 176+ .append(
 177+ $j('<span />')
 178+ .css('margin', '5px')
 179+ .text( editAttribute.title ),
 180+
 181+ $j('<input />')
 182+ .attr( {
 183+ 'id' : _this.getEditToolId( toolId, attributeName),
 184+ 'size': 5
 185+ })
 186+ .data('initialValue', initialValue )
 187+ .sequenceEditInput( _this.sequenceEdit )
 188+ .val( initialValue )
 189+ .change(function(){
 190+ // Run the editableType update function:
 191+ _this.editableTypes[ editType ].update(
 192+ _this,
 193+ smilClip,
 194+ attributeName,
 195+ $j( this ).val()
 196+ );
 197+ })
 198+ );
 199+ },
 200+
 201+ /*drawTrimClipTool: function( clipNode ){
 202+ $target = this.sequenceEdit.getToolTarget();
 203+ $target.empty().append(
 204+ $j('<div />')
 205+ .addClass("toolTarget")
 206+ .append(
 207+ $j('<h3 />').text(
 208+
 209+ ),
 210+ // Width of the container images thumbs set-in-out
 211+
 212+ $j('<div />')
 213+ .addClass("ui-helper-clearfix"),
 214+ // Start time and end time text:
 215+ $j( '<div />' )
 216+ .css({
 217+ 'float': 'left',
 218+ 'width': '200px',
 219+ 'background-color': '#AAA'
 220+ })
 221+ .append(
 222+ $j('<span />')
 223+ .text( gM('mwe-sequenceedit-start-time') ),
 224+ $j('<input />')
 225+ .attr('size', 5)
 226+ )
 227+ )
 228+ )
 229+ )
 230+ }*/
 231+}
 232+
 233+} )( window.mw );
\ No newline at end of file

Status & tagging log