Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -174,6 +174,11 @@ |
175 | 175 | 'licenses' => array( |
176 | 176 | 'fal' |
177 | 177 | ) |
| 178 | + ), |
| 179 | + array( |
| 180 | + 'head' => 'mwe-upwiz-license-none-applicable-head', |
| 181 | + 'subhead' => 'mwe-upwiz-license-none-applicable-subhead', |
| 182 | + 'special' => 'delete' |
178 | 183 | ) |
179 | 184 | ), |
180 | 185 | 'defaults' => array(), |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -298,6 +298,11 @@ |
299 | 299 | 'mwe-upwiz-license-public-domain-subhead', |
300 | 300 | 'mwe-upwiz-license-usgov-head', |
301 | 301 | 'mwe-upwiz-license-misc', |
| 302 | + 'mwe-upwiz-license-custom-head', |
| 303 | + 'mwe-upwiz-license-custom-subhead', |
| 304 | + 'mwe-upwiz-license-none-applicable-head', |
| 305 | + 'mwe-upwiz-license-none-applicable-subhead', |
| 306 | + 'mwe-upwiz-license-none-applicable', |
302 | 307 | 'mwe-upwiz-categories', |
303 | 308 | 'mwe-upwiz-categories-add', |
304 | 309 | 'mwe-upwiz-category-remove', |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -245,6 +245,15 @@ |
246 | 246 | 'mwe-upwiz-license-usgov-head' => '{{PLURAL:$1|This work was|These works were}} made by the United States government', |
247 | 247 | 'mwe-upwiz-license-misc' => 'Miscellaneous reasons', |
248 | 248 | |
| 249 | + 'mwe-upwiz-license-custom-head' => 'Experts only: enter the code for a license not shown here', |
| 250 | + 'mwe-upwiz-license-custom-subhead' => 'Enter wikitext that will add a license template to your uploads.', |
| 251 | + |
| 252 | + 'mwe-upwiz-license-none-applicable-head' => 'I don\'t know if any of the above choices apply or not! Help!', |
| 253 | + 'mwe-upwiz-license-none-applicable-subhead' => 'If you aren\'t absolutely sure what the intentions of the original author were then please do not upload {{PLURAL:$1|this file|these files}} to {{SITENAME}}. Press the button below to abandon {{PLURAL:$1|this upload|these uploads}} -- don\'t worry, nothing\'s been published yet.', |
| 254 | + |
| 255 | + 'mwe-upwiz-license-none-applicable' => 'Abandon {{PLURAL:$1|this upload|these uploads}} without publishing', |
| 256 | + |
| 257 | + |
249 | 258 | 'mwe-upwiz-categories' => 'Categories', |
250 | 259 | 'mwe-upwiz-categories-add' => 'Add', |
251 | 260 | 'mwe-upwiz-category-remove' => 'Remove this category', |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js |
— | — | @@ -290,14 +290,14 @@ |
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Interface widget to choose among various deeds -- for instance, if own work, or not own work, or other such cases. |
294 | | - * @param selector where to put this deed chooser |
295 | | - * @param deeds Array of UploadWizardDeed |
296 | | - * @param uploadCount whether this chooser applies to multiple files (changes messaging mostly) |
| 294 | + * @param {String|jQuery} selector where to put this deed chooser |
| 295 | + * @param {Array[UploadWizardDeed]} deeds |
| 296 | + * @param {Array[UploadWizardUpload]} uploads that this applies to (this is just to make deleting and plurals work) |
297 | 297 | */ |
298 | | -mw.UploadWizardDeedChooser = function( selector, deeds, uploadCount ) { |
| 298 | +mw.UploadWizardDeedChooser = function( selector, deeds, uploads ) { |
299 | 299 | var _this = this; |
300 | 300 | _this.$selector = $j( selector ); |
301 | | - _this.uploadCount = uploadCount ? uploadCount : 1; |
| 301 | + _this.uploads = mw.isDefined( uploads ) ? uploads : []; |
302 | 302 | |
303 | 303 | |
304 | 304 | _this.$errorEl = $j( '<div class="mwe-error"></div>' ); |
— | — | @@ -315,7 +315,7 @@ |
316 | 316 | + '<span class="mwe-upwiz-deed-header">' |
317 | 317 | + '<input id="' + id +'" name="' + _this.name + '" type="radio" value="' + deed.name + ' /">' |
318 | 318 | + '<label for="' + id + '" class="mwe-upwiz-deed-name">' |
319 | | - + gM( 'mwe-upwiz-source-' + deed.name, _this.uploadCount ) |
| 319 | + + gM( 'mwe-upwiz-source-' + deed.name, _this.uploads.length ) |
320 | 320 | + '</label>' |
321 | 321 | + '</span>' |
322 | 322 | + '</div>' |
— | — | @@ -342,6 +342,10 @@ |
343 | 343 | // set the "value" to be the null deed; which will cause an error if the data is submitted. |
344 | 344 | _this.choose( mw.UploadWizardNullDeed ); |
345 | 345 | |
| 346 | + // set the "delete associated upload" option, if available |
| 347 | + // this has a somewhat nasty & twisted dependency on the licenses config, since if you enable the 'special delete' |
| 348 | + // option there, you have to remember to pass a deleter here |
| 349 | + _this.bindDeleter(); |
346 | 350 | }; |
347 | 351 | |
348 | 352 | |
— | — | @@ -366,7 +370,7 @@ |
367 | 371 | _this.hideError(); |
368 | 372 | } else { |
369 | 373 | if ( _this.deed === mw.UploadWizardNullDeed ) { |
370 | | - _this.showError( gM( 'mwe-upwiz-deeds-need-deed', _this.uploadCount ) ); |
| 374 | + _this.showError( gM( 'mwe-upwiz-deeds-need-deed', _this.uploads.length ) ); |
371 | 375 | $j( _this ).bind( 'chooseDeed', function() { |
372 | 376 | _this.hideError(); |
373 | 377 | } ); |
— | — | @@ -386,9 +390,9 @@ |
387 | 391 | }, |
388 | 392 | |
389 | 393 | /** |
390 | | - * How many uploads this deed controls |
| 394 | + * Uploads this deed controls |
391 | 395 | */ |
392 | | - uploadCount: 0, |
| 396 | + uploads: [], |
393 | 397 | |
394 | 398 | |
395 | 399 | // XXX it's impossible to choose the null deed if we stick with radio buttons, so that may be useless later |
— | — | @@ -442,8 +446,35 @@ |
443 | 447 | |
444 | 448 | remove: function() { |
445 | 449 | this.$selector.html(''); |
| 450 | + }, |
| 451 | + |
| 452 | + /** |
| 453 | + * This is a bit of a hack -- originally deeds were not supposed to know what uploads they applied to, |
| 454 | + * the associated upload would just read that data when it needed to, or rebind itself on the fly. |
| 455 | + * Unfortunately it's starting to become a bit messed up; to make deleting work, now the deeds know about the uploads, |
| 456 | + * and the uploads know about the deeds. Really ought to be that there is some channel of communication that the uploads |
| 457 | + * listen to, which could include a 'delete yourself' event. |
| 458 | + * So, what this does: |
| 459 | + * In the event that our license config includes the "special" item for i-don't-know-what-the-license-is, |
| 460 | + * this will create a button there that deletes all the associated uploads. |
| 461 | + */ |
| 462 | + bindDeleter: function() { |
| 463 | + var deedChooser = this; |
| 464 | + $j( deedChooser.$selector.find( '.mwe-upwiz-license-special-delete' ) ).each( function() { |
| 465 | + $j( this ).append( |
| 466 | + $j( '<button></button>' ) |
| 467 | + .attr( 'type', 'button' ) |
| 468 | + .msg( 'mwe-upwiz-license-none-applicable', deedChooser.uploads.length ) |
| 469 | + .button() |
| 470 | + .addClass( 'ui-button-text ui-button-textonly' ) |
| 471 | + .click( function() { |
| 472 | + $j.each( deedChooser.uploads, function( i, upload ) { |
| 473 | + upload.remove(); |
| 474 | + } ); |
| 475 | + } ) |
| 476 | + ); |
| 477 | + } ); |
446 | 478 | } |
447 | | - |
448 | 479 | }; |
449 | 480 | |
450 | 481 | } )( jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | * 'defaults' => array of template string names (can be empty array), |
9 | 9 | * 'licenses' => array of template string names (matching keys in mw.UploadWizard.config.licenses) |
10 | 10 | * optional: 'licenseGroups' => groups of licenses, with more explanation |
| 11 | + * optional: 'special' => String -- indicates, don't put licenses here, instead leave a placeholder div, with class based on this string. |
11 | 12 | * @param {Numbe} count of the things we are licensing (it matters to some texts) |
12 | 13 | */ |
13 | 14 | |
— | — | @@ -97,12 +98,10 @@ |
98 | 99 | } |
99 | 100 | } ); |
100 | 101 | } |
| 102 | + |
101 | 103 | |
102 | 104 | if ( mw.isDefined( config['licenseGroups'] ) ) { |
103 | 105 | $j.each( config['licenseGroups'], function( i, group ) { |
104 | | - if ( !mw.isDefined( group['licenses'] ) ) { |
105 | | - throw new Error( 'improper config' ); |
106 | | - } |
107 | 106 | var $group = $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license-group' ); |
108 | 107 | // if there is no header, just append licenses to the group div. |
109 | 108 | var $body = $group; |
— | — | @@ -120,7 +119,12 @@ |
121 | 120 | $body.append( $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license-group-subhead' ).msg( group.subhead, _this.count ) ); |
122 | 121 | } |
123 | 122 | var $licensesDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-deed-license' ); |
124 | | - appendLicenses( $licensesDiv, group ); |
| 123 | + if ( mw.isDefined( group['special'] ) ) { |
| 124 | + // put a placeholder in our interface for our caller to place some special interface in |
| 125 | + $licensesDiv.append( $j( '<div></div>' ).addClass( 'mwe-upwiz-license-special-' + group.special ) ); |
| 126 | + } else { |
| 127 | + appendLicenses( $licensesDiv, group ); |
| 128 | + } |
125 | 129 | $body.append( $licensesDiv ); |
126 | 130 | _this.$selector.append( $group ); |
127 | 131 | } ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -547,17 +547,11 @@ |
548 | 548 | |
549 | 549 | /** |
550 | 550 | * Reset the entire interface so we can upload more stuff |
| 551 | + * (depends on updateFileCounts to reset the interface when uploads go down to 0) |
551 | 552 | * Depending on whether we split uploading / detailing, it may actually always be as simple as loading a URL |
552 | 553 | */ |
553 | 554 | reset: function() { |
554 | | - // window.location = wgArticlePath.replace( '$1', 'Special:UploadWizard?skiptutorial=true' ); |
555 | | - var _this = this; |
556 | | - // deeds page |
557 | | - _this.deedChooser.remove(); |
558 | | - _this.removeMatchingUploads( function() { return true; } ); |
559 | | - // this could be slicker... need to reset the headline AND get rid of individual divs |
560 | | - $( '#mwe-upwiz-thanks' ).html( '' ); |
561 | | - _this.moveToStep( 'file' ); |
| 555 | + this.removeMatchingUploads( function() { return true; } ); |
562 | 556 | }, |
563 | 557 | |
564 | 558 | |
— | — | @@ -577,7 +571,7 @@ |
578 | 572 | $j( '#mwe-first-spinner' ).remove(); |
579 | 573 | |
580 | 574 | // feedback request |
581 | | - if ( mw.isDefined( mw.UploadWizard.config['feedbackPage'] ) && mw.UploadWizard.config['feedbackPage'] != '' ) { |
| 575 | + if ( mw.isDefined( mw.UploadWizard.config['feedbackPage'] ) && mw.UploadWizard.config['feedbackPage'] !== '' ) { |
582 | 576 | var feedback = new mw.Feedback( _this.api, |
583 | 577 | new mw.Title( mw.UploadWizard.config['feedbackPage'] ) ); |
584 | 578 | $j( '#contentSub' ) |
— | — | @@ -734,10 +728,12 @@ |
735 | 729 | deeds.push( customDeed ); |
736 | 730 | } |
737 | 731 | |
| 732 | + var uploadsClone = $j.map( _this.uploads, function( x ) { return x; } ); |
738 | 733 | _this.deedChooser = new mw.UploadWizardDeedChooser( |
739 | 734 | '#mwe-upwiz-deeds', |
740 | 735 | deeds, |
741 | | - _this.uploads.length ); |
| 736 | + uploadsClone |
| 737 | + ); |
742 | 738 | |
743 | 739 | |
744 | 740 | $j( '<div></div>' ) |
— | — | @@ -749,7 +745,7 @@ |
750 | 746 | .insertBefore( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-custom' ) ) |
751 | 747 | .msg( 'mwe-upwiz-deeds-custom-prompt' ); |
752 | 748 | } |
753 | | - |
| 749 | + |
754 | 750 | _this.moveToStep( 'deeds' ); |
755 | 751 | |
756 | 752 | }, |
— | — | @@ -874,13 +870,13 @@ |
875 | 871 | // remove the div that passed along the trigger |
876 | 872 | var $div = $j( upload.ui.div ); |
877 | 873 | $div.unbind(); // everything |
878 | | - // sexily fade away |
879 | | - $div.fadeOut('fast', function() { |
| 874 | + // sexily fade away (TODO if we are looking at it) |
| 875 | + //$div.fadeOut('fast', function() { |
880 | 876 | $div.remove(); |
881 | 877 | // and do what we in the wizard need to do after an upload is removed |
882 | 878 | mw.UploadWizardUtil.removeItem( _this.uploads, upload ); |
883 | 879 | _this.updateFileCounts(); |
884 | | - }); |
| 880 | + //} ); |
885 | 881 | }, |
886 | 882 | |
887 | 883 | |
— | — | @@ -996,8 +992,8 @@ |
997 | 993 | } ); |
998 | 994 | |
999 | 995 | this.allowCloseWindow = mw.confirmCloseWindow( { |
1000 | | - message: function() { return gM( 'mwe-upwiz-prevent-close', _this.uploads.length ) }, |
1001 | | - test: function() { return _this.uploads.length > 0 } |
| 996 | + message: function() { return gM( 'mwe-upwiz-prevent-close', _this.uploads.length ); }, |
| 997 | + test: function() { return _this.uploads.length > 0; } |
1002 | 998 | } ); |
1003 | 999 | |
1004 | 1000 | $j( '#mwe-upwiz-progress' ).show(); |
— | — | @@ -1047,6 +1043,7 @@ |
1048 | 1044 | $j( '#mwe-upwiz-progress' ).hide(); |
1049 | 1045 | $j( '#mwe-upwiz-upload-ctrls' ).show(); |
1050 | 1046 | $j( '#mwe-upwiz-add-file' ).show(); |
| 1047 | + this.moveToStep( 'file' ); |
1051 | 1048 | return; |
1052 | 1049 | } |
1053 | 1050 | var errorCount = 0; |
— | — | @@ -1127,6 +1124,21 @@ |
1128 | 1125 | $j( '#mwe-upwiz-upload-ctrls' ).show(); |
1129 | 1126 | $j( '#mwe-upwiz-progress' ).hide(); |
1130 | 1127 | $j( '#mwe-upwiz-add-file' ).show(); |
| 1128 | + |
| 1129 | + // fix various other pages that may have state |
| 1130 | + $j( '#mwe-upwiz-thanks' ).html( '' ); |
| 1131 | + |
| 1132 | + if ( mw.isDefined( _this.deedChooser ) ) { |
| 1133 | + _this.deedChooser.remove(); |
| 1134 | + } |
| 1135 | + |
| 1136 | + // remove any blocks on closing the window |
| 1137 | + if ( mw.isDefined( _this.allowCloseWindow ) ) { |
| 1138 | + _this.allowCloseWindow(); |
| 1139 | + } |
| 1140 | + |
| 1141 | + // and move back to the file step |
| 1142 | + _this.moveToStep( 'file' ); |
1131 | 1143 | } |
1132 | 1144 | |
1133 | 1145 | // allow an "add another upload" button only if we aren't at max |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -279,7 +279,8 @@ |
280 | 280 | _this.upload.deedChooser = new mw.UploadWizardDeedChooser( |
281 | 281 | _this.deedDiv, |
282 | 282 | [ new mw.UploadWizardDeedOwnWork(), |
283 | | - new mw.UploadWizardDeedThirdParty() ] |
| 283 | + new mw.UploadWizardDeedThirdParty() ], |
| 284 | + [ _this.upload ] |
284 | 285 | ); |
285 | 286 | }, |
286 | 287 | |