Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js |
— | — | @@ -86,7 +86,8 @@ |
87 | 87 | |
88 | 88 | "mwe-prevent-close": "Your files are still uploading. Are you sure you want to navigate away from this page?", |
89 | 89 | |
90 | | - "mwe-upwiz-files-complete": "Your files finished uploading!" |
| 90 | + "mwe-upwiz-files-complete": "Your files finished uploading!", |
| 91 | + "mwe-upwiz-deeds-later": "Set deeds and licenses for each file individually on the next page" |
91 | 92 | } ); |
92 | 93 | |
93 | 94 | |
— | — | @@ -1865,8 +1866,9 @@ |
1866 | 1867 | |
1867 | 1868 | + '<div class="mwe-upwiz-stepdiv" id="mwe-upwiz-stepdiv-deeds">' |
1868 | 1869 | + '<div id="mwe-upwiz-deeds-intro"></div>' |
1869 | | - + '<div id="mwe-upwiz-deeds-thumbnails"></div>' |
1870 | | - + '<div id="mwe-upwiz-deeds"></div>' |
| 1870 | + + '<div id="mwe-upwiz-deeds-thumbnails" class="ui-helper-clearfix"></div>' |
| 1871 | + + '<div id="mwe-upwiz-deeds" class="ui-helper-clearfix"></div>' |
| 1872 | + + '<div id="mwe-upwiz-deeds-custom" class="ui-helper-clearfix"></div>' |
1871 | 1873 | + '<div class="mwe-upwiz-buttons"/>' |
1872 | 1874 | + '<button class="mwe-upwiz-button-next" disabled="true" />' |
1873 | 1875 | + '</div>' |
— | — | @@ -1907,12 +1909,6 @@ |
1908 | 1910 | // within FILE step div |
1909 | 1911 | $j('#mwe-upwiz-upload-ctrl').click( function() { |
1910 | 1912 | _this.removeEmptyUploads(); |
1911 | | - |
1912 | | - // we set up deed chooser here, because it's only now that we know how many uploads there are |
1913 | | - // possibly it could have some kind of morphing interface for singular/plural, but this doesn't |
1914 | | - // seem too bad for now. |
1915 | | - _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-deeds', ( _this.uploads.length > 1 ) ); |
1916 | | - |
1917 | 1913 | _this.startUploads(); |
1918 | 1914 | } ); |
1919 | 1915 | |
— | — | @@ -1921,12 +1917,63 @@ |
1922 | 1918 | } ); |
1923 | 1919 | |
1924 | 1920 | // DEEDS div |
| 1921 | + _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-deeds' ); |
| 1922 | + |
| 1923 | + var customDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 1924 | + isReady: function() { return true; }, |
| 1925 | + setQuantity: function( n ) { return; } |
| 1926 | + } ); |
| 1927 | + |
| 1928 | + $j( '#mwe-upwiz-deeds-custom' ).append( |
| 1929 | + $j( '<div id="mwe-upwiz-deeds-later" style="hidden"/>' ) |
| 1930 | + .append( $j( '<label>' ) |
| 1931 | + .append( |
| 1932 | + $j( '<input />') |
| 1933 | + .attr( { type: 'checkbox', value: 'deeds-later' } ) |
| 1934 | + .addClass( 'mwe-accept-deed' ) |
| 1935 | + .click( function() { |
| 1936 | + if ( $j( this ).is( ':checked' ) ) { |
| 1937 | + _this.deedChooser.showDeedChoice(); |
| 1938 | + _this.deedChooser.choose( customDeed ); |
| 1939 | + } else { |
| 1940 | + _this.deedChooser.choose( mw.UploadWizardNullDeed ); |
| 1941 | + } |
| 1942 | + } ), |
| 1943 | + $j( '<span />').append( gM( 'mwe-upwiz-deeds-later' ) ) |
| 1944 | + ) |
| 1945 | + ) |
| 1946 | + ); |
| 1947 | + |
| 1948 | + $j( _this.deedChooser ).bind( 'setQuantity', function() { |
| 1949 | + if ( _this.count > 1 ) { |
| 1950 | + $j( '#mwe-upwiz-deeds-later' ).show(); |
| 1951 | + } else { |
| 1952 | + $j( '#mwe-upwiz-deeds-later' ).hide(); |
| 1953 | + } |
| 1954 | + } ); |
| 1955 | + |
1925 | 1956 | $j( '#mwe-upwiz-deeds-intro' ).html( gM( 'mwe-upwiz-deeds-intro' ) ); |
1926 | 1957 | |
1927 | 1958 | $j( '#mwe-upwiz-stepdiv-deeds .mwe-upwiz-button-next').click( function() { |
1928 | 1959 | _this.moveToStep('details'); |
1929 | 1960 | } ); |
1930 | 1961 | |
| 1962 | + $j( _this.deedChooser ).bind( 'chooseDeed', function() { |
| 1963 | + $j( '#mwe-upwiz-stepdiv-deeds' ).enableNextButton(); |
| 1964 | + var isCustom = ( _this.deedChooser.deed === customDeed ); |
| 1965 | + $j.each( _this.uploads, function( i, upload ) { |
| 1966 | + upload.details.toggleCustomDeed( isCustom ); |
| 1967 | + } ); |
| 1968 | + } ); |
| 1969 | + |
| 1970 | + $j( _this.deedChooser ).bind( 'chooseNullDeed', function() { |
| 1971 | + $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
| 1972 | + $j.each( _this.uploads, function( i, upload ) { |
| 1973 | + upload.details.toggleCustomDeed( false ); |
| 1974 | + } ); |
| 1975 | + } ); |
| 1976 | + |
| 1977 | + |
1931 | 1978 | // DETAILS div |
1932 | 1979 | $j( '#mwe-upwiz-stepdiv-details' ).click( function() { |
1933 | 1980 | _this.detailsSubmit( function() { |
— | — | @@ -2032,13 +2079,19 @@ |
2033 | 2080 | */ |
2034 | 2081 | setUploadFilled: function( upload ) { |
2035 | 2082 | var _this = this; |
| 2083 | + |
2036 | 2084 | // XXX check if it has a file? |
| 2085 | + |
2037 | 2086 | _this.uploads.push( upload ); |
2038 | 2087 | _this.updateFileCounts(); |
2039 | 2088 | |
2040 | | - upload.deedPreview = new mw.UploadWizardDeedPreview( upload ); |
2041 | | - upload.deedChooser = _this.deedChooser; |
2042 | | - |
| 2089 | + upload.deedPreview = new mw.UploadWizardDeedPreview( upload ); |
| 2090 | + |
| 2091 | + // this will modify upload, so it has a .deedChooser property. |
| 2092 | + // We use a method to so we notify deedChooser that it has a new upload -- interface |
| 2093 | + // will change based on quantity etc. Maybe we could be clever with bind here. |
| 2094 | + _this.deedChooser.attach( upload ); |
| 2095 | + |
2043 | 2096 | // set up details |
2044 | 2097 | upload.details = new mw.UploadWizardDetails( upload, $j( '#mwe-upwiz-macro-files' )); |
2045 | 2098 | }, |
— | — | @@ -2054,7 +2107,10 @@ |
2055 | 2108 | */ |
2056 | 2109 | removeUpload: function( upload ) { |
2057 | 2110 | var _this = this; |
2058 | | - upload.unbind(); // everything |
| 2111 | + $j( upload ).unbind(); // everything |
| 2112 | + if ( upload.deedChooser ) { |
| 2113 | + upload.deedChooser.detach( upload ); |
| 2114 | + } |
2059 | 2115 | mw.UploadWizardUtil.removeItem( _this.uploads, upload ); |
2060 | 2116 | _this.updateFileCounts(); |
2061 | 2117 | }, |
— | — | @@ -2352,35 +2408,35 @@ |
2353 | 2409 | }; |
2354 | 2410 | |
2355 | 2411 | mw.UploadWizardNullDeed = $j.extend( new mw.UploadWizardDeed(), { |
2356 | | - isReady: function() { |
2357 | | - return false; |
2358 | | - } |
| 2412 | + isReady: function() { return false; }, |
| 2413 | + |
| 2414 | + setQuantity: function( n ) { return; } |
| 2415 | + |
2359 | 2416 | } ); |
2360 | 2417 | |
2361 | 2418 | |
2362 | 2419 | |
| 2420 | + |
| 2421 | + |
2363 | 2422 | /** |
2364 | 2423 | * @param selector where to put this deed chooser |
2365 | 2424 | * @param isPlural whether this chooser applies to multiple files (changes messaging mostly) |
2366 | 2425 | */ |
2367 | | -mw.UploadWizardDeedChooser = function( selector, isPlural ) { |
| 2426 | +mw.UploadWizardDeedChooser = function( selector ) { |
2368 | 2427 | var _this = this; |
2369 | 2428 | _this.selector = selector; |
2370 | 2429 | _this.deed = mw.UploadWizardNullDeed; |
2371 | 2430 | |
2372 | 2431 | items = []; |
2373 | 2432 | $j.each( [ 'ownwork', 'thirdparty' ], function (i, key) { |
2374 | | - gMkey = isPlural ? key + '-plural' : key; |
2375 | 2433 | var item = |
2376 | 2434 | '<div class="mwe-upwiz-macro-deed-' + key + ' mwe-upwiz-deed">' |
2377 | 2435 | + '<div class="mwe-upwiz-deed-option-title">' |
2378 | 2436 | + '<span class="mwe-upwiz-deed-header mwe-closed">' |
2379 | | - + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">' |
2380 | | - + gM( 'mwe-upwiz-source-' + gMkey ) |
2381 | | - + '</a>' |
| 2437 | + + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name"></a>' |
2382 | 2438 | + '</span>' |
2383 | 2439 | + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
2384 | | - + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-' + gMkey ) + '</span>' |
| 2440 | + + '<span class="mwe-upwiz-deed-name"></span>' |
2385 | 2441 | + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
2386 | 2442 | + '</span>' |
2387 | 2443 | + '</div>' |
— | — | @@ -2391,17 +2447,63 @@ |
2392 | 2448 | |
2393 | 2449 | $j( selector ).html( items.join('') ); |
2394 | 2450 | |
2395 | | - $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { _this.showDeedChoice(); } ); |
| 2451 | + $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { |
| 2452 | + _this.choose( mw.UploadWizardNullDeed ); |
| 2453 | + _this.showDeedChoice(); |
| 2454 | + } ); |
2396 | 2455 | |
2397 | | - // this sets up the hidden divs propertly, so we can set up deeds behind the scenes. |
| 2456 | + _this.choose( mw.UploadWizardNullDeed ); |
2398 | 2457 | _this.showDeedChoice(); |
2399 | 2458 | |
2400 | 2459 | // set up the deed interfaces |
2401 | | - _this.setupDeedOwnWork( isPlural ); |
2402 | | - _this.setupDeedThirdParty( isPlural ); |
| 2460 | + _this.deeds = { |
| 2461 | + 'ownwork' : _this.setupDeedOwnWork(), |
| 2462 | + 'thirdparty' : _this.setupDeedThirdParty() |
| 2463 | + }; |
| 2464 | + |
| 2465 | + _this.setQuantity(1); |
2403 | 2466 | }; |
2404 | 2467 | |
| 2468 | + |
2405 | 2469 | mw.UploadWizardDeedChooser.prototype = { |
| 2470 | + |
| 2471 | + count: 0, |
| 2472 | + |
| 2473 | + attach: function( upload ) { |
| 2474 | + var _this = this; |
| 2475 | + upload.deedChooser = _this; |
| 2476 | + _this.count++; |
| 2477 | + _this.setQuantity(); |
| 2478 | + }, |
| 2479 | + |
| 2480 | + detach: function( upload ) { |
| 2481 | + _this.count--; |
| 2482 | + _this.setQuantity(); |
| 2483 | + }, |
| 2484 | + |
| 2485 | + // modify various interface strings depending on singular, multiple deeds |
| 2486 | + setQuantity: function() { |
| 2487 | + var _this = this; |
| 2488 | + mw.log( "setting quantity of deed to " + _this.count ); |
| 2489 | + var isPlural = _this.count > 1; |
| 2490 | + $j.each( [ 'ownwork', 'thirdparty' ], function (i, key) { |
| 2491 | + |
| 2492 | + // fix the deed title that opens and closes |
| 2493 | + gMkey = isPlural ? key + '-plural' : key; |
| 2494 | + $j( _this.selector ) |
| 2495 | + .find( '.mwe-upwiz-macro-deed-' + key) |
| 2496 | + .find( '.mwe-upwiz-deed-name' ) |
| 2497 | + .html( gM( 'mwe-upwiz-source-' + gMkey ) ); |
| 2498 | + |
| 2499 | + // any other internal strings in the deed |
| 2500 | + if ( _this.deeds[key] ) { |
| 2501 | + _this.deeds[key].setQuantity( _this.count ); |
| 2502 | + } |
| 2503 | + |
| 2504 | + } ); |
| 2505 | + |
| 2506 | + }, |
| 2507 | + |
2406 | 2508 | choose: function( deed ) { |
2407 | 2509 | var _this = this; |
2408 | 2510 | _this.deed = deed; |
— | — | @@ -2425,8 +2527,6 @@ |
2426 | 2528 | $j( _this.selector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).show(); |
2427 | 2529 | $j( _this.selector ).find( '.mwe-upwiz-deed' ).maskSafeShow(); |
2428 | 2530 | $j( _this.selector ).find( '.mwe-upwiz-deed-form' ).maskSafeHide(); |
2429 | | - // reset deed |
2430 | | - _this.choose( mw.UploadWizardNullDeed ); |
2431 | 2531 | }, |
2432 | 2532 | |
2433 | 2533 | /** |
— | — | @@ -2442,7 +2542,7 @@ |
2443 | 2543 | /** |
2444 | 2544 | * Set up the form and deed object for the deed option that says these uploads are all the user's own work. |
2445 | 2545 | */ |
2446 | | - setupDeedOwnWork: function( isPlural ) { |
| 2546 | + setupDeedOwnWork: function() { |
2447 | 2547 | mw.log("setupdeed own work"); |
2448 | 2548 | var _this = this; |
2449 | 2549 | |
— | — | @@ -2454,10 +2554,8 @@ |
2455 | 2555 | var licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
2456 | 2556 | licenseInput.setDefaultValues(); |
2457 | 2557 | |
2458 | | - var plural = isPlural ? '-plural' : ''; |
| 2558 | + var ownWorkDeed = $j.extend( new mw.UploadWizardDeed(), { |
2459 | 2559 | |
2460 | | - var ownWorkDeed = $j.extend( new mw.UploadWizardDeed(), { |
2461 | | - |
2462 | 2560 | licenseInput: licenseInput, |
2463 | 2561 | |
2464 | 2562 | isReady: function() { |
— | — | @@ -2484,111 +2582,136 @@ |
2485 | 2583 | } ); |
2486 | 2584 | wikiText += '}}'; |
2487 | 2585 | return wikiText; |
2488 | | - } |
2489 | | - } ); |
| 2586 | + }, |
2490 | 2587 | |
2491 | | - var standardDiv = $j( '<div />' ) |
2492 | | - .append( |
2493 | | - $j( '<input />') |
2494 | | - .attr( { type: 'checkbox' } ) |
2495 | | - .click( function() { |
2496 | | - if ( $j( this ).is( ':checked' ) ) { |
2497 | | - $j( _this.selector ) |
2498 | | - .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
2499 | | - .attr( 'checked', false ); |
2500 | | - ownWorkDeed.licenseInput.setDefaultValues(); |
2501 | | - _this.choose( ownWorkDeed ); |
2502 | | - } else { |
2503 | | - _this.choose( mw.UploadWizardNullDeed ); |
2504 | | - } |
2505 | | - } ) |
2506 | | - .addClass( 'mwe-upwiz-deed-accept-ownwork-default mwe-accept-deed mwe-checkbox-hang-indent' ), |
2507 | | - $j( '<p />' ) |
2508 | | - .addClass( 'mwe-checkbox-hang-indent-text' ) |
2509 | | - .html( gM( 'mwe-upwiz-source-ownwork-assert' + plural, |
2510 | | - $j( '<input />' ) |
2511 | | - .attr( { name: 'author' } ) |
2512 | | - .addClass( 'mwe-upwiz-sign' ) ) ), |
2513 | | - $j( '<p />' ) |
2514 | | - .addClass( 'mwe-checkbox-hang-indent-text' ) |
2515 | | - .addClass( 'mwe-small-print' ) |
2516 | | - .html( gM ( 'mwe-upwiz-source-ownwork-assert-note' ) ) |
2517 | | - ); |
| 2588 | + createInterface: function( deedChooser ) { |
| 2589 | + var _this = this; |
| 2590 | + _this.deedChooser = deedChooser; |
2518 | 2591 | |
2519 | | - var toggleDiv = $j('<div />'); |
| 2592 | + var standardDiv = $j( '<div />' ) |
| 2593 | + .append( |
| 2594 | + $j( '<input />') |
| 2595 | + .attr( { type: 'checkbox' } ) |
| 2596 | + .click( function() { |
| 2597 | + if ( $j( this ).is( ':checked' ) ) { |
| 2598 | + $j( deedChooser.selector ) |
| 2599 | + .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
| 2600 | + .attr( 'checked', false ); |
| 2601 | + _this.licenseInput.setDefaultValues(); |
| 2602 | + deedChooser.choose( ownWorkDeed ); |
| 2603 | + } else { |
| 2604 | + deedChooser.choose( mw.UploadWizardNullDeed ); |
| 2605 | + } |
| 2606 | + } ) |
| 2607 | + .addClass( 'mwe-upwiz-deed-accept-ownwork-default mwe-accept-deed mwe-checkbox-hang-indent' ), |
2520 | 2608 | |
2521 | | - var customDiv = $j('<div/>') |
2522 | | - .maskSafeHide() |
2523 | | - .append( |
2524 | | - $j( '<input />') |
2525 | | - .attr( { type: 'checkbox' } ) |
2526 | | - .click( function() { |
2527 | | - if ( $j( this ).is( ':checked' ) ) { |
2528 | | - $j( _this.selector ) |
2529 | | - .find( '.mwe-upwiz-deed-accept-ownwork-default' ) |
2530 | | - .attr( 'checked', false ) |
2531 | | - _this.choose( ownWorkDeed ); |
2532 | | - } else { |
2533 | | - _this.choose( mw.UploadWizardNullDeed ); |
2534 | | - } |
2535 | | - } ) |
2536 | | - .addClass( 'mwe-upwiz-deed-accept-ownwork-custom mwe-accept-deed mwe-checkbox-hang-indent' ), |
2537 | | - $j( '<p />' ) |
2538 | | - .addClass( 'mwe-checkbox-hang-indent-text' ) |
2539 | | - .append( gM( 'mwe-upwiz-source-ownwork-assert-custom' + plural, |
2540 | | - '<span class="mwe-custom-author-input"></span>' ) ), |
2541 | | - licenseInputDiv |
2542 | | - ); |
| 2609 | + // text added in setQuantit |
| 2610 | + $j( '<p class="mwe-upwiz-source-ownwork-assert mwe-checkbox-hang-indent-text"/>' ), |
2543 | 2611 | |
2544 | | - $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' ) |
2545 | | - .append( $j( '<div class="mwe-upwiz-deed-form-internal" />' ) |
2546 | | - .append( standardDiv, |
2547 | | - toggleDiv, |
2548 | | - customDiv ) |
2549 | | - ); |
| 2612 | + $j( '<p />' ) |
| 2613 | + .addClass( 'mwe-checkbox-hang-indent-text' ) |
| 2614 | + .addClass( 'mwe-small-print' ) |
| 2615 | + .html( gM ( 'mwe-upwiz-source-ownwork-assert-note' ) ) |
| 2616 | + ); |
2550 | 2617 | |
2551 | | - |
2552 | | - |
2553 | | - mw.UploadWizardUtil.makeFadingToggler( standardDiv, toggleDiv, customDiv ); |
| 2618 | + var toggleDiv = $j('<div />'); |
2554 | 2619 | |
2555 | | - // if they select 'fewer options', and they have selected the deed in there, we should unselect it |
2556 | | - $j( toggleDiv ).bind( 'close', function(e) { |
2557 | | - e.stopPropagation(); |
2558 | | - if ( $j( _this.selector ).find( '.mwe-upwiz-deed-accept-ownwork-custom' ).is( ':checked' ) ) { |
2559 | | - $j( _this.selector ) |
2560 | | - .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
2561 | | - .attr( 'checked', false ); |
2562 | | - _this.choose( mw.UploadWizardNullDeed ); |
2563 | | - } |
2564 | | - } ); |
| 2620 | + var customDiv = $j('<div/>') |
| 2621 | + .maskSafeHide() |
| 2622 | + .append( |
| 2623 | + $j( '<input />') |
| 2624 | + .attr( { type: 'checkbox' } ) |
| 2625 | + .click( function() { |
| 2626 | + if ( $j( this ).is( ':checked' ) ) { |
| 2627 | + $j( deedChooser.selector ) |
| 2628 | + .find( '.mwe-upwiz-deed-accept-ownwork-default' ) |
| 2629 | + .attr( 'checked', false ) |
| 2630 | + deedChooser.choose( ownWorkDeed ); |
| 2631 | + } else { |
| 2632 | + deedChooser.choose( mw.UploadWizardNullDeed ); |
| 2633 | + } |
| 2634 | + } ) |
| 2635 | + .addClass( 'mwe-upwiz-deed-accept-ownwork-custom mwe-accept-deed mwe-checkbox-hang-indent' ), |
| 2636 | + $j( '<p class="mwe-upwiz-source-ownwork-assert-custom mwe-checkbox-hang-indent-text" />' ), |
| 2637 | + licenseInputDiv |
| 2638 | + ); |
2565 | 2639 | |
2566 | | - // have to add the author input this way -- gM() will flatten it to a string and we'll lose it as a dom object |
2567 | | - $j( _this.selector ).find( '.mwe-custom-author-input' ).append( authorInput ); |
| 2640 | + $j( deedChooser.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' ) |
| 2641 | + .append( $j( '<div class="mwe-upwiz-deed-form-internal" />' ) |
| 2642 | + .append( standardDiv, |
| 2643 | + toggleDiv, |
| 2644 | + customDiv ) |
| 2645 | + ); |
2568 | 2646 | |
2569 | | - // synchronize both username signatures |
2570 | | - // set initial value to configured username |
2571 | | - // if one changes all the others change |
2572 | | - $j( _this.selector ).find( '.mwe-upwiz-sign' ) |
2573 | | - .attr( { value: mw.getConfig( 'userName' ) } ) |
2574 | | - .keyup( function() { |
2575 | | - var thisInput = this; |
2576 | | - var thisVal = $j( thisInput ).val(); |
2577 | | - $j.each( $j( '.mwe-upwiz-sign' ), function( i, input ) { |
2578 | | - if (thisInput !== input) { |
2579 | | - $j( input ).val( thisVal ); |
| 2647 | + |
| 2648 | + |
| 2649 | + mw.UploadWizardUtil.makeFadingToggler( standardDiv, toggleDiv, customDiv ); |
| 2650 | + |
| 2651 | + // if they select 'fewer options', and they have selected the deed in there, we should unselect it |
| 2652 | + $j( toggleDiv ).bind( 'close', function(e) { |
| 2653 | + e.stopPropagation(); |
| 2654 | + if ( $j( deedChooser.selector ).find( '.mwe-upwiz-deed-accept-ownwork-custom' ).is( ':checked' ) ) { |
| 2655 | + $j( deedChooser.selector ) |
| 2656 | + .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
| 2657 | + .attr( 'checked', false ); |
| 2658 | + deedChooser.choose( mw.UploadWizardNullDeed ); |
2580 | 2659 | } |
2581 | 2660 | } ); |
2582 | | - } ); |
2583 | | - |
2584 | 2661 | |
| 2662 | + _this.setQuantity( 1 ); |
| 2663 | + }, |
| 2664 | + |
| 2665 | + |
| 2666 | + setQuantity: function( n ) { |
| 2667 | + var _this = this; |
| 2668 | + var plural = n > 1 ? '-plural' : ''; |
| 2669 | + $j( _this.deedChooser.selector ) |
| 2670 | + .find( 'p.mwe-upwiz-source-ownwork-assert' ) |
| 2671 | + .html( gM( 'mwe-upwiz-source-ownwork-assert' + plural, |
| 2672 | + $j( '<input />' ) |
| 2673 | + .attr( { name: 'author' } ) |
| 2674 | + .addClass( 'mwe-upwiz-sign' ) ) ); |
| 2675 | + |
| 2676 | + $j( _this.deedChooser.selector ) |
| 2677 | + .find( 'p.mwe-upwiz-source-ownwork-assert-custom' ) |
| 2678 | + .html( gM( 'mwe-upwiz-source-ownwork-assert-custom' + plural, |
| 2679 | + '<span class="mwe-custom-author-input"></span>' ) ); |
| 2680 | + |
| 2681 | + // have to add the author input this way -- gM() will flatten it to a string and we'll lose it as a dom object |
| 2682 | + $j( _this.deedChooser.selector ).find( '.mwe-custom-author-input' ).append( authorInput ); |
| 2683 | + |
| 2684 | + // synchronize both username signatures |
| 2685 | + // set initial value to configured username |
| 2686 | + // if one changes all the others change |
| 2687 | + $j( _this.deedChooser.selector ).find( '.mwe-upwiz-sign' ) |
| 2688 | + .attr( { value: mw.getConfig( 'userName' ) } ) |
| 2689 | + .keyup( function() { |
| 2690 | + var thisInput = this; |
| 2691 | + var thisVal = $j( thisInput ).val(); |
| 2692 | + $j.each( $j( '.mwe-upwiz-sign' ), function( i, input ) { |
| 2693 | + if (thisInput !== input) { |
| 2694 | + $j( input ).val( thisVal ); |
| 2695 | + } |
| 2696 | + } ); |
| 2697 | + } ); |
| 2698 | + |
| 2699 | + |
| 2700 | + } |
| 2701 | + } ); |
| 2702 | + |
| 2703 | + ownWorkDeed.createInterface( _this ); |
| 2704 | + |
2585 | 2705 | $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-header-link').click( |
2586 | 2706 | function() { |
2587 | 2707 | _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork' ) ); |
2588 | 2708 | } |
2589 | | - ); |
| 2709 | + ); |
| 2710 | + |
| 2711 | + return ownWorkDeed; |
| 2712 | + |
2590 | 2713 | }, |
2591 | 2714 | |
2592 | | - setupDeedThirdParty: function( isPlural ) { |
| 2715 | + setupDeedThirdParty: function() { |
2593 | 2716 | var _this = this; |
2594 | 2717 | var sourceInput = $j('<textarea class="mwe-source mwe-long-textarea" name="source" rows="1" cols="40"></textarea>' ) |
2595 | 2718 | .growTextArea() |
— | — | @@ -2607,33 +2730,51 @@ |
2608 | 2731 | return (! mw.isEmpty( $j( this.sourceInput ).val() ) ) |
2609 | 2732 | && (! mw.isEmpty( $j( this.authorInput ).val() ) ) |
2610 | 2733 | && this.licenseInput.isSet() |
| 2734 | + }, |
| 2735 | + |
| 2736 | + createInterface: function( deedChooser ) { |
| 2737 | + var _this = this; |
| 2738 | + _this.deedChooser = deedChooser; |
| 2739 | + |
| 2740 | + $j( deedChooser.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ).append( |
| 2741 | + $j( '<div class="mwe-upwiz-deed-form-internal"/>' ) |
| 2742 | + .append( |
| 2743 | + $j( '<div class="mwe-upwiz-source-thirdparty-custom-plural-intro" />' ), |
| 2744 | + $j( '<div />' ) |
| 2745 | + .addClass( "mwe-upwiz-thirdparty-fields" ) |
| 2746 | + .append( $j( '<label />' ) |
| 2747 | + .attr( { 'for' : 'source' } ) |
| 2748 | + .text( gM( 'mwe-upwiz-source' ) ) ) |
| 2749 | + .append( sourceInput ), |
| 2750 | + $j( '<div />' ) |
| 2751 | + .addClass( "mwe-upwiz-thirdparty-fields" ) |
| 2752 | + .append( $j( '<label />' ) |
| 2753 | + .attr( { 'for' : 'author' } ) |
| 2754 | + .text( gM( 'mwe-upwiz-author' ) ) ) |
| 2755 | + .append( authorInput ), |
| 2756 | + $j( '<div />' ).addClass( 'mwe-upwiz-thirdparty-license' ) |
| 2757 | + .text( gM( 'mwe-upwiz-source-thirdparty-license' ) ), |
| 2758 | + licenseInputDiv |
| 2759 | + ) |
| 2760 | + ); |
| 2761 | + |
| 2762 | + thirdPartyDeed.setQuantity( 1 ); |
| 2763 | + }, |
| 2764 | + |
| 2765 | + |
| 2766 | + setQuantity: function( n ) { |
| 2767 | + var _this = this; |
| 2768 | + $j( _this.deedChooser.selector ) |
| 2769 | + .find( 'div.mwe-upwiz-source-thirdparty-custom-plural-intro' ) |
| 2770 | + .html( n > 1 ? gM( 'mwe-upwiz-source-thirdparty-custom-plural-intro' ) : '' ); |
2611 | 2771 | } |
| 2772 | + |
2612 | 2773 | |
2613 | 2774 | } ); |
| 2775 | + |
| 2776 | + thirdPartyDeed.createInterface( _this ); |
2614 | 2777 | |
2615 | | - $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ).append( |
2616 | | - $j( '<div class="mwe-upwiz-deed-form-internal"/>' ) |
2617 | | - .append( |
2618 | | - ( isPlural ? $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-plural-intro' ) ) |
2619 | | - : '' ), |
2620 | | - $j( '<div />' ) |
2621 | | - .addClass( "mwe-upwiz-thirdparty-fields" ) |
2622 | | - .append( $j( '<label />' ) |
2623 | | - .attr( { 'for' : 'source' } ) |
2624 | | - .text( gM( 'mwe-upwiz-source' ) ) ) |
2625 | | - .append( sourceInput ), |
2626 | | - $j( '<div />' ) |
2627 | | - .addClass( "mwe-upwiz-thirdparty-fields" ) |
2628 | | - .append( $j( '<label />' ) |
2629 | | - .attr( { 'for' : 'author' } ) |
2630 | | - .text( gM( 'mwe-upwiz-author' ) ) ) |
2631 | | - .append( authorInput ), |
2632 | | - $j( '<div />' ).addClass( 'mwe-upwiz-thirdparty-license' ) |
2633 | | - .text( gM( 'mwe-upwiz-source-thirdparty-license' ) ), |
2634 | | - licenseInputDiv |
2635 | | - ) |
2636 | | - ); |
2637 | | - |
| 2778 | + // set up the header |
2638 | 2779 | $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-header-link').click( |
2639 | 2780 | function() { |
2640 | 2781 | _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty' ) ); |
— | — | @@ -2641,6 +2782,7 @@ |
2642 | 2783 | } |
2643 | 2784 | ); |
2644 | 2785 | |
| 2786 | + return thirdPartyDeed; |
2645 | 2787 | } |
2646 | 2788 | }; |
2647 | 2789 | |
— | — | @@ -2949,9 +3091,14 @@ |
2950 | 3092 | |
2951 | 3093 | $j.fn.enableNextButton = function() { |
2952 | 3094 | this.find( '.mwe-upwiz-button-next' ) |
2953 | | - .removeAttr( 'disabled' ) |
2954 | | - .effect( 'pulsate', { times: 3 }, 1000 ); |
| 3095 | + .removeAttr( 'disabled' ); |
| 3096 | + // .effect( 'pulsate', { times: 3 }, 1000 ); |
2955 | 3097 | }; |
| 3098 | + |
| 3099 | + $j.fn.disableNextButton = function() { |
| 3100 | + this.find( '.mwe-upwiz-button-next' ) |
| 3101 | + .attr( 'disabled', true ); |
| 3102 | + } |
2956 | 3103 | |
2957 | 3104 | |
2958 | 3105 | } )( jQuery ); |