Index: branches/js2-work/phase3/js/mwEmbed/loader.js |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | |
91 | 91 | // Default request timeout ( for cases where we inlucde js and normal browser timeout can't be used ) |
92 | 92 | // stored in seconds |
93 | | - 'defaultRequestTimeout' : 10, |
| 93 | + 'defaultRequestTimeout' : 20, |
94 | 94 | |
95 | 95 | // Default user language is "en" Can be overwritten by: |
96 | 96 | // "uselang" url param |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js |
— | — | @@ -49,10 +49,10 @@ |
50 | 50 | 'upload_mode' : 'api', |
51 | 51 | |
52 | 52 | // Callback for modifying form data on submit |
53 | | - 'onsubmit_cb' : null, |
| 53 | + 'beforeSubmitCb' : null, |
54 | 54 | |
55 | 55 | // Equivalent to $wgUseCopyrightUpload in php ( should be set via configuration ) |
56 | | - 'useCopyrightUpload' : true, |
| 56 | + 'rewriteDescriptionText' : true, |
57 | 57 | |
58 | 58 | // Callback which is called when the source name changes |
59 | 59 | 'selectFileCb': false |
— | — | @@ -223,16 +223,14 @@ |
224 | 224 | return true; |
225 | 225 | } |
226 | 226 | |
227 | | - // Call the onsubmit_cb option if set: |
228 | | - if( this.onsubmit_cb && typeof this.onsubmit_cb == 'function' ) { |
229 | | - this.onsubmit_cb(); |
| 227 | + // Call the beforeSubmitCb option if set: |
| 228 | + if( this.beforeSubmitCb && typeof this.beforeSubmitCb == 'function' ) { |
| 229 | + this.beforeSubmitCb(); |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Remap the upload form to the "api" form: |
233 | | - this.remapFormToApi(); |
| 233 | + this.remapFormToApi(); |
234 | 234 | |
235 | | - |
236 | | - |
237 | 235 | mw.log(" about to run onSubmit try / catch: detectUploadMode" ); |
238 | 236 | // Put into a try catch so we are sure to return false: |
239 | 237 | try { |
— | — | @@ -251,6 +249,7 @@ |
252 | 250 | _this.upload_mode = mode; |
253 | 251 | _this.doUpload(); |
254 | 252 | } ); |
| 253 | + |
255 | 254 | } catch( e ) { |
256 | 255 | mw.log( '::error in this.ui or doUpload ' + e ); |
257 | 256 | } |
— | — | @@ -497,9 +496,9 @@ |
498 | 497 | // Else try with the form name: |
499 | 498 | comment_value = $j( "[name='comment']").val(); |
500 | 499 | } |
501 | | - mw.log( 'getUploadDescription:: base:' + comment_value + ' ucr:' + this.useCopyrightUpload ); |
| 500 | + mw.log( 'getUploadDescription:: base:' + comment_value + ' ucr:' + this.rewriteDescriptionText ); |
502 | 501 | // Set license, copyStatus, source if available ( generally not available SpecialUpload needs some refactoring ) |
503 | | - if ( this.useCopyrightUpload ) { |
| 502 | + if ( this.rewriteDescriptionText ) { |
504 | 503 | var license = ( $j("[name='wpLicense']").length ) ? $j("[name='wpLicense']").val() : ''; |
505 | 504 | var copyStatus = ( $j("[name='wpUploadCopyStatus']" ).length ) ? $j("[name='wpUploadCopyStatus']" ).val() : ''; |
506 | 505 | var source = ( $j("[name='wpSource']").length ) ? $j("[name='wpSource']").val() : ''; |
— | — | @@ -513,7 +512,7 @@ |
514 | 513 | |
515 | 514 | /** |
516 | 515 | * Get the comment text ( port of getInitialPageText from SpecialUpload.php |
517 | | - * We only copy part of the check where useCopyrightUpload is enabled as |
| 516 | + * We only copy part of the check where rewriteDescriptionText is enabled as |
518 | 517 | * to not conflict with other js rewrites. |
519 | 518 | * |
520 | 519 | * @param {String} comment Comment string |
— | — | @@ -532,7 +531,7 @@ |
533 | 532 | licensetxt; |
534 | 533 | } |
535 | 534 | if( source ){ |
536 | | - pageText += '== ' + gM( 'filesource' ) + " ==\n" . source ; |
| 535 | + pageText += '== ' + gM( 'filesource' ) + " ==\n" + source ; |
537 | 536 | } |
538 | 537 | return pageText; |
539 | 538 | }, |
— | — | @@ -735,20 +734,18 @@ |
736 | 735 | // Async upload, do AJAX status polling |
737 | 736 | _this.upload_session_key = apiRes.upload.upload_session_key; |
738 | 737 | _this.doAjaxUploadStatus(); |
739 | | - mw.log( "set upload_session_key: " + _this.upload_session_key ); |
| 738 | + mw.log( "Set upload_session_key: " + _this.upload_session_key ); |
740 | 739 | return true; |
741 | 740 | } |
742 | 741 | |
743 | 742 | if ( apiRes.upload && apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ) { |
744 | 743 | // Call the completion callback if available. |
745 | 744 | if ( typeof _this.doneUploadCb == 'function' ) { |
746 | | - // check if the callback returns true and close up shop |
747 | | - if( _this.doneUploadCb( apiRes ) ){ |
| 745 | + _this.doneUploadCb( apiRes ) |
748 | 746 | // Close the ui |
749 | 747 | _this.ui.close(); |
750 | 748 | return true; |
751 | | - } |
752 | | - } |
| 749 | + } |
753 | 750 | // Else pass off the api Success to interface: |
754 | 751 | _this.ui.showApiSuccess( apiRes ); |
755 | 752 | return true; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js |
— | — | @@ -31,11 +31,23 @@ |
32 | 32 | "kalturaSearch" : "modules/AddMedia/searchLibs/kalturaSearch.js" |
33 | 33 | }); |
34 | 34 | |
35 | | - /** |
36 | | - * Note: We should move relevant parts of these style sheets to the addMedia/css folder |
37 | | - * phase 2: We should separate out sheet sets per sub-module: |
38 | | - */ |
| 35 | + // Upload form includes "datapicker" |
| 36 | + mw.addModuleLoader( 'AddMedia.UploadForm', function( callback ){ |
| 37 | + var request = [ |
| 38 | + [ |
| 39 | + 'mw.UploadForm', |
| 40 | + '$j.ui' |
| 41 | + ], |
| 42 | + [ |
| 43 | + '$j.ui.datepicker' |
| 44 | + ] |
| 45 | + ]; |
| 46 | + mw.load( request , function() { |
| 47 | + callback( 'AddMedia.UploadForm' ); |
| 48 | + } ); |
| 49 | + }) |
39 | 50 | |
| 51 | + |
40 | 52 | //Setup the addMediaWizard module |
41 | 53 | mw.addModuleLoader( 'AddMedia.addMediaWizard', function( callback ) { |
42 | 54 | // Load all the required libs: |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js |
— | — | @@ -99,9 +99,10 @@ |
100 | 100 | */ |
101 | 101 | ( function( $ ) { |
102 | 102 | $.fn.firefogg = function( options ) { |
103 | | - if ( !options ) |
| 103 | + if ( !options ){ |
104 | 104 | options = { }; |
105 | | - |
| 105 | + } |
| 106 | + |
106 | 107 | // Add the selector |
107 | 108 | options[ 'selector' ] = this.selector; |
108 | 109 | |
— | — | @@ -183,7 +184,7 @@ |
184 | 185 | this.showInstallFirefog(); |
185 | 186 | return ; |
186 | 187 | } |
187 | | - if( console.firebug ) { |
| 188 | + if( typeof console != 'undefined' && console.firebug ) { |
188 | 189 | this.appendFirebugWarning(); |
189 | 190 | } |
190 | 191 | mw.log( "installCheckMode no firefogg init"); |
— | — | @@ -1225,12 +1226,11 @@ |
1226 | 1227 | this.action_done = true; |
1227 | 1228 | // Call the callback |
1228 | 1229 | if ( typeof _this.doneUploadCb == 'function' ) { |
1229 | | - // check if the callback returns true and close up shop |
1230 | | - if( _this.doneUploadCb( apiRes ) ){ |
1231 | | - _this.ui.close(); |
1232 | | - return true; |
1233 | | - } |
1234 | | - } |
| 1230 | + _this.doneUploadCb( apiRes ) |
| 1231 | + // Close the ui |
| 1232 | + _this.ui.close(); |
| 1233 | + return true; |
| 1234 | + } |
1235 | 1235 | // Else pass off the api Success to interface: |
1236 | 1236 | _this.ui.showApiSuccess( apiResult ); |
1237 | 1237 | return true; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadForm.js |
— | — | @@ -9,7 +9,10 @@ |
10 | 10 | "mwe-license_cc-by-sa" : "Creative Commons Share Alike (3.0)", |
11 | 11 | "mwe-upload" : "Upload file", |
12 | 12 | "mwe-destfilename" : "Destination filename:", |
| 13 | + |
13 | 14 | "mwe-summary" : "Summary", |
| 15 | + "mwe-date-of-work" : "Date of the work", |
| 16 | + |
14 | 17 | "mwe-error_not_loggedin" : "You do not appear to be logged in or do not have upload privileges.", |
15 | 18 | |
16 | 19 | "mwe-error-not-loggedin-file" : "You do not appear to be logged in or there was an error in the software. You can $1 and try again", |
— | — | @@ -161,6 +164,8 @@ |
162 | 165 | |
163 | 166 | // MediaWiki API supports chunk uploads: |
164 | 167 | 'enable_chunks' : false, |
| 168 | + // We manually rewrite our description text |
| 169 | + 'rewriteDescriptionText' : false, |
165 | 170 | |
166 | 171 | 'form_selector' : '#suf_upload', |
167 | 172 | |
— | — | @@ -174,31 +179,41 @@ |
175 | 180 | 'warn_target' : "#wpDestFile-warning" |
176 | 181 | } ); |
177 | 182 | }, |
178 | | - 'onsubmit_cb' : function( ) { |
179 | | - // Update with basic info template: |
180 | | - // TODO: it would be nice to have a template generator class |
181 | | - var desc = $j('#wpUploadDescription').val(); |
182 | | - |
183 | | - // Update the template if the user does not already have template code: |
184 | | - if( desc.indexOf('{{Information') == -1) { |
185 | | - $j('#wpUploadDescription').val( |
186 | | -'== {{int:filedesc}} ==' + "\n" + |
187 | | -'{{Information' + "\n" + |
188 | | -'|Description={{en|' + desc + "\n}}\n" + |
189 | | -'|Author=[[User:' + wgUserName + '|' + wgUserName + ']]' + "\n" + |
190 | | -'|Source=' + "\n" + |
191 | | -'|Date=' + "\n" + |
192 | | -'|Permission=' + "\n" + |
193 | | -'|other_versions=' + "\n" + |
194 | | -'}}' + "\n" + |
195 | | -'{{self|cc-by-sa-3.0}}' + "\n" |
196 | | - ); |
197 | | - } |
| 183 | + 'beforeSubmitCb' : function( ) { |
| 184 | + buildAssetDescription(); |
198 | 185 | } |
199 | 186 | } ); |
200 | 187 | }); |
201 | 188 | } |
202 | 189 | /** |
| 190 | + * Build the Asset Description info template |
| 191 | + * and update the wpUploadDescription value |
| 192 | + */ |
| 193 | + function buildAssetDescription(){ |
| 194 | + // Update with basic info template: |
| 195 | + // TODO: it would be nice to have a template generator class |
| 196 | + // this is basicaly a simple version of the commons form hack |
| 197 | + var desc = $j('#comment-desc').val(); |
| 198 | + var date = $j('#comment-date').val(); |
| 199 | + |
| 200 | + // Update the template if the user does not already have template code: |
| 201 | + if( desc.indexOf('{{Information') == -1) { |
| 202 | + $j('#wpUploadDescription').val( |
| 203 | + '== {{int:filedesc}} ==' + "\n" + |
| 204 | + '{{Information' + "\n" + |
| 205 | + '|Description={{en|' + desc + "\n}}\n" + |
| 206 | + '|Author=[[User:' + wgUserName + '|' + wgUserName + ']]' + "\n" + |
| 207 | + '|Source=' + "\n" + |
| 208 | + '|Date=' + date + "\n" + |
| 209 | + '|Permission=' + "\n" + |
| 210 | + '|other_versions=' + "\n" + |
| 211 | + '}}' + "\n" + |
| 212 | + '== {{int:license}} ==' + "\n" + |
| 213 | + '{{self|cc-by-sa-3.0}}' + "\n" |
| 214 | + ); |
| 215 | + } |
| 216 | + } |
| 217 | + /** |
203 | 218 | * Setup a fileBrowse proxy for a given target |
204 | 219 | */ |
205 | 220 | function setupApiFileBrowseProxy ( options ) { |
— | — | @@ -233,6 +248,7 @@ |
234 | 249 | 'warn_target': '#file-warning' |
235 | 250 | } ); |
236 | 251 | }, |
| 252 | + |
237 | 253 | // Timeout callback |
238 | 254 | 'timeoutCb' : function(){ |
239 | 255 | mw.log("timed out in setting up setupApiFileBrowseProxy"); |
— | — | @@ -248,7 +264,19 @@ |
249 | 265 | } ); |
250 | 266 | |
251 | 267 | // Setup submit binding: |
252 | | - $j('#wpUploadBtn').click( function(){ |
| 268 | + $j('#wpUploadBtn').click( function(){ |
| 269 | + |
| 270 | + // Update the asset description: |
| 271 | + buildAssetDescription(); |
| 272 | + |
| 273 | + // Dissable upload button and add loader: |
| 274 | + $j( '#wpUploadBtn' ) |
| 275 | + .attr( 'disabled', 'disabled' ) |
| 276 | + .before( |
| 277 | + $j('<span />').loadingSpinner() |
| 278 | + ); |
| 279 | + |
| 280 | + |
253 | 281 | // Build the output and send upload request to fileProxy |
254 | 282 | mw.ApiProxy.sendServerMsg( { |
255 | 283 | 'apiUrl' : options.apiUrl, |
— | — | @@ -262,8 +290,7 @@ |
263 | 291 | 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false' |
264 | 292 | } |
265 | 293 | } |
266 | | - } ); |
267 | | - // Maybe set loading to spinner |
| 294 | + } ); |
268 | 295 | } ); |
269 | 296 | |
270 | 297 | // Overwide the form submit: |
— | — | @@ -317,7 +344,7 @@ |
318 | 345 | "doneUploadCb" : function( resultData ) { |
319 | 346 | if( !resultData || ! resultData.upload || ! resultData.upload['filename']){ |
320 | 347 | mw.log( "Error in upload form no upload data in done Upload callback "); |
321 | | - return false; |
| 348 | + return true; |
322 | 349 | } |
323 | 350 | var wTitle = resultData.upload['filename']; |
324 | 351 | mw.log( 'uploadForm: doneUploadCb : '+ wTitle); |
— | — | @@ -331,8 +358,8 @@ |
332 | 359 | // Pull up resource editor: |
333 | 360 | remoteSearchDriver.showResourceEditor( resource ); |
334 | 361 | } ); |
335 | | - // Return false to close progress window: |
336 | | - return false; |
| 362 | + // Return true to close progress window: |
| 363 | + return true; |
337 | 364 | } |
338 | 365 | } ); |
339 | 366 | |
— | — | @@ -497,7 +524,7 @@ |
498 | 525 | $j( '<br />' ), |
499 | 526 | $j( '<label />' ) |
500 | 527 | .attr({ |
501 | | - 'for' : "wpUploadDescription" |
| 528 | + 'for' : "comment-desc" |
502 | 529 | }) |
503 | 530 | .text( gM( 'mwe-summary' ) ), |
504 | 531 | |
— | — | @@ -505,16 +532,65 @@ |
506 | 533 | |
507 | 534 | $j( '<textarea />' ) |
508 | 535 | .attr( { |
509 | | - 'id' : "wpUploadDescription", |
| 536 | + 'id' : "comment-desc", |
510 | 537 | 'cols' : "30", |
511 | 538 | 'rows' : "3", |
512 | | - 'name' : "wpUploadDescription", |
| 539 | + 'name' : "comment-desc", |
513 | 540 | 'tabindex' : "3" |
514 | 541 | } ), |
515 | 542 | |
516 | 543 | $j( '<br />' ) |
517 | 544 | ); |
| 545 | + // Add the hidden wpUploadDescription |
| 546 | + $uploadForm.append( |
| 547 | + $j( '<input />' ) |
| 548 | + .attr( { |
| 549 | + 'id' : "wpUploadDescription", |
| 550 | + 'type' : "hidden", |
| 551 | + 'name' : "wpUploadDescription" |
| 552 | + } ) |
| 553 | + .val('') |
| 554 | + ) |
518 | 555 | |
| 556 | + //Add date of work |
| 557 | + $uploadForm.append( |
| 558 | + $j( '<label />' ) |
| 559 | + .attr({ |
| 560 | + 'for' : "comment-date" |
| 561 | + }) |
| 562 | + .text( gM( 'mwe-date-of-work' ) ), |
| 563 | + |
| 564 | + $j( '<br />' ), |
| 565 | + |
| 566 | + $j( '<input />' ) |
| 567 | + .attr( { |
| 568 | + 'id' : "comment-date", |
| 569 | + 'size' : 15, |
| 570 | + 'name' : "comment-date", |
| 571 | + 'tabindex' : "4" |
| 572 | + } ) |
| 573 | + .datepicker({ |
| 574 | + changeMonth: true, |
| 575 | + changeYear: true, |
| 576 | + verticalOffset: 40, |
| 577 | + dateFormat: 'yy-mm-dd', |
| 578 | + onSelect: function( dateText ) { |
| 579 | + $j( this ).val( dateText ); |
| 580 | + }, |
| 581 | + beforeShow: function() { |
| 582 | + $j('#ui-datepicker-div').css({ |
| 583 | + 'z-index': 10001 |
| 584 | + }); |
| 585 | + return true; |
| 586 | + } |
| 587 | + }), |
| 588 | + |
| 589 | + $j( '<br />' ) |
| 590 | + ) |
| 591 | + |
| 592 | + |
| 593 | + |
| 594 | + |
519 | 595 | // Add watchlist checkbox |
520 | 596 | $uploadForm.append( |
521 | 597 | $j('<input />') |
— | — | @@ -523,7 +599,7 @@ |
524 | 600 | 'value' : 'true', |
525 | 601 | 'id' : 'wpWatchthis', |
526 | 602 | 'name' : 'watch', |
527 | | - 'tabindex' : 7 |
| 603 | + 'tabindex' : "5" |
528 | 604 | }), |
529 | 605 | |
530 | 606 | $j( '<label />' ) |
— | — | @@ -541,7 +617,7 @@ |
542 | 618 | 'value' : "true", |
543 | 619 | 'id' : "wpIgnoreWarning", |
544 | 620 | 'name' : "ignorewarnings", |
545 | | - 'tabindex' : "8" |
| 621 | + 'tabindex' : "6" |
546 | 622 | } ), |
547 | 623 | |
548 | 624 | $j( '<label />' ) |
— | — | @@ -600,7 +676,7 @@ |
601 | 677 | 'value' : gM( 'mwe-upload' ), |
602 | 678 | 'name' : "wpUploadBtn", |
603 | 679 | 'id' : "wpUploadBtn", |
604 | | - 'tabindex' : "9" |
| 680 | + 'tabindex' : "7" |
605 | 681 | }) |
606 | 682 | ); |
607 | 683 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -1043,13 +1043,11 @@ |
1044 | 1044 | // Show the upload form (use the standard module AddMedia.firefogg |
1045 | 1045 | // This way we get a high cache hit rate by using a general module |
1046 | 1046 | // and not grouping mw.UploadForm into the upload code set |
1047 | | - mw.load( 'AddMedia.firefogg', function() { |
1048 | | - mw.load( 'mw.UploadForm', function() { |
1049 | | - var provider = _this.content_providers[ 'this_wiki' ]; |
1050 | | - // Load this_wiki search system to grab the resource |
1051 | | - _this.loadSearchLib( provider, function() { |
1052 | | - _this.showUploadForm( provider ); |
1053 | | - } ); |
| 1047 | + mw.load( [ 'AddMedia.firefogg', 'AddMedia.UploadForm' ], function() { |
| 1048 | + var provider = _this.content_providers[ 'this_wiki' ]; |
| 1049 | + // Load this_wiki search system to grab the resource |
| 1050 | + _this.loadSearchLib( provider, function() { |
| 1051 | + _this.showUploadForm( provider ); |
1054 | 1052 | } ); |
1055 | 1053 | } ); |
1056 | 1054 | }, |
— | — | @@ -2405,7 +2403,7 @@ |
2406 | 2404 | } |
2407 | 2405 | |
2408 | 2406 | // Load the preview text: |
2409 | | - _this.parse( |
| 2407 | + mw.parseWikiText( |
2410 | 2408 | description, _this.canonicalFileNS + ':' + resource.target_resource_title, |
2411 | 2409 | function( descHtml ) { |
2412 | 2410 | $j( '#rsd_import_desc' ).html( descHtml ); |
— | — | @@ -2419,12 +2417,12 @@ |
2420 | 2418 | mw.log( " Do preview asset update" ); |
2421 | 2419 | $j( '#rsd_import_desc' ).html( mw.loading_spinner() ); |
2422 | 2420 | // load the preview text: |
2423 | | - _this.parse( |
| 2421 | + mw.parseWikiText( |
2424 | 2422 | $j( '#wpUploadDescription' ).val(), |
2425 | 2423 | _this.canonicalFileNS + ':' + resource.target_resource_title, |
2426 | | - function( o ) { |
| 2424 | + function( parseHtml ) { |
2427 | 2425 | mw.log( 'got updated preview: ' ); |
2428 | | - $j( '#rsd_import_desc' ).html( o ); |
| 2426 | + $j( '#rsd_import_desc' ).html( parseHtml ); |
2429 | 2427 | } |
2430 | 2428 | ); |
2431 | 2429 | return false; |
— | — | @@ -2795,9 +2793,9 @@ |
2796 | 2794 | var embed_code = _this.getEmbedCode( resource ); |
2797 | 2795 | var pos = $j( _this.target_textbox ).textSelection( 'getCaretPosition' ); |
2798 | 2796 | var editWikiText = $j( _this.target_textbox ).val(); |
2799 | | - var parseText = editWikiText.substr(0, pos) + embed_code + editWikiText.substr( pos ); |
2800 | | - _this.parse( |
2801 | | - parseText, |
| 2797 | + var wikiText = editWikiText.substr(0, pos) + embed_code + editWikiText.substr( pos ); |
| 2798 | + mw.parseWikiText( |
| 2799 | + wikiText, |
2802 | 2800 | _this.target_title, |
2803 | 2801 | function( phtml ) { |
2804 | 2802 | $j( '#rsd_preview_display' ).html( phtml ); |
— | — | @@ -2826,28 +2824,9 @@ |
2827 | 2825 | } else { |
2828 | 2826 | return resource.pSobj.getEmbedWikiCode( resource ); |
2829 | 2827 | } |
2830 | | - }, |
| 2828 | + }, |
2831 | 2829 | |
2832 | 2830 | /** |
2833 | | - * issues the wikitext parse call |
2834 | | - * |
2835 | | - * @param {String} wikitext Wiki Text to be parsed by mediaWiki api call |
2836 | | - * @param {String} title Context title of the content to be parsed |
2837 | | - * @param {Function} callback Function called with api parser output |
2838 | | - */ |
2839 | | - parse: function( wikitext, title, callback ) { |
2840 | | - mw.getJSON( mw.getLocalApiUrl(), |
2841 | | - { |
2842 | | - 'action': 'parse', |
2843 | | - 'title' : title, |
2844 | | - 'text': wikitext |
2845 | | - }, function( data ) { |
2846 | | - callback( data.parse.text['*'] ); |
2847 | | - } |
2848 | | - ); |
2849 | | - }, |
2850 | | - |
2851 | | - /** |
2852 | 2831 | * Insert a resource |
2853 | 2832 | * |
2854 | 2833 | * Calls updateTextArea with the passed resource |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js |
— | — | @@ -101,12 +101,8 @@ |
102 | 102 | if( !options.token ){ |
103 | 103 | mw.log( "Error: no token for file browse "); |
104 | 104 | return false; |
105 | | - } |
| 105 | + } |
106 | 106 | |
107 | | - mw.log( "browseFile:: " + $j(options.target).length ); |
108 | | - |
109 | | - mw.log( "BROWSE FILE:: cb: " + options.doneUploadCb); |
110 | | - |
111 | 107 | if( ! options.apiUrl ) { |
112 | 108 | mw.log( "Error: no api url to target" ); |
113 | 109 | return false; |
— | — | @@ -239,9 +235,9 @@ |
240 | 236 | } |
241 | 237 | |
242 | 238 | //Setup a new context |
243 | | - var context = createContext({ |
| 239 | + var context = createContext( { |
244 | 240 | 'apiUrl' : options.apiUrl |
245 | | - }); |
| 241 | + } ); |
246 | 242 | |
247 | 243 | // Send a msg to the server frameName from the server domain |
248 | 244 | // Setup an object to be packaged into the frame |
— | — | @@ -388,12 +384,19 @@ |
389 | 385 | /** |
390 | 386 | * Get the client frame path |
391 | 387 | */ |
392 | | - function getClientFrame( context ) { |
| 388 | + function getClientFrame( context ) { |
393 | 389 | // Check if the mwEmbed is on the same server as we are |
394 | 390 | if( mw.isLocalDomain( mw.getMwEmbedPath() ) ){ |
395 | 391 | return mw.getMwEmbedPath() + 'modules/ApiProxy/NestedCallbackIframe.html'; |
396 | | - } else { |
397 | | - // Use the nested callback function |
| 392 | + } else { |
| 393 | + // Use the nested callback function ( server frame point back ) |
| 394 | + nestedServerFrame = getServerFrame( { |
| 395 | + 'apiUrl' : mw.getLocalApiUrl(), |
| 396 | + 'pageName' : 'ApiProxyNestedCb' |
| 397 | + } ); |
| 398 | + |
| 399 | + // Update the context to include the nestedCallbackFlag flag in the request |
| 400 | + return nestedServerFrame; |
398 | 401 | } |
399 | 402 | } |
400 | 403 | |
— | — | @@ -421,8 +424,10 @@ |
422 | 425 | } |
423 | 426 | var parsedUrl = mw.parseUri( context.apiUrl ); |
424 | 427 | |
| 428 | + var pageName = ( context.pageName ) ? context.pageName : 'ApiProxy' |
| 429 | + |
425 | 430 | return parsedUrl.protocol + '://' + parsedUrl.authority |
426 | | - + '/w/index.php/MediaWiki:ApiProxy' + gadgetWithJS; |
| 431 | + + '/w/index.php/MediaWiki:' + pageName + gadgetWithJS; |
427 | 432 | } |
428 | 433 | |
429 | 434 | /** |
— | — | @@ -531,11 +536,11 @@ |
532 | 537 | * @param {Object} context |
533 | 538 | */ |
534 | 539 | function proxyNotReadyTimeout( context ) { |
535 | | - mw.log( 'proxyNotReadyTimeout::' + context[ 'timeoutCb' ]); |
| 540 | + mw.log( "Error:: api proxy timeout " + context.contextKey ); |
536 | 541 | |
537 | 542 | // See if we have a callback function to call ( do not display the dialog ) |
538 | 543 | if( context[ 'timeoutCb' ] && typeof context[ 'timeoutCb' ] == 'function' ) { |
539 | | - context[ 'timeoutCb' ](); |
| 544 | + context[ 'timeoutCb' ] ( ); |
540 | 545 | return true; |
541 | 546 | } |
542 | 547 | |
— | — | @@ -546,7 +551,7 @@ |
547 | 552 | doFrameProxy( context ); |
548 | 553 | } |
549 | 554 | buttons[ gM( 'mwe-cancel' ) ] = function() { |
550 | | - mw.closeLoaderDialog(); |
| 555 | + mw.closeLoaderDialog ( ); |
551 | 556 | } |
552 | 557 | |
553 | 558 | // Setup the login link: |
— | — | @@ -595,10 +600,15 @@ |
596 | 601 | */ |
597 | 602 | function serverHandleRequest( ) { |
598 | 603 | var clientRequest = getClientRequest(); |
599 | | - mw.log(" handle client request :: " + JSON.stringify( clientRequest ) ); |
| 604 | + mw.log(" Handle client request :: " + JSON.stringify( clientRequest ) ); |
600 | 605 | //debugger; |
601 | 606 | // Process request type: |
602 | | - switch( clientRequest['action'] ){ |
| 607 | + switch( clientRequest[ 'action' ] ){ |
| 608 | + case 'nestedCallback': |
| 609 | + alert('nestedCallback') |
| 610 | + // pretend this was a nested callback |
| 611 | + return $.nested(''); |
| 612 | + break; |
603 | 613 | case 'browseFile': |
604 | 614 | return serverBrowseFile(); |
605 | 615 | break; |
— | — | @@ -781,6 +791,10 @@ |
782 | 792 | 'fileName' : fileName |
783 | 793 | } ); |
784 | 794 | }, |
| 795 | + |
| 796 | + // Api proxy does not handle descriptionText rewrite |
| 797 | + 'rewriteDescriptionText' : false, |
| 798 | + |
785 | 799 | // Set the doneUploadCb if set in the browseFile options |
786 | 800 | 'doneUploadCb' : function ( apiResult ){ |
787 | 801 | sendClientMsg( { |
— | — | @@ -862,9 +876,8 @@ |
863 | 877 | if( ! clientRequest.contextKey ) { |
864 | 878 | mw.log( "Error: missing context key " ); |
865 | 879 | return false; |
866 | | - } |
| 880 | + } |
867 | 881 | |
868 | | - |
869 | 882 | var nestName = 'NestedFrame_' + $j( 'iframe' ).length; |
870 | 883 | |
871 | 884 | // Append the iframe to body |
— | — | @@ -872,7 +885,7 @@ |
873 | 886 | 'src' : clientFrame, |
874 | 887 | 'request' : msgObj, |
875 | 888 | // Client msgs just have the contextKey ( not the full context ) |
876 | | - 'context' : { |
| 889 | + 'context' : { |
877 | 890 | 'contextKey' : clientRequest.contextKey |
878 | 891 | } |
879 | 892 | } ); |
— | — | @@ -892,10 +905,12 @@ |
893 | 906 | * be removed from the dom after its done loading |
894 | 907 | */ |
895 | 908 | function appendIframe( options ){ |
896 | | - |
897 | | - |
898 | | - var s = '<iframe '; |
899 | | - // check for context |
| 909 | + |
| 910 | + // Build out iframe in string since IE throws away attributes of |
| 911 | + // jQuery iframe buildout |
| 912 | + var s = '<iframe '; |
| 913 | + |
| 914 | + // Check for context |
900 | 915 | if( ! options[ 'context' ] ) { |
901 | 916 | mw.log("Error missing context"); |
902 | 917 | return false; |
— | — | @@ -911,7 +926,6 @@ |
912 | 927 | if( ! options[ 'name' ] ) { |
913 | 928 | options[ 'name' ] = 'mwApiProxyFrame_' + $j('iframe').length; |
914 | 929 | } |
915 | | - |
916 | 930 | |
917 | 931 | // Add the frame name / id: |
918 | 932 | s += 'name="' + mw.escapeQuotes( options[ 'name' ] ) + '" '; |
— | — | @@ -921,16 +935,17 @@ |
922 | 936 | if( ! options['style'] ){ |
923 | 937 | options['style'] = 'display:none'; |
924 | 938 | } |
| 939 | + |
925 | 940 | // Add style attribute: |
926 | 941 | s += 'style="' + mw.escapeQuotes( options[ 'style' ] ) + '" '; |
927 | 942 | |
928 | 943 | // Special handler for src and packaged hash request: |
929 | | - if( options.src ){ |
| 944 | + if( options.src ) { |
930 | 945 | s += 'src="' + options.src; |
931 | | - if( options.request ){ |
932 | | - |
| 946 | + if( options.request ) { |
| 947 | + |
933 | 948 | // Add the contextKey to the request |
934 | | - options.request[ 'contextKey' ] = context.contextKey; |
| 949 | + options.request[ 'contextKey' ] = context.contextKey; |
935 | 950 | |
936 | 951 | // Add the escaped version of the request: |
937 | 952 | s += '#' + encodeURIComponent( JSON.stringify( options.request ) ); |
— | — | @@ -946,26 +961,27 @@ |
947 | 962 | options[ 'target' ] = 'body'; |
948 | 963 | } |
949 | 964 | var nameTarget = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ; |
950 | | - mw.log( "Append iframe:" + options[ 'name' ] + ' to: ' + nameTarget); |
| 965 | + mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + nameTarget + " \n WITH REQUEST: " + JSON.stringify( options.request ) ); |
| 966 | + |
951 | 967 | // Append to target |
952 | | - $j( options['target'] ).append( s ); |
| 968 | + $j( options[ 'target' ] ).append( s ); |
953 | 969 | |
954 | 970 | // Setup the onload callback |
955 | | - $j( '#' + options['name'] ).get( 0 ).onload = function() { |
| 971 | + $j( '#' + options[ 'name' ] ).get( 0 ).onload = function() { |
956 | 972 | if( ! options.persist ){ |
957 | 973 | // Schedule the removal of the iframe |
958 | | - // We don't call it directly since some browsers seem to call "ready" |
959 | | - // before blocking code is done running |
| 974 | + // We don't call remove directly since some browsers seem to call "ready" |
| 975 | + // before blocking javascript code is done running |
960 | 976 | setTimeout( function() { |
961 | 977 | $j('#' + options[ 'name' ] ).remove(); |
962 | 978 | }, 10 ); |
963 | 979 | } |
964 | 980 | }; |
| 981 | + |
965 | 982 | // Setupt the timeout check: |
966 | 983 | setTimeout( function() { |
967 | | - if ( context[ 'proxyLoaded'] === false ) { |
| 984 | + if ( context[ 'proxyLoaded' ] === false ) { |
968 | 985 | // We timed out no api proxy (should make sure the user is "logged in") |
969 | | - mw.log( "Error:: api proxy timeout" + context.contextKey ); |
970 | 986 | proxyNotReadyTimeout( context ); |
971 | 987 | } |
972 | 988 | }, mw.getConfig( 'defaultRequestTimeout') * 1000 ); |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -1362,6 +1362,24 @@ |
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | /** |
| 1366 | + * Issues the wikitext parse call |
| 1367 | + * |
| 1368 | + * @param {String} wikitext Wiki Text to be parsed by mediaWiki api call |
| 1369 | + * @param {String} title Context title of the content to be parsed |
| 1370 | + * @param {Function} callback Function called with api parser output |
| 1371 | + */ |
| 1372 | + mw.parseWikiText = function( wikitext, title, callback ) { |
| 1373 | + mw.getJSON( mw.getLocalApiUrl(), |
| 1374 | + { |
| 1375 | + 'action': 'parse', |
| 1376 | + 'title' : title, |
| 1377 | + 'text': wikitext |
| 1378 | + }, function( data ) { |
| 1379 | + callback( data.parse.text['*'] ); |
| 1380 | + } |
| 1381 | + ); |
| 1382 | + } |
| 1383 | + /** |
1366 | 1384 | * mediaWiki JSON a wrapper for jQuery getJSON: |
1367 | 1385 | * |
1368 | 1386 | * The mediaWiki version lets you skip the url part |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -4,8 +4,8 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r103'; |
9 | | -var mwUseScriptLoader = false; |
| 8 | +var mwRemoteVersion = 'r104'; |
| 9 | +var mwUseScriptLoader = true; |
10 | 10 | |
11 | 11 | // Log the mwRemote version ( will determine what version of js we get ) |
12 | 12 | if( window.console ){ |
— | — | @@ -121,6 +121,10 @@ |
122 | 122 | mw.load( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() ); |
123 | 123 | } ); |
124 | 124 | } |
| 125 | + if ( wgPageName == 'MediaWiki:ApiProxyNestedCb' ) { |
| 126 | + // Note top.mw.ApiProxy.nested frame needs to be on the same domain of course |
| 127 | + top.mw.ApiProxy.nested( window.location.href.split("#")[1] || false ); |
| 128 | + } |
125 | 129 | |
126 | 130 | // OggHandler rewrite for view pages: |
127 | 131 | var vidIdList = []; |
Index: branches/js2-work/phase3/js/editPage.js |
— | — | @@ -15,8 +15,8 @@ |
16 | 16 | 'default_query': wgTitle, |
17 | 17 | 'target_title': wgPageName, |
18 | 18 | |
19 | | - // if the info overlay per asset should be displayed |
20 | | - 'displayResourceInfoIcons' : false, |
| 19 | + // If the info overlay per asset should be displayed |
| 20 | + 'displayResourceInfoIcons' : true, |
21 | 21 | |
22 | 22 | // If we should display buttons to switch between "box" and "detailed" view |
23 | 23 | 'displayResultFormatButton' : false, |