* improved inline AMW upload
authorMichael Dale <dale@users.mediawiki.org>
Fri, 28 Aug 2009 03:53:17 +0000 (03:53 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Fri, 28 Aug 2009 03:53:17 +0000 (03:53 +0000)
js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
js2/mwEmbed/libAddMedia/remoteSearchDriver.js
js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js
js2/mwEmbed/libAddMedia/simpleUploadForm.js

index ada2edd..a800bd2 100644 (file)
@@ -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 ;
                        }
                }
        },
index c546627..23f1747 100644 (file)
@@ -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('<div id="rsd_modal_target" style="position:absolute;top:30px;left:0px;bottom:45px;right:0px;" title="' + gM('mwe-add_media_wizard') + '" ></div>');
+                       $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>');
                        _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();
index b7223ff..b1c14ad 100644 (file)
@@ -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) );                        
                        }
                );                      
index 00d9237..70325b2 100644 (file)
@@ -58,11 +58,17 @@ var default_form_options = {
                                                '<input id="wpUploadFile" type="file" style="display: inline;" name="wpUploadFile" size="15"/><br>' +
                        
                                                '<label for="wpDestFile">' +gM('mwe-destfilename') + '</label><br>'+
-                                               '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
+                                               '<input id="wpDestFile" type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
                        
                                                '<label for="wpUploadDescription">' + gM('mwe-summary') + ':</label><br>' +
-                                               '<textarea cols="30" rows="3" name="wpUploadDescription" tabindex="3"/><br>'+
-                       
+                                               '<textarea id="wpUploadDescription" cols="30" rows="3" name="wpUploadDescription" tabindex="3"/><br>'+
+                                               
+                                               '<input type="checkbox" value="true" id="wpWatchthis" name="watch" tabindex="7"/>'+
+                                               '<label for="wpWatchthis">Watch this file</label>'+
+                                               
+                                               '<input type="checkbox" value="true" id="wpIgnoreWarning" name="ignorewarnings" tabindex="8"/>'+
+                                               '<label for="wpIgnoreWarning">Ignore any warnings</label></br>'+
+                                               
                                                '<div id="wpDestFile-warning"></div>' +
                                                '<div style="clear:both;"></div>' +
                        
@@ -89,7 +95,7 @@ var default_form_options = {
                        });
                        //do destination fill:
                        //@@should integrate with doDestinationFill on upload page
-                       $j("#suf-upload [name='wpUploadFile']").change(function(){
+                       $j("#wpUploadFile").change(function(){
                                var path = $j(this).val();
                                // Find trailing part
                                var slash = path.lastIndexOf('/');
@@ -104,17 +110,17 @@ var default_form_options = {
                                }
                                fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
                                // Output result
-                               $j("#suf-upload [name='wpDestFile']").val( fname );
+                               $j("#wpDestFile").val( fname );
                                //do destination check
-                               $j("#suf-upload [name='wpDestFile']").doDestCheck({
+                               $j("#wpDestFile").doDestCheck({
                                        'warn_target':'#wpDestFile-warning'
                                });
                        });
 
 
                        //do destination check:
-                       $j("[name='wpDestFile']").change(function(){
-                               $j(this).doDestCheck({
+                       $j("#wpDestFile").change(function(){
+                               $j("#wpDestFile").doDestCheck({
                                        'warn_target':'#wpDestFile-warning'
                                });
                        });
@@ -130,7 +136,7 @@ var default_form_options = {
                                        'form_rewrite': true,
                                        'target_edit_from' : '#suf-upload',
                                        'new_source_cb' : function( orgFilename, oggName ){
-                                               $j("#suf-upload [name='wpDestFile']").val( oggName ).doDestCheck({
+                                               $j("#wpDestFile").val( oggName ).doDestCheck({
                                                        warn_target: "#wpDestFile-warning"
                                                });
                                        },