Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -28,11 +28,8 @@ |
29 | 29 | |
30 | 30 | var default_firefogg_options = { |
31 | 31 | // Callback for upload completion |
32 | | - 'done_upload_cb': false, |
| 32 | + 'done_upload_cb': false, |
33 | 33 | |
34 | | - // True if Firefogg is enabled in the client |
35 | | - 'have_firefogg': false, |
36 | | - |
37 | 34 | // The API URL to upload to |
38 | 35 | 'api_url': null, |
39 | 36 | |
— | — | @@ -86,7 +83,10 @@ |
87 | 84 | 'firefogg_form_action': true, |
88 | 85 | |
89 | 86 | // True if we should show a preview of the encoding progress |
90 | | - 'show_preview': false |
| 87 | + 'show_preview': true, |
| 88 | + |
| 89 | + //If we should enable chunk uploads ( mediaWiki api supports chunk uploads) |
| 90 | + 'enable_chunks' : false |
91 | 91 | }; |
92 | 92 | |
93 | 93 | |
— | — | @@ -242,7 +242,6 @@ |
243 | 243 | |
244 | 244 | // Now show the form |
245 | 245 | $j( _this.selector ).show(); |
246 | | - |
247 | 246 | if ( _this.getFirefogg() ) { |
248 | 247 | // Firefogg enabled |
249 | 248 | // If we're in upload mode, show the input filename |
— | — | @@ -395,10 +394,11 @@ |
396 | 395 | * Display an upload progress overlay. Overrides the function in mvBaseUploadInterface. |
397 | 396 | */ |
398 | 397 | displayProgressOverlay: function() { |
399 | | - this.pe_displayProgressOverlay(); |
| 398 | + this.pe_displayProgressOverlay(); |
400 | 399 | // If we are uploading video (not in passthrough mode), show preview button |
401 | | - if( this.getFirefogg() && !this.getEncoderSettings()['passthrough'] |
402 | | - && !this.isCopyUpload() ) |
| 400 | + if( this.getFirefogg() |
| 401 | + && !this.isCopyUpload() |
| 402 | + && !this.getEncoderSettings()['passthrough'] ) |
403 | 403 | { |
404 | 404 | this.createPreviewControls(); |
405 | 405 | } |
— | — | @@ -409,10 +409,19 @@ |
410 | 410 | */ |
411 | 411 | createPreviewControls: function() { |
412 | 412 | var _this = this; |
| 413 | + |
| 414 | + // Set the initial button html: |
| 415 | + var buttonHtml = ''; |
| 416 | + if( _this.show_preview == true ){ |
| 417 | + buttonHtml = $j.btnHtml( gM( 'fogg-hidepreview' ), 'fogg_preview', 'triangle-1-s' ); |
| 418 | + } else { |
| 419 | + buttonHtml = $j.btnHtml( gM( 'fogg-preview' ), 'fogg_preview', 'triangle-1-e' ); |
| 420 | + } |
| 421 | + |
413 | 422 | // Add the preview button and canvas |
414 | 423 | $j( '#upProgressDialog' ).append( |
415 | 424 | '<div style="clear:both;height:3em"/>' + |
416 | | - $j.btnHtml( gM( 'fogg-preview' ), 'fogg_preview', 'triangle-1-e' ) + |
| 425 | + buttonHtml + |
417 | 426 | '<div style="padding:10px;">' + |
418 | 427 | '<canvas style="margin:auto;" id="fogg_preview_canvas" />' + |
419 | 428 | '</div>' |
— | — | @@ -421,14 +430,6 @@ |
422 | 431 | // Set the initial state |
423 | 432 | if ( _this.show_preview == true ) { |
424 | 433 | $j( '#fogg_preview_canvas' ).show(); |
425 | | - } else { |
426 | | - // Fix the icon class |
427 | | - $j( this ).children( '.ui-icon' ) |
428 | | - .removeClass( 'ui-icon-triangle-1-s' ) |
429 | | - .addClass( 'ui-icon-triangle-1-e' ); |
430 | | - // Set the button text |
431 | | - $j( this ).children( '.btnText' ).text( gM( 'fogg-preview' ) ); |
432 | | - $j( '#fogg_preview_canvas' ).hide(); |
433 | 434 | } |
434 | 435 | |
435 | 436 | // Bind the preview button |
— | — | @@ -556,7 +557,7 @@ |
557 | 558 | */ |
558 | 559 | updateSourceFileUI: function() { |
559 | 560 | js_log( 'videoSelectReady' ); |
560 | | - |
| 561 | + var _this = this; |
561 | 562 | if ( !_this.fogg.sourceInfo || !_this.fogg.sourceFilename ) { |
562 | 563 | // Something wrong with the source file? |
563 | 564 | js_log( 'selectSourceFile: sourceInfo/sourceFilename missing' ); |
— | — | @@ -620,7 +621,7 @@ |
621 | 622 | return false; |
622 | 623 | } |
623 | 624 | try { |
624 | | - this.sourceFileInfo = JSON.parse( firefogg.sourceInfo ); |
| 625 | + this.sourceFileInfo = JSON.parse( this.fogg.sourceInfo ); |
625 | 626 | } catch ( e ) { |
626 | 627 | js_error( 'error could not parse fogg sourceInfo' ); |
627 | 628 | return false; |
— | — | @@ -797,21 +798,23 @@ |
798 | 799 | js_log( "firefogg: doUpload:: " + |
799 | 800 | ( this.getFirefogg() ? 'on' : 'off' ) + |
800 | 801 | ' up mode:' + _this.upload_mode ); |
801 | | - |
802 | | - // If Firefogg is disabled, just invoke the parent method |
803 | | - if( !this.getFirefogg() || !this.firefogg_form_action ) { |
| 802 | + |
| 803 | + // If Firefogg is disabled or doing an copyByUrl upload, just invoke the parent method |
| 804 | + if( !this.getFirefogg() || this.isCopyUpload() ) { |
804 | 805 | _this.pe_doUpload(); |
805 | 806 | return; |
806 | 807 | } |
807 | | - |
808 | | - if ( _this.upload_mode == 'post' ) { |
| 808 | + // We can do a chunk upload |
| 809 | + if( _this.upload_mode == 'post' && _this.enable_chunks ){ |
| 810 | + _this.doChunkUpload(); |
| 811 | + } else if ( _this.upload_mode == 'post' ) { |
809 | 812 | // Encode and then do a post upload |
810 | 813 | _this.doEncode( |
811 | 814 | function /* onProgress */ ( progress ) { |
812 | 815 | _this.updateProgress( progress ); |
813 | 816 | }, |
814 | 817 | function /* onDone */ () { |
815 | | - js_log( 'done with encoding do POST upload:' + _this.editForm.action ); |
| 818 | + js_log( 'done with encoding do POST upload:' + _this.form.action ); |
816 | 819 | // ignore warnings & set source type |
817 | 820 | //_this.formData[ 'wpIgnoreWarning' ]='true'; |
818 | 821 | _this.formData['wpSourceType'] = 'upload'; |
— | — | @@ -824,9 +827,6 @@ |
825 | 828 | _this.doUploadStatus(); |
826 | 829 | } |
827 | 830 | ); |
828 | | - } else if ( _this.upload_mode == 'api' ) { |
829 | | - // We have the API so we can do a chunk upload |
830 | | - _this.doChunkUpload(); |
831 | 831 | } else { |
832 | 832 | js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode ); |
833 | 833 | } |
— | — | @@ -1027,34 +1027,30 @@ |
1028 | 1028 | js_log( 'Error:firefogg upload error: ' + _this.fogg.state ); |
1029 | 1029 | return; |
1030 | 1030 | } |
1031 | | - |
1032 | | - if ( _this.upload_mode == 'api' ) { |
1033 | | - if ( apiResult && apiResult.resultUrl ) { |
1034 | | - var buttons = {}; |
1035 | | - buttons[ gM( 'mwe-go-to-resource' ) ] = function() { |
1036 | | - window.location = apiResult.resultUrl; |
1037 | | - } |
1038 | | - var go_to_url_txt = gM( 'mwe-go-to-resource' ); |
1039 | | - var showMessage = true; |
1040 | | - if ( typeof _this.done_upload_cb == 'function' ) { |
1041 | | - // Call the callback |
1042 | | - // It will return false if it doesn't want us to show our own "done" message |
1043 | | - showMessage = _this.done_upload_cb( _this.formData ); |
1044 | | - } |
1045 | | - if ( showMessage ) { |
1046 | | - _this.updateProgressWin( gM( 'mwe-successfulupload' ), |
1047 | | - gM( 'mwe-upload_done', apiResult.resultUrl ), buttons ); |
1048 | | - } else { |
1049 | | - this.action_done = true; |
1050 | | - $j( '#upProgressDialog' ).empty().dialog( 'close' ); |
1051 | | - } |
| 1031 | + if ( apiResult && apiResult.resultUrl ) { |
| 1032 | + var buttons = {}; |
| 1033 | + buttons[ gM( 'mwe-go-to-resource' ) ] = function() { |
| 1034 | + window.location = apiResult.resultUrl; |
| 1035 | + } |
| 1036 | + var go_to_url_txt = gM( 'mwe-go-to-resource' ); |
| 1037 | + var showMessage = true; |
| 1038 | + if ( typeof _this.done_upload_cb == 'function' ) { |
| 1039 | + // Call the callback |
| 1040 | + // It will return false if it doesn't want us to show our own "done" message |
| 1041 | + showMessage = _this.done_upload_cb( _this.formData ); |
| 1042 | + } |
| 1043 | + if ( showMessage ) { |
| 1044 | + _this.updateProgressWin( gM( 'mwe-successfulupload' ), |
| 1045 | + gM( 'mwe-upload_done', apiResult.resultUrl ), buttons ); |
1052 | 1046 | } else { |
1053 | | - // Done state with error? Not really possible given how firefogg works... |
1054 | | - js_log( " Upload done in chunks mode, but no resultUrl!" ); |
| 1047 | + this.action_done = true; |
| 1048 | + $j( '#upProgressDialog' ).empty().dialog( 'close' ); |
1055 | 1049 | } |
1056 | 1050 | } else { |
1057 | | - js_log( "Error:: not supported upload mode" + _this.upload_mode ); |
| 1051 | + // Done state with error? Not really possible given how firefogg works... |
| 1052 | + js_log( " Upload done in chunks mode, but no resultUrl!" ); |
1058 | 1053 | } |
| 1054 | + |
1059 | 1055 | } |
1060 | 1056 | uploadStatus(); |
1061 | 1057 | }, |
— | — | @@ -1068,7 +1064,7 @@ |
1069 | 1065 | } |
1070 | 1066 | js_log( 'firefogg:cancel' ) |
1071 | 1067 | if ( confirm( gM( 'mwe-cancel-confim' ) ) ) { |
1072 | | - // FIXME: sillyness |
| 1068 | + // FIXME: sillyness ( upstream firefogg cancel fix needed ) |
1073 | 1069 | if ( navigator.oscpu && navigator.oscpu.search( 'Win' ) >= 0 ) { |
1074 | 1070 | alert( 'sorry we do not yet support cancel on windows' ); |
1075 | 1071 | } else { |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js |
— | — | @@ -133,9 +133,15 @@ |
134 | 134 | // set up the binding per the config |
135 | 135 | if ( opt.enable_fogg ) { |
136 | 136 | $j( "#wpUploadFile" ).firefogg( { |
137 | | - // an api url (we won't submit directly to action of the form) |
| 137 | + // An api url (we won't submit directly to action of the form) |
138 | 138 | 'api_url' : opt.api_target, |
| 139 | + |
| 140 | + // If we should do a form rewrite |
139 | 141 | 'form_rewrite': true, |
| 142 | + |
| 143 | + // MediaWiki API supports chunk uploads: |
| 144 | + 'enable_chunks' : true, |
| 145 | + |
140 | 146 | 'edit_form_selector' : '#suf-upload', |
141 | 147 | 'new_source_cb' : function( orgFilename, oggName ) { |
142 | 148 | $j( "#wpDestFile" ).val( oggName ).doDestCheck( { |
Index: trunk/phase3/js2/uploadPage.js |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | var _this = this; |
12 | 12 | // If wgEnableFirefogg is not boolean false, set to true |
13 | 13 | if ( typeof wgEnableFirefogg == 'undefined' ) |
14 | | - wgEnableFirefogg = true; |
| 14 | + wgEnableFirefogg = true; |
15 | 15 | |
16 | 16 | if ( wgEnableFirefogg ) { |
17 | 17 | // Set up the upload handler to Firefogg. Should work with the HTTP uploads too. |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | // An API URL (we won't submit directly to action of the form) |
20 | 20 | 'api_url': wgServer + wgScriptPath + '/api.php', |
21 | 21 | 'form_rewrite': true, |
| 22 | + // MediaWiki API supports chunk uploads: |
| 23 | + 'enable_chunks' : true, |
22 | 24 | 'edit_form_selector': mwUploadFormSelector, |
23 | 25 | 'new_source_cb': function( orgFilename, oggName ) { |
24 | 26 | $j( '#wpDestFile' ).val( oggName ); |