
dale at svn
Nov 25, 2009, 11:02 AM
Post #1 of 1
(135 views)
Permalink
|
|
SVN: [59431] trunk/phase3/js2/mwEmbed/libAddMedia
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59431 Revision: 59431 Author: dale Date: 2009-11-25 19:02:37 +0000 (Wed, 25 Nov 2009) Log Message: ----------- * restored basic non-firefogg upload functionality per r59320 breakage Modified Paths: -------------- trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js Modified: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js =================================================================== --- trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js 2009-11-25 18:07:04 UTC (rev 59430) +++ trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js 2009-11-25 19:02:37 UTC (rev 59431) @@ -93,7 +93,7 @@ // Set up the submit action: $j( this.form ).submit( function() { - _this.onSubmit(); + return _this.onSubmit(); } ); }, @@ -101,8 +101,8 @@ * onsubmit handler for the upload form */ onSubmit: function() { + var _this = this; js_log( 'Base::onSubmit:' ); - // Run the original onsubmit (if not run yet set flag to avoid excessive chaining) if ( typeof( this.orig_onsubmit ) == 'function' ) { if ( ! this.orig_onsubmit() ) { @@ -123,18 +123,19 @@ for ( var i = 0; i < data.length; i++ ) { if ( data[i]['name'] ) this.formData[ data[i]['name'] ] = data[i]['value']; - } + } // Put into a try catch so we are sure to return false: try { - // Get a clean loader: - // FIXME: this function does not exist in this class - this.displayProgressOverlay(); + + // Display a progress dialog + _this.displayProgressOverlay(); // For some unknown reason we have to drop down the #p-search z-index: $j( '#p-search' ).css( 'z-index', 1 ); var _this = this; - this.detectUploadMode( function( mode ) { + _this.detectUploadMode( function( mode ) { + _this.upload_mode = mode; _this.doUpload(); } ); } catch( e ) { @@ -143,7 +144,7 @@ // Don't submit the form we will do the post in ajax return false; - } + }, /** * Determine the correct upload mode. @@ -218,13 +219,13 @@ */ doUpload: function() { if ( this.upload_mode == 'api' ) { - _this.doApiCopyUpload(); + this.doApiCopyUpload(); } else if ( this.upload_mode == 'post' ) { - _this.doPostUpload(); + this.doPostUpload(); } else { js_error( 'Error: unrecongized upload mode: ' + this.upload_mode ); } - } + }, /** * Change the upload form so that when submitted, it sends a request to @@ -235,6 +236,7 @@ * selected a file in them, which they may well do before DOM ready. */ remapFormToApi: function() { + var _this = this; if ( !this.api_url ) return false; @@ -263,15 +265,13 @@ /** * Returns true if the current form has copy upload selected, false otherwise. */ - isCopyUpload: function() { - if ( this.http_copy_upload == null ) { - if ( $j( '#wpSourceTypeFile' ).length == 0 - || $j( '#wpSourceTypeFile' ).get( 0 ).checked ) - { - this.http_copy_upload = false; - } else if ( $j('#wpSourceTypeURL').get( 0 ).checked ) { - this.http_copy_upload = true; - } + isCopyUpload: function() { + if ( $j( '#wpSourceTypeFile' ).length == 0 + || $j( '#wpSourceTypeFile' ).get( 0 ).checked ) + { + this.http_copy_upload = false; + } else if ( $j('#wpSourceTypeURL').get( 0 ).checked ) { + this.http_copy_upload = true; } return this.http_copy_upload; }, @@ -358,7 +358,7 @@ } else if ( doc.body ) { // Get the json string json = $j( doc.body ).find( 'pre' ).text(); - js_log( 'iframe:json::' + json_str + "\nbody:" + $j( doc.body ).html() ); + //js_log( 'iframe:json::' + json_str + "\nbody:" + $j( doc.body ).html() ); if ( json ) { response = window["eval"]( "(" + json + ")" ); } else { @@ -436,7 +436,7 @@ // Trigger an initial request (subsequent ones will be done by a timer) this.onAjaxUploadStatusTimer(); - } + }, /** * This is called when the timer which separates XHR requests elapses. @@ -778,7 +778,7 @@ js_log( "call done_upload_cb" ); // This overrides our normal completion handling so we close the // dialog immediately. - $j( '#upProgressDialog' ).dialog( 'close' ); + $j( '#upProgressDialog' ).dialog( 'destroy' ).remove(); _this.done_upload_cb( apiRes.upload ); return false; } @@ -786,7 +786,7 @@ var buttons = {}; // "Return" button buttons[ gM( 'mwe-return-to-form' ) ] = function() { - $j( this ).dialog( 'close' ); + $j( this ).dialog( 'destroy' ).remove(); _this.form_post_override = false; } // "Go to resource" button @@ -866,7 +866,6 @@ */ displayProgressOverlay: function() { var _this = this; - // Remove the old instance if present if( $j( '#upProgressDialog' ).length != 0 ) { $j( '#upProgressDialog' ).dialog( 'destroy' ).remove(); Modified: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js =================================================================== --- trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js 2009-11-25 18:07:04 UTC (rev 59430) +++ trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js 2009-11-25 19:02:37 UTC (rev 59431) @@ -243,7 +243,7 @@ // Now show the form $j( _this.selector ).show(); - if ( _this.firefoggCheck() ) { + if ( _this.getFirefogg() ) { // Firefogg enabled // If we're in upload mode, show the input filename if ( _this.form_type == 'upload' ) @@ -294,11 +294,13 @@ } // Set up the click handler for the "save local file" button - $j( _this.target_btn_save_local_file ) + if( _this.target_btn_save_local_file ){ + $j( _this.target_btn_save_local_file ) .unbind() .click( function() { _this.doLocalEncodeAndSave(); } ); + } }, /* @@ -347,7 +349,7 @@ } // If Firefogg is not available, just show a "please install" message - if ( !this.firefoggCheck() ) { + if ( !this.getFirefogg() ) { if ( !this.target_please_install ) { $j( this.selector ).after( this.getControlHtml( 'target_please_install' ) ); this.target_please_install = this.selector + ' ~ .target_please_install'; @@ -393,7 +395,7 @@ * Display an upload progress overlay. Overrides the function in mvBaseUploadInterface. */ displayProgressOverlay: function() { - this.pe_dispProgressOverlay(); + this.pe_displayProgressOverlay(); // If we are uploading video (not in passthrough mode), show preview button if( this.getFirefogg() && !this.getEncoderSettings()['passthrough'] && !this.isCopyUpload() ) @@ -666,7 +668,7 @@ _this.updateProgress( 1 ); setTimeout( function() { _this.onLocalEncodeDone(); - } + }); } ); }, @@ -674,7 +676,7 @@ /** * This is called when a local encode operation has completed. It updates the UI. */ - onLocalEncodeDone() { + onLocalEncodeDone: function() { var _this = this; _this.updateProgressWin( gM( 'fogg-encoding-done' ), gM( 'fogg-encoding-done' ) + '<br>' + @@ -717,11 +719,11 @@ * Get the appropriate encoder settings for the current Firefogg object, * into which a video has already been selected. */ - getEncoderSettings function() { + getEncoderSettings: function() { if ( this.current_encoder_settings == null ) { // Clone the default settings - var defaults = function () {}; - var defaults.prototype = this.default_encoder_settings; + var defaults = function () { }; + defaults.prototype = this.default_encoder_settings; var settings = new defaults(); // Grab the extension @@ -848,11 +850,7 @@ if ( dotPos != -1 ) { ext = fileName.substring( dotPos ).toLowerCase(); } - if ( $j.inArray( ext.substr( 1 ), _this.ogg_extensions ) == -1 ) { - _this.formData['filename'] = fileName.substr( - 0, - - + if ( $j.inArray( ext.substr( 1 ), _this.ogg_extensions ) == -1 ) { var extreg = new RegExp( ext + '$', 'i' ); _this.formData['filename'] = fileName.replace( extreg, '.ogg' ); } Modified: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js =================================================================== --- trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js 2009-11-25 18:07:04 UTC (rev 59430) +++ trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js 2009-11-25 19:02:37 UTC (rev 59431) @@ -19,7 +19,7 @@ var default_form_options = { 'enable_fogg' : true, - 'licence_options':['cc-by-sa'], + 'licence_options' : ['cc-by-sa'], 'api_target' : false, 'ondone_cb' : null }; @@ -53,7 +53,7 @@ // hidden input: '<input type="hidden" name="action" value="upload">' + '<input type="hidden" name="format" value="jsonfm">' + - '<input type="hidden" name="token" value="' + eToken + '">' + + '<input type="hidden" id="wpEditToken" name="wpEditToken" value="' + eToken + '">' + // form name set: '<label for="wpUploadFile">' + gM( 'mwe-select_file' ) + '</label><br>' + @@ -121,7 +121,7 @@ // do destination check: - $j( "#wpDestFile" ).change( function() { + $j( "#wpDestFile" ).change( function() { $j( "#wpDestFile" ).doDestCheck( { 'warn_target':'#wpDestFile-warning' } ); @@ -136,7 +136,7 @@ // an api url (we won't submit directly to action of the form) 'api_url' : opt.api_target, 'form_rewrite': true, - 'target_edit_from' : '#suf-upload', + 'edit_form_selector' : '#suf-upload', 'new_source_cb' : function( orgFilename, oggName ) { $j( "#wpDestFile" ).val( oggName ).doDestCheck( { warn_target: "#wpDestFile-warning" _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|