r59431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59430‎ | r59431 | r59432 >
Date:19:02, 25 November 2009
Author:dale
Status:deferred
Tags:
Comment:
* restored basic non-firefogg upload functionality per r59320 breakage
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -243,7 +243,7 @@
244244 // Now show the form
245245 $j( _this.selector ).show();
246246
247 - if ( _this.firefoggCheck() ) {
 247+ if ( _this.getFirefogg() ) {
248248 // Firefogg enabled
249249 // If we're in upload mode, show the input filename
250250 if ( _this.form_type == 'upload' )
@@ -294,11 +294,13 @@
295295 }
296296
297297 // Set up the click handler for the "save local file" button
298 - $j( _this.target_btn_save_local_file )
 298+ if( _this.target_btn_save_local_file ){
 299+ $j( _this.target_btn_save_local_file )
299300 .unbind()
300301 .click( function() {
301302 _this.doLocalEncodeAndSave();
302303 } );
 304+ }
303305 },
304306
305307 /*
@@ -347,7 +349,7 @@
348350 }
349351
350352 // If Firefogg is not available, just show a "please install" message
351 - if ( !this.firefoggCheck() ) {
 353+ if ( !this.getFirefogg() ) {
352354 if ( !this.target_please_install ) {
353355 $j( this.selector ).after( this.getControlHtml( 'target_please_install' ) );
354356 this.target_please_install = this.selector + ' ~ .target_please_install';
@@ -393,7 +395,7 @@
394396 * Display an upload progress overlay. Overrides the function in mvBaseUploadInterface.
395397 */
396398 displayProgressOverlay: function() {
397 - this.pe_dispProgressOverlay();
 399+ this.pe_displayProgressOverlay();
398400 // If we are uploading video (not in passthrough mode), show preview button
399401 if( this.getFirefogg() && !this.getEncoderSettings()['passthrough']
400402 && !this.isCopyUpload() )
@@ -666,7 +668,7 @@
667669 _this.updateProgress( 1 );
668670 setTimeout( function() {
669671 _this.onLocalEncodeDone();
670 - }
 672+ });
671673 }
672674 );
673675 },
@@ -674,7 +676,7 @@
675677 /**
676678 * This is called when a local encode operation has completed. It updates the UI.
677679 */
678 - onLocalEncodeDone() {
 680+ onLocalEncodeDone: function() {
679681 var _this = this;
680682 _this.updateProgressWin( gM( 'fogg-encoding-done' ),
681683 gM( 'fogg-encoding-done' ) + '<br>' +
@@ -717,11 +719,11 @@
718720 * Get the appropriate encoder settings for the current Firefogg object,
719721 * into which a video has already been selected.
720722 */
721 - getEncoderSettings function() {
 723+ getEncoderSettings: function() {
722724 if ( this.current_encoder_settings == null ) {
723725 // Clone the default settings
724 - var defaults = function () {};
725 - var defaults.prototype = this.default_encoder_settings;
 726+ var defaults = function () { };
 727+ defaults.prototype = this.default_encoder_settings;
726728 var settings = new defaults();
727729
728730 // Grab the extension
@@ -848,11 +850,7 @@
849851 if ( dotPos != -1 ) {
850852 ext = fileName.substring( dotPos ).toLowerCase();
851853 }
852 - if ( $j.inArray( ext.substr( 1 ), _this.ogg_extensions ) == -1 ) {
853 - _this.formData['filename'] = fileName.substr(
854 - 0,
855 -
856 -
 854+ if ( $j.inArray( ext.substr( 1 ), _this.ogg_extensions ) == -1 ) {
857855 var extreg = new RegExp( ext + '$', 'i' );
858856 _this.formData['filename'] = fileName.replace( extreg, '.ogg' );
859857 }
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js
@@ -19,7 +19,7 @@
2020
2121 var default_form_options = {
2222 'enable_fogg' : true,
23 - 'licence_options':['cc-by-sa'],
 23+ 'licence_options' : ['cc-by-sa'],
2424 'api_target' : false,
2525 'ondone_cb' : null
2626 };
@@ -53,7 +53,7 @@
5454 // hidden input:
5555 '<input type="hidden" name="action" value="upload">' +
5656 '<input type="hidden" name="format" value="jsonfm">' +
57 - '<input type="hidden" name="token" value="' + eToken + '">' +
 57+ '<input type="hidden" id="wpEditToken" name="wpEditToken" value="' + eToken + '">' +
5858
5959 // form name set:
6060 '<label for="wpUploadFile">' + gM( 'mwe-select_file' ) + '</label><br>' +
@@ -121,7 +121,7 @@
122122
123123
124124 // do destination check:
125 - $j( "#wpDestFile" ).change( function() {
 125+ $j( "#wpDestFile" ).change( function() {
126126 $j( "#wpDestFile" ).doDestCheck( {
127127 'warn_target':'#wpDestFile-warning'
128128 } );
@@ -136,7 +136,7 @@
137137 // an api url (we won't submit directly to action of the form)
138138 'api_url' : opt.api_target,
139139 'form_rewrite': true,
140 - 'target_edit_from' : '#suf-upload',
 140+ 'edit_form_selector' : '#suf-upload',
141141 'new_source_cb' : function( orgFilename, oggName ) {
142142 $j( "#wpDestFile" ).val( oggName ).doDestCheck( {
143143 warn_target: "#wpDestFile-warning"
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -93,7 +93,7 @@
9494
9595 // Set up the submit action:
9696 $j( this.form ).submit( function() {
97 - _this.onSubmit();
 97+ return _this.onSubmit();
9898 } );
9999 },
100100
@@ -101,8 +101,8 @@
102102 * onsubmit handler for the upload form
103103 */
104104 onSubmit: function() {
 105+ var _this = this;
105106 js_log( 'Base::onSubmit:' );
106 -
107107 // Run the original onsubmit (if not run yet set flag to avoid excessive chaining)
108108 if ( typeof( this.orig_onsubmit ) == 'function' ) {
109109 if ( ! this.orig_onsubmit() ) {
@@ -123,18 +123,19 @@
124124 for ( var i = 0; i < data.length; i++ ) {
125125 if ( data[i]['name'] )
126126 this.formData[ data[i]['name'] ] = data[i]['value'];
127 - }
 127+ }
128128 // Put into a try catch so we are sure to return false:
129129 try {
130 - // Get a clean loader:
131 - // FIXME: this function does not exist in this class
132 - this.displayProgressOverlay();
 130+
 131+ // Display a progress dialog
 132+ _this.displayProgressOverlay();
133133
134134 // For some unknown reason we have to drop down the #p-search z-index:
135135 $j( '#p-search' ).css( 'z-index', 1 );
136136
137137 var _this = this;
138 - this.detectUploadMode( function( mode ) {
 138+ _this.detectUploadMode( function( mode ) {
 139+ _this.upload_mode = mode;
139140 _this.doUpload();
140141 } );
141142 } catch( e ) {
@@ -143,7 +144,7 @@
144145
145146 // Don't submit the form we will do the post in ajax
146147 return false;
147 - }
 148+ },
148149
149150 /**
150151 * Determine the correct upload mode.
@@ -218,13 +219,13 @@
219220 */
220221 doUpload: function() {
221222 if ( this.upload_mode == 'api' ) {
222 - _this.doApiCopyUpload();
 223+ this.doApiCopyUpload();
223224 } else if ( this.upload_mode == 'post' ) {
224 - _this.doPostUpload();
 225+ this.doPostUpload();
225226 } else {
226227 js_error( 'Error: unrecongized upload mode: ' + this.upload_mode );
227228 }
228 - }
 229+ },
229230
230231 /**
231232 * Change the upload form so that when submitted, it sends a request to
@@ -235,6 +236,7 @@
236237 * selected a file in them, which they may well do before DOM ready.
237238 */
238239 remapFormToApi: function() {
 240+ var _this = this;
239241 if ( !this.api_url )
240242 return false;
241243
@@ -263,15 +265,13 @@
264266 /**
265267 * Returns true if the current form has copy upload selected, false otherwise.
266268 */
267 - isCopyUpload: function() {
268 - if ( this.http_copy_upload == null ) {
269 - if ( $j( '#wpSourceTypeFile' ).length == 0
270 - || $j( '#wpSourceTypeFile' ).get( 0 ).checked )
271 - {
272 - this.http_copy_upload = false;
273 - } else if ( $j('#wpSourceTypeURL').get( 0 ).checked ) {
274 - this.http_copy_upload = true;
275 - }
 269+ isCopyUpload: function() {
 270+ if ( $j( '#wpSourceTypeFile' ).length == 0
 271+ || $j( '#wpSourceTypeFile' ).get( 0 ).checked )
 272+ {
 273+ this.http_copy_upload = false;
 274+ } else if ( $j('#wpSourceTypeURL').get( 0 ).checked ) {
 275+ this.http_copy_upload = true;
276276 }
277277 return this.http_copy_upload;
278278 },
@@ -358,7 +358,7 @@
359359 } else if ( doc.body ) {
360360 // Get the json string
361361 json = $j( doc.body ).find( 'pre' ).text();
362 - js_log( 'iframe:json::' + json_str + "\nbody:" + $j( doc.body ).html() );
 362+ //js_log( 'iframe:json::' + json_str + "\nbody:" + $j( doc.body ).html() );
363363 if ( json ) {
364364 response = window["eval"]( "(" + json + ")" );
365365 } else {
@@ -436,7 +436,7 @@
437437
438438 // Trigger an initial request (subsequent ones will be done by a timer)
439439 this.onAjaxUploadStatusTimer();
440 - }
 440+ },
441441
442442 /**
443443 * This is called when the timer which separates XHR requests elapses.
@@ -778,7 +778,7 @@
779779 js_log( "call done_upload_cb" );
780780 // This overrides our normal completion handling so we close the
781781 // dialog immediately.
782 - $j( '#upProgressDialog' ).dialog( 'close' );
 782+ $j( '#upProgressDialog' ).dialog( 'destroy' ).remove();
783783 _this.done_upload_cb( apiRes.upload );
784784 return false;
785785 }
@@ -786,7 +786,7 @@
787787 var buttons = {};
788788 // "Return" button
789789 buttons[ gM( 'mwe-return-to-form' ) ] = function() {
790 - $j( this ).dialog( 'close' );
 790+ $j( this ).dialog( 'destroy' ).remove();
791791 _this.form_post_override = false;
792792 }
793793 // "Go to resource" button
@@ -866,7 +866,6 @@
867867 */
868868 displayProgressOverlay: function() {
869869 var _this = this;
870 -
871870 // Remove the old instance if present
872871 if( $j( '#upProgressDialog' ).length != 0 ) {
873872 $j( '#upProgressDialog' ).dialog( 'destroy' ).remove();

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59320* fixed audio vs video display height in remoteMwEmbed rewrite...dale18:45, 21 November 2009

Status & tagging log