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("seqRs refresh chain::" + _this
.pSeq
.disp_menu_item
);
36 _this
.pSeq
.parent_do_refresh_timeline();
37 //add our local bindings if our window is 'active'
38 if(_this
.pSeq
.disp_menu_item
== 'cliplib'){
39 _this
.addResultBindings();
44 resourceEdit:function(){
48 addResultBindings:function(){
51 //setup parent bindings:
52 this.parent_addResultBindings();
54 //add an aditional click binding
55 $j('.rsd_res_item').click(function(){
56 js_log('SeqRemoteSearch: rsd_res_item: click (remove sequence_add_target)');
57 _this
.sequence_add_target
=false;
60 //add an additional drag binding
61 $j( '.rsd_res_item' ).draggable('destroy').draggable({
63 return $j( this ).clone().appendTo('body').css({'z-index':9999}).get(0);
70 $j(".mv_clip_drag").droppable( 'destroy' ).droppable({
71 accept
: '.rsd_res_item',
72 over:function(event
, ui
){
73 js_log("over : mv_clip_drag: " + $j(this).attr('id') );
74 $j(this).css('border-right', 'solid thick red');
76 out:function(event
, ui
){
77 $j(this).css('border-right', 'solid thin white');
79 drop: function(event
, ui
) {
80 $j(this).css('border-right', 'solid thin white');
81 js_log("Droped: "+ $j(ui
.draggable
).attr('id') +' on ' + $j(this).attr('id') );
82 _this
.sequence_add_target
= $j(this).attr('id');
83 //load the orginal draged item
84 var rObj
= _this
.getResourceFromId( $j(ui
.draggable
).attr('id') );
85 _this
.resourceEdit(rObj
, ui
.draggable
);
90 insertResource:function(rObj
){
92 js_log("SEQ insert resource after:" + _this
.sequence_add_target
);
93 if(_this
.sequence_add_target
){
94 var tClip
= _this
.pSeq
.getClipFromSeqID( _this
.sequence_add_target
);
95 var target_order
= false;
97 var target_order
= tClip
.order
;
99 //@@todo show watting of sorts.
103 //check for target insert path
104 this.checkImportResource( rObj
, function(){
108 'uri' : _this
.cFileNS
+ ':' + rObj
.target_resource_title
,
111 //set via local properites if avaliable
112 clipConfig
['src'] = (rObj
.local_src
) ? rObj
.local_src
: rObj
.src
;
113 clipConfig
['poster'] = (rObj
.local_poster
) ? rObj
.local_poster
: rObj
.poster
;
115 if(rObj
.start_time
&& rObj
.end_time
){
116 clipConfig
['dur'] = npt2seconds( rObj
.end_time
) - npt2seconds( rObj
.start_time
);
118 //provide a default duration
119 clipConfig
['dur'] = 4;
123 //create the media element (target order+1 (since we insert (after)
124 _this
.pSeq
.plObj
.tryAddMediaObj(clipConfig
, target_order
+1 );
125 //refresh the timeline:
126 _this
.pSeq
.do_refresh_timeline();
127 js_log("run close all: ");
131 getClipEditControlActions:function(){
134 'insert_seq':function(rObj
){
135 _this
.insertResource( rObj
)
137 'cancel':function(rObj
){
138 _this
.cancelClipEditCB( rObj
)
142 resourceEdit:function(rObj
, rsdElement
){
144 //don't resize to default (full screen behavior)
145 _this
.dmodalCss
= {};
146 //open up a new target_contaienr:
147 if($j('#seq_resource_import').length
== 0)
148 $j('body').append('<div id="seq_resource_import" style="position:relative"></div>');
150 $j('#seq_resource_import').dialog('destroy').dialog({
156 "Cancel": function() {
157 $j(this).dialog("close");
161 _this
.target_container
= '#seq_resource_import';
162 //do parent resource edit (with updated target)
163 this.parent_resourceEdit(rObj
, rsdElement
);
166 js_log( 'should close: seq_resource_import');
167 $j('#seq_resource_import').dialog('close').dialog('destroy').remove();
168 this.parent_closeAll();
170 getEditToken:function(callback
){
171 if(this.pSeq
.sequenceEditToken
){
172 callback( this.pSeq
.sequenceEditToken
)
174 this.parent_getEditToken(callback
);
177 cancelClipEditCB:function(){
178 js_log('seqRSD:cancelClipEditCB');
179 $j('#seq_resource_import').dialog('close').dialog('destroy').remove();