r54614 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54613‎ | r54614 | r54615 >
Date:22:59, 7 August 2009
Author:dale
Status:deferred
Tags:
Comment:
* sequence fixes for adding new media ( was adding new clips with generic playback library instead of type based playback lib clips)
* fixed bug where drag and drop of clips did not work where you re-arranged clips while not displaying the add-media-wizard tab
* fixed display of sequence playhead on clip click
* added deselect of clips on escape
* Other minor code cleanup
Modified paths:
  • /trunk/phase3/js2/editPage.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libSequencer/mvSequencer.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/seqRemoteSearchDriver.js
@@ -34,10 +34,8 @@
3535 js_log("seqRemoteSearchDriver::" + _this.pSeq.disp_menu_item);
3636 //call the parent
3737 _this.pSeq.parent_do_refresh_timeline();
38 - //add our local bindings if our window is 'active'
39 - if(_this.pSeq.disp_menu_item == 'cliplib'){
40 - _this.addResultBindings();
41 - }
 38+ //add our local bindings
 39+ _this.addResultBindings();
4240 return true;
4341 }
4442 }
@@ -121,7 +119,7 @@
122120 }
123121
124122 //create the media element (target order+1 (since we insert (after)
125 - _this.pSeq.plObj.tryAddMediaObj( clipConfig, (parseInt(target_order) + 1) );
 123+ _this.pSeq.plObj.tryAddMediaObj( clipConfig, (parseInt(target_order) + 1) );
126124 //refresh the timeline:
127125 _this.pSeq.do_refresh_timeline();
128126 js_log("run close all: ");
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -541,12 +541,10 @@
542542 setStatus:function(value){
543543 $j('#mv_time_'+this.id).html( value );
544544 },
545 - setSliderValue:function(value){
546 - if( this.controls ){
547 - //slider is on 1000 scale:
548 - var val = parseInt( value *1000 );
549 - $j('#mv_play_head_' + this.id).slider('value', val);
550 - }
 545+ setSliderValue:function(value){
 546+ //slider is on 1000 scale:
 547+ var val = parseInt( value *1000 );
 548+ $j('#mv_play_head_' + this.id).slider('value', val);
551549 },
552550 getPlayHeadPos: function(prec_done){
553551 var _this = this;
@@ -648,10 +646,12 @@
649647 this.cur_clip.embed.stop();
650648 },
651649 updateCurrentClip:function( new_clip ){
652 - js_log('f:updateCurrentClip:'+new_clip.id);
 650+ js_log('f:updateCurrentClip:'+new_clip.id);
653651 //make sure we are not switching to the current
654 - if( this.cur_clip.id == new_clip.id )
655 - return js_log('trying to updateCurrentClip to same clip');
 652+ if( this.cur_clip.id == new_clip.id ){
 653+ js_log('trying to updateCurrentClip to same clip');
 654+ return false;
 655+ }
656656
657657 //keep the active play clip in sync (stop the other clip)
658658 if( this.cur_clip ){
@@ -1099,8 +1099,7 @@
11001100 //setup the embed object:
11011101 setUpEmbedObj:function(){
11021102 js_log('mvClip:setUpEmbedObj()');
1103 - //init:
1104 - //debugger;
 1103+ //init:
11051104
11061105
11071106 this.embed=null;
@@ -1111,8 +1110,8 @@
11121111 src:this.src
11131112 };
11141113
1115 - this.setBaseEmbedDim(init_pl_embed);
1116 - //always display controls for playlists:
 1114+ this.setBaseEmbedDim( init_pl_embed );
 1115+
11171116
11181117 //if in sequence mode hide controls / embed links
11191118 // init_pl_embed.play_button=false;
@@ -1124,9 +1123,9 @@
11251124 if(this.poster)init_pl_embed['thumbnail']=this.poster;
11261125
11271126 if( this.type )init_pl_embed['type'] = this.type;
1128 -
1129 - this.embed = new PlMvEmbed( init_pl_embed );
11301127
 1128+ this.embed = new PlMvEmbed( init_pl_embed );
 1129+
11311130 //js_log('media Duration:' + this.embed.getDuration() );
11321131 //js_log('media element:'+ this.embed.media_element.length);
11331132 //js_log('type of embed:' + typeof(this.embed) + ' seq:' + this.pp.sequencer+' pb:'+ this.embed.play_button);
@@ -1299,12 +1298,12 @@
13001299
13011300 var th=Math.round( _this.pl_layout.clip_desc * _this.height );
13021301 var tw=Math.round( th * _this.pl_layout.clip_aspect );
 1302+
13031303 //run the parent stop:
13041304 this.pe_stop();
13051305 var pl_height = (_this.sequencer=='true')?_this.height+27:_this.height;
13061306
13071307 this.getHTML();
1308 -
13091308 },
13101309 play:function(){
13111310 //js_log('pl eb play');
@@ -1328,8 +1327,8 @@
13291328 //setup hover images (for playhead and next/prev buttons)
13301329 this.pc.pp.setUpHover();
13311330 //call the parent postEmbedJS
1332 - this.pe_postEmbedJS();
1333 - mv_lock_vid_updates=false;
 1331+ this.pe_postEmbedJS();
 1332+ mv_lock_vid_updates=false;
13341333 },
13351334 getPlayButton:function(){
13361335 return this.pe_getPlayButton(this.pc.pp.id);
@@ -1338,6 +1337,7 @@
13391338 //status updates handled by playlist obj
13401339 },
13411340 setSliderValue:function(value){
 1341+ js_log('PlMvEmbed:setSliderValue:' + value);
13421342 //setSlider value handled by playlist obj
13431343 }
13441344 }
@@ -1353,8 +1353,8 @@
13541354 //js_log('data:'+ this.data.toString());
13551355 $j.each(this.data.split("\n"), function(i,n){
13561356 //js_log('on line '+i+' val:'+n+' len:'+n.length);
1357 - if(n.charAt(0)!='#'){
1358 - if(n.length>3){
 1357+ if( n.charAt(0) != '#' ){
 1358+ if( n.length > 3 ){
13591359 //@@todo make sure its a valid url
13601360 //js_log('add url: '+i + ' '+ n);
13611361 var cur_clip = new mvClip({type:'srcClip',id:'p_'+this_pl.id+'_c_'+inx,pp:this_pl,src:n,order:inx});
@@ -1883,9 +1883,9 @@
18841884 'title':'',
18851885 'interface_url':"",
18861886 'linkback':"",
1887 - 'mTitle':"",
1888 - 'mTalk':"",
1889 - 'mTouchedTime':""
 1887+ 'mTitle':"",
 1888+ 'mTalk':"",
 1889+ 'mTouchedTime':""
18901890 };
18911891 $j.each(meta_tags, function(i,meta_elm){
18921892 //js_log( "on META tag: "+ $j(meta_elm).attr('name') );
@@ -1926,13 +1926,14 @@
19271927 js_log("done proc seq tags");
19281928 return true;
19291929 },
1930 - tryAddMediaObj:function(mConfig, order, track_id){
1931 - var mediaElement = document.createElement('ref');
 1930+ tryAddMediaObj:function(mConfig, order, track_id){
 1931+ js_log('tryAddMediaObj::');
 1932+ var mediaElement = document.createElement('div');
19321933 for(var i =0; i < mv_smil_ref_supported_attributes.length;i++){
19331934 var attr = mv_smil_ref_supported_attributes[i];
19341935 if(mConfig[attr])
1935 - $j(mediaElement).attr(attr, mConfig[attr]);
1936 - }
 1936+ $j(mediaElement).attr( attr, mConfig[attr] );
 1937+ }
19371938 this.tryAddMedia(mediaElement, order, track_id);
19381939 },
19391940 tryAddMedia:function(mediaElement, order, track_id){
@@ -1944,21 +1945,24 @@
19451946 "id":'p_' + _this.id + '_c_' + order,
19461947 "pp":this, //set the parent playlist object pointer
19471948 "order": order
1948 - };
 1949+ };
19491950 var clipObj = new mvSMILClip(mediaElement, cConfig );
19501951
19511952 //set optional params track
19521953 if( typeof track_id != 'undefined')
19531954 clipObj["track_id"] = track_id;
19541955
1955 - //debugger;
 1956+
19561957 if ( clipObj ){
19571958 //set up embed:
1958 - clipObj.setUpEmbedObj();
 1959+ clipObj.setUpEmbedObj();
 1960+ //inhreit embedObject (only called on "new media"
 1961+ clipObj.embed.init_with_sources_loaded();
19591962 //add clip to track:
19601963 this.addCliptoTrack( clipObj , order);
 1964+
19611965 return true;
1962 - }
 1966+ }
19631967 //@@todo we could throw error details here once we integrate try catches everywhere :P
19641968 return false;
19651969 }
@@ -1992,8 +1996,7 @@
19931997 _this = this;
19941998 this.params = {};
19951999 //make new mvCLip with ClipInit vals
1996 - var myMvClip = new mvClip( mvClipInit );
1997 -
 2000+ var myMvClip = new mvClip( mvClipInit );
19982001 //inherit mvClip
19992002 for(var method in myMvClip){
20002003 if(typeof this[method] != 'undefined' ){
@@ -2095,7 +2098,8 @@
20962099 * http://www.w3.org/TR/SMIL3/smil-timing.html#Timing-ClockValueSyntax
20972100 * (probably have to use a Time object to fully support the smil spec
20982101 */
2099 -function smilParseTime(time_str){
 2102+function smilParseTime( time_str ){
 2103+ time_str = time_str + '';
21002104 //first check for hh:mm:ss time:
21012105 if(time_str.split(':').length == 3){
21022106 return npt2seconds(time_str);
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvSequencer.js
@@ -620,9 +620,14 @@
621621 if( e.which == 16 )
622622 _this.key_shift_down = false;
623623
624 - if( e.which == 17)
 624+ if( e.which == 17 )
625625 _this.key_ctrl_down = false;
626626
 627+ //escape key (for now deselect)
 628+ if( e.which == 27 )
 629+ _this.deselectClip();
 630+
 631+
627632 //backspace or delete key while not focused on a text area:
628633 if( (e.which == 8 || e.which == 46) && !_this.inputFocus)
629634 _this.removeSelectedClips();
@@ -1331,10 +1336,14 @@
13321337 return insert_key;
13331338 },
13341339 deselectClip:function( clipElm ){
1335 - $j(clipElm).removeClass("mv_selected_clip");
1336 - //make sure the transition sibling is removed:
1337 - $j(clipElm).siblings('.clip_trans_box').removeClass( 'mv_selected_transition' );
1338 - $j('#' + $j(clipElm).parent().attr("id") + '_adj').fadeOut("fast");
 1340+ if(!clipElm){
 1341+ $j('.mv_selected_clip').removeClass("mv_selected_clip");
 1342+ }else{
 1343+ $j(clipElm).removeClass("mv_selected_clip");
 1344+ //make sure the transition sibling is removed:
 1345+ $j(clipElm).siblings('.clip_trans_box').removeClass( 'mv_selected_transition' );
 1346+ $j('#' + $j(clipElm).parent().attr("id") + '_adj').fadeOut("fast");
 1347+ }
13391348 },
13401349 getClipFromSeqID:function( clip_seq_id ){
13411350 js_log('get id from: ' + clip_seq_id);
@@ -1512,20 +1521,23 @@
15131522 mvSeqPlayList.prototype = {
15141523 init:function(element){
15151524 var myPlObj = new mvPlayList(element);
 1525+
15161526 //inherit mvClip
15171527 for(var method in myPlObj){
15181528 if(typeof this[method] != 'undefined' ){
1519 - this['parent_'+method]=myPlObj[method];
 1529+ this[ 'parent_' + method ]=myPlObj[method];
15201530 }else{
15211531 this[method] = myPlObj[method];
15221532 }
15231533 }
 1534+
15241535 this.org_control_height = this.pl_layout.control_height;
15251536 //do specific mods:(controls and title are managed by the sequencer)
15261537 this.pl_layout.title_bar_height=0;
15271538 this.pl_layout.control_height=0;
15281539 },
15291540 setSliderValue:function( perc ){
 1541+ js_log('setSliderValue::'+ perc);
15301542 //get the track_clipThumb_height from parent mvSequencer
15311543 var frame_width = Math.round( this.pSeq.track_clipThumb_height * 1.3333333 );
15321544 var container_width = frame_width+60;
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js
@@ -225,15 +225,17 @@
226226 }
227227 ///js_log('did vI style');
228228 //now swap out the video element for the embed_video obj:
229 - $j(video_element).after(embed_video).remove();
230 - //js_log('did swap');
231 - $j('#'+embed_video.id).get(0).on_dom_swap();
 229+ $j(video_element).after(embed_video).remove();
 230+ //js_log('did swap');
 231+ $j('#'+embed_video.id).get(0).on_dom_swap();
 232+
232233 // now that "embed_video" is stable, do more initialization (if we are ready)
233234 if($j('#'+embed_video.id).get(0).loading_external_data==false &&
234235 $j('#'+embed_video.id).get(0).init_with_sources_loadedDone==false){
235236 //load and set ready state since source are available:
236237 $j('#'+embed_video.id).get(0).init_with_sources_loaded();
237 - }
 238+ }
 239+
238240 js_log('done with child: ' + embed_video.id + ' len:' + global_player_list.length);
239241 return true;
240242 },
@@ -1185,7 +1187,7 @@
11861188 js_log('set loading_external_data=false');
11871189 _this.loading_external_data=false;
11881190
1189 - _this.init_with_sources_loaded();
 1191+ _this.init_with_sources_loaded();
11901192 });
11911193 }
11921194 },
@@ -1222,7 +1224,7 @@
12231225 var missing_type ='';
12241226 var or ='';
12251227 for( var i=0; i < this.media_element.sources.length; i++){
1226 - missing_type+=or + this.media_element.sources[i].mime_type;
 1228+ missing_type+= or + this.media_element.sources[i].mime_type;
12271229 or=' or ';
12281230 }
12291231 if( this.pc )
@@ -1231,7 +1233,7 @@
12321234 this.load_error= this.getPluginMissingHTML(missing_type);
12331235 }
12341236 },
1235 - inheritEmbedObj:function(){
 1237+ inheritEmbedObj:function(){
12361238 js_log("inheritEmbedObj:duration is: " + this.duration);
12371239 //@@note: tricky cuz direct overwrite is not so ideal.. since the extended object is already tied to the dom
12381240 //clear out any non-base embedObj stuff:
@@ -1651,24 +1653,24 @@
16521654 },
16531655 getHTML : function (){
16541656 //@@todo check if we have sources avaliable
1655 - js_log('embedVideo:getHTML : ' + this.id );
 1657+ js_log('embedVideo:getHTML : ' + this.id + ' resource type: ' + this.type);
16561658 var _this = this;
16571659 var html_code = '';
16581660 html_code = '<div id="videoPlayer_'+this.id+'" style="width:'+this.width+'px;" class="videoPlayer">';
1659 - html_code += '<div style="width:'+parseInt(this.width)+'px;height:'+parseInt(this.height)+'px;" id="mv_embedded_player_'+this.id+'">' +
1660 - this.getThumbnailHTML() +
1661 - '</div>';
1662 - //js_log("mvEmbed:controls "+ typeof this.controls);
1663 - if(this.controls)
1664 - {
1665 - js_log("f:getHTML:AddControls");
1666 - html_code +='<div id="mv_embedded_controls_' + this.id + '" class="ui-widget ui-corner-bottom ui-state-default controls" >';
1667 - html_code += this.getControlsHTML();
1668 - html_code +='</div>';
1669 - //block out some space by encapulating the top level div
1670 - $j(this).wrap('<div style="width:'+parseInt(this.width)+'px;height:'
1671 - +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>');
1672 - }
 1661+ html_code += '<div style="width:'+parseInt(this.width)+'px;height:'+parseInt(this.height)+'px;" id="mv_embedded_player_'+this.id+'">' +
 1662+ this.getThumbnailHTML() +
 1663+ '</div>';
 1664+ //js_log("mvEmbed:controls "+ typeof this.controls);
 1665+ if(this.controls)
 1666+ {
 1667+ js_log("f:getHTML:AddControls");
 1668+ html_code +='<div id="mv_embedded_controls_' + this.id + '" class="ui-widget ui-corner-bottom ui-state-default controls" >';
 1669+ html_code += this.getControlsHTML();
 1670+ html_code +='</div>';
 1671+ //block out some space by encapulating the top level div
 1672+ $j(this).wrap('<div style="width:'+parseInt(this.width)+'px;height:'
 1673+ +(parseInt(this.height)+ctrlBuilder.height)+'px"></div>');
 1674+ }
16731675 html_code += '</div>'; //videoPlayer div close
16741676 //js_log('should set: '+this.id);
16751677 $j(this).html( html_code );
@@ -2129,7 +2131,7 @@
21302132 + source.getTitle()+'</a> '+ '</li>'+"\n";
21312133 if( source.getURI().indexOf('?t=')!==-1){
21322134 out+=dl_line;
2133 - }else if(this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt"){
 2135+ }else if( this.getMIMEType()=="text/cmml" || this.getMIMEType()=="text/x-srt" ){
21342136 dl_txt_list+=dl_line;
21352137 }else{
21362138 dl_list+=dl_line;
@@ -2186,7 +2188,7 @@
21872189 },
21882190 /*
21892191 * base embed pause
2190 - * there is no general way to pause the video
 2192+ * there is no general way to pause the video
21912193 * must be overwritten by embed object to support this functionality.
21922194 */
21932195 pause: function(){
Index: trunk/phase3/js2/editPage.js
@@ -24,12 +24,16 @@
2525 init:function(){
2626 var _this = this;
2727 //@@todo check for new version of toolbar and via toolbar api:
28 - if(typeof $j.fn.toolbar == 'undefined'){
29 - //add the add-media-wizard button for old toolbar:
30 - $j('#toolbar').append('<img style="cursor:pointer" id="btn-add-media-wiz" src="' + mv_skin_img_path + 'Button_add_media.png">');
31 - $j('#btn-add-media-wiz').addMediaWiz(
32 - mwAddMediaConfig
33 - );
34 - }
 28+
 29+ //add the add-media-wizard button for old toolbar:
 30+ $j('#toolbar').append('<img style="cursor:pointer" id="btn-add-media-wiz" src="' + mv_skin_img_path + 'Button_add_media.png">');
 31+ $j('#btn-add-media-wiz').addMediaWiz(
 32+ mwAddMediaConfig
 33+ );
 34+
 35+ //add to new toolbar (need to use api)
 36+ //$j('[rel=insert] .tool-file').addMediaWiz(
 37+ // mwAddMediaConfig
 38+ //);
3539 }
3640 }

Status & tagging log