4 * for now just simple single stack transition control
10 "mwe-transition_in" : "Transition in",
11 "mwe-transition_out" : "Transition out",
12 "mwe-effects" : "Effects stack",
13 "mwe-remove_transition" : "Remove transition",
14 "mwe-edit_transin" : "Edit transition into clip",
15 "mwe-edit_transout" : "Edit transition out of clip",
16 "mwe-add-transition" : "Add a transition"
19 var default_timed_effect_values
= {
20 'rObj': null, // the resource object
21 'clip_disp_ct':null, // target clip disp
22 'control_ct':null, // control container
24 'parent_ct': null, // parent container
25 'pSeq': null, // parent sequence Object
27 'edit_action': null, // the requested edit action
30 var mvTimedEffectsEdit = function( iObj
) {
31 return this.init( iObj
);
33 // set up the mvSequencer object
34 mvTimedEffectsEdit
.prototype = {
35 // the menu_items Object contains: default html, js setup/loader functions
38 'title':gM( 'mwe-transition_in' ),
39 'clip_attr':'transIn',
40 'doEdit':function( _this
) {
41 _this
.doTransitionDisplayEdit( 'transin' );
45 'title':gM( 'mwe-transition_out' ),
46 'clip_attr':'transOut',
47 'doEdit':function( _this
) {
48 _this
.doTransitionDisplayEdit( 'transout' );
52 'title':gM( 'mwe-effects' ),
53 'clip_attr':'Effects',
54 'doEdit':function( _this
) {
56 _this
.doEditEffectDisplayEdit();
60 init:function( iObj
) {
62 for ( var i
in default_timed_effect_values
) {
69 doEditMenu:function() {
70 js_log( 'mvTimedEffects : doEditMenu::' );
72 // add in subMenus if set
73 // check for submenu and add to item container
75 // update the default edit display (if we have a target)
76 var tTarget
= 'transin';
77 if ( this.rObj
.transOut
)
79 if ( this.rObj
.effects
)
84 o
+= '<div id="mv_submenu_timedeffect">';
88 $j
.each( this.menu_items
, function( sInx
, mItem
) {
89 if ( sInx
== tTarget
) {
92 // check if the given editType is valid for our given media type
94 '<a id="mv_te_' + sInx
+ '" href="#te_' + sInx
+ '">' + mItem
.title
+ '</a>' +
96 tabc
+= '<div id="te_' + sInx
+ '" style="overflow:auto;" ></div>';
101 // add sub menu container with menu html:
102 $j( '#' + this.control_ct
).html( o
) ;
103 js_log( 'should have set: #' + this.control_ct
+ ' to: ' + o
);
105 $j( '#mv_submenu_timedeffect' ).tabs( {
106 selected
: selected_tab
,
107 select: function( event
, ui
) {
108 _this
.doDisplayEdit( $j( ui
.tab
).attr( 'id' ).replace( 'mv_te_', '' ) );
110 } ).addClass( 'ui-tabs-vertical ui-helper-clearfix' );
112 $j( "#mv_submenu_clipedit li" ).removeClass( 'ui-corner-top' ).addClass( 'ui-corner-left' );
113 _this
.doDisplayEdit( tTarget
);
115 doDisplayEdit:function( tab_id
) {
116 // @@todo fix the double display of doDisplayEdit
117 js_log( "doDisplayEdit::" );
118 if ( !this.menu_items
[ tab_id
] ) {
119 js_log( 'error: doDisplayEdit missing item:' + tab_id
);
121 // use the menu_item config to map to function display
122 this.menu_items
[tab_id
].doEdit( this );
125 doEditEffectDisplayEdit:function() {
127 var appendTarget
= '#te_effects';
128 js_log( 'type:' + _this
.rObj
['type'] );
129 $j( appendTarget
).html( gM( 'mwe-loading_txt' ) );
130 // @@todo integrate into core and loading system:
131 loadExternalJs( mv_embed_path
+ 'libClipEdit/pixastic-editor/editor.js?' + getMwReqParam() );
132 loadExternalJs( mv_embed_path
+ 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
133 loadExternalJs( mv_embed_path
+ 'libClipEdit/pixastic-editor/ui.js?' + getMwReqParam() );
134 loadExternalJs( mv_embed_path
+ 'libClipEdit/pixastic-editor/uidata.js?' + getMwReqParam() );
135 loadExternalCss( mv_embed_path
+ 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
137 var isPixasticReady = function() {
138 if ( typeof PixasticEditor
!= 'undefined' ) {
139 $j( appendTarget
).html( '<a href="#" class="run_effect_demo">Run Pixastic Editor Demo</a> (not yet fully integrated/ super alpha)<br> best to view <a href="http://www.pixastic.com/editor-test/">stand alone</a>' );
140 $j( appendTarget
+ ' .run_effect_demo' ).click( function() {
142 var imgElm
= $j( '.clip_container:visible img' ).get( 0 );
143 PixasticEditor
.load( imgElm
);
146 setTimeout( isPixasticReady
, 100 )
151 doTransitionDisplayEdit:function( target_item
) {
153 js_log( "doTransitionDisplayEdit: " + target_item
);
154 var apendTarget
= '#te_' + target_item
;
155 // check if we have a transition of type clip_attr
156 if ( !this.rObj
[ this.menu_items
[ target_item
].clip_attr
] ) {
157 // empty append the transition list:
158 this.getTransitionListControl( apendTarget
);
161 var cTran
= this.rObj
[ this.menu_items
[ target_item
].clip_attr
];
162 var o
= '<h3>' + gM( 'mwe-edit_' + target_item
) + '</h3>';
164 '<select class="te_select_type">';
165 for ( var typeKey
in mvTransLib
.type
) {
166 var selAttr
= ( cTran
.type
== typeKey
) ? ' selected':'';
167 o
+= '<option value="' + typeKey
+ '"' + selAttr
+ '>' + typeKey
+ '</option>';
169 o
+= '</select><br>';
170 o
+= '<span class="te_subtype_container"></span>';
172 // add html and select bindings
173 $j( apendTarget
).html( o
).children( '.te_select_type' )
174 .change( function() {
175 var selectedType
= $j( this ).val();
176 // update subtype listing:
177 _this
.getSubTypeControl( target_item
, selectedType
, apendTarget
+ ' .te_subtype_container' );
179 // add subtype control
180 _this
.getSubTypeControl( target_item
, cTran
.type
, apendTarget
+ ' .te_subtype_container' );
182 // add remove transition button:
183 $j( apendTarget
).append( '<br><br>' + $j
.btnHtml( gM( 'mwe-remove_transition' ), 'te_remove_transition', 'close' ) )
184 .children( '.te_remove_transition' )
186 // remove the transtion from the playlist
187 _this
.pSeq
.plObj
.transitions
[cTran
.id
] = null;
188 // remove the transtion from the clip:
189 _this
.rObj
[ _this
.menu_items
[ target_item
].clip_attr
] = null;
190 // update the interface:
191 _this
.doTransitionDisplayEdit( target_item
);
192 // update the sequence
193 _this
.pSeq
.do_refresh_timeline();
196 getSubTypeControl:function( target_item
, transition_type
, htmlTarget
) {
198 var cTran
= this.rObj
[ this.menu_items
[ target_item
].clip_attr
];
199 var o
= 'Sub Type:<select class="te_subtype_select">';
200 for ( var subTypeKey
in mvTransLib
.type
[ transition_type
] ) {
201 var selAttr
= ( cTran
.subtype
== subTypeKey
) ? ' selected' : '';
202 o
+= '<option value="' + subTypeKey
+ '"' + selAttr
+ '>' + subTypeKey
+ '</option>';
204 o
+= '</select><br>';
205 $j( htmlTarget
).html( o
)
206 .children( '.te_subtype_select' )
207 .change( function() {
208 // update the property
209 cTran
.subtype
= $j( this ).val();
210 // re-gen timeline / playlist
211 _this
.pSeq
.do_refresh_timeline();
213 _this
.getSubTypeControl( target_item
, transition_type
, htmlTarget
);
216 // check for extra properties control:
217 for ( var i
= 0; i
< mvTransLib
.type
[ transition_type
][ cTran
.subtype
].attr
.length
; i
++ ) {
218 var tAttr
= mvTransLib
.type
[ transition_type
][ cTran
.subtype
].attr
[i
]
221 var cColor
= ( cTran
['fadeColor'] ) ? cTran
['fadeColor']:'';
222 $j( htmlTarget
).append( 'Select Color: <div class="colorSelector"><div class="colorIndicator" style="background-color: ' + cColor
+ '"></div></div>' );
223 js_log( 'cs target: ' + htmlTarget
+ ' .colorSelector' );
226 $j( htmlTarget
+ ' .colorSelector' ).ColorPicker( {
228 onShow: function ( colpkr
) {
229 // make sure its ontop:
230 $j( colpkr
).css( "zIndex", "12" );
231 $j( colpkr
).fadeIn( 500 );
234 onHide: function ( colpkr
) {
235 $j( colpkr
).fadeOut( 500 );
236 _this
.pSeq
.plObj
.setCurrentTime( 0, function() {
237 js_log( "render ready" );
241 onChange: function ( hsb
, hex
, rgb
) {
242 $j( htmlTarget
+ ' .colorIndicator' ).css( 'backgroundColor', '#' + hex
);
243 // update the transition
244 cTran
['fadeColor'] = '#' + hex
;
250 // and finally add effect timeline scruber (for timed effects this also stores keyframes)
253 getTransitionListControl : function( target_out
) {
254 js_log( "getTransitionListControl" );
255 var o
= '<h3>' + gM( 'mwe-add-transition' ) + '</h3>';
256 for ( var type
in mvTransLib
['type'] ) {
257 js_log( 'on tran type: ' + i
);
258 var base_trans_name
= i
;
259 var tLibSet
= mvTransLib
['type'][ type
];
260 for ( var subtype
in tLibSet
) {
261 o
+= '<img style="float:left;padding:10px;" ' +
262 'src="' + mvTransLib
.getTransitionIcon( type
, subtype
) + '">';
265 $j( target_out
).html( o
);