Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php |
— | — | @@ -310,7 +310,7 @@ |
311 | 311 | |
312 | 312 | //temp for testing: |
313 | 313 | if( $mvgJSDebug ) |
314 | | - $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/external_media_wizard.js?{$unique_req_param}\"></script>" ); |
| 314 | + $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/add_media_wizard.js?{$unique_req_param}\"></script>" ); |
315 | 315 | |
316 | 316 | $mvCssUrl = $mvgScriptPath . '/skins/mv_custom.css'; |
317 | 317 | $wgOut->addLink( array( |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mv_upload.js |
— | — | @@ -23,6 +23,8 @@ |
24 | 24 | init:function( iObj ){ |
25 | 25 | var _this = this; |
26 | 26 | js_log('init uploader'); |
| 27 | + if(!iObj) |
| 28 | + iObj = {}; |
27 | 29 | for(var i in default_upload_options){ |
28 | 30 | if(iObj[i]){ |
29 | 31 | this[i] = iObj[i]; |
— | — | @@ -30,41 +32,57 @@ |
31 | 33 | this[i] = default_upload_options[i]; |
32 | 34 | } |
33 | 35 | } |
| 36 | + //check if we are on the uplaod page: |
| 37 | + this.on_upload_page = ( wgPageName== "Special:Upload")?true:false; |
| 38 | + js_log('f:mvUploader: onuppage:' + this.on_upload_page); |
34 | 39 | //grab firefogg.js: |
35 | | - mvJsLoader.doLoad({'upFirefogg' : 'libAddMedia/firefogg.js'},function(){ |
36 | | - //for now grab the upload HTML (uggly but will be replaced by API shortly I promise ) |
37 | | - $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){ |
38 | | - //filter the data: |
39 | | - sp = data.indexOf('<div id="content">'); |
40 | | - se = data.indexOf('<!-- end content -->'); |
41 | | - if(sp!=-1 && se !=-1){ |
42 | | - $j('#'+_this.target_div).html( data.substr(sp, (se-sp) ) ); |
43 | | - } |
44 | | - //add firebug html if not already there: ( same as $wgEnableFirebug ) |
45 | | - if( $j('#fogg-video-file').length==0 ){ |
46 | | - _this.addFirebugHtml(); |
47 | | - }else{ |
48 | | - js_log('firefogg already there init:'); |
49 | | - } |
50 | | - init_firefogg({'add_done_action':function( rTitle ){ |
| 40 | + mvJsLoader.doLoad({'upFirefogg' : 'libAddMedia/firefogg.js'},function(){ |
| 41 | + //if we are not on the upload page grab the upload html via ajax: |
| 42 | + if( !_this.on_upload_page){ |
| 43 | + $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){ |
| 44 | + sp = data.indexOf('<div id="content">'); |
| 45 | + se = data.indexOf('<!-- end content -->'); |
| 46 | + if(sp!=-1 && se !=-1){ |
| 47 | + $j('#'+_this.target_div).html( data.substr(sp, (se-sp) ) ); |
| 48 | + } |
| 49 | + _this.setupFirefogg(); |
| 50 | + }); |
| 51 | + }else{ |
| 52 | + _this.setupFirefogg(); |
| 53 | + } |
| 54 | + }); |
| 55 | + }, |
| 56 | + setupFirefogg:function(){ |
| 57 | + var _this = this; |
| 58 | + //add firebug html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php ) |
| 59 | + if( $j('#fogg-video-file').length==0 ){ |
| 60 | + js_log('add addFirefoggHtml'); |
| 61 | + _this.addFirefoggHtml(); |
| 62 | + }else{ |
| 63 | + js_log('firefogg already there init:'); |
| 64 | + } |
| 65 | + //set up the upload_done action |
| 66 | + //redirect if we are on the upload page |
| 67 | + //do a callback if in called from gui) |
| 68 | + var intFirefoggObj = (this.on_upload_page)? |
| 69 | + {'upload_done_action':'redirect'}: |
| 70 | + {'upload_done_action':function( rTitle ){ |
51 | 71 | js_log('add_done_action callback for uploader'); |
52 | | - //call the parent insert resource preview |
53 | | - |
| 72 | + //call the parent insert resource preview |
54 | 73 | } |
55 | | - }); |
56 | | - //set up the bindings |
57 | | - $j('#mw-upload-form').submit(function(){ |
58 | | - //do an ajax submit |
59 | | - |
60 | | - //(don't do the normal submit) |
61 | | - return false; |
62 | | - }); |
63 | | - }); |
64 | | - }); |
| 74 | + }; |
| 75 | + init_firefogg( intFirefoggObj ); |
| 76 | + //firefogg handles the form submit (even on image uploads when called by gui) |
| 77 | + if( !this.on_upload_page ){ |
| 78 | + $j('#mw-upload-form').submit(function(){ |
| 79 | + return false; |
| 80 | + }); |
| 81 | + } |
65 | 82 | }, |
66 | 83 | //same add code as specialUpload if($wgEnableFirefogg){ |
67 | | - addFirebugHtml:function(){ |
68 | | - $j('#mw-upload-table .mw-input :first').wrap('<div id="wg-base-upload"></div>'); |
| 84 | + addFirefoggHtml:function(){ |
| 85 | + var itd_html = $j('#mw-upload-table .mw-input:first').html(); |
| 86 | + $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>'); |
69 | 87 | //add in firefogg control |
70 | 88 | $j('#wg-base-upload').after('<p id="fogg-enable-item" >' + |
71 | 89 | '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="Select File..">' + |
— | — | @@ -74,9 +92,7 @@ |
75 | 93 | '<span id="wgfogg_installed" style="display:none" >'+ |
76 | 94 | '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' + |
77 | 95 | getMsg('upload-enable-converter') + |
78 | | - '<span><br></p>'); |
79 | | - alert('wtf'); |
80 | | - js_log('FOUND: ' + $j('#fogg-enable-item').length + ' wg: ' + $j('#wgEnableFirefogg').length ); |
| 96 | + '<span><br></p>'); |
81 | 97 | //add in loader dl box: |
82 | 98 | $j('#mw-upload-table').before('<div id="dlbox-centered" class="dlbox-centered" >'+ |
83 | 99 | '<h5>' + getMsg('upload-in-progress') + '</h5>' + |
— | — | @@ -87,9 +103,6 @@ |
88 | 104 | '<span id="fogg-status-transcode">' + getMsg('upload-transcoded-status') + '</span>'+ |
89 | 105 | '<span style="display:none" id="fogg-status-upload">' + getMsg('uploaded-status') + '</span>' + |
90 | 106 | '</div>'+ |
91 | | - '<div class="dlbox-overlay" ></div>'); |
92 | | - //init firefogg (check for its existance) |
93 | | - js_log('FOUND: ' + $j('#wgEnableFirefogg').length ); |
94 | | - js_log('run init_firefogg'); |
| 107 | + '<div class="dlbox-overlay" ></div>'); |
95 | 108 | } |
96 | 109 | } |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/firefogg.js |
— | — | @@ -194,12 +194,12 @@ |
195 | 195 | var sstring = 'var wgTitle = "' + data['wpDestFile'].replace('_',' '); |
196 | 196 | if( result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){ |
197 | 197 | js_log('upload done got redirect found: ' +sstring); |
198 | | - if(_this.add_done_action == 'redirect'){ |
| 198 | + if(_this.upload_done_action == 'redirect'){ |
199 | 199 | window.location = wgArticlePath.replace(/\$1/, 'File:' + data['wpDestFile'] ); |
200 | 200 | }else{ |
201 | 201 | //check if the add_done_action is a callback: |
202 | | - if(typeof _this.add_done_action == 'function') |
203 | | - _this.add_done_action(); |
| 202 | + if(typeof _this.upload_done_action == 'function') |
| 203 | + _this.upload_done_action(); |
204 | 204 | } |
205 | 205 | }else{ |
206 | 206 | js_log('upload page error: did not find: ' +sstring); |