From b94a4821e2331071e3fc45de84ba3caa4a522d3e Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 28 Aug 2009 03:53:17 +0000 Subject: [PATCH] * improved inline AMW upload --- .../libAddMedia/mvBaseUploadInterface.js | 15 ++++++------ js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 8 +++---- .../libAddMedia/searchLibs/mediaWikiSearch.js | 3 ++- js2/mwEmbed/libAddMedia/simpleUploadForm.js | 24 ++++++++++++------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index ada2eddb91..a800bd2b4b 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -236,13 +236,13 @@ mvBaseUploadInterface.prototype = { //reset the done with action flag: _this.action_done = false; - js_log('run editForm submit()'); - var tmpAryData = $j('#mw-upload-form' ).serializeArray(); + /*js_log('run editForm submit()'); + var tmpAryData = $j(_this.editForm).serializeArray(); for(var i=0; i < tmpAryData.length; i++){ if( tmpAryData[i]['name'] ) js_log('name: ' + tmpAryData[i]['name'] + ' = ' + tmpAryData[i]['value']); - } - $j('#mw-upload-form').submit(); + }*/ + $j(_this.editForm).submit(); return false; }else if( _this.upload_mode == 'api' && $j('#wpSourceTypeURL').get(0).checked){ @@ -568,7 +568,7 @@ mvBaseUploadInterface.prototype = { js_log('ignorewarning req:') //re-inciate the upload proccess $j('#wpIgnoreWarning').attr('checked', true); - $j( '#mw-upload-form' ).submit(); + $j( _this.editForm ).submit(); }; bObj[ gM('mwe-return-to-form') ] = function(){ $j(this).dialog('close'); @@ -608,7 +608,8 @@ mvBaseUploadInterface.prototype = { //close up shop: $j('#upProgressDialog').dialog('close'); //call the callback: - _this.done_upload_cb( url ); + _this.done_upload_cb( apiRes.upload ); + return false; }else{ var bObj = {}; bObj[ gM('mwe-return-to-form')] = function(){ @@ -621,8 +622,8 @@ mvBaseUploadInterface.prototype = { _this.action_done = true; _this.updateProgressWin( gM('mwe-successfulupload'), gM( 'mwe-upload_done', url), bObj); js_log('apiRes.upload.imageinfo::'+url); + return true; } - return ; } } }, diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index c54662768d..23f1747956 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -443,7 +443,7 @@ remoteSearchDriver.prototype = { var _this = this; //add the parent target_container if not provided or missing if(!_this.target_container || $j(_this.target_container).length==0){ - $j('body').append('
'); + $j('body').append('
'); _this.target_container = '#rsd_modal_target'; //js_log('appended: #rsd_modal_target' + $j(_this.target_container).attr('id')); //js_log('added target id:' + $j(_this.target_container).attr('id')); @@ -636,11 +636,11 @@ remoteSearchDriver.prototype = { //deal with the api form upload form directly: $j('#upload_form').simpleUploadForm({ "api_target" : _this.upload_api_target , - "ondone_cb" : function( resultData ){ - var wTitle = resultData['wpDestFile']; + "ondone_cb" : function( resultData ){ + var wTitle = resultData['filename']; //add a loading div _this.addResourceEditLoader(); - + //@@note: we have most of what we need in resultData imageinfo cp.sObj.addByTitle( wTitle, function( rObj ){ //redraw (with added result if new) _this.drawOutputResults(); diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index b7223ffc00..b1c14adb7e 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -16,6 +16,7 @@ mediaWikiSearch.prototype = { }, //returns a rObj by title addByTitle:function( title , callback){ + js_log("AddByTitle::" + title); var _this = this; var reqObj = { 'action':'query', @@ -28,7 +29,7 @@ mediaWikiSearch.prototype = { do_api_req( { 'data':reqObj, 'url':this.cp.api_url - }, function(data){ + }, function(data){ callback( _this.addSingleResult(data) ); } ); diff --git a/js2/mwEmbed/libAddMedia/simpleUploadForm.js b/js2/mwEmbed/libAddMedia/simpleUploadForm.js index 00d9237980..70325b2fd4 100644 --- a/js2/mwEmbed/libAddMedia/simpleUploadForm.js +++ b/js2/mwEmbed/libAddMedia/simpleUploadForm.js @@ -58,11 +58,17 @@ var default_form_options = { '
' + '
'+ - '
'+ + '
'+ '
' + - '