r65649 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65648‎ | r65649 | r65650 >
Date:00:32, 29 April 2010
Author:neilk
Status:deferred
Tags:
Comment:
widgetized the deed chooser; able to override deeds
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/css/uploadWizard.css (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js
@@ -18,15 +18,20 @@
1919 "mwe-upwiz-progressbar-uploading": "uploading",
2020 "mwe-upwiz-remaining": "$1 remaining",
2121 "mwe-upwiz-intro-details": "Thank you! Now we need some basic information about the files you just uploaded.",
22 - "mwe-upwiz-source-ownwork": "These files are my own work.",
23 - "mwe-upwiz-source-ownwork-assert": "I, $1, the copyright holder of this work, hereby grant anyone the right to use these works for any purpose, as long as they credit me and share derivative work under the same terms.",
24 - "mwe-upwiz-source-ownwork-assert-custom": "I, $1, the copyright holder of this work, hereby publish these works under the following license(s):",
 22+ "mwe-upwiz-source-ownwork": "This file is my own work.",
 23+ "mwe-upwiz-source-ownwork-plural": "These files are my own work.",
 24+ "mwe-upwiz-source-ownwork-assert": "I, $1, the copyright holder of this work, hereby grant anyone the right to use this work for any purpose, as long as they credit me and share derivative work under the same terms.",
 25+ "mwe-upwiz-source-ownwork-assert-plural": "I, $1, the copyright holder of these works, hereby grant anyone the right to use these works for any purpose, as long as they credit me and share derivative work under the same terms.",
 26+ "mwe-upwiz-source-ownwork-assert-custom": "I, $1, the copyright holder of this work, hereby publish this work under the following license(s):",
 27+ "mwe-upwiz-source-ownwork-assert-custom-plural": "I, $1, the copyright holder of these works, hereby publish these works under the following license(s):",
2528 "mwe-upwiz-source-ownwork-assert-note": "This means you release your work under a double Creative Commons Attribution ShareAlike and GFDL license.",
2629 "mwe-upwiz-source-permission": "Their author gave you explicit permission to upload them",
27 - "mwe-upwiz-source-thirdparty": "These files are not my own work.",
 30+ "mwe-upwiz-source-thirdparty": "This file is not my own work.",
 31+ "mwe-upwiz-source-thirdparty-plural": "These files are not my own work.",
2832 "mwe-upwiz-source-thirdparty-intro" : "Please enter the address where you found each file.",
29 - "mwe-upwiz-source-thirdparty-custom-intro" : "If all files have the same source, author, and copyright status, you may enter them only once for all of them.",
30 - "mwe-upwiz-source-thirdparty-license" : "The copyright holder of these works published them under the following license(s):",
 33+ "mwe-upwiz-source-thirdparty-custom-plural-intro" : "If all files have the same source, author, and copyright status, you may enter them only once for all of them.",
 34+ "mwe-upwiz-source-thirdparty-license" : "The copyright holder of this work published them under the following license(s):",
 35+ "mwe-upwiz-source-thirdparty-license-plural" : "The copyright holder of these works published them under the following license(s):",
3136 "mwe-upwiz-source-thirdparty-accept": "OK",
3237 "mwe-upwiz-source-custom": "Did you know? You can <a href=\"$1\">customize</a> the default options you see here.",
3338 "mwe-upwiz-more-options": "more options...",
@@ -68,7 +73,10 @@
6974
7075 "mwe-fileexists" : "A file with this name exists already. Please check <b><tt>$1<\/tt><\/b> if you are not sure if you want to replace it.",
7176 "mwe-thumbnail-more" : "Enlarge",
72 - "mwe-upwiz-overwrite" : "Replace the file"
 77+ "mwe-upwiz-overwrite" : "Replace the file",
 78+
 79+ "mwe-copyright-macro": "As above",
 80+ "mwe-copyright-custom": "Custom"
7381 } );
7482
7583
@@ -1014,7 +1022,7 @@
10151023
10161024 _this.locationInput = $j( '<input type="text" class="mwe-location" size="20"/>' );
10171025
1018 - var aboutThisWorkDiv = $j('<fieldset class="mwe-fieldset"></fieldset>')
 1026+ var aboutThisWorkFieldset = $j('<fieldset class="mwe-fieldset"></fieldset>')
