2 * the base Upload Interface for uploading.
4 * this base uploader is optionally extended by Firefogg
6 * @@todo: checkme: gM 'thumbnail-more' is used; only defined in MediaWiki core. Will that work properly?
9 "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)",
10 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
11 "mwe-upload-transcoded-status" : "Transcoded",
12 "mwe-uploaded-status" : "Uploaded",
13 "mwe-upload-stats-fileprogres" : "$1 of $2",
14 "mwe-upload_completed" : "Your upload is complete",
15 "mwe-upload_done" : "<a href=\"$1\">Your upload <i>should be<\/i> accessible<\/a>.",
16 "mwe-upload-unknown-size" : "Unknown size",
17 "mwe-cancel-confim" : "Are you sure you want to cancel?",
18 "mwe-successfulupload" : "Upload successful",
19 "mwe-uploaderror" : "Upload error",
20 "mwe-uploadwarning" : "Upload warning",
21 "mwe-unknown-error" : "Unknown error:",
22 "mwe-return-to-form" : "Return to form",
23 "mwe-file-exists-duplicate" : "This file is a duplicate of the following file:",
24 "mwe-fileexists" : "A file with this name exists already. Please check <b><tt>$1<\/tt><\/b> if you are not sure if you want to change it.",
25 "mwe-fileexists-thumb" : "<center><b>Existing file<\/b><\/center>",
26 "mwe-ignorewarning" : "Ignore warning and save file anyway",
27 "mwe-file-thumbnail-no" : "The filename begins with <b><tt>$1<\/tt><\/b>",
28 "mwe-go-to-resource" : "Go to resource page",
29 "mwe-upload-misc-error" : "Unknown upload error",
30 "mwe-wgfogg_warning_bad_extension" : "You have selected a file with an unsuported extension (<a href=\"http:\/\/commons.wikimedia.org\/wiki\/Commons:Firefogg#Supported_File_Types\">more information<\/a>).",
31 "mwe-cancel-button" : "Cancel",
32 "mwe-ok-button" : "OK"
35 var default_bui_options
= {
37 'parent_uploader':null,
39 'done_upload_cb': null,
40 'target_edit_from':null,
42 //default upload mode is 'api' but if no api_url will try tp post
46 var mvBaseUploadInterface = function( iObj
){
47 return this.init( iObj
);
49 mvBaseUploadInterface
.prototype = {
50 parent_uploader
:false,
51 formData
:{}, //the form to be submitted
52 warnings_sessionkey
:null,
53 chunks_supported
:false,
54 form_post_override
:false,
58 init: function( iObj
){
61 //inherit iObj properties:
62 for(var i
in default_bui_options
){
66 this[i
] = default_bui_options
[i
];
72 //set up the local pointer to the edit form:
73 _this
.editForm
= _this
.getEditForm();
76 //if in api re-map the upload form to api: (we have to do this BEFORE the users selects a file)
77 if(_this
.upload_mode
== 'api'){
78 _this
.doRemapFormToApi();
81 //set up the org_onsubmit if not set:
82 if( typeof( _this
.org_onsubmit
) == 'undefined' && _this
.editForm
.onsubmit
)
83 _this
.org_onsubmit
= _this
.editForm
.onsubmit
;
85 //set up the submit action:
86 $j( _this
.editForm
).submit( function(){
87 js_log('setupForm.onSubmit:');
88 //run the original onsubmit (if not run yet set flag to avoid excessive chaining )
89 if( typeof( _this
.org_onsubmit
) == 'function' ){
90 if( ! _this
.org_onsubmit() ){
91 //error in org submit return false;
95 //check for post action override:
96 if( _this
.form_post_override
){
97 js_log('form_post_override is true do form proccessing:');
100 //get the input form data in flat json:
101 js_log('update formData::');
102 var tmpAryData
= $j( _this
.editForm
).serializeArray();
103 for(var i
=0; i
< tmpAryData
.length
; i
++){
104 if( tmpAryData
[i
]['name'] )
105 _this
.formData
[ tmpAryData
[i
]['name'] ] = tmpAryData
[i
]['value'];
107 //put into a try catch so we are sure to return false:
109 //get a clean loader:
110 _this
.dispProgressOverlay();
112 //for some unknown reason we have to drop down the #p-search z-index:
113 $j('#p-search').css('z-index', 1);
115 //select upload mode:
116 _this
.detectUploadMode();
118 js_log('::error in dispProgressOverlay or detectUploadMode');
121 //don't submit the form we will do the post in ajax
127 detectUploadMode:function( callback
){
129 js_log('detectUploadMode::' + _this
.upload_mode
);
130 //check the upload mode:
131 if( _this
.upload_mode
== 'autodetect' ){
132 js_log('detectUploadMode::' + _this
.upload_mode
+ ' api:' + _this
.api_url
);
133 if( ! _this
.api_url
)
134 return js_error( 'Error: can\'t autodetect mode without api url' );
136 'data': { 'action' : 'paraminfo', 'modules' : 'upload' },
137 'url' : _this
.api_url
139 if( typeof data
.paraminfo
== 'undefined' || typeof data
.paraminfo
.modules
== 'undefined' )
140 return js_error( 'Error: bad api results' );
141 if( typeof data
.paraminfo
.modules
[0].classname
== 'undefined'){
142 js_log( 'Autodetect Upload Mode: \'post\' ');
143 _this
.upload_mode
= 'post';
145 js_log( 'Autodetect Upload Mode: api ' );
146 _this
.upload_mode
= 'api';
147 //check to see if chunks are supported:
148 for( var i
in data
.paraminfo
.modules
[0].parameters
){
149 var pname
= data
.paraminfo
.modules
[0].parameters
[i
].name
;
150 if( pname
== 'enablechunks' ){
151 js_log( 'this.chunks_supported = true' );
152 _this
.chunks_supported
= true;
157 js_log("do call: doUploadSwitch");
158 _this
.doUploadSwitch();
161 _this
.doUploadSwitch();
164 //@@NOTE this could probably be depricated to just have a special:upload page that uses api keys?
165 // or maybe its usefull to seperate js and non-js submits
166 doRemapFormToApi:function(){
172 $j(_this
.editForm
).attr('action', _this
.api_url
);
176 if( $j(_this
.editForm
).find("[name='action']").length
== 0)
177 $j(_this
.editForm
).append('<input type="hidden" name="action" value="upload">');
180 if( $j(_this
.editForm
).find("[name='format']").length
== 0)
181 $j(_this
.editForm
).append('<input type="hidden" name="format" value="jsonfm">');
183 //map a new hidden form
184 $j(_this
.editForm
).find("[name='wpUploadFile']").attr('name', 'file');
185 $j(_this
.editForm
).find("[name='wpDestFile']").attr('name', 'filename');
186 $j(_this
.editForm
).find("[name='wpUploadDescription']").attr('name', 'comment');
187 $j(_this
.editForm
).find("[name='wpEditToken']").attr('name', 'token');
188 $j(_this
.editForm
).find("[name='wpIgnoreWarning']").attr('name', 'ignorewarnings');
189 $j(_this
.editForm
).find("[name='wpWatchthis']").attr('name', 'watch');
191 //update the status to 100% progress bar (no status in iframe submit)
192 $j('#up-progressbar' ).progressbar( 'value', parseInt( 100 ) );
193 $j('#up-status-container').html( gM('mwe-upload-in-progress') );
195 doUploadSwitch:function(){
197 js_log('mvUPload:doUploadSwitch():' + _this
.upload_mode
);
198 //issue a normal post request
199 if( _this
.upload_mode
== 'post' ) {
200 //we don't support the upload api
201 //trick the browser into thinking the wpUpload button was pressed (there might be a cleaner way to do this)
202 $j(_this
.editForm
).append(
203 '<input type="hidden" name="wpUpload" value="' + $j('input[name=\'wpUpload\']').val() + '"/>'
206 _this
.form_post_override
= true;
207 js_log('doUploadSwitch:: submit call');
209 _this
.editForm
.submit();
211 _this
.upload_mode
== 'api' &&
212 ( $j('#wpSourceTypeFile').length
== 0 || $j('#wpSourceTypeFile').get(0).checked
)
214 //@@TODO check for sendAsBinnary to support firefox 3.5 progress
216 //set the form target to iframe target:
217 _this
.iframeId
= 'f_' + ($j('iframe').length
+ 1);
219 $j("body").append('<iframe src="javascript:false;" id="' + _this
.iframeId
+ '" ' +
220 'name="' + _this
.iframeId
+ '" style="display:none;" ></iframe>');
221 $j(_this
.editForm
).attr('target', _this
.iframeId
);
223 //set up the done binding
224 $j('#' + _this
.iframeId
).load(function(){
225 _this
.proccessIframeResult( $j(this).get(0) );
227 //set the action to the api url:
228 $j(_this
.editForm
).attr('action', _this
.api_url
);
230 js_log('do iframe form submit to: ' + $j(_this
.editForm
).attr('target')
231 + ' destName:' + $j(_this
.editForm
).find("[name='filename']").val() );
235 _this
.form_post_override
= true;
236 //reset the done with action flag:
237 _this
.action_done
= false;
239 /*js_log('run editForm submit()');
240 var tmpAryData = $j(_this.editForm).serializeArray();
241 for(var i=0; i < tmpAryData.length; i++){
242 if( tmpAryData[i]['name'] )
243 js_log('name: ' + tmpAryData[i]['name'] + ' = ' + tmpAryData[i]['value']);
245 $j(_this
.editForm
).submit();
248 }else if( _this
.upload_mode
== 'api' && $j('#wpSourceTypeURL').get(0).checked
){
249 js_log('doHttpUpload (no form submit) ');
250 //if the api is supported.. && source type is http do upload with http status updates
252 'url' : $j('#wpUploadFileURL').val(),
253 'filename' : $j('#wpDestFile').val(),
254 'comment' : $j('#wpUploadDescription').val(),
255 'watch' : ($j('#wpWatchthis').is(':checked'))?'true':'false'
257 //set up ignore warnings and watch arguments:
258 if( $j('#wpIgnoreWarning').is(':checked') ){
259 httpUpConf
[ 'ignorewarnings'] = 'true';
261 if( $j('#wpWatchthis').is(':checked') ){
262 httpUpConf
[ 'watch'] = 'true';
264 //check for editToken
265 _this
.etoken
= $j("#wpEditToken").val();
266 _this
.doHttpUpload( httpUpConf
);
268 js_error( 'Error: unrecongized upload mode: ' + _this
.upload_mode
);
272 proccessIframeResult:function(iframe
){
274 var doc
= iframe
.contentDocument
? iframe
.contentDocument
: frames
[iframe
.id
].document
;
276 if (doc
.readyState
&& doc
.readyState
!= 'complete'){
280 if (doc
.body
&& doc
.body
.innerHTML
== "false"){
284 if (doc
.XMLDocument
){
285 // response is a xml document IE property
286 response
= doc
.XMLDocument
;
287 } else if (doc
.body
){
289 json_str
= $j(doc
.body
).find('pre').html();
290 js_log('iframe:json::' + json_str
+ "\nbody:" + $j(doc
.body
).html() );
293 response
= window
["eval"]("(" +json_str
+ ")");
298 // response is a xml document
301 //do proccess the api result
302 _this
.processApiResult( response
);
304 doHttpUpload:function( opt
){
306 //set the http box to loading (in case we don't get an update for some time)
307 $j('#dlbox-centered').html( '<h5>' + _this
.getProgressTitle() + '</h5>' +
308 mv_get_loading_img( 'left:40%;top:20%')
313 'asyncdownload' : true //do a s
315 //set config from options:
320 //else try and get a token:
321 if(!_this
.etoken
&& _this
.api_url
){
322 js_log('Error:doHttpUpload: missing token');
324 req
['token'] =_this
.etoken
;
326 //reset the done with action flag:
327 _this
.action_done
= false;
331 'url' : _this
.api_url
333 _this
.processApiResult( data
);
336 doAjaxWarningIgnore:function(){
338 if( !_this
.upload_session_key
)
339 return js_error('missing upload_session_key (can\'t ignore warnigns');
340 //do the ignore warnings submit to the api:
342 'ignorewarnings' : 'true',
343 'sessionkey' :!_this
.upload_session_key
345 //add token if present:
347 req
['token'] = this.etoken
;
353 _this
.processApiResult(data
);
356 doAjaxUploadStatus:function() {
359 //set up the progress display for status updates:
360 _this
.dispProgressOverlay();
363 'httpstatus' : 'true',
364 'sessionkey' : _this
.upload_session_key
366 //add token if present:
368 req
['token'] = this.etoken
;
370 var uploadStatus = function(){
371 //do the api request:
374 'url' : _this
.api_url
376 //@@check if we are done
377 if( data
.upload
['apiUploadResult'] ){
378 //update status to 100%
379 _this
.updateProgress( 1 );
380 if(typeof JSON
== 'undefined'){
381 //we need to load the jQuery json parser: (older browsers don't have JSON.parse
385 var apiResult
= $j
.secureEvalJSON( data
.upload
['apiUploadResult'] );
386 _this
.processApiResult( apiResult
);
391 apiResult
= JSON
.parse ( data
.upload
['apiUploadResult'] ) ;
393 //could not parse api result
394 js_log('errro: could not parse apiUploadResult ')
396 _this
.processApiResult( apiResult
);
401 //@@ else update status:
402 if( data
.upload
['content_length'] && data
.upload
['loaded'] ){
403 //we have content length we can show percentage done:
404 var perc
= data
.upload
['loaded'] / data
.upload
['content_length'];
406 _this
.updateProgress( perc
);
407 //special case update the file progress where we have data size:
408 $j('#up-status-container').html(
409 gM('mwe-upload-stats-fileprogres', [
410 formatSize( data
.upload
['loaded'] ),
411 formatSize( data
.upload
['content_length'] )
415 }else if( data
.upload
['loaded'] ){
416 _this
.updateProgress( 1 );
417 js_log('just have loaded (no cotent length: ' + data
.upload
['loaded']);
418 //for lack of content-length requests:
419 $j('#up-status-container').html(
420 gM('mwe-upload-stats-fileprogres', [
421 formatSize( data
.upload
['loaded'] ),
422 gM('mwe-upload-unknown-size')
427 //(we got a result) set it to 100ms + your server update interval (in our case 2s)
428 setTimeout(uploadStatus
, 2100);
433 apiUpdateErrorCheck:function( apiRes
){
435 if( apiRes
.error
|| ( apiRes
.upload
&& apiRes
.upload
.result
== "Failure" ) ){
436 //gennerate the error button:
438 bObj
[ gM('mwe-return-to-form') ] = function(){
439 _this
.form_post_override
= false;
440 $j(this).empty().dialog('close');
443 //@@TODO should be refactored to more specialUpload page type error handling
445 //check a few places for the error code:
447 var errorReplaceArg
='';
448 if( apiRes
.error
&& apiRes
.error
.code
){
449 error_code
= apiRes
.error
.code
;
450 }else if( apiRes
.upload
.code
){
451 if(typeof apiRes
.upload
.code
== 'object'){
452 if(apiRes
.upload
.code
[0]){
453 error_code
= apiRes
.upload
.code
[0];
455 if(apiRes
.upload
.code
['status']){
456 error_code
= apiRes
.upload
.code
['status'];
457 if(apiRes
.upload
.code
['filtered'])
458 errorReplaceArg
=apiRes
.upload
.code
['filtered'];
466 if(typeof apiRes
.error
== 'string')
467 error_msg
= apiRes
.error
;
468 //error space is too large so we don't front load it
469 //this upload error space replicates code in: SpecialUpload.php::processUpload()
470 //would be nice if we refactored that to the upload api.(problem is some need special actions)
471 var error_msg_key
= {
472 '2' : 'largefileserver',
475 '5' : 'illegalfilename'
478 //@@todo: need to write conditionals that mirror SpecialUpload for handling these error types:
479 var error_onlykey
= {
480 '1': 'BEFORE_PROCESSING',
481 '6': 'PROTECTED_PAGE',
482 '7': 'OVERWRITE_EXISTING_FILE',
483 '8': 'FILETYPE_MISSING',
484 '9': 'FILETYPE_BADTYPE',
485 '10': 'VERIFICATION_ERROR',
486 '11': 'UPLOAD_VERIFICATION_ERROR',
487 '12': 'UPLOAD_WARNING',
488 '13': 'INTERNAL_ERROR',
489 '14': 'MIN_LENGHT_PARTNAME'
492 //do a remote call to get the error msg:
493 if(!error_code
|| error_code
== 'unknown-error'){
494 if(typeof JSON
!= 'undefined'){
495 js_log('Error: apiRes: ' + JSON
.stringify( apiRes
) );
497 if( apiRes
.upload
.error
== 'internal-error'){
498 errorKey
= apiRes
.upload
.details
[0];
499 gMsgLoadRemote(errorKey
, function(){
500 _this
.updateProgressWin( gM( 'mwe-uploaderror' ), gM( errorKey
), bObj
);
506 _this
.updateProgressWin( gM('mwe-uploaderror'), gM('mwe-unknown-error') + '<br>' + error_msg
, bObj
);
509 if(apiRes
.error
&& apiRes
.error
.info
){
510 _this
.updateProgressWin( gM('mwe-uploaderror'), apiRes
.error
.info
,bObj
);
513 if(typeof error_code
== 'number' && typeof error_msg_key
[error_code
] == 'undefined' ){
514 if(apiRes
.upload
.code
.finalExt
){
515 _this
.updateProgressWin( gM('mwe-uploaderror'), gM('mwe-wgfogg_warning_bad_extension', apiRes
.upload
.code
.finalExt
) , bObj
);
517 _this
.updateProgressWin( gM('mwe-uploaderror'), gM('mwe-unknown-error') + ' : ' + error_code
, bObj
);
520 js_log('get key: ' + error_msg_key
[ error_code
])
521 gMsgLoadRemote( error_msg_key
[ error_code
], function(){
522 _this
.updateProgressWin( gM('mwe-uploaderror'), gM( error_msg_key
[ error_code
], errorReplaceArg
), bObj
);
530 //check for upload.error type erros.
531 if( apiRes
.upload
&& apiRes
.upload
.error
){
532 js_log(' apiRes.upload.error: ' + apiRes
.upload
.error
);
533 _this
.updateProgressWin( gM('mwe-uploaderror'), gM('mwe-unknown-error') + '<br>', bObj
);
536 //check for known warnings:
537 if(apiRes
.upload
&& apiRes
.upload
.warnings
){
540 for(var wtype
in apiRes
.upload
.warnings
){
541 var winfo
= apiRes
.upload
.warnings
[wtype
]
546 if(winfo
[1] && winfo
[1].title
&& winfo
[1].title
.mTextform
){
547 wmsg
+= gM('mwe-file-exists-duplicate') +' '+
548 '<b>' + winfo
[1].title
.mTextform
+ '</b>';
550 //misc error (weird that winfo[1] not present
551 wmsg
+= gM('mwe-upload-misc-error') + ' ' + wtype
;
554 case 'file-thumbnail-no':
555 wmsg
+= gM('mwe-file-thumbnail-no', winfo
);
558 wmsg
+= gM('mwe-upload-misc-error') + ' ' + wtype
;
564 if( apiRes
.upload
.warnings
.sessionkey
)
565 _this
.warnings_sessionkey
= apiRes
.upload
.warnings
.sessionkey
;
567 bObj
[ gM('mwe-ignorewarning') ] = function() {
568 js_log('ignorewarning req:')
569 //re-inciate the upload proccess
570 $j('#wpIgnoreWarning').attr('checked', true);
571 $j( _this
.editForm
).submit();
573 bObj
[ gM('mwe-return-to-form') ] = function(){
574 $j(this).empty().dialog('close');
575 _this
.form_post_override
= false;
577 _this
.updateProgressWin( gM('mwe-uploadwarning'), '<h3>' + gM('mwe-uploadwarning') + '</h3>' +wmsg
+ '<p>',bObj
);
583 processApiResult: function( apiRes
){
585 js_log('processApiResult::');
586 //check for upload api error:
587 // {"upload":{"result":"Failure","error":"unknown-error","code":{"status":5,"filtered":"NGC2207%2BIC2163.jpg"}}}
588 if( _this
.apiUpdateErrorCheck(apiRes
) === false){
589 //error returned false (updated and
592 //check for upload_session key for async upload:
593 if( apiRes
.upload
&& apiRes
.upload
.upload_session_key
){
594 //set the session key
595 _this
.upload_session_key
= apiRes
.upload
.upload_session_key
;
597 //do ajax upload status:
598 _this
.doAjaxUploadStatus();
599 js_log("set upload_session_key: " + _this
.upload_session_key
);
603 if( apiRes
.upload
.imageinfo
&& apiRes
.upload
.imageinfo
.descriptionurl
){
604 var url
= apiRes
.upload
.imageinfo
.descriptionurl
;
606 if( _this
.done_upload_cb
&& typeof _this
.done_upload_cb
== 'function'){
607 js_log("call done_upload_cb");
609 $j('#upProgressDialog').empty().dialog('close');
611 _this
.done_upload_cb( apiRes
.upload
);
615 bObj
[ gM('mwe-return-to-form')] = function(){
616 $j(this).empty().dialog('close');
617 _this
.form_post_override
= false;
619 bObj
[ gM('mwe-go-to-resource') ] = function(){
620 window
.location
= url
;
622 _this
.action_done
= true;
623 _this
.updateProgressWin( gM('mwe-successfulupload'), gM( 'mwe-upload_done', url
), bObj
);
624 js_log('apiRes.upload.imageinfo::'+url
);
630 updateProgressWin:function(title_txt
, msg
, buttons
){
633 title_txt
= _this
.getProgressTitle();
635 msg
= mv_get_loading_img( 'left:40%;top:40px;');
636 $j( '#upProgressDialog' ).dialog('option', 'title', title_txt
);
637 $j( '#upProgressDialog' ).html( msg
);
639 $j('#upProgressDialog').dialog('option','buttons', buttons
);
641 //@@todo should fix jquery ui to not use object keys as user msg's
643 bObj
[ gM('mwe-ok-button') ] = function(){
644 $j(this).empty().dialog('close');
646 $j('#upProgressDialog').dialog('option','buttons', bObj
);
649 getProgressTitle:function(){
650 return gM('mwe-upload-in-progress');
652 getEditForm:function(){
653 if( this.target_edit_from
&& $j( this.target_edit_from
).length
!= 0){
654 return $j( this.target_edit_from
).get(0);
656 //just return the first form fond on the page.
657 return $j('form :first').get(0);
659 updateProgress:function( perc
){
660 //js_log('update progress: ' + perc);
661 $j( '#up-progressbar' ).progressbar('value', parseInt( perc
* 100 ) );
662 $j( '#up-pstatus' ).html( parseInt( perc
* 100 ) + '% - ' );
664 /*update to jQuery.ui progress display type */
665 dispProgressOverlay:function(){
668 //remove old instance:
669 if($j('#upProgressDialog').length
!=0 ){
670 $j('#upProgressDialog').dialog( 'destroy' ).remove();
673 $j('body').append('<div id="upProgressDialog" ></div>');
675 $j('#upProgressDialog').dialog({
676 title
:_this
.getProgressTitle(),
682 beforeclose: function(event
, ui
) {
683 if( event
.button
==0 && _this
.action_done
=== false){
684 return _this
.cancel_action();
686 //click on button (dont do close action);
690 buttons
: _this
.cancel_button()
692 $j('#upProgressDialog').html(
693 '<div id="up-pbar-container" style="width:90%;height:15px;" >' +
694 '<div id="up-progressbar" style="height:15px;"></div>' +
695 '<div id="up-status-container">'+
696 '<span id="up-pstatus">0% - </span> ' +
697 '<span id="up-status-state">' + gM('mwe-uploaded-status') + '</span> ' +
701 //just display an empty progress window
702 $j('#upProgressDialog').dialog('open');
704 //setup progress bar:
705 $j('#up-progressbar').progressbar({
709 cancel_button:function(){
711 var cancelBtn
= new Array();
712 cancelBtn
[ gM('mwe-cancel-button') ] = function(){
713 return _this
.cancel_action(this)
717 cancel_action : function( dlElm
){
719 if( confirm( gM('mwe-cancel-confim') )){
720 //@@todo (cancel the encode / upload)
721 $j(this).empty().dialog('close');
729 //add some jquery binding helpers
732 * doDestCheck checks the destination
734 $.fn
.doDestCheck = function( opt
){
736 js_log('doDestCheck::' + _this
.selector
);
738 //set up option defaults;
740 opt
.warn_target
= '#wpDestFile-warning';
743 $j( opt
.warn_target
).empty();
746 $j( _this
.selector
).append('<img id="mw-spinner-wpDestFile" src ="'+ stylepath
+ '/common/images/spinner.gif" />');
748 //try and get a thumb of the current file (check its destination)
751 'titles': 'File:' + $j(_this
.selector
).val(),//@@todo we may need a more clever way to get a the filename
753 'iiprop':'url|mime|size',
758 $j('#mw-spinner-wpDestFile').remove();
759 if(data
&& data
.query
&& data
.query
.pages
){
760 if( data
.query
.pages
[-1] ){
761 //all good no file there
763 for(var page_id
in data
.query
.pages
){
764 var ntitle
= ( data
.query
.normalized
)? data
.query
.normalized
[0].to
: data
.query
.pages
[ page_id
].title
765 var img
= data
.query
.pages
[ page_id
].imageinfo
[0];
766 $j('#wpDestFile-warning').html(
769 gM('mwe-fileexists', ntitle
) +
771 '<div class="thumb tright">' +
772 '<div style="width: ' + ( parseInt(img
.thumbwidth
)+2 ) + 'px;" class="thumbinner">' +
773 '<a title="' + ntitle
+ '" class="image" href="' + img
.descriptionurl
+ '">' +
774 '<img width="' + img
.thumbwidth
+ '" height="' + img
.thumbheight
+ '" border="0" class="thumbimage" ' +
775 'src="' + img
.thumburl
+ '"' +
776 ' alt="' + ntitle
+ '"/>' +
778 '<div class="thumbcaption">' +
779 '<div class="magnify">' +
780 '<a title="' + gM('thumbnail-more') + '" class="internal" ' +
781 'href="' + img
.descriptionurl
+'"><img width="15" height="11" alt="" ' +
782 'src="' + stylepath
+ "/common/images/magnify-clip.png\" />" +
785 gM('mwe-fileexists-thumb') +