r55645 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55644‎ | r55645 | r55646 >
Date:03:53, 28 August 2009
Author:dale
Status:deferred
Tags:
Comment:
* improved inline AMW upload
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js
@@ -16,6 +16,7 @@
1717 },
1818 //returns a rObj by title
1919 addByTitle:function( title , callback){
 20+ js_log("AddByTitle::" + title);
2021 var _this = this;
2122 var reqObj = {
2223 'action':'query',
@@ -28,7 +29,7 @@
2930 do_api_req( {
3031 'data':reqObj,
3132 'url':this.cp.api_url
32 - }, function(data){
 33+ }, function(data){
3334 callback( _this.addSingleResult(data) );
3435 }
3536 );
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -443,7 +443,7 @@
444444 var _this = this;
445445 //add the parent target_container if not provided or missing
446446 if(!_this.target_container || $j(_this.target_container).length==0){
447 - $j('body').append('<div id="rsd_modal_target" style="position:absolute;top:30px;left:0px;bottom:45px;right:0px;" title="' + gM('mwe-add_media_wizard') + '" ></div>');
 447+ $j('body').append('<div id="rsd_modal_target" style="position:absolute;top:30px;left:0px;bottom:33px;right:0px;" title="' + gM('mwe-add_media_wizard') + '" ></div>');
448448 _this.target_container = '#rsd_modal_target';
449449 //js_log('appended: #rsd_modal_target' + $j(_this.target_container).attr('id'));
450450 //js_log('added target id:' + $j(_this.target_container).attr('id'));
@@ -636,11 +636,11 @@
637637 //deal with the api form upload form directly:
638638 $j('#upload_form').simpleUploadForm({
639639 "api_target" : _this.upload_api_target ,
640 - "ondone_cb" : function( resultData ){
641 - var wTitle = resultData['wpDestFile'];
 640+ "ondone_cb" : function( resultData ){
 641+ var wTitle = resultData['filename'];
642642 //add a loading div
643643 _this.addResourceEditLoader();
644 -
 644+ //@@note: we have most of what we need in resultData imageinfo
645645 cp.sObj.addByTitle( wTitle, function( rObj ){
646646 //redraw (with added result if new)
647647 _this.drawOutputResults();
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js
@@ -58,11 +58,17 @@
5959 '<input id="wpUploadFile" type="file" style="display: inline;" name="wpUploadFile" size="15"/><br>' +
6060
6161 '<label for="wpDestFile">' +gM('mwe-destfilename') + '</label><br>'+
62 - '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
 62+ '<input id="wpDestFile" type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
6363
6464 '<label for="wpUploadDescription">' + gM('mwe-summary') + ':</label><br>' +
65 - '<textarea cols="30" rows="3" name="wpUploadDescription" tabindex="3"/><br>'+
66 -
 65+ '<textarea id="wpUploadDescription" cols="30" rows="3" name="wpUploadDescription" tabindex="3"/><br>'+
 66+
 67+ '<input type="checkbox" value="true" id="wpWatchthis" name="watch" tabindex="7"/>'+
 68+ '<label for="wpWatchthis">Watch this file</label>'+
 69+
 70+ '<input type="checkbox" value="true" id="wpIgnoreWarning" name="ignorewarnings" tabindex="8"/>'+
 71+ '<label for="wpIgnoreWarning">Ignore any warnings</label></br>'+
 72+
6773 '<div id="wpDestFile-warning"></div>' +
6874 '<div style="clear:both;"></div>' +
6975
@@ -89,7 +95,7 @@
9096 });
9197 //do destination fill:
9298 //@@should integrate with doDestinationFill on upload page
93 - $j("#suf-upload [name='wpUploadFile']").change(function(){
 99+ $j("#wpUploadFile").change(function(){
94100 var path = $j(this).val();
95101 // Find trailing part
96102 var slash = path.lastIndexOf('/');
@@ -104,17 +110,17 @@
105111 }
106112 fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
107113 // Output result
108 - $j("#suf-upload [name='wpDestFile']").val( fname );
 114+ $j("#wpDestFile").val( fname );
109115 //do destination check
110 - $j("#suf-upload [name='wpDestFile']").doDestCheck({
 116+ $j("#wpDestFile").doDestCheck({
111117 'warn_target':'#wpDestFile-warning'
112118 });
113119 });
114120
115121
116122 //do destination check:
117 - $j("[name='wpDestFile']").change(function(){
118 - $j(this).doDestCheck({
 123+ $j("#wpDestFile").change(function(){
 124+ $j("#wpDestFile").doDestCheck({
119125 'warn_target':'#wpDestFile-warning'
120126 });
121127 });
@@ -130,7 +136,7 @@
131137 'form_rewrite': true,
132138 'target_edit_from' : '#suf-upload',
133139 'new_source_cb' : function( orgFilename, oggName ){
134 - $j("#suf-upload [name='wpDestFile']").val( oggName ).doDestCheck({
 140+ $j("#wpDestFile").val( oggName ).doDestCheck({
135141 warn_target: "#wpDestFile-warning"
136142 });
137143 },
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -236,13 +236,13 @@
237237 //reset the done with action flag:
238238 _this.action_done = false;
239239
240 - js_log('run editForm submit()');
241 - var tmpAryData = $j('#mw-upload-form' ).serializeArray();
 240+ /*js_log('run editForm submit()');
 241+ var tmpAryData = $j(_this.editForm).serializeArray();
242242 for(var i=0; i < tmpAryData.length; i++){
243243 if( tmpAryData[i]['name'] )
244244 js_log('name: ' + tmpAryData[i]['name'] + ' = ' + tmpAryData[i]['value']);
245 - }
246 - $j('#mw-upload-form').submit();
 245+ }*/
 246+ $j(_this.editForm).submit();
247247
248248 return false;
249249 }else if( _this.upload_mode == 'api' && $j('#wpSourceTypeURL').get(0).checked){
@@ -568,7 +568,7 @@
569569 js_log('ignorewarning req:')
570570 //re-inciate the upload proccess
571571 $j('#wpIgnoreWarning').attr('checked', true);
572 - $j( '#mw-upload-form' ).submit();
 572+ $j( _this.editForm ).submit();
573573 };
574574 bObj[ gM('mwe-return-to-form') ] = function(){
575575 $j(this).dialog('close');
@@ -608,7 +608,8 @@
609609 //close up shop:
610610 $j('#upProgressDialog').dialog('close');
611611 //call the callback:
612 - _this.done_upload_cb( url );
 612+ _this.done_upload_cb( apiRes.upload );
 613+ return false;
613614 }else{
614615 var bObj = {};
615616 bObj[ gM('mwe-return-to-form')] = function(){
@@ -621,8 +622,8 @@
622623 _this.action_done = true;
623624 _this.updateProgressWin( gM('mwe-successfulupload'), gM( 'mwe-upload_done', url), bObj);
624625 js_log('apiRes.upload.imageinfo::'+url);
 626+ return true;
625627 }
626 - return ;
627628 }
628629 }
629630 },

Status & tagging log