10191027 .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-about-this-work' ) ) )
10201028 .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' )
10211029 .append( $j( '<div class="mwe-upwiz-details-label-input"></div>' )
@@ -1027,35 +1035,28 @@
10281036 )
10291037 );
10301038
1031 -/*
1032 - // XXX why is rows=1 giving me two rows. Is this growTextArea's fault?
1033 - _this.sourceInput = $j('<textarea class="mwe-source" rows="1" cols="40"></textarea>' ).growTextArea();
1034 - _this.sourceDiv = $j( '<div></div>' )
1035 - .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-source' ) ) )
1036 - .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.sourceInput ) );
1037 -
 1039+ var copyrightInfoFieldset = $j('<fieldset class="mwe-fieldset"></fieldset>')
 1040+ .append(
 1041+ $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-copyright-info' ) ),
 1042+ $j( '<div class="mwe-upwiz-copyright-info" />' ).append(
 1043+ $j( '<label />' ).append (
 1044+ $j( '<input type="radio" name="custom-deed" value="macro" />' ),
 1045+ gM( 'mwe-copyright-macro' ) ),
 1046+ $j( '<label />' ).append (
 1047+ $j( '<input type="radio" name="custom-deed" value="custom" />' ),
 1048+ gM( 'mwe-copyright-custom' ) ) ),
 1049+ $j( '<div class="mwe-upwiz-custom-deed" />' )
 1050+ );
 1051+
 1052+ $j( copyrightInfoFieldset ).find( 'input[name="custom-deed"]' ).change( function() {
 1053+ var value = $j( copyrightInfoFieldset ).find( 'input[name="custom-deed"]:checked' ).val();
 1054+ _this.toggleCustomDeed( value === 'custom' );
 1055+ } );
10381056
1039 - _this.authorInput = $j('<textarea class="mwe-author" rows="1" cols="40"></textarea>' ).growTextArea();
1040 - _this.authorDiv = $j( '<div></div>' )
1041 - .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-author' ) ) )
1042 - .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.authorInput ) );
1043 -
1044 -
1045 - var licenseInputDiv = $j('<div></div>');
1046 - _this.licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv );
1047 - _this.licenseDiv = $j( '<div></div>' )
1048 - .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-license' ) ) )
1049 - .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( licenseInputDiv ) );
1050 -*/
1051 -
1052 - // XXX create a toggler that will switch between a custom deed chooser and the upload's chooser
1053 - var copyrightInfoDiv = $j('<fieldset class="mwe-fieldset"></fieldset>')
1054 - .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-copyright-info' ) ) )
1055 - .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' )
1056 - .html( "As above" ) ); // XXX
 1057+ $j( copyrightInfoFieldset ).find( 'input[value="macro"]' ).attr( 'checked', true );
10571058
10581059
1059 - var aboutTheFileDiv = $j('<fieldset class="mwe-fieldset"></fieldset>')
 1060+ var aboutFileFieldset = $j('<fieldset class="mwe-fieldset"></fieldset>')
10601061 .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-about-format' ) ) )
10611062 .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' )
10621063 .append( $j( '<div></div>' )
@@ -1077,9 +1078,9 @@
10781079 .append( _this.titleContainerDiv )
10791080 .append( _this.moreDetailsCtrlDiv )
10801081 .append( $j( _this.moreDetailsDiv )
1081 - .append( aboutThisWorkDiv )
1082 - .append( copyrightInfoDiv )
1083 - .append( aboutTheFileDiv )
 1082+ .append( aboutThisWorkFieldset )
 1083+ .append( copyrightInfoFieldset )
 1084+ .append( aboutFileFieldset )
10841085 .append( otherInformationDiv )
10851086 )
10861087 );
@@ -1095,6 +1096,22 @@
10961097 mw.UploadWizardDetails.prototype = {
10971098
10981099 /**
 1100+ * toggles whether we use the 'macro' deed or our own
 1101+ */
 1102+ toggleCustomDeed: function( isUsingCustomDeed ) {
 1103+ var _this = this;
 1104+ var deedDiv = $j( _this.div ).find( '.mwe-upwiz-custom-deed' );
 1105+ if ( isUsingCustomDeed ) {
 1106+ _this.upload.wizardDeedChooser = _this.upload.deedChooser;
 1107+ _this.upload.deedChooser = new mw.UploadWizardDeedChooser( deedDiv );
 1108+ } else {
 1109+ _this.upload.deedChooser = _this.upload.wizardDeedChooser;
 1110+ deedDiv.empty();
 1111+ }
 1112+ },
 1113+
 1114+
 1115+ /**
10991116 * Sets the filename from the title plus this upload's extension.
11001117 */
11011118 setFilenameFromTitle: function() {
@@ -1863,7 +1880,7 @@
18641881 } ) );
18651882 } );
18661883
1867 - _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-macro-deeds' );
 1884+ _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-macro-deeds', true );
18681885
18691886 // add one to start
18701887 var upload = _this.newUpload( '#mwe-upwiz-add-file' );
@@ -2287,62 +2304,57 @@
22882305
22892306
22902307
2291 -mw.UploadWizardDeedChooser = function( selector ) {
 2308+/**
 2309+ * @param selector where to put this deed chooser
 2310+ * @param isPlural whether this chooser applies to multiple files (changes messaging mostly)
 2311+ */
 2312+mw.UploadWizardDeedChooser = function( selector, isPlural ) {
22922313 var _this = this;
22932314 _this.selector = selector;
22942315 _this.deed = mw.UploadWizardNullDeed;
2295 -
2296 - $j( selector ).html(
2297 - '<div class="mwe-upwiz-macro-deed-ownwork mwe-upwiz-deed">'
2298 - + '<div class="mwe-upwiz-deed-option-title">'
2299 - + '<span class="mwe-upwiz-deed-header mwe-closed">'
2300 - + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">'
2301 - + gM( 'mwe-upwiz-source-ownwork' )
2302 - + '</a>'
2303 - + '</span>'
2304 - + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">'
2305 - + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-ownwork' ) + '</span>'
2306 - + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>'
2307 - + '</span>'
2308 - + '</div>' // more deed stuff set up below
2309 - + '<div class="mwe-upwiz-deed-form"></div>'
2310 - + '</div>'
23112316
2312 - + '<div class="mwe-upwiz-macro-deed-thirdparty mwe-upwiz-deed">'
2313 - + '<div class="mwe-upwiz-deed-option-title">'
2314 - + '<span class="mwe-upwiz-deed-header mwe-closed">'
2315 - + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">'
2316 - + gM( 'mwe-upwiz-source-thirdparty' )
2317 - + '</a>'
2318 - + '</span>'
2319 - + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">'
2320 - + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</span>'
2321 - + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>'
2322 - + '</span>'
2323 - + '</div>' // more deed stuff set up below
2324 - + '<div class="mwe-upwiz-deed-form"></div>'
2325 - + '</div>'
2326 - );
 2317+ items = [];
 2318+ $j.each( [ 'ownwork', 'thirdparty' ], function (i, key) {
 2319+ gMkey = isPlural ? key + '-plural' : key;
 2320+ var item =
 2321+ '<div class="mwe-upwiz-macro-deed-' + key + ' mwe-upwiz-deed">'
 2322+ + '<div class="mwe-upwiz-deed-option-title">'
 2323+ + '<span class="mwe-upwiz-deed-header mwe-closed">'
 2324+ + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">'
 2325+ + gM( 'mwe-upwiz-source-' + gMkey )
 2326+ + '</a>'
 2327+ + '</span>'
 2328+ + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">'
 2329+ + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-' + gMkey ) + '</span>'
 2330+ + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>'
 2331+ + '</span>'
 2332+ + '</div>'
 2333+ + '<div class="mwe-upwiz-deed-form"></div>'
 2334+ + '</div>'
 2335+ items.push(item);
 2336+ } );
23272337
 2338+ $j( selector ).html( items.join('') );
 2339+
23282340 $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { _this.showDeedChoice(); } );
23292341
2330 - _this.setupDeedOwnWork();
2331 - _this.setupDeedThirdParty();
 2342+ // this sets up the hidden divs propertly, so we can set up deeds behind the scenes.
23322343 _this.showDeedChoice();
 2344+
 2345+ // set up the deed interfaces
 2346+ _this.setupDeedOwnWork( isPlural );
 2347+ _this.setupDeedThirdParty( isPlural );
23332348 };
23342349
23352350 mw.UploadWizardDeedChooser.prototype = {
23362351 choose: function( deed ) {
23372352 var _this = this;
23382353 _this.deed = deed;
2339 - mw.log( "choosing deed!" );
2340 - mw.log( deed );
23412354 if ( deed === mw.UploadWizardNullDeed ) {
23422355 $j( _this ).trigger( 'chooseNullDeed' );
23432356 $j( _this.selector )
23442357 .find( 'input.mwe-accept-deed' )
23452358 .attr( 'checked', false )
2346 - mw.log("choose null deed");
23472359 } else {
23482360 $j( _this ).trigger( 'chooseDeed' );
23492361 }
@@ -2363,19 +2375,19 @@
23642376 },
23652377
23662378 /**
2367 - * From the deed choice page, show a deed
 2379+ * From the deed choice page, show a particular deed
23682380 */
2369 - showDeed: function( selector ) {
2370 - $j( selector ).find( '.mwe-upwiz-deed-header.mwe-open' ).show();
2371 - $j( selector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).hide();
2372 - $j( selector ).siblings().maskSafeHide();
2373 - $j( selector ).find( '.mwe-upwiz-deed-form' ).maskSafeShow();
 2381+ showDeed: function( deedSelector ) {
 2382+ $j( deedSelector ).find( '.mwe-upwiz-deed-header.mwe-open' ).show();
 2383+ $j( deedSelector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).hide();
 2384+ $j( deedSelector ).siblings().maskSafeHide();
 2385+ $j( deedSelector ).find( '.mwe-upwiz-deed-form' ).maskSafeShow();
23742386 },
23752387
23762388 /**
23772389 * Set up the form and deed object for the deed option that says these uploads are all the user's own work.
23782390 */
2379 - setupDeedOwnWork: function() {
 2391+ setupDeedOwnWork: function( isPlural ) {
23802392 mw.log("setupdeed own work");
23812393 var _this = this;
23822394
@@ -2387,6 +2399,8 @@
23882400 var licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv );
23892401 licenseInput.setDefaultValues();
23902402
 2403+ var plural = isPlural ? '-plural' : '';
 2404+
23912405 var ownWorkDeed = $j.extend( new mw.UploadWizardDeed(), {
23922406
23932407 licenseInput: licenseInput,
@@ -2436,7 +2450,7 @@
24372451 .addClass( 'mwe-upwiz-deed-accept-ownwork-default mwe-accept-deed mwe-checkbox-hang-indent' ),
24382452 $j( '<p />' )
24392453 .addClass( 'mwe-checkbox-hang-indent-text' )
2440 - .html( gM( 'mwe-upwiz-source-ownwork-assert',
 2454+ .html( gM( 'mwe-upwiz-source-ownwork-assert' + plural,
24412455 $j( '<input />' )
24422456 .attr( { name: 'author' } )
24432457 .addClass( 'mwe-upwiz-sign' ) ) ),
@@ -2449,6 +2463,7 @@
24502464 var toggleDiv = $j('<div />');
24512465
24522466 var customDiv = $j('<div/>')
 2467+ .maskSafeHide()
24532468 .append(
24542469 $j( '<input />')
24552470 .attr( { type: 'checkbox' } )
@@ -2465,10 +2480,10 @@
24662481 .addClass( 'mwe-upwiz-deed-accept-ownwork-custom mwe-accept-deed mwe-checkbox-hang-indent' ),
24672482 $j( '<p />' )
24682483 .addClass( 'mwe-checkbox-hang-indent-text' )
2469 - .append( gM( 'mwe-upwiz-source-ownwork-assert-custom',
 2484+ .append( gM( 'mwe-upwiz-source-ownwork-assert-custom' + plural,
24702485 '<span class="mwe-custom-author-input"></span>' ) ),
24712486 licenseInputDiv
2472 - ).maskSafeHide();
 2487+ );
24732488
24742489 $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' )
24752490 .append( $j( '<div class="mwe-upwiz-deed-form-internal" />' )
@@ -2513,12 +2528,12 @@
25142529
25152530 $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-header-link').click(
25162531 function() {
2517 - _this.showDeed( $j( '.mwe-upwiz-macro-deed-ownwork' ) );
 2532+ _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork' ) );
25182533 }
25192534 );
25202535 },
25212536
2522 - setupDeedThirdParty: function() {
 2537+ setupDeedThirdParty: function( isPlural ) {
25232538 var _this = this;
25242539 var sourceInput = $j('<textarea class="mwe-source mwe-long-textarea" name="source" rows="1" cols="40"></textarea>' )
25252540 .growTextArea()
@@ -2540,12 +2555,12 @@
25412556 }
25422557
25432558 } );
2544 -
25452559
25462560 $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ).append(
25472561 $j( '<div class="mwe-upwiz-deed-form-internal"/>' )
25482562 .append(
2549 - $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-intro' ) ),
 2563+ ( isPlural ? $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-plural-intro' ) )
 2564+ : '' ),
25502565 $j( '<div />' )
25512566 .addClass( "mwe-upwiz-thirdparty-fields" )
25522567 .append( $j( '<label />' )
@@ -2566,7 +2581,7 @@
25672582
25682583 $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-header-link').click(
25692584 function() {
2570 - _this.showDeed( $j( '.mwe-upwiz-macro-deed-thirdparty' ) );
 2585+ _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty' ) );
25712586 _this.choose( thirdPartyDeed );
25722587 }
25732588 );
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/css/uploadWizard.css
@@ -395,6 +395,10 @@
396396 width: 370px;
397397 }
398398
 399+fieldset .mwe-long-textarea {
 400+ width: 280px;
 401+}
 402+
399403 .mwe-upwiz-details-label {
400404 width: 100px;
401405 float: left;
@@ -404,16 +408,17 @@
405409
406410 }
407411
408 -#mwe-upwiz-details-filename. {
 412+.mwe-upwiz-details-filename. {
409413 overflow: hidden;
410414 width: 350px;
411415 }
412416
413 -#mwe-upwiz-other-textarea, fieldset.mwe-fieldset {
414 - width: 450px;
415 -}
 417+.mwe-upwiz-other-textarea {
 418+ width: 468px;
 419+}
416420
417421 fieldset.mwe-fieldset {
 422+ width: 450px;
418423 border: 1px solid #cccccc;
419424 padding-left: 12px;
420425 padding-right: 12px;
@@ -446,5 +451,27 @@
447452 }
448453
449454
 455+.mwe-upwiz-copyright-info label {
 456+ display: inline-block;
 457+ padding-left: 15px;
 458+ text-indent: -15px;
 459+ margin-right: 15px;
 460+}
450461
 462+.mwe-upwiz-copyright-info input {
 463+ width: 13px;
 464+ height: 13px;
 465+ padding: 0;
 466+ margin: 0px 3px 0px 0px;
 467+ vertical-align: bottom;
 468+ position: relative;
 469+ top: -1px;
 470+}
451471
 472+
 473+.mwe-upwiz-custom-deed {
 474+ margin-top: 5px;
 475+}
 476+
 477+
 478+

Status & tagging log