// Set up the submit action:
$j( this.form ).submit( function() {
- _this.onSubmit();
+ return _this.onSubmit();
} );
},
* 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() ) {
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 ) {
// Don't submit the form we will do the post in ajax
return false;
- }
+ },
/**
* Determine the correct upload mode.
*/
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
* selected a file in them, which they may well do before DOM ready.
*/
remapFormToApi: function() {
+ var _this = this;
if ( !this.api_url )
return false;
/**
* 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;
},
} 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 {
// 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.
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;
}
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
*/
displayProgressOverlay: function() {
var _this = this;
-
// Remove the old instance if present
if( $j( '#upProgressDialog' ).length != 0 ) {
$j( '#upProgressDialog' ).dialog( 'destroy' ).remove();
// 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' )
}
// 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();
} );
+ }
},
/*
}
// 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';
* 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() )
_this.updateProgress( 1 );
setTimeout( function() {
_this.onLocalEncodeDone();
- }
+ });
}
);
},
/**
* 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>' +
* 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
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' );
}
var default_form_options = {
'enable_fogg' : true,
- 'licence_options':['cc-by-sa'],
+ 'licence_options' : ['cc-by-sa'],
'api_target' : false,
'ondone_cb' : null
};
// 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>' +
// do destination check:
- $j( "#wpDestFile" ).change( function() {
+ $j( "#wpDestFile" ).change( function() {
$j( "#wpDestFile" ).doDestCheck( {
'warn_target':'#wpDestFile-warning'
} );
// 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"