Index: trunk/extensions/MetavidWiki/skins/external_media_wizard.js |
— | — | @@ -1,9 +1,20 @@ |
2 | 2 | //add media wizard integration for mediaWiki |
3 | 3 | |
4 | | -//to support remote media searching. |
5 | | - |
| 4 | +/* config */ |
6 | 5 | var mv_embed_url = 'http://localhost/wiki/extensions/MetavidWiki/skins/mv_embed/mv_embed.js'; |
| 6 | +//Setup your content providers (see the remoteSearchDriver::content_providers for all options) |
| 7 | +var wg_content_proivers_config = { |
| 8 | + 'wiki_commons':{ |
| 9 | + 'local':false //note you will need to enable url file uploading to import assets |
| 10 | + }, |
| 11 | + 'metavid':{ |
| 12 | + 'local':true //this will change the output from [[embed:StreamName]] to [[remoteEmbed:roe_url]] |
| 13 | + } |
| 14 | +} |
| 15 | +var wg_local_wiki_api_url = 'http://localhost/wiki/api.php'; |
7 | 16 | |
| 17 | + |
| 18 | +//*code should not have to modify anything below*/ |
8 | 19 | //check if we are on a edit page: |
9 | 20 | if(wgAction=='edit'){ |
10 | 21 | //add onPage ready request: |
— | — | @@ -15,19 +26,26 @@ |
16 | 27 | 'onClick="mv_do_load_wiz()" />'; |
17 | 28 | }); |
18 | 29 | } |
| 30 | +var caret_pos={}; |
19 | 31 | function mv_do_load_wiz(){ |
| 32 | + caret_pos={}; |
| 33 | + tb = document.getElementById('wpTextbox1'); |
| 34 | + caret_pos.s = getTextCusorStartPos( tb ); |
| 35 | + caret_pos.e = getTextCusorEndPos( tb ); |
| 36 | + |
20 | 37 | //show the loading screen: |
21 | 38 | var body_elm = document.getElementsByTagName("body")[0]; |
22 | 39 | body_elm.innerHTML = body_elm.innerHTML + ''+ |
23 | 40 | '<div id="modalbox" style="background:#DDD;border:3px solid #666666;'+ |
24 | | - 'top:30px;left:100px;right:100px;bottom:30px;position:fixed;z-index:100;">'+ |
| 41 | + 'top:30px;left:20px;right:20px;bottom:30px;position:fixed;z-index:100;">'+ |
25 | 42 | |
26 | 43 | 'loading external media wizard<blink>...</blink>'+ |
27 | 44 | |
28 | 45 | '</div>'+ |
29 | 46 | '<div id="mv_overlay" style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+ |
30 | 47 | 'top:0;width:100%;z-index:5;filter:alpha(opacity=60);-moz-opacity: 0.6;'+ |
31 | | - 'opacity: 0.6;"/>'; |
| 48 | + 'opacity: 0.6;"/>'; |
| 49 | + |
32 | 50 | //inject mv_embed |
33 | 51 | if( typeof MV_EMBED_VERSION == 'undefined'){ |
34 | 52 | var e = document.createElement("script"); |
— | — | @@ -37,7 +55,8 @@ |
38 | 56 | setTimeout('check_for_mv_embed();', 25); |
39 | 57 | }else{ |
40 | 58 | check_for_mv_embed(); |
41 | | - } |
| 59 | + } |
| 60 | + return false; |
42 | 61 | } |
43 | 62 | function check_for_mv_embed(){ |
44 | 63 | if( typeof MV_EMBED_VERSION == 'undefined'){ |
— | — | @@ -46,7 +65,31 @@ |
47 | 66 | mv_do_remote_search({ |
48 | 67 | 'target_id':'modalbox', |
49 | 68 | 'profile':'mediawiki_edit', |
50 | | - 'default_query':wgTitle |
| 69 | + 'target_textbox': 'wpTextbox1', |
| 70 | + 'caret_pos':caret_pos, |
| 71 | + //note selections in the textbox will take over the default query |
| 72 | + 'default_query': wgTitle, |
| 73 | + 'cpconfig':wg_content_proivers_config, |
| 74 | + 'local_wiki_api_url': wg_local_wiki_api_url |
51 | 75 | }); |
52 | 76 | } |
53 | 77 | } |
| 78 | +/*once we modify the dom we lose the text selection :( so here are some get pos functions */ |
| 79 | +function getTextCusorStartPos(o){ |
| 80 | + if (o.createTextRange) { |
| 81 | + var r = document.selection.createRange().duplicate() |
| 82 | + r.moveEnd('character', o.value.length) |
| 83 | + if (r.text == '') return o.value.length |
| 84 | + return o.value.lastIndexOf(r.text) |
| 85 | + } else return o.selectionStart |
| 86 | +} |
| 87 | +function getTextCusorEndPos(o){ |
| 88 | + if (o.createTextRange) { |
| 89 | + var r = document.selection.createRange().duplicate(); |
| 90 | + r.moveStart('character', -o.value.length); |
| 91 | + return r.text.length; |
| 92 | + } else{ |
| 93 | + return o.selectionEnd |
| 94 | + } |
| 95 | +} |
| 96 | + |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_sequencer.js |
— | — | @@ -444,10 +444,24 @@ |
445 | 445 | //propogate the edit tokens |
446 | 446 | //if on an edit page just grab from the form: |
447 | 447 | this.sequenceEditToken = $j('input[@wpEditToken]').val(); |
448 | | - if(typeof this.sequenceEditToken == 'undefined'){ |
| 448 | + if(typeof this.sequenceEditToken == 'undefined'){ |
| 449 | + var reqObj = {'action':'query','prop':'info','intoken':'edit','titles': this_seq.plObj.mTitle}; |
| 450 | + var api_url = this.plObj.interface_url.replace(/index\.php/, 'api.php'); |
| 451 | + do_api_req( reqObj, api_url,function(data){ |
| 452 | + if(data.page[0]['edittoken']) |
| 453 | + this_seq.sequenceEditToken = data.page[0]['edittoken']; |
| 454 | + this_seq.updateSeqSaveButtons(); |
| 455 | + }); |
| 456 | + reqObj['titles']=this_seq.plObj.mTalk; |
| 457 | + do_api_req(reqObj, api_url, function(){ |
| 458 | + if(data.page[0]['edittoken']) |
| 459 | + this_seq.clipboardEditToken = data.page[0]['edittoken']; |
| 460 | + }); |
| 461 | + //also grab permmisions for sending clipboard commands to the server |
| 462 | + |
449 | 463 | //(calling the sequencer inline) try and get edit token via api call: |
450 | 464 | //(somewhat fragile way to get at the api... should move to config |
451 | | - var token_url =this.plObj.interface_url.replace(/index\.php/, 'api.php'); |
| 465 | + /*var token_url = this.plObj.interface_url.replace(/index\.php/, 'api.php'); |
452 | 466 | token_url += '?action=query&format=xml&prop=info&intoken=edit&titles='; |
453 | 467 | $j.ajax({ |
454 | 468 | type: "GET", |
— | — | @@ -457,11 +471,11 @@ |
458 | 472 | if( $j(pageElm).attr('edittoken') ){ |
459 | 473 | this_seq.sequenceEditToken = $j(pageElm).attr('edittoken'); |
460 | 474 | } |
461 | | - this_seq.updateSeqSaveButtons(); |
| 475 | + |
462 | 476 | } |
463 | | - }); |
| 477 | + });*/ |
464 | 478 | //also grab permmisions for sending clipboard commands to the server |
465 | | - $j.ajax({ |
| 479 | + /*$j.ajax({ |
466 | 480 | type:"GET", |
467 | 481 | url: token_url + this_seq.plObj.mTalk, |
468 | 482 | success:function(data){ |
— | — | @@ -470,7 +484,7 @@ |
471 | 485 | this_seq.clipboardEditToken = $j(pageElm).attr('edittoken'); |
472 | 486 | } |
473 | 487 | } |
474 | | - }); |
| 488 | + });*/ |
475 | 489 | } |
476 | 490 | |
477 | 491 | |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_clipedit.js |
— | — | @@ -1,16 +1,145 @@ |
2 | 2 | /* |
3 | | -hanndles clip edit controls |
| 3 | + hanndles clip edit controls |
4 | 4 | 'inoutpoints':0, //should let you set the in and out points of clip |
5 | 5 | 'panzoom':0, //should allow setting keyframes and tweening modes |
6 | 6 | 'overlays':0, //should allow setting "locked to clip" overlay tracks |
7 | | - 'audio':0 //should allow controling the audio volume (with keyframes) |
| 7 | + 'audio':0 //should allow controlling the audio volume (with keyframes) |
8 | 8 | */ |
9 | 9 | |
| 10 | +gMsg['mv_crop']='Crop Image'; |
| 11 | +gMsg['mv_apply_crop']='Apply Crop to Image'; |
| 12 | +gMsg['mv_reset_crop']='Rest Crop'; |
| 13 | +gMsg['mv_insert_image_page']='Insert Into page'; |
| 14 | +gMsg['mv_preview_insert']= 'Preview Insert'; |
| 15 | +gMsg['mv_cancel_image_insert']='Cancel Image Insert'; |
| 16 | + |
| 17 | +var default_clipedit_values = { |
| 18 | + 'rObj': null, // the resource object |
| 19 | + 'clip_disp_ct':null,//target clip disp |
| 20 | + 'control_ct':null, //control container |
| 21 | + 'media_type': null, //media type |
| 22 | + 'p_rsdObj': null, //parent remote search object |
| 23 | + 'parent_ct': null //parent container |
| 24 | +} |
10 | 25 | var mvClipEdit = function(initObj) { |
11 | 26 | return this.init(initObj); |
12 | 27 | }; |
13 | 28 | mvClipEdit.prototype = { |
| 29 | + |
| 30 | + selTool:null, //selected tool |
| 31 | + crop: null, //the crop values |
| 32 | + base_img_src:null, |
| 33 | + |
14 | 34 | init:function( initObj){ |
15 | | - //setup the clip editor |
| 35 | + //init object: |
| 36 | + for(var i in default_clipedit_values){ |
| 37 | + if( initObj[i] ){ |
| 38 | + this[i] = initObj[i]; |
| 39 | + } |
| 40 | + } |
| 41 | + //check the media_type: |
| 42 | + js_log('mvClipEdit:: media type:' + this.media_type + 'base width: ' + rObj.width + ' bh: ' + rObj.height); |
| 43 | + |
| 44 | + |
| 45 | + //could seperate out into media Types objects for now just call method |
| 46 | + if(this.media_type == 'image'){ |
| 47 | + this.setUpImageCtrl(); |
| 48 | + }else if(this.media_type=='jpeg'){ |
| 49 | + this.setUpVideoCtrl(); |
| 50 | + } |
| 51 | + }, |
| 52 | + setUpImageCtrl:function(){ |
| 53 | + var _this = this; |
| 54 | + //by default apply Crop tool |
| 55 | + $j('#'+this.control_ct).html( |
| 56 | + '<h3>Edit tools</h3>' + |
| 57 | + '<div class="mv_edit_button mv_crop_button_base" id="mv_crop_button" alt="crop" title="'+getMsg('mv_crop')+'"/>'+ |
| 58 | + '<a href="#" class="mv_crop_msg">' + getMsg('mv_crop') + '</a> '+ |
| 59 | + '<a href="#" style="display:none" class="mv_apply_crop">' + getMsg('mv_apply_crop') + '</a> '+ |
| 60 | + '<a href="#" style="display:none" class="mv_rest_crop">' + getMsg('mv_reset_crop') + '</a> '+ |
| 61 | + '<br style="clear:both"><br>'+ |
| 62 | + |
| 63 | + '<div class="mv_edit_button mv_scale_button_base" id="mv_scale_button" alt="crop" title="'+getMsg('mv_scale')+'"></div>'+ |
| 64 | + '<a href="#" class="mv_scale_msg">' + getMsg('mv_scale') + '</a><br>'+ |
| 65 | + '<a href="#" style="display:none" class="mv_apply_scale">' + getMsg('mv_apply_scale') + '</a> '+ |
| 66 | + '<a href="#" style="display:none" class="mv_rest_scale">' + getMsg('mv_reset_scale') + '</a> '+ |
| 67 | + |
| 68 | + '<h3>Inline Caption Description</h3>'+ |
| 69 | + '<textarea id="mv_img_desc" rows="4" cols="30"></textarea><br>'+ |
| 70 | + '<h3>Actions</h3>'+ |
| 71 | + '<input type="button" class="mv_insert_image_page" value="' + getMsg('mv_insert_image_page') + '"> '+ |
| 72 | + '<input type="button" class="mv_preview_insert" value="' + getMsg('mv_preview_insert')+ '"> '+ |
| 73 | + '<a href="#" class="mv_cancel_img_edit" title="' + getMsg('mv_cancel_image_insert')+'">' + getMsg('mv_cancel_image_insert') + '</a> ' |
| 74 | + ); |
| 75 | + //add bidings: |
| 76 | + $j('#mv_crop_button,.mv_crop_msg,.mv_apply_crop').click(function(){ |
| 77 | + js_log('click:mv_crop_button: base width: ' + rObj.width + ' bh: ' + rObj.height); |
| 78 | + if($j('#mv_crop_button').hasClass('mv_crop_button_selected')){ |
| 79 | + _this.applyCrop(); |
| 80 | + }else{ |
| 81 | + js_log('click:turn on'); |
| 82 | + _this.enableCrop(); |
| 83 | + } |
| 84 | + }); |
| 85 | + $j('.mv_rest_crop').click(function(){ |
| 86 | + $j('.mv_apply_crop,.mv_rest_crop').hide(); |
| 87 | + $j('.mv_crop_msg').show(); |
| 88 | + $j('#mv_crop_button').removeClass('mv_crop_button_selected').addClass('mv_crop_button_base').attr('title',getMsg('mv_crop')); |
| 89 | + _this.rObj.crop=null; |
| 90 | + $j('#'+_this.clip_disp_ct ).empty().html( |
| 91 | + '<img src="'+ _this.rObj.url + '" id="rsd_edit_img">' |
| 92 | + ) |
| 93 | + }); |
| 94 | + $j('.mv_insert_image_page').click(function(){ |
| 95 | + _this.applyCrop(); |
| 96 | + //have the (parent remote search object) do the insert |
| 97 | + _this.p_rsdObj.insertResource( rObj ); |
| 98 | + }); |
| 99 | + $j('.mv_preview_insert').click(function(){ |
| 100 | + _this.applyCrop(); |
| 101 | + //copy over the desc text to the resouce object |
| 102 | + _this.p_rsdObj.previewResource( rObj ); |
| 103 | + }); |
| 104 | + $j('.mv_cancel_img_edit').click( function(){ |
| 105 | + $j('#' + _this.parent_ct).fadeOut("fast"); |
| 106 | + }); |
| 107 | + }, |
| 108 | + applyCrop:function(){ |
| 109 | + var _this = this; |
| 110 | + $j('.mv_apply_crop').hide(); |
| 111 | + $j('.mv_crop_msg').show(); |
| 112 | + $j('#mv_crop_button').removeClass('mv_crop_button_selected').addClass('mv_crop_button_base').attr('title',getMsg('mv_crop')); |
| 113 | + js_log('click:turn off'); |
| 114 | + if(_this.rObj.crop){ |
| 115 | + //empty out and display croped: |
| 116 | + $j('#'+_this.clip_disp_ct ).empty().html( |
| 117 | + '<div id="mv_cropcotainer" style="overflow:hidden;position:absolute;'+ |
| 118 | + 'width:' + _this.rObj.crop.w + 'px;'+ |
| 119 | + 'height:' + _this.rObj.crop.h + 'px;">'+ |
| 120 | + '<div id="mv_crop_img" style="position:absolute;'+ |
| 121 | + 'top:-' + _this.rObj.crop.y +'px;'+ |
| 122 | + 'left:-' + _this.rObj.crop.x + 'px;">'+ |
| 123 | + '<img src="' + _this.rObj.url + '">'+ |
| 124 | + '</div>'+ |
| 125 | + '</div>' |
| 126 | + ); |
| 127 | + } |
| 128 | + }, |
| 129 | + enableCrop:function(){ |
| 130 | + var _this = this; |
| 131 | + $j('.mv_crop_msg').hide(); |
| 132 | + $j('.mv_rest_crop,.mv_apply_crop').show(); |
| 133 | + $j('#mv_crop_button').removeClass('mv_crop_button_base').addClass('mv_crop_button_selected').attr('title',getMsg('mv_crop_done')); |
| 134 | + $j('#' + _this.clip_disp_ct + ' img').Jcrop({ |
| 135 | + onSelect: function(c){ |
| 136 | + js_log('on select:' + c.x +','+ c.y+','+ c.x2+','+ c.y2+','+ c.w+','+ c.h); |
| 137 | + _this.rObj.crop = c; |
| 138 | + }, |
| 139 | + onChange: function(c){ |
| 140 | + } |
| 141 | + }); |
| 142 | + }, |
| 143 | + setUpVideoCtrl:function(){ |
| 144 | + |
16 | 145 | } |
17 | | -} |
| 146 | +} |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_17.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_17.png |
___________________________________________________________________ |
Added: svn:mime-type |
18 | 147 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_logo_17.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_logo_17.png |
___________________________________________________________________ |
Added: svn:mime-type |
19 | 148 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/Button_add_media.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/Button_add_media.png |
___________________________________________________________________ |
Added: svn:mime-type |
20 | 149 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_17.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_17.png |
___________________________________________________________________ |
Added: svn:mime-type |
21 | 150 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-text-layer-24.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-text-layer-24.png |
___________________________________________________________________ |
Added: svn:mime-type |
22 | 151 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock_icon_over.xcf |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock_icon_over.xcf |
___________________________________________________________________ |
Added: svn:mime-type |
23 | 152 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-scale_over.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-scale_over.png |
___________________________________________________________________ |
Added: svn:mime-type |
24 | 153 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-scale.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-scale.png |
___________________________________________________________________ |
Added: svn:mime-type |
25 | 154 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/loading_bar_ani.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/loading_bar_ani.gif |
___________________________________________________________________ |
Added: svn:mime-type |
26 | 155 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-text-layer-24_over.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-text-layer-24_over.png |
___________________________________________________________________ |
Added: svn:mime-type |
27 | 156 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-crop_over.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-crop_over.png |
___________________________________________________________________ |
Added: svn:mime-type |
28 | 157 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-crop.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/stock-tool-button-crop.png |
___________________________________________________________________ |
Added: svn:mime-type |
29 | 158 | + application/octet-stream |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css |
— | — | @@ -541,7 +541,11 @@ |
542 | 542 | padding:10px; |
543 | 543 | float:left; |
544 | 544 | border: thin solid #BBB; |
| 545 | + overflow:hidden; |
545 | 546 | } |
| 547 | +.mv_clip_box_result_over{ |
| 548 | + border: thin solid #F99; |
| 549 | +} |
546 | 550 | .mv_clip_list_result{ |
547 | 551 | padding:10px; |
548 | 552 | } |
— | — | @@ -550,3 +554,22 @@ |
551 | 555 | background:#DEF; |
552 | 556 | height:22px; |
553 | 557 | } |
| 558 | + |
| 559 | +/* edit buttons: */ |
| 560 | +.mv_edit_button{ |
| 561 | + width:22px; |
| 562 | + height:22px; |
| 563 | + float:left; |
| 564 | +} |
| 565 | +.mv_crop_button_base{ |
| 566 | + background-image: url('images/stock-tool-button-crop.png'); |
| 567 | +} |
| 568 | +.mv_crop_button_selected{ |
| 569 | + background-image: url('images/stock-tool-button-crop_over.png'); |
| 570 | +} |
| 571 | +.mv_scale_button_base{ |
| 572 | + background-image: url('images/stock-tool-button-scale.png'); |
| 573 | +} |
| 574 | +.mv_scale_button_selected{ |
| 575 | + background-image: url('images/stock-tool-button-scale_over.png'); |
| 576 | +} |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -130,8 +130,13 @@ |
131 | 131 | return gMsg[key]; |
132 | 132 | } else{ |
133 | 133 | return '[' + key + ']'; |
134 | | - } |
| 134 | + } |
135 | 135 | } |
| 136 | +function mv_get_loading_img( style, class){ |
| 137 | + var class_attr = (class)?'class="'+class+'"':'class="mv_loading_img"'; |
| 138 | + return '<img '+class_attr+' style="' + style +'" src="'+ |
| 139 | + mv_embed_path + 'skins/' + mv_skin_name + '/images/loading_ani.gif">'; |
| 140 | +} |
136 | 141 | |
137 | 142 | /* the base video control JSON object with default attributes |
138 | 143 | * for supported attribute details see README |
— | — | @@ -2920,7 +2925,7 @@ |
2921 | 2926 | } |
2922 | 2927 | |
2923 | 2928 | //build request string: (force the format to json): |
2924 | | - var req_url = api_url +'?format=json'; |
| 2929 | + var req_url = api_url + '?format=json'; |
2925 | 2930 | for(var i in req_param){ |
2926 | 2931 | req_url += '&' + encodeURIComponent( i ) + '=' + encodeURIComponent( req_param[i] ); |
2927 | 2932 | } |
— | — | @@ -2937,10 +2942,10 @@ |
2938 | 2943 | } |
2939 | 2944 | }); |
2940 | 2945 | }else{ |
2941 | | - //remote request append callback |
2942 | | - eval('_global.mycpfn' + ( global_cb_count++ ) + ' = ' + callback ); |
2943 | | - req_url += '&callback=mycpfn' + global_cb_count; |
2944 | | - loadExternalJs( req_url ); |
| 2946 | + var fname = 'mycpfn_' + ( global_cb_count++ ); |
| 2947 | + _global[ fname ] = callback ; |
| 2948 | + req_url += '&callback=' + fname; |
| 2949 | + loadExternalJs( req_url ); |
2945 | 2950 | } |
2946 | 2951 | } |
2947 | 2952 | //do a "normal" request (should be deprecated via extending the mediaWiki API) |
— | — | @@ -2964,8 +2969,7 @@ |
2965 | 2970 | global_req_cb.push(callback); |
2966 | 2971 | //prepend json_ to feed_format if not already requesting json format |
2967 | 2972 | if( req_url.indexOf("feed_format=")!=-1 && req_url.indexOf("feed_format=json")==-1) |
2968 | | - req_url = req_url.replace(/feed_format=/, 'feed_format=json_'); |
2969 | | - |
| 2973 | + req_url = req_url.replace(/feed_format=/, 'feed_format=json_'); |
2970 | 2974 | loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1)); |
2971 | 2975 | } |
2972 | 2976 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | gMsg['rsd_list_layout'] = 'List Layout'; |
15 | 15 | gMsg['rsd_results_desc']= 'Results <b>$0</b> of <b>$1</b>'; |
16 | 16 | gMsg['rsd_layout'] = 'Layout:'; |
| 17 | +gMsg['rsd_resource_edit']='Edit Resource:'; |
17 | 18 | |
18 | 19 | var default_remote_search_options = { |
19 | 20 | 'profile':'mediawiki_edit', |
— | — | @@ -20,6 +21,10 @@ |
21 | 22 | |
22 | 23 | 'default_provider_id':'all', //all or one of the content_providers ids |
23 | 24 | |
| 25 | + 'caret_pos':null, |
| 26 | + 'local_wiki_api_url':null, |
| 27 | + |
| 28 | + 'target_textbox':null, |
24 | 29 | 'instance_name': null, //a globally accessible callback instance name |
25 | 30 | 'default_query':'', //default search query |
26 | 31 | //specific to sequence profile |
— | — | @@ -64,24 +69,28 @@ |
65 | 70 | 'wiki_commons':{ |
66 | 71 | 'enabled':1, |
67 | 72 | 'checked':1, |
68 | | - 'd' :0, |
69 | | - 'title' :'Wikipedia Commons', |
| 73 | + 'd' :1, |
| 74 | + 'title' :'Wikipedia Commons', |
70 | 75 | 'desc' : 'Wikimedia Commons is a media file repository making available public domain '+ |
71 | | - 'and freely-licensed educational media content (images, sound and video clips) to all.', |
| 76 | + 'and freely-licensed educational media content (images, sound and video clips) to all.', |
| 77 | + 'hompage': 'http://commons.wikimedia.org/wiki/Main_Page', |
72 | 78 | 'api_url':'http://commons.wikimedia.org/w/api.php', |
73 | 79 | 'lib' :'mediaWiki', |
74 | 80 | 'search_title':false, //disable title search |
75 | | - 'local' :true |
| 81 | + 'local' :false, |
| 82 | + 'resource_prefix': '' //what prefix to use on imported resources |
76 | 83 | }, |
77 | 84 | 'metavid':{ |
78 | 85 | 'enabled':1, |
79 | 86 | 'checked':1, |
80 | | - 'd' :1, |
| 87 | + 'd' :0, |
81 | 88 | 'title' :'Metavid.org', |
| 89 | + 'homepage':'http://metavid.org', |
82 | 90 | 'desc' : 'Metavid hosts thousands of hours of US house and senate floor proceedings', |
83 | 91 | 'api_url':'http://localhost/wiki/index.php?title=Special:MvExportSearch', |
84 | 92 | 'lib' : 'metavid', |
85 | | - 'local' :false |
| 93 | + 'local' :false, |
| 94 | + 'resource_prefix': 'MV_' //what prefix to use on imported resources |
86 | 95 | }, |
87 | 96 | 'archive_org':{ |
88 | 97 | 'enabled':0, |
— | — | @@ -89,12 +98,17 @@ |
90 | 99 | 'd' :0, |
91 | 100 | 'title' : 'Archive.org', |
92 | 101 | 'desc' : 'The Internet Archive, a digital library of cultural artifacts', |
| 102 | + 'homepage':'http://archive.org', |
93 | 103 | 'lib' : 'archive', |
94 | | - 'local' : false |
| 104 | + 'local' : false, |
| 105 | + 'resource_prefix': 'AO_' |
95 | 106 | } |
96 | 107 | }, |
97 | 108 | //some default layout values: |
98 | 109 | thumb_width : 80, |
| 110 | + image_edit_width : 600, |
| 111 | + video_edit_width : 400, |
| 112 | + insert_text_pos : 0, //insert at the start (will be overwiten by the user cursor pos) |
99 | 113 | result_display_mode : 'box', //box or list or preview |
100 | 114 | |
101 | 115 | init:function( initObj ){ |
— | — | @@ -105,10 +119,30 @@ |
106 | 120 | }else{ |
107 | 121 | this[ i ] =default_remote_search_options[i]; |
108 | 122 | } |
| 123 | + } |
| 124 | + //set up the content provider config: |
| 125 | + if(this.cpconfig){ |
| 126 | + for(var cpc in cpconfig){ |
| 127 | + for(var cinx in this.cpconfig[cpc]){ |
| 128 | + if( this.content_providers[cpc] ) |
| 129 | + this.content_providers[ cpc ][ cinx ] = this.cpconfig[cpc][ cinx]; |
| 130 | + } |
| 131 | + } |
109 | 132 | } |
| 133 | + |
| 134 | + //overwrite the default query if a text selection was made: |
| 135 | + if(this.target_textbox) |
| 136 | + this.getTexboxSelection(); |
| 137 | + |
110 | 138 | this.init_interface_html(); |
111 | 139 | this.add_interface_bindings(); |
112 | | - }, |
| 140 | + }, |
| 141 | + //gets the in and out points for insert position or grabs the selected text for search |
| 142 | + getTexboxSelection:function(){ |
| 143 | + if(this.caret_pos.s && this.caret_pos.e && |
| 144 | + (this.caret_pos.s != this.caret_pos.e)) |
| 145 | + this.default_query = $j('#'+this.target_textbox).val().substring(this.caret_pos.s, this.caret_pos.e).replace(/ /g, '\xa0') || '\xa0' |
| 146 | + }, |
113 | 147 | //sets up the initial html interface |
114 | 148 | init_interface_html:function(){ |
115 | 149 | var out = '<div class="rsd_control_container" style="width:100%">' + |
— | — | @@ -126,8 +160,8 @@ |
127 | 161 | ' id="rms_search_button"/>'+ |
128 | 162 | '</td>'+ |
129 | 163 | '<td>'; |
130 | | - out += '<a src="#" id="mso_selprovider" >Select Providers</a><br>'; |
131 | | - out += '<a src="#" id="mso_cancel" >Cancel</a><br>'; |
| 164 | + out += '<a href="#" id="mso_selprovider" >Select Providers</a><br>'; |
| 165 | + out += '<a href="#" id="mso_cancel" >Cancel</a><br>'; |
132 | 166 | out += '</td>'+ |
133 | 167 | '</tr>'+ |
134 | 168 | '</table>'; |
— | — | @@ -182,27 +216,21 @@ |
183 | 217 | 'opacity':0 |
184 | 218 | }, "normal", function(){ |
185 | 219 | $j(this).hide(); |
186 | | - }) |
| 220 | + }); |
187 | 221 | } |
188 | | - }); |
189 | | - //setup bindings for search tabs: |
190 | | - $j('.rsd_cp_tabs li').click(function(){ |
191 | | - _this.selectTab( $j(this).attr('id').replace(/rsd_tab_/, '') ); |
192 | | - }); |
193 | | - |
| 222 | + }); |
194 | 223 | //setup binding for search provider check box: |
195 | 224 | //search button: |
196 | 225 | $j('#rms_search_button').click(function(){ |
197 | 226 | _this.runSearch(); |
198 | | - }); |
| 227 | + }); |
199 | 228 | }, |
200 | 229 | runSearch: function(){ |
201 | 230 | var _this = this; |
202 | 231 | //set loading div: |
203 | | - $j('#rsd_results').append('<div style="postion:absolute;top:0px;left:0px;height:100%;width:100%;'+ |
204 | | - '-moz-opacity:.50; filter:alpha(opacity=50); opacity:.50;z-index:100">' + |
205 | | - '<img style="padding:10px;" src="'+ |
206 | | - mv_embed_path + 'skins/' + mv_skin_name + '/images/loading_ani.gif">'+ |
| 232 | + $j('#rsd_results').append('<div style="position:absolute;top:0px;left:0px;height:100%;width:100%;'+ |
| 233 | + 'background-color:#FFF;margin:30px">' + |
| 234 | + mv_get_loading_img('padding:30px') + |
207 | 235 | '</div>'); |
208 | 236 | //get a remote search object for each search provider and run the search |
209 | 237 | for(var cp_id in this.content_providers){ |
— | — | @@ -242,6 +270,7 @@ |
243 | 271 | } |
244 | 272 | }, |
245 | 273 | drawTabs: function(){ |
| 274 | + var _this = this; |
246 | 275 | //add the tabs to the rsd_results container: |
247 | 276 | var o= '<ul class="rsd_cp_tabs" >'; |
248 | 277 | o+='<li id="rsd_tab_combined" ><img src="' + mv_embed_path + 'skins/'+mv_skin_name+ '/remote_search/combined_tab.png"></li>'; |
— | — | @@ -256,41 +285,313 @@ |
257 | 286 | //outout the resource results holder |
258 | 287 | o+='<div id="rsd_results" />'; |
259 | 288 | $j('#rsd_results_container').html(o); |
260 | | - }, |
| 289 | + |
| 290 | + //setup bindings for tabs: |
| 291 | + $j('.rsd_cp_tabs li').click(function(){ |
| 292 | + _this.selectTab( $j(this).attr('id').replace(/rsd_tab_/, '') ); |
| 293 | + }); |
| 294 | + }, |
| 295 | + //@@todo we could load the id with the content provider id to find the object faster... |
| 296 | + getResourceFromId:function( rid ){ |
| 297 | + //strip out /res/ if preset: |
| 298 | + rid = rid.replace(/res_/, ''); |
| 299 | + for(var cp_id in this.content_providers){ |
| 300 | + cp = this.content_providers[ cp_id ]; |
| 301 | + if( cp['sObj']){ |
| 302 | + for(var rInx in cp.sObj.resultsObj){ |
| 303 | + if(rInx == rid) |
| 304 | + return cp.sObj.resultsObj[rInx]; |
| 305 | + }; |
| 306 | + } |
| 307 | + } |
| 308 | + js_log("ERROR: could not find " + rid); |
| 309 | + return false; |
| 310 | + }, |
261 | 311 | drawOutputResults: function(){ |
262 | 312 | js_log('f:drawOutputResults'); |
263 | 313 | var _this = this; |
264 | 314 | var o=''; |
265 | 315 | $j('#rsd_results').empty(); |
266 | 316 | //output the results bar / controls |
267 | | - _this.setResultBarControl(); |
| 317 | + _this.setResultBarControl(); |
268 | 318 | |
269 | 319 | //output all the results (hide based on tab selection) |
270 | 320 | for(var cp_id in this.content_providers){ |
271 | 321 | cp = this.content_providers[ cp_id ]; |
272 | 322 | //output results based on display mode & input: |
273 | 323 | if(typeof cp['sObj'] != 'undefined'){ |
274 | | - $j.each(cp.sObj.resultsObj, function(rInx, resultItem){ |
| 324 | + $j.each(cp.sObj.resultsObj, function(rInx, rItem){ |
275 | 325 | var disp = ( cp.d ) ? '' : 'display:none;'; |
276 | 326 | if( _this.result_display_mode == 'box' ){ |
277 | | - o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result res_' + cp_id +'" style="' + disp + 'width:' + |
278 | | - _this.thumb_width + 'px;height:'+ parseInt(_this.thumb_width) +'px">'; |
279 | | - o+='<img style="width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
| 327 | + o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result" style="' + disp + 'width:' + |
| 328 | + _this.thumb_width + 'px;height:'+ (_this.thumb_width-20) +'px">'; |
| 329 | + o+='<img title="'+rItem.title+'" class="rsd_res_item" id="res_' + rInx +'" style="width:' + _this.thumb_width + 'px;" src="' + rItem.poster + '">'; |
280 | 330 | o+='</div>'; |
281 | 331 | }else if(_this.result_display_mode == 'list'){ |
282 | | - o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result res_' + cp_id +'" style="' + disp + 'width:90%">'; |
283 | | - o+='<img style="float:left;width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">'; |
284 | | - o+= cp.sObj.specialFormatDesc( resultItem.desc ) ; |
| 332 | + o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result res_' + rInx +'" style="' + disp + 'width:90%">'; |
| 333 | + o+='<img class="rsd_res_item" id="res_' + cp_id +'" style="float:left;width:' + _this.thumb_width + 'px; padding:5px;" src="' + rItem.poster + '">'; |
| 334 | + o+= rItem.desc ; |
285 | 335 | o+='</div>'; |
286 | 336 | o+='<div style="clear:both" />'; |
287 | 337 | } |
288 | 338 | }); |
289 | 339 | } |
290 | | - } |
291 | | - js_log('should add to rsd:' + o); |
| 340 | + } |
292 | 341 | //put in the new output: |
293 | | - $j('#rsd_results').append( o ); |
| 342 | + $j('#rsd_results').append( o ) |
| 343 | + //remove rss only display class if present |
| 344 | + $j('#rsd_results .mv_rss_view_only').remove(); |
| 345 | + this.addResultBindings(); |
294 | 346 | }, |
| 347 | + addResultBindings:function(){ |
| 348 | + var _this = this; |
| 349 | + $j('.mv_clip_box_result').hover(function(){ |
| 350 | + $j(this).addClass('mv_clip_box_result_over'); |
| 351 | + },function(){ |
| 352 | + $j(this).removeClass('mv_clip_box_result_over'); |
| 353 | + }); |
| 354 | + //resource click action: (bring up the resource editor) |
| 355 | + $j('.rsd_res_item').click(function(){ |
| 356 | + //get the resource obj: |
| 357 | + rObj = _this.getResourceFromId( this.id ); |
| 358 | + //remove any existing resource edit interface: |
| 359 | + $j('#rsd_resource_edit').remove(); |
| 360 | + //append to the top level of model window: |
| 361 | + $j( '#'+ _this.target_id ).append('<div id="rsd_resource_edit" '+ |
| 362 | + 'style="position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#FFF;">' + |
| 363 | + '<h3 style="margin:4px;">' + getMsg('rsd_resource_edit') + ' ' + rObj.title +'</h3>'+ |
| 364 | + '<div id="clip_edit_disp" style="position:absolute;top:30px;left:0px;bottom:0px;'+ |
| 365 | + 'width:' + (_this.image_edit_width+30) + 'px;overflow:auto;" >' + |
| 366 | + mv_get_loading_img('position:absolute;top:30px;left:30px', 'mv_img_loader') + |
| 367 | + '</div>'+ |
| 368 | + '<div id="clip_edit_ctrl" style="position:absolute;border:solid thin blue;'+ |
| 369 | + 'top:30px;left:' + (_this.image_edit_width+30) +'px;bottom:0px;right:0px;">'+ |
| 370 | + mv_get_loading_img('padding:30px') + |
| 371 | + '</div>'+ |
| 372 | + '</div>'); |
| 373 | + $j('#rsd_resource_edit').css('opacity',0); |
| 374 | + |
| 375 | + $j('#rsd_edit_img').remove();//remove any existing rsd_edit_img |
| 376 | + |
| 377 | + //left side holds the image right size the controls / |
| 378 | + $j(this).clone().attr('id', 'rsd_edit_img').appendTo('#clip_edit_disp').css({ |
| 379 | + 'position':'absolute', |
| 380 | + 'top':'40%', |
| 381 | + 'left':'20%', |
| 382 | + 'opacity':0 |
| 383 | + }); |
| 384 | + if(rObj.mime.indexOf('image')!=-1){ |
| 385 | + //set width to default image_edit_width |
| 386 | + var maxWidth = _this.image_edit_width; |
| 387 | + var mediaType = 'image'; |
| 388 | + }else{ |
| 389 | + //set to default video size: |
| 390 | + var maxWidth = _this.video_edit_width; |
| 391 | + var mediaType = 'video'; |
| 392 | + } |
| 393 | + //assume we keep aspect ratio for the thumbnail that we clicked: |
| 394 | + var tRatio = $j(this).height() / $j(this).width(); |
| 395 | + if( ! tRatio ) |
| 396 | + var tRatio = 1; //set ratio to 1 if the width of the thumbnail can't be found for some reason |
| 397 | + |
| 398 | + js_log('set from ' + $j('#rsd_edit_img').width()+'x'+ $j('#rsd_edit_img').height() + ' to init thumbimage to ' + maxWidth + ' x ' + parseInt( tRatio * maxWidth) ); |
| 399 | + //scale up image and swap with high res version |
| 400 | + $j('#rsd_edit_img').animate({ |
| 401 | + 'opacity':1, |
| 402 | + 'top':'0px', |
| 403 | + 'left':'0px', |
| 404 | + 'width': maxWidth + 'px', |
| 405 | + 'height': parseInt( tRatio * maxWidth) + 'px' |
| 406 | + }, "slow"); // do it slow to give it a chance to finish loading the HQ version |
| 407 | + _this.loadHQImg(rObj, {'width':maxWidth}, 'rsd_edit_img', function(){ |
| 408 | + $j('.mv_img_loader').remove(); |
| 409 | + }); |
| 410 | + //also fade in the container: |
| 411 | + $j('#rsd_resource_edit').animate({ |
| 412 | + 'opacity':1, |
| 413 | + 'background-color':'#FFF', |
| 414 | + 'z-index':99 |
| 415 | + }); |
| 416 | + _this.doMediaEdit( rObj , mediaType ); |
| 417 | + }); |
| 418 | + }, |
| 419 | + loadHQImg:function(rObj, size, target_img_id, callback){ |
| 420 | + //get the HQ image url: |
| 421 | + rObj.pSobj.getImageObj( rObj, size, function( imObj ){ |
| 422 | + rObj['url'] = imObj.url; |
| 423 | + //see if we need to animate some transition |
| 424 | + var newSize = false; |
| 425 | + if( size.width != imObj.width ){ |
| 426 | + js_log('loadHQImg:size mismatch: ' + size.width + ' != ' + imObj.width ); |
| 427 | + newSize={ |
| 428 | + 'width':imObj.width + 'px', |
| 429 | + 'height':imObj.height + 'px' |
| 430 | + } |
| 431 | + //update the rObj (hopefully this happens before people select their crop) |
| 432 | + rObj['width'] = imObj.width; |
| 433 | + rObj['height'] = imObj.height; |
| 434 | + //set the target id to the new size: |
| 435 | + $j('#'+target_img_id).animate( newSize ); |
| 436 | + }else{ |
| 437 | + js_log('using req size: ' + imObj.width + 'x' + imObj.height); |
| 438 | + $j('#'+target_img_id).animate( {'width':imObj.width+'px', 'height' : imObj.height + 'px'}); |
| 439 | + } |
| 440 | + //don't swap it in untill its loaded: |
| 441 | + var img = new Image(); |
| 442 | + // load the image image: |
| 443 | + $j(img).load(function () { |
| 444 | + $j('#'+target_img_id).attr('src', imObj.url); |
| 445 | + //let the caller know we are done and what size we ended up with: |
| 446 | + callback(); |
| 447 | + }).error(function () { |
| 448 | + js_log("Error with: " + imObj.url); |
| 449 | + }).attr('src', imObj.url); |
| 450 | + }); |
| 451 | + }, |
| 452 | + //loads the media editor: |
| 453 | + doMediaEdit:function( rObj , mediaType){ |
| 454 | + var _this = this; |
| 455 | + var mvClipInit = { |
| 456 | + 'rObj':rObj, //the resource object |
| 457 | + 'parent_ct':'rsd_resource_edit', |
| 458 | + 'clip_disp_ct':'clip_edit_disp', |
| 459 | + 'control_ct': 'clip_edit_ctrl', |
| 460 | + 'media_type': mediaType, |
| 461 | + 'p_rsdObj': _this |
| 462 | + |
| 463 | + }; |
| 464 | + var loadLibs = {'mvClipEdit':'libSequencer/mv_clipedit.js'}; |
| 465 | + if( mediaType == 'image'){ |
| 466 | + //load the croping library: |
| 467 | + loadLibs['$j.Jcrop']='jquery/plugins/Jcrop/js/jquery.Jcrop.js'; |
| 468 | + //@@todo integrate css calls into mvJsLoader or move jcrop css |
| 469 | + loadExternalCss( mv_embed_path + 'jquery/plugins/Jcrop/css/jquery.Jcrop.css'); |
| 470 | + } |
| 471 | + //load the library: |
| 472 | + mvJsLoader.doLoad( loadLibs, |
| 473 | + function(){ |
| 474 | + js_log('done loading libs: mvClipEdit + Jcrop'); |
| 475 | + //run the image clip tools |
| 476 | + _this.cEdit = new mvClipEdit( mvClipInit ); |
| 477 | + }); |
| 478 | + }, |
| 479 | + checkImportResource:function( rObj, callback){ |
| 480 | + //check if the resource is "locally accesible" |
| 481 | + if( rObj.pSobj.local ){ |
| 482 | + callback( rObj ); |
| 483 | + }else{ |
| 484 | + var _this = this; |
| 485 | + var cp = rObj.pSobj.cp; |
| 486 | + |
| 487 | + //first check if the resource is not already on this wiki: |
| 488 | + var target_resource_title = cp.resource_prefix + rObj.titleKey; |
| 489 | + reqObj={'action':'query', titles:target_resource_title}; |
| 490 | + do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
| 491 | + if( ! data.query.pages['-1'] ){ |
| 492 | + //resource is already present: |
| 493 | + callback( rObj ); |
| 494 | + }else{ |
| 495 | + var base_resource_desc = '{Information '+ |
| 496 | + '|Description= ' + rObj.title + ' imported from ' + '[' + cp.homepage + |
| 497 | + ' ' + cp.title+']' + "\n" + |
| 498 | + '|Source=' + '[' + rObj.link +' Original Source]'+ "\n" + |
| 499 | + '|Author= US government' +"\n"+ |
| 500 | + '|Date= October 1st 2008' +"\n"+ |
| 501 | + '|Permission=' +"\n"+ |
| 502 | + '|other_versions=' +"\n"+ |
| 503 | + '}}'; |
| 504 | + //@@ show user dialog to import the resource |
| 505 | + $j( '#'+ _this.target_id ).append('<div id="rsd_resource_import" '+ |
| 506 | + 'style="position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#FFF;">' + |
| 507 | + '<h3>Resource: ' + rObj.title + ' needs to be imported to this wiki</h3>'+ |
| 508 | + rObj.pSobj.getEmbedHTML( rObj, {'max_height':'300'} )+ //get embedHTML: |
| 509 | + '<br>'+ |
| 510 | + //output the rendered and non-renderd version of description for easy swiching: |
| 511 | + '<strong>Resource Description:</strong>'+ |
| 512 | + '<a id="rsd_import_aedit" href="#">Edit</a>'+ |
| 513 | + '<a style="display:none;" id="rsd_import_apreview" href="#">Preview</a>'+ |
| 514 | + '<div id="rsd_impoart_desc" syle="width:60%;border:solid thin black;height:300px;overflow:auto;">'+ |
| 515 | + mv_get_loading_img('position:absolute;top:5px;left:5px', 'mv_img_loader') + |
| 516 | + '</div>'+ |
| 517 | + '<textarea id="rsd_import_ta" style="display:none" id="mv_img_desc" rows="4" cols="30">'+ |
| 518 | + base_resource_desc + |
| 519 | + '</textarea><br>'+ |
| 520 | + '<input id="rsd_import_doimport" type="button" value="Do Import Resource">'+ |
| 521 | + '<a href="#">Cancel Import</a>'+ |
| 522 | + '</div>'); |
| 523 | + //load the preview text: |
| 524 | + _this.getParsedWikiText( base_resource_desc, function( o ){ |
| 525 | + $j('#rsd_impoart_desc').html(o); |
| 526 | + }); |
| 527 | + //add bidings: |
| 528 | + $j('#rsd_import_aedit').click(function(){ |
| 529 | + $j(this).hide(); |
| 530 | + $j('#rsd_impoart_desc').hide(); |
| 531 | + $j('#rsd_import_apreview,#rsd_import_ta').show(); |
| 532 | + }); |
| 533 | + $j('#rsd_import_apreview').click(function(){ |
| 534 | + $j(this).hide(); |
| 535 | + $j('#rsd_impoart_desc').show().html( |
| 536 | + mv_get_loading_img('position:absolute;top:5px;left:5px', 'mv_img_loader') |
| 537 | + ); |
| 538 | + //load the preview text: |
| 539 | + _this.getParsedWikiText( $j('#rsd_import_ta').val() , function( o ){ |
| 540 | + $j('#rsd_impoart_desc').html(o); |
| 541 | + }); |
| 542 | + }); |
| 543 | + $j('#rsd_import_doimport').click(function(){ |
| 544 | + //replace the parent with progress bar: |
| 545 | + $j('rsd_resource_import').html( |
| 546 | + '<h3>Importing asset</h3>'+ |
| 547 | + mv_get_loading_img('position:absolute;top:5px;left:5px', 'mv_img_loader') |
| 548 | + ); |
| 549 | + //get an edittoken: |
| 550 | + var reqObj = {'action':'query','prop':'info','intoken':'edit','titles': rObj.titleKey }; |
| 551 | + do_api_req( reqObj, cp.api_url,function(data){ |
| 552 | + js_log('edit token: ' + data.page[0]['edittoken']); |
| 553 | + }); |
| 554 | + |
| 555 | + }); |
| 556 | + } |
| 557 | + }); |
| 558 | + } |
| 559 | + }, |
| 560 | + previewResource:function( rObj ){ |
| 561 | + var _this = this; |
| 562 | + this.checkImportResource( rObj, function(){ |
| 563 | + //put another window ontop: |
| 564 | + $j( '#'+ _this.target_id ).append('<div id="rsd_resource_preview" '+ |
| 565 | + 'style="position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#FFF;">' + |
| 566 | + '<h3>preview resource: ' + rObj.title + '</h3>'+ |
| 567 | + '<div id="rsd_preview_display" style="position:absolute;width:100%;bottom:30px;>'+ |
| 568 | + mv_get_loading_img('position:absolute;top:30px;left:30px', 'mv_img_loader') + |
| 569 | + '</div>'+ |
| 570 | + '<div id="rsd_preview_control" style="position:absolute;width:60%;left:40%;bottom:0px;height:30px;">'+ |
| 571 | + '<input type="button" id="preview_do_insert" value="Do Insert">'+ |
| 572 | + '<a href="#" id="preview_close">Close Preview</a>'+ |
| 573 | + '</div>'+ |
| 574 | + '</div>'); |
| 575 | + //add bindings: |
| 576 | + $j('#preview_do_insert').click(function(){ |
| 577 | + _this.insertResource( rObj ); |
| 578 | + }); |
| 579 | + $j('#preview_close').click(function(){ |
| 580 | + $j('#rsd_resource_preview').remove(); |
| 581 | + }); |
| 582 | + }); |
| 583 | + }, |
| 584 | + getParsedWikiText:function( wikitext, title, callback ){ |
| 585 | + var reqObj = { |
| 586 | + 'action':'parse', |
| 587 | + 'text':wikitext |
| 588 | + }; |
| 589 | + do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
| 590 | + callback( data.parse['*'] ); |
| 591 | + }); |
| 592 | + }, |
| 593 | + insertResource:function( rObj){ |
| 594 | + |
| 595 | + }, |
295 | 596 | setResultBarControl:function( ){ |
296 | 597 | var _this = this; |
297 | 598 | var box_dark_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon_dark.png'; |
— | — | @@ -364,6 +665,7 @@ |
365 | 666 | var rsd_default_rss_item_mapping = { |
366 | 667 | 'poster' : 'media:thumbnail@url', |
367 | 668 | 'roe_url' : 'media:roe_embed@url', |
| 669 | + 'title' : 'title', |
368 | 670 | 'link' : 'link', |
369 | 671 | 'desc' : 'description' |
370 | 672 | } |
— | — | @@ -387,7 +689,7 @@ |
388 | 690 | /* |
389 | 691 | * Parses and adds video rss based input format |
390 | 692 | * @data XML data to parse |
391 | | - * @provider_url the source url (used to gennerate absolute links) |
| 693 | + * @provider_url the source url (used to generate absolute links) |
392 | 694 | */ |
393 | 695 | addRSSData:function( data , provider_url ){ |
394 | 696 | var _this = this; |
— | — | @@ -436,15 +738,16 @@ |
437 | 739 | rObj[p] = http_host + http_path + rObj[p]; |
438 | 740 | } |
439 | 741 | } |
440 | | - } |
| 742 | + } |
| 743 | + //add pointer to parent serach obj: |
| 744 | + rObj['pSobj'] = _this; |
| 745 | + //add the result to the result set: |
441 | 746 | _this.resultsObj[inx] = rObj; |
442 | 747 | }); |
443 | 748 | }, |
444 | | - /* |
445 | | - * by default just retun the desc unmodified |
446 | | - */ |
447 | | - specialFormatDesc:function( desc_html) { |
448 | | - return desc_html; |
| 749 | + //by default just retrun the existing image: |
| 750 | + getImageObj:function( rObj, size, callback){ |
| 751 | + callback( {'url':rObj.poster} ); |
449 | 752 | } |
450 | 753 | } |
451 | 754 | /* |
— | — | @@ -454,7 +757,7 @@ |
455 | 758 | return this.init(initObj); |
456 | 759 | }; |
457 | 760 | metavidSearch.prototype = { |
458 | | - rObj:{ //set up the default request paramaters |
| 761 | + reqObj:{ //set up the default request paramaters |
459 | 762 | 'order':'recent', |
460 | 763 | 'feed_format':'rss' |
461 | 764 | }, |
— | — | @@ -469,6 +772,12 @@ |
470 | 773 | } |
471 | 774 | } |
472 | 775 | }, |
| 776 | + getImageObj:function( rObj, size, callback ){ |
| 777 | + js_log('metavidSearch:getImageObj:'+size + ' s:' + size ); |
| 778 | + //metavid uses a dynamic image request url: |
| 779 | + var pparts = this.parseURI( rObj.poster ); |
| 780 | + callback( {'url':rObj.poster} ); |
| 781 | + }, |
473 | 782 | getSearchResults:function(){ |
474 | 783 | var _this = this; |
475 | 784 | //start loading: |
— | — | @@ -477,10 +786,11 @@ |
478 | 787 | //proccess all options |
479 | 788 | url = this.cp.api_url; |
480 | 789 | //add on the req_param |
481 | | - for(var i in this.rObj){ |
482 | | - url += '&' + i + '=' + this.rObj[i]; |
| 790 | + for(var i in this.reqObj){ |
| 791 | + url += '&' + i + '=' + this.reqObj[i]; |
483 | 792 | } |
484 | 793 | //do basic query: |
| 794 | + this.last_query = $j('#rsd_q').val(); |
485 | 795 | url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val(); |
486 | 796 | do_request(url, function(data){ |
487 | 797 | //should have an xml rss data object: |
— | — | @@ -488,18 +798,7 @@ |
489 | 799 | //done loading: |
490 | 800 | _this.loading=0; |
491 | 801 | }); |
492 | | - }, |
493 | | - addRSSData:function(data, url){ |
494 | | - this.parent_addRSSData(data, url); |
495 | | - //special metavid rss feed proccessing: strip mv_rss_view_only |
496 | | - |
497 | | - }, |
498 | | - /* |
499 | | - * special format description output. |
500 | | - */ |
501 | | - specialFormatDesc:function( desc_html ){ |
502 | | - return desc_html; |
503 | | - } |
| 802 | + } |
504 | 803 | } |
505 | 804 | |
506 | 805 | var mediaWikiSearch = function( initObj ) { |
— | — | @@ -525,48 +824,62 @@ |
526 | 825 | this.resultsObj={}; |
527 | 826 | //do two queries against the Image / File / MVD namespace: |
528 | 827 | //build the image request object: |
529 | | - var rObj = { |
| 828 | + var reqObj = { |
530 | 829 | 'action':'query', |
531 | 830 | 'generator':'search', |
532 | | - 'gsrsearch': encodeURIComponent( $j('#'+this.target_input).val() ), |
| 831 | + 'gsrsearch': encodeURIComponent( $j('#rsd_q').val() ), |
533 | 832 | 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) |
534 | 833 | 'gsrwhat':'title', |
| 834 | + 'gsrlimit':30, |
535 | 835 | 'prop':'imageinfo|revisions|categories', |
536 | | - 'iiprop':'url', |
537 | | - 'iiurlwidth':'80', |
| 836 | + 'iiprop':'url|mime', |
| 837 | + 'iiurlwidth': parseInt( this.rsd.thumb_width ), |
538 | 838 | 'rvprop':'content' |
539 | 839 | }; |
540 | 840 | //set up the number of request: |
541 | 841 | this.completed_req=0; |
542 | | - this.num_req=2; |
| 842 | + this.num_req=1; |
| 843 | + this.last_query = $j('#rsd_q').val(); |
543 | 844 | //setup the number of requests result flag: |
544 | | - do_api_req( rObj, this.cp.api_url , function(data){ |
| 845 | + //do_api_req( reqObj, this.cp.api_url , function(data){ |
545 | 846 | //parse the return data |
546 | | - _this.addResults( data); |
547 | | - _this.checkRequestDone(); |
548 | | - }); |
| 847 | + // _this.addResults( data); |
| 848 | + // _this.checkRequestDone(); |
| 849 | + //}); |
549 | 850 | //also do a request for page titles (would be nice if api could query both at the same time) |
550 | | - rObj['gsrwhat']='text'; |
551 | | - do_api_req( rObj, this.cp.api_url , function(data){ |
| 851 | + reqObj['gsrwhat']='text'; |
| 852 | + do_api_req( reqObj, this.cp.api_url , function(data){ |
552 | 853 | //parse the return data |
553 | 854 | _this.addResults( data); |
554 | | - _this.checkRequestDone(); |
| 855 | + //_this.checkRequestDone(); //only need if we do two queries one for title one for text |
| 856 | + _this.loading = false; |
555 | 857 | }); |
556 | | - }, |
| 858 | + }, |
557 | 859 | addResults:function( data ){ |
| 860 | + var _this = this |
558 | 861 | //make sure we have pages to idoerate: |
559 | 862 | if(data.query && data.query.pages){ |
560 | 863 | for(var page_id in data.query.pages){ |
561 | 864 | var page = data.query.pages[ page_id ]; |
562 | 865 | this.resultsObj[page_id]={ |
563 | | - 'uri':page.title, |
564 | | - 'poster':page.imageinfo.thumburl, |
| 866 | + 'titleKey':page.title, |
| 867 | + 'link':'null', |
| 868 | + 'title':page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv/ig, ''), |
| 869 | + 'poster':page.imageinfo[0].thumburl, |
| 870 | + 'thumbwidth':page.imageinfo[0].thumbwidth, |
| 871 | + 'thumbheight':page.imageinfo[0].thumbheight, |
| 872 | + 'mime':page.imageinfo[0].mime, |
565 | 873 | 'src':page.imageinfo.url, |
566 | | - 'desc':page.revisions[0]['*'], |
| 874 | + 'desc':page.revisions[0]['*'], |
| 875 | + //add pointer to parent serach obj: |
| 876 | + 'pSobj':_this, |
567 | 877 | 'meta':{ |
568 | 878 | 'categories':page.categories |
569 | 879 | } |
570 | 880 | } |
| 881 | + for(var i in this.resultsObj[page_id]){ |
| 882 | + //js_log('added '+ i +' '+ this.resultsObj[page_id][i]); |
| 883 | + } |
571 | 884 | } |
572 | 885 | }else{ |
573 | 886 | js_log('no results:' + data); |
— | — | @@ -579,5 +892,76 @@ |
580 | 893 | if(this.completed_req == this.num_req){ |
581 | 894 | this.loading = 0; |
582 | 895 | } |
| 896 | + }, |
| 897 | + getImageObj:function( rObj, size, callback ){ |
| 898 | + //build the query to get the req size image: |
| 899 | + var reqObj = { |
| 900 | + 'action':'query', |
| 901 | + 'format':'json', |
| 902 | + 'titles':rObj.titleKey, |
| 903 | + 'prop':'imageinfo', |
| 904 | + 'iiprop':'url|size|mime' |
| 905 | + } |
| 906 | + //set the width: |
| 907 | + if(size.width) |
| 908 | + reqObj['iiurlwidth']= size.width; |
| 909 | + |
| 910 | + do_api_req( reqObj, this.cp.api_url , function(data){ |
| 911 | + var imObj = {}; |
| 912 | + for(var page_id in data.query.pages){ |
| 913 | + var iminfo = data.query.pages[ page_id ].imageinfo[0]; |
| 914 | + //check if thumb size > than image size and is jpeg or png (it will not scale well above its max res) |
| 915 | + if( ( iminfo.mime=='image/jpeg' || iminfo=='image/png' ) && |
| 916 | + iminfo.thumbwidth > iminfo.width ){ |
| 917 | + imObj['url'] = iminfo.url; |
| 918 | + imObj['width'] = iminfo.width; |
| 919 | + imObj['height'] = iminfo.height; |
| 920 | + }else{ |
| 921 | + imObj['url'] = iminfo.thumburl; |
| 922 | + imObj['width'] = iminfo.thumbwidth; |
| 923 | + imObj['height'] = iminfo.thumbheight; |
| 924 | + } |
| 925 | + } |
| 926 | + js_log('getImageObj: get: ' + size.width + ' got url:' + imObj.url); |
| 927 | + callback( imObj ); |
| 928 | + }); |
| 929 | + }, |
| 930 | + //the insert image function |
| 931 | + insertImage:function( cEdit ){ |
| 932 | + if(!cEdit) |
| 933 | + var cEdit = _this.cEdit; |
| 934 | + }, |
| 935 | + getEmbedHTML: function( rObj , options) { |
| 936 | + //set up the output var with the default values: |
| 937 | + var outOpt = { 'width': rObj.width, 'height': rObj.height, 'src' : rObj.url}; |
| 938 | + if( options.max_height ){ |
| 939 | + outOpt.height = (options.max_height > rObj.height) ? rObj.height : options.max_height; |
| 940 | + outOpt.width = (rObj.width / rObj.height) *outOpt.height; |
| 941 | + } |
| 942 | + if(rObj.mime.indexOf('image')!=-1){ |
| 943 | + return '<img src="' + outOpt.src + '" style="width:' + outOpt.width + 'px;height:' + outOpt.height +'px">'; |
| 944 | + } |
| 945 | + js_log('ERROR:unsupored mime type: ' + rObj.mime); |
| 946 | + }, |
| 947 | + //returns the inline wikitext for insertion (template based crops for now) |
| 948 | + getEmbedWikiText: function( rObj , callback ){ |
| 949 | + //set default layout to right justified |
| 950 | + var layout = ( rObj.layout)? rObj.layout:"right" |
| 951 | + //if crop is null do simple output: |
| 952 | + if( rObj.crop == null) |
| 953 | + callback( '[[' + rObj.titleKey + '|layout' + '|'+rObj.width + 'px|' + rObj.inlineDesc + ']]' ); |
| 954 | + |
| 955 | + //using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop |
| 956 | + //should be replaced with server side cropping |
| 957 | + callback( '{{Preview Crop '+ |
| 958 | +'|Image = ' + rObj.titleKey + "\n" + |
| 959 | +'|bSize = ' + rObj.width + "\n" + |
| 960 | +'|cWidth = ' + rObj.crop.w + "\n" + |
| 961 | +'|cHeight = ' + rObj.crop.h + "\n" + |
| 962 | +'|oTop = ' + rObj.crop.y + "\n" + |
| 963 | +'|oLeft = ' + rObj.crop.x + "\n" + |
| 964 | +'|Location =' + layout + "\n" + |
| 965 | +'|Description =' + rObj.inlineDesc + "\n" + |
| 966 | +'}}'); |
583 | 967 | } |
584 | 968 | } |
\ No newline at end of file |