Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -243,7 +243,7 @@ |
244 | 244 | // Now show the form |
245 | 245 | $j( _this.selector ).show(); |
246 | 246 | |
247 | | - if ( _this.firefoggCheck() ) { |
| 247 | + if ( _this.getFirefogg() ) { |
248 | 248 | // Firefogg enabled |
249 | 249 | // If we're in upload mode, show the input filename |
250 | 250 | if ( _this.form_type == 'upload' ) |
— | — | @@ -294,11 +294,13 @@ |
295 | 295 | } |
296 | 296 | |
297 | 297 | // 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 ) |
299 | 300 | .unbind() |
300 | 301 | .click( function() { |
301 | 302 | _this.doLocalEncodeAndSave(); |
302 | 303 | } ); |
| 304 | + } |
303 | 305 | }, |
304 | 306 | |
305 | 307 | /* |
— | — | @@ -347,7 +349,7 @@ |
348 | 350 | } |
349 | 351 | |
350 | 352 | // If Firefogg is not available, just show a "please install" message |
351 | | - if ( !this.firefoggCheck() ) { |
| 353 | + if ( !this.getFirefogg() ) { |
352 | 354 | if ( !this.target_please_install ) { |
353 | 355 | $j( this.selector ).after( this.getControlHtml( 'target_please_install' ) ); |
354 | 356 | this.target_please_install = this.selector + ' ~ .target_please_install'; |
— | — | @@ -393,7 +395,7 @@ |
394 | 396 | * Display an upload progress overlay. Overrides the function in mvBaseUploadInterface. |
395 | 397 | */ |
396 | 398 | displayProgressOverlay: function() { |
397 | | - this.pe_dispProgressOverlay(); |
| 399 | + this.pe_displayProgressOverlay(); |
398 | 400 | // If we are uploading video (not in passthrough mode), show preview button |
399 | 401 | if( this.getFirefogg() && !this.getEncoderSettings()['passthrough'] |
400 | 402 | && !this.isCopyUpload() ) |
— | — | @@ -666,7 +668,7 @@ |
667 | 669 | _this.updateProgress( 1 ); |
668 | 670 | setTimeout( function() { |
669 | 671 | _this.onLocalEncodeDone(); |
670 | | - } |
| 672 | + }); |
671 | 673 | } |
672 | 674 | ); |
673 | 675 | }, |
— | — | @@ -674,7 +676,7 @@ |
675 | 677 | /** |
676 | 678 | * This is called when a local encode operation has completed. It updates the UI. |
677 | 679 | */ |
678 | | - onLocalEncodeDone() { |
| 680 | + onLocalEncodeDone: function() { |
679 | 681 | var _this = this; |
680 | 682 | _this.updateProgressWin( gM( 'fogg-encoding-done' ), |
681 | 683 | gM( 'fogg-encoding-done' ) + '<br>' + |
— | — | @@ -717,11 +719,11 @@ |
718 | 720 | * Get the appropriate encoder settings for the current Firefogg object, |
719 | 721 | * into which a video has already been selected. |
720 | 722 | */ |
721 | | - getEncoderSettings function() { |
| 723 | + getEncoderSettings: function() { |
722 | 724 | if ( this.current_encoder_settings == null ) { |
723 | 725 | // 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; |
726 | 728 | var settings = new defaults(); |
727 | 729 | |
728 | 730 | // Grab the extension |
— | — | @@ -848,11 +850,7 @@ |
849 | 851 | if ( dotPos != -1 ) { |
850 | 852 | ext = fileName.substring( dotPos ).toLowerCase(); |
851 | 853 | } |
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 ) { |
857 | 855 | var extreg = new RegExp( ext + '$', 'i' ); |
858 | 856 | _this.formData['filename'] = fileName.replace( extreg, '.ogg' ); |
859 | 857 | } |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | var default_form_options = { |
22 | 22 | 'enable_fogg' : true, |
23 | | - 'licence_options':['cc-by-sa'], |
| 23 | + 'licence_options' : ['cc-by-sa'], |
24 | 24 | 'api_target' : false, |
25 | 25 | 'ondone_cb' : null |
26 | 26 | }; |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | // hidden input: |
55 | 55 | '<input type="hidden" name="action" value="upload">' + |
56 | 56 | '<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 + '">' + |
58 | 58 | |
59 | 59 | // form name set: |
60 | 60 | '<label for="wpUploadFile">' + gM( 'mwe-select_file' ) + '</label><br>' + |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | |
123 | 123 | |
124 | 124 | // do destination check: |
125 | | - $j( "#wpDestFile" ).change( function() { |
| 125 | + $j( "#wpDestFile" ).change( function() { |
126 | 126 | $j( "#wpDestFile" ).doDestCheck( { |
127 | 127 | 'warn_target':'#wpDestFile-warning' |
128 | 128 | } ); |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | // an api url (we won't submit directly to action of the form) |
138 | 138 | 'api_url' : opt.api_target, |
139 | 139 | 'form_rewrite': true, |
140 | | - 'target_edit_from' : '#suf-upload', |
| 140 | + 'edit_form_selector' : '#suf-upload', |
141 | 141 | 'new_source_cb' : function( orgFilename, oggName ) { |
142 | 142 | $j( "#wpDestFile" ).val( oggName ).doDestCheck( { |
143 | 143 | warn_target: "#wpDestFile-warning" |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | |
95 | 95 | // Set up the submit action: |
96 | 96 | $j( this.form ).submit( function() { |
97 | | - _this.onSubmit(); |
| 97 | + return _this.onSubmit(); |
98 | 98 | } ); |
99 | 99 | }, |
100 | 100 | |
— | — | @@ -101,8 +101,8 @@ |
102 | 102 | * onsubmit handler for the upload form |
103 | 103 | */ |
104 | 104 | onSubmit: function() { |
| 105 | + var _this = this; |
105 | 106 | js_log( 'Base::onSubmit:' ); |
106 | | - |
107 | 107 | // Run the original onsubmit (if not run yet set flag to avoid excessive chaining) |
108 | 108 | if ( typeof( this.orig_onsubmit ) == 'function' ) { |
109 | 109 | if ( ! this.orig_onsubmit() ) { |
— | — | @@ -123,18 +123,19 @@ |
124 | 124 | for ( var i = 0; i < data.length; i++ ) { |
125 | 125 | if ( data[i]['name'] ) |
126 | 126 | this.formData[ data[i]['name'] ] = data[i]['value']; |
127 | | - } |
| 127 | + } |
128 | 128 | // Put into a try catch so we are sure to return false: |
129 | 129 | 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(); |
133 | 133 | |
134 | 134 | // For some unknown reason we have to drop down the #p-search z-index: |
135 | 135 | $j( '#p-search' ).css( 'z-index', 1 ); |
136 | 136 | |
137 | 137 | var _this = this; |
138 | | - this.detectUploadMode( function( mode ) { |
| 138 | + _this.detectUploadMode( function( mode ) { |
| 139 | + _this.upload_mode = mode; |
139 | 140 | _this.doUpload(); |
140 | 141 | } ); |
141 | 142 | } catch( e ) { |
— | — | @@ -143,7 +144,7 @@ |
144 | 145 | |
145 | 146 | // Don't submit the form we will do the post in ajax |
146 | 147 | return false; |
147 | | - } |
| 148 | + }, |
148 | 149 | |
149 | 150 | /** |
150 | 151 | * Determine the correct upload mode. |
— | — | @@ -218,13 +219,13 @@ |
219 | 220 | */ |
220 | 221 | doUpload: function() { |
221 | 222 | if ( this.upload_mode == 'api' ) { |
222 | | - _this.doApiCopyUpload(); |
| 223 | + this.doApiCopyUpload(); |
223 | 224 | } else if ( this.upload_mode == 'post' ) { |
224 | | - _this.doPostUpload(); |
| 225 | + this.doPostUpload(); |
225 | 226 | } else { |
226 | 227 | js_error( 'Error: unrecongized upload mode: ' + this.upload_mode ); |
227 | 228 | } |
228 | | - } |
| 229 | + }, |
229 | 230 | |
230 | 231 | /** |
231 | 232 | * Change the upload form so that when submitted, it sends a request to |
— | — | @@ -235,6 +236,7 @@ |
236 | 237 | * selected a file in them, which they may well do before DOM ready. |
237 | 238 | */ |
238 | 239 | remapFormToApi: function() { |
| 240 | + var _this = this; |
239 | 241 | if ( !this.api_url ) |
240 | 242 | return false; |
241 | 243 | |
— | — | @@ -263,15 +265,13 @@ |
264 | 266 | /** |
265 | 267 | * Returns true if the current form has copy upload selected, false otherwise. |
266 | 268 | */ |
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; |
276 | 276 | } |
277 | 277 | return this.http_copy_upload; |
278 | 278 | }, |
— | — | @@ -358,7 +358,7 @@ |
359 | 359 | } else if ( doc.body ) { |
360 | 360 | // Get the json string |
361 | 361 | 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() ); |
363 | 363 | if ( json ) { |
364 | 364 | response = window["eval"]( "(" + json + ")" ); |
365 | 365 | } else { |
— | — | @@ -436,7 +436,7 @@ |
437 | 437 | |
438 | 438 | // Trigger an initial request (subsequent ones will be done by a timer) |
439 | 439 | this.onAjaxUploadStatusTimer(); |
440 | | - } |
| 440 | + }, |
441 | 441 | |
442 | 442 | /** |
443 | 443 | * This is called when the timer which separates XHR requests elapses. |
— | — | @@ -778,7 +778,7 @@ |
779 | 779 | js_log( "call done_upload_cb" ); |
780 | 780 | // This overrides our normal completion handling so we close the |
781 | 781 | // dialog immediately. |
782 | | - $j( '#upProgressDialog' ).dialog( 'close' ); |
| 782 | + $j( '#upProgressDialog' ).dialog( 'destroy' ).remove(); |
783 | 783 | _this.done_upload_cb( apiRes.upload ); |
784 | 784 | return false; |
785 | 785 | } |
— | — | @@ -786,7 +786,7 @@ |
787 | 787 | var buttons = {}; |
788 | 788 | // "Return" button |
789 | 789 | buttons[ gM( 'mwe-return-to-form' ) ] = function() { |
790 | | - $j( this ).dialog( 'close' ); |
| 790 | + $j( this ).dialog( 'destroy' ).remove(); |
791 | 791 | _this.form_post_override = false; |
792 | 792 | } |
793 | 793 | // "Go to resource" button |
— | — | @@ -866,7 +866,6 @@ |
867 | 867 | */ |
868 | 868 | displayProgressOverlay: function() { |
869 | 869 | var _this = this; |
870 | | - |
871 | 870 | // Remove the old instance if present |
872 | 871 | if( $j( '#upProgressDialog' ).length != 0 ) { |
873 | 872 | $j( '#upProgressDialog' ).dialog( 'destroy' ).remove(); |