1 /*the sequence remote search driver
2 extends the base remote search driver with sequence specific stuff. could seperate this out into seperate lib.
5 var seqRemoteSearchDriver = function(iObj){
6 return this.init( iObj )
8 seqRemoteSearchDriver.prototype = {
9 sequence_add_target:false,
10 init:function( this_seq ){
12 js_log("init:seqRemoteSearchDriver");
13 //setup remote search driver with a seq parent:
16 'target_container' : '#cliplib_ic',
17 'local_wiki_api_url': this_seq.getLocalApiUrl(),
18 'instance_name' : this_seq.instance_name + '.mySearch',
19 'default_query' : this.pSeq.plObj.title
21 //inherit the remoteSearchDriver properties:n
22 var tmpRSD = new remoteSearchDriver( iObj );
25 this['parent_'+i] = tmpRSD[i];
30 //extend parent_do_refresh_timeline actions:
31 if(!this.pSeq.parent_do_refresh_timeline){
32 this.pSeq.parent_do_refresh_timeline = this.pSeq.do_refresh_timeline;
33 this.pSeq.do_refresh_timeline = function(){
34 js_log("seqRemoteSearchDriver::" + _this.pSeq.disp_menu_item);
36 _this.pSeq.parent_do_refresh_timeline();
37 //add our local bindings
38 _this.addResultBindings();
43 resourceEdit:function(){
47 addResultBindings:function(){
50 //setup parent bindings:
51 this.parent_addResultBindings();
53 //add an aditional click binding
54 $j('.rsd_res_item').click(function(){
55 js_log('SeqRemoteSearch: rsd_res_item: click (remove sequence_add_target)');
56 _this.sequence_add_target =false;
59 //add an additional drag binding
60 $j( '.rsd_res_item' ).draggable('destroy').draggable({
62 return $j( this ).clone().appendTo('body').css({'z-index':9999}).get(0);
69 $j(".mv_clip_drag").droppable( 'destroy' ).droppable({
70 accept: '.rsd_res_item',
71 over:function(event, ui){
72 //js_log("over : mv_clip_drag: " + $j(this).attr('id') );
73 $j(this).css('border-right', 'solid thick red');
75 out:function(event, ui){
76 $j(this).css('border-right', 'solid thin white');
78 drop: function(event, ui) {
79 $j(this).css('border-right', 'solid thin white');
80 js_log("Droped: "+ $j(ui.draggable).attr('id') +' on ' + $j(this).attr('id') );
81 _this.sequence_add_target = $j(this).attr('id');
82 //load the orginal draged item
83 var rObj = _this.getResourceFromId( $j(ui.draggable).attr('id') );
84 _this.resourceEdit(rObj, ui.draggable);
89 insertResource:function(rObj){
91 js_log("SEQ insert resource after:" + _this.sequence_add_target + ' of type: ' + rObj.mime);
92 if(_this.sequence_add_target ){
93 var tClip = _this.pSeq.getClipFromSeqID( _this.sequence_add_target );
94 var target_order = false;
96 var target_order = tClip.order;
98 //@@todo show watting of sorts.
102 //check for target insert path
103 this.checkImportResource( rObj, function(){
107 'uri' : _this.cFileNS + ':' + rObj.target_resource_title,
110 //set via local properites if avaliable
111 clipConfig['src'] = (rObj.local_src) ? rObj.local_src : rObj.src;
112 clipConfig['poster'] = ( rObj.local_poster ) ? rObj.local_poster : rObj.poster;
114 if(rObj.start_time && rObj.end_time){
115 clipConfig['dur'] = npt2seconds( rObj.end_time ) - npt2seconds( rObj.start_time );
117 //provide a default duration if none set
118 clipConfig['dur'] = 4;
121 //create the media element (target order+1 (since we insert (after)
122 _this.pSeq.plObj.tryAddMediaObj( clipConfig, (parseInt(target_order) + 1) );
123 //refresh the timeline:
124 _this.pSeq.do_refresh_timeline();
125 js_log("run close all: ");
129 getClipEditControlActions:function(){
132 'insert_seq':function(rObj){
133 _this.insertResource( rObj )
135 'cancel':function(rObj){
136 _this.cancelClipEditCB( rObj )
140 resourceEdit:function(rObj, rsdElement){
142 //don't resize to default (full screen behavior)
143 _this.dmodalCss = {};
144 //open up a new target_contaienr:
145 if($j('#seq_resource_import').length == 0)
146 $j('body').append('<div id="seq_resource_import" style="position:relative"></div>');
148 $j('#seq_resource_import').dialog('destroy').dialog({
154 "Cancel": function() {
155 $j(this).dialog("close");
159 _this.target_container = '#seq_resource_import';
160 //do parent resource edit (with updated target)
161 this.parent_resourceEdit(rObj, rsdElement);
164 js_log( 'should close: seq_resource_import');
165 $j('#seq_resource_import').dialog('close').dialog('destroy').remove();
166 this.parent_closeAll();
168 getEditToken:function(callback){
169 if(this.pSeq.sequenceEditToken){
170 callback( this.pSeq.sequenceEditToken )
172 this.parent_getEditToken(callback);
175 cancelClipEditCB:function(){
176 js_log('seqRSD:cancelClipEditCB');
177 $j('#seq_resource_import').dialog('close').dialog('destroy').remove();