Index: trunk/extensions/UploadWizard/styles/uploadWizard.css |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | margin-left: 24px; |
340 | 340 | } |
341 | 341 | |
342 | | -.mwe-upwiz-deed-name { |
| 342 | +.mwe-upwiz-deed.selected .mwe-upwiz-deed-name { |
343 | 343 | font-weight: bold; |
344 | 344 | } |
345 | 345 | |
— | — | @@ -466,7 +466,7 @@ |
467 | 467 | } |
468 | 468 | |
469 | 469 | .mwe-upwiz-deed-form-internal { |
470 | | - padding: 5px 0px 20px 20px; |
| 470 | + padding: 5px 0px 20px 40px; |
471 | 471 | } |
472 | 472 | |
473 | 473 | |
— | — | @@ -503,3 +503,8 @@ |
504 | 504 | a.mwe-upwiz-tooltip-link { |
505 | 505 | cursor: pointer; |
506 | 506 | } |
| 507 | + |
| 508 | +.mwe-error { |
| 509 | + color: #ff0000; |
| 510 | + display: none; |
| 511 | +} |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -33,8 +33,12 @@ |
34 | 34 | 'mwe-upwiz-upload' => 'Upload', |
35 | 35 | 'mwe-upwiz-upload-count' => '$1 {{PLURAL:$1|file|files}} of $2 {{PLURAL:$2|file|files}} uploaded', |
36 | 36 | 'mwe-upwiz-progressbar-uploading' => 'uploading', |
37 | | - 'mwe-upwiz-remaining' => '$1 {{PLURAL:$1|file|files}} remaining', |
38 | | - 'mwe-upwiz-deeds-intro' => "Thank you! Now we need to set a license for these files, so everyone can legally view or modify them. First, we will have to know where you got them.", |
| 37 | + 'mwe-upwiz-secs-remaining' => '$1 {{PLURAL:$1|second|seconds}} remaining', |
| 38 | + 'mwe-upwiz-mins-secs-remaining' => '$1 {{PLURAL:$1|minute|minutes}} $2 {{PLURAL:$2|second|seconds}} remaining', |
| 39 | + 'mwe-upwiz-hrs-mins-secs-remaining' => '$1 {{PLURAL:$1|hour|hours}} $2 {{PLURAL:$2|minute|minutes}} $3 {{PLURAL:$3|second|seconds}} remaining', |
| 40 | + 'mwe-upwiz-deeds-intro' => "This site requires you to set a license for uploaded files, so everyone can legally reuse them for any purpose.", |
| 41 | + 'mwe-upwiz-deeds-macro-prompt' => "Set a license for {{PLURAL:$1|the above file|all the above files}}:", |
| 42 | + 'mwe-upwiz-deeds-custom-prompt' => "Or:", |
39 | 43 | 'mwe-upwiz-details-intro' => 'Now we need some basic information about the files.', |
40 | 44 | 'mwe-upwiz-source-ownwork' => '{{PLURAL:$1|This file is|These files are}} my own work.', |
41 | 45 | 'mwe-upwiz-source-ownwork-assert' => 'I, $2, the copyright holder of {{PLURAL:$1|this work|these works}}, hereby grant anyone the right to use {{PLURAL:$1|this work|these works}} for any purpose, as long as they credit me and share derivative work under the same terms.', |
— | — | @@ -46,7 +50,7 @@ |
47 | 51 | 'mwe-upwiz-source-thirdparty-custom-multiple-intro' => 'If all files have the same source, author, and copyright status, you may enter them only once for all of them.', |
48 | 52 | 'mwe-upwiz-source-thirdparty-license' => 'The copyright holder of {{PLURAL:$1|this work|these works}} published {{PLURAL:$1|it|them}} under the following license(s):', |
49 | 53 | 'mwe-upwiz-source-thirdparty-accept' => 'OK', |
50 | | - 'mwe-upwiz-source-custom' => 'Did you know? You can <a href="$1">customize</a> the default options you see here.', |
| 54 | + 'mwe-upwiz-source-custom' => 'Choose licenses for each file individually on the next page.', |
51 | 55 | 'mwe-upwiz-more-options' => 'more options...', |
52 | 56 | 'mwe-upwiz-fewer-options' => 'fewer options...', |
53 | 57 | 'mwe-upwiz-desc' => 'Description in', |
— | — | @@ -92,7 +96,6 @@ |
93 | 97 | 'mwe-upwiz-upload-another' => 'Upload more files', |
94 | 98 | 'mwe-prevent-close' => 'Your files are still uploading. Are you sure you want to navigate away from this page?', |
95 | 99 | 'mwe-upwiz-files-complete' => 'Your files finished uploading!', |
96 | | - 'mwe-upwiz-deeds-later' => 'Set deeds and licenses for each file individually on the next page', |
97 | 100 | 'mwe-upwiz-tooltip-author' => 'The name of the person who took the photo, or painted the picture, drew the drawing, etc.', |
98 | 101 | 'mwe-upwiz-tooltip-source' => 'Where this digital file came from -- could be a URL, or a book or publication', |
99 | 102 | 'mwe-upwiz-tooltip-sign' => 'You can use your wiki user name or your real name. In both cases, this will be linked to your wiki user page', |
— | — | @@ -104,6 +107,7 @@ |
105 | 108 | 'mwe-upwiz-file-need-start' => 'Please press this button to start your uploads.', |
106 | 109 | 'mwe-upwiz-file-need-complete' => 'Please wait until all files have finished uploading.', |
107 | 110 | 'mwe-upwiz-deeds-need-deed' => 'Please explain where you got {{PLURAL:$1|this file|these files}} and how this site can use {{PLURAL:$1|it|them}}, by selecting one of the options.', |
| 111 | + 'mwe-upwiz-deeds-need-license' => 'Please select a license.' |
108 | 112 | ); |
109 | 113 | |
110 | 114 | /** Message documentation (Message documentation) |
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | * @param values (optional) array of license key names to activate by default |
186 | 186 | * @param change (optional) function to execute when any value changes |
187 | 187 | */ |
188 | | -mw.UploadWizardLicenseInput = function( div, values ) { |
| 188 | +mw.UploadWizardLicenseInput = function( selector, values ) { |
189 | 189 | var _this = this; |
190 | 190 | |
191 | 191 | _this.change = function() {}; |
— | — | @@ -202,14 +202,15 @@ |
203 | 203 | |
204 | 204 | _this.inputs = []; |
205 | 205 | |
206 | | - $div = $j( div ); |
| 206 | + _this.$selector = $j( selector ); |
| 207 | + _this.$selector.append( $j( '<div class="mwe-error"></div>' ) ); |
207 | 208 | $j.each( _this.licenses, function( key, data ) { |
208 | 209 | var id = 'license_' + key + '_' + c; |
209 | 210 | var input = $j( '<input />' ) |
210 | 211 | .attr( { id: id, type: 'checkbox', value: key } ) |
211 | 212 | .click( function() { _this.change() } ); |
212 | 213 | data.input = input.get(0); |
213 | | - $div.append( |
| 214 | + _this.$selector.append( |
214 | 215 | data.input, |
215 | 216 | $j( '<label />' ).attr( { 'for': id } ).html( data.text ), |
216 | 217 | $j( '<br/>' ) |
— | — | @@ -278,6 +279,26 @@ |
279 | 280 | }, |
280 | 281 | |
281 | 282 | /** |
| 283 | + * Check if a valid value is set, |
| 284 | + * Side effect: add notes to the interface if no valid value |
| 285 | + * @return boolean; true if a value set, false otherwise |
| 286 | + */ |
| 287 | + validate: function() { |
| 288 | + var isValid = this.isSet(); |
| 289 | + if (!isValid) { |
| 290 | + var $errorEl = this.$selector.find( '.mwe-error' ) |
| 291 | + $errorEl.html( gM( 'mwe-upwiz-deeds-need-license' ) ).show(); |
| 292 | + var $inputs = _this.$selector.find( 'input[type=checkbox]' ) |
| 293 | + $inputs.bind( 'click.hideError', function() { |
| 294 | + $errorEl.hide(); |
| 295 | + $inputs.unbind( 'click.hideError' ); |
| 296 | + } ) |
| 297 | + } |
| 298 | + return isValid; |
| 299 | + }, |
| 300 | + |
| 301 | + |
| 302 | + /** |
282 | 303 | * Returns true if any license is set |
283 | 304 | * @return boolean |
284 | 305 | */ |
— | — | @@ -1093,16 +1114,13 @@ |
1094 | 1115 | var _this = this; |
1095 | 1116 | _this.copyrightInfoFieldset.show(); |
1096 | 1117 | _this.upload.wizardDeedChooser = _this.upload.deedChooser; |
1097 | | - _this.upload.deedChooser = new mw.UploadWizardDeedChooser( _this.deedDiv ); |
| 1118 | + _this.upload.deedChooser = new mw.UploadWizardDeedChooser( |
| 1119 | + _this.deedDiv, |
| 1120 | + [ new mw.UploadWizardDeedOwnWork(), |
| 1121 | + new mw.UploadWizardDeedThirdParty() ] |
| 1122 | + ); |
1098 | 1123 | }, |
1099 | 1124 | |
1100 | | - useDeedChooser: function( deedChooser ) { |
1101 | | - var _this = this; |
1102 | | - _this.upload.deedChooser = deedChooser; |
1103 | | - _this.deedDiv.empty(); |
1104 | | - }, |
1105 | | - |
1106 | | - |
1107 | 1125 | /** |
1108 | 1126 | * Sets the filename from the title plus this upload's extension. |
1109 | 1127 | */ |
— | — | @@ -1865,11 +1883,18 @@ |
1866 | 1884 | _this.startUploads(); |
1867 | 1885 | } ); |
1868 | 1886 | |
| 1887 | + |
| 1888 | + // handler for next button |
1869 | 1889 | $j( '#mwe-upwiz-stepdiv-file .mwe-upwiz-button-next').click( function() { |
| 1890 | + // check if there is an upload at all |
1870 | 1891 | if ( _this.uploads.length === 0 ) { |
1871 | 1892 | alert( gM( 'mwe-upwiz-file-need-file' ) ); |
1872 | 1893 | return; |
1873 | 1894 | } |
| 1895 | + |
| 1896 | + |
| 1897 | + // check if all uploads are finished. The upload with the most advanced state |
| 1898 | + // will be copied to 'overallState' |
1874 | 1899 | var overallState = 'new'; |
1875 | 1900 | $j.each( _this.uploads, function( i, upload ) { |
1876 | 1901 | if ( upload.state == 'transporting' ) { |
— | — | @@ -1878,111 +1903,97 @@ |
1879 | 1904 | overallState = 'transported'; |
1880 | 1905 | } |
1881 | 1906 | } ); |
| 1907 | + |
| 1908 | + // if uploads aren't initiated or finished uploading, throw up errors, otherwise, let's |
| 1909 | + // go to the next step. |
1882 | 1910 | if ( overallState == 'new' ) { |
1883 | 1911 | alert( gM( 'mwe-upwiz-file-need-start' ) ); |
1884 | 1912 | } else if ( overallState == 'transporting' ) { |
1885 | 1913 | alert( gM( 'mwe-upwiz-file-need-complete' ) ); |
1886 | 1914 | } else if ( overallState == 'transported' ) { |
| 1915 | + |
| 1916 | + |
| 1917 | + // okay all uploads are done, we're ready to go to the next step |
| 1918 | + |
| 1919 | + // do some last minute prep before advancing to the DEEDS page |
| 1920 | + |
| 1921 | + // these deeds are standard |
| 1922 | + var deeds = [ |
| 1923 | + new mw.UploadWizardDeedOwnWork( _this.uploads.length ), |
| 1924 | + new mw.UploadWizardDeedThirdParty( _this.uploads.length ), |
| 1925 | + ]; |
| 1926 | + |
| 1927 | + // if we have multiple uploads, also give them the option to set |
| 1928 | + // licenses individually |
| 1929 | + if ( _this.uploads.length > 1 ) { |
| 1930 | + var customDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 1931 | + validate: function() { return true; }, |
| 1932 | + $formFields: null, |
| 1933 | + name: 'custom', |
| 1934 | + } ); |
| 1935 | + deeds.push( customDeed ); |
| 1936 | + } |
| 1937 | + |
| 1938 | + _this.deedChooser = new mw.UploadWizardDeedChooser( |
| 1939 | + '#mwe-upwiz-deeds', |
| 1940 | + deeds, |
| 1941 | + _this.uploads.length ); |
| 1942 | + |
| 1943 | + $j( '<div>' ).html( gM( 'mwe-upwiz-deeds-macro-prompt' ) ) |
| 1944 | + .insertBefore ( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-ownwork' ) ); |
| 1945 | + |
| 1946 | + if ( _this.uploads.length > 1 ) { |
| 1947 | + $j( '<div style="margin-top: 1em">' ).html( gM( 'mwe-upwiz-deeds-custom-prompt' ) ) |
| 1948 | + .insertBefore( _this.deedChooser.$selector.find( '.mwe-upwiz-deed-custom' ) ); |
| 1949 | + } |
| 1950 | + |
1887 | 1951 | _this.moveToStep( 'deeds' ); |
| 1952 | + |
1888 | 1953 | } else { |
| 1954 | + // should never happen, since all the state names are well known |
| 1955 | + // compare with the 'makeTransitioner' call for the upload page |
1889 | 1956 | alert( "error: could not recognize state of uploads: " + overallState ); |
1890 | 1957 | } |
1891 | 1958 | |
1892 | 1959 | } ); |
1893 | 1960 | |
| 1961 | + |
1894 | 1962 | // DEEDS div |
1895 | | - _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-deeds' ); |
1896 | 1963 | |
1897 | | - var customDeed = $j.extend( new mw.UploadWizardDeed(), { |
1898 | | - isReady: function() { return true; }, |
1899 | | - setQuantity: function() { return; } |
1900 | | - } ); |
1901 | | - |
1902 | | - $j( '#mwe-upwiz-deeds-custom' ).append( |
1903 | | - $j( '<div id="mwe-upwiz-deeds-later-div" />' ) |
1904 | | - .hide() |
1905 | | - .append( $j( '<label>' ) |
1906 | | - .append( |
1907 | | - $j( '<input id="mwe-upwiz-deeds-later" ' |
1908 | | - + 'type="checkbox" value="deeds-later" class="mwe-accept-deed" />') |
1909 | | - .click( function() { |
1910 | | - if ( $j( this ).is( ':checked' ) ) { |
1911 | | - _this.deedChooser.showDeedChoice(); |
1912 | | - _this.deedChooser.choose( customDeed ); |
1913 | | - //_this.deedChooser.trigger( 'isReady' ); |
1914 | | - } else { |
1915 | | - _this.deedChooser.choose( mw.UploadWizardNullDeed ); |
1916 | | - } |
1917 | | - } ), |
1918 | | - $j( '<span />').append( gM( 'mwe-upwiz-deeds-later' ) ) |
1919 | | - ) |
1920 | | - ) |
1921 | | - ); |
1922 | | - |
1923 | | - $j( _this.deedChooser ).bind( 'setQuantityEvent', function() { |
1924 | | - mw.log( "checking this deedchooser count " + _this.deedChooser.count ); |
1925 | | - if ( _this.deedChooser.count > 1 ) { |
1926 | | - $j( '#mwe-upwiz-deeds-later-div' ).show(); |
1927 | | - } else { |
1928 | | - $j( '#mwe-upwiz-deeds-later-div' ).hide(); |
1929 | | - } |
1930 | | - } ); |
1931 | | - |
1932 | | - // XXX mediawiki PLURAL |
1933 | 1964 | $j( '#mwe-upwiz-deeds-intro' ).html( gM( 'mwe-upwiz-deeds-intro' ) ); |
1934 | 1965 | |
1935 | 1966 | $j( '#mwe-upwiz-stepdiv-deeds .mwe-upwiz-button-next').click( function() { |
1936 | | - if ( $j( '#mwe-upwiz-deeds-later-checkbox' ).is( ':checked' ) |
1937 | | - || |
1938 | | - _this.deedChooser.isReady() ) { |
1939 | | - _this.moveToStep('details'); |
1940 | | - } else { |
1941 | | - _this.deedChooser.deed.showValidationTips(); |
1942 | | - } |
1943 | | - } ); |
| 1967 | + if ( _this.deedChooser.validate() ) { |
1944 | 1968 | |
1945 | | - // XXX perhaps we should defer this until we click next |
1946 | | - $j( _this.deedChooser ).bind( 'chooseDeed', function() { |
1947 | | - var isCustom = ( _this.deedChooser.deed === customDeed ); |
1948 | | - $j.each( _this.uploads, function( i, upload ) { |
1949 | | - if (isCustom) { |
1950 | | - upload.details.useCustomDeedChooser(); |
1951 | | - } else { |
1952 | | - upload.details.useDeedChooser( _this.deedChooser ); |
1953 | | - } |
1954 | | - } ); |
1955 | | - } ); |
| 1969 | + var isCustom = ( _this.deedChooser.deed.name == 'later' ); |
| 1970 | + |
| 1971 | + $j.each( _this.uploads, function( i, upload ) { |
| 1972 | + if ( isCustom ) { |
| 1973 | + upload.details.useCustomDeedChooser(); |
| 1974 | + } else { |
| 1975 | + upload.deedChooser = _this.deedChooser; |
| 1976 | + } |
| 1977 | + } ); |
1956 | 1978 | |
1957 | | - // XXX perhaps we should defer this until we click next |
1958 | | - $j( _this.deedChooser ).bind( 'chooseNullDeed', function() { |
1959 | | - $j.each( _this.uploads, function( i, upload ) { |
1960 | | - upload.details.deedChooser = _this.deedChooser; |
1961 | | - } ); |
1962 | | - // $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
| 1979 | + _this.moveToStep('details'); |
| 1980 | + } |
1963 | 1981 | } ); |
1964 | 1982 | |
1965 | | - /* |
1966 | | - // XXX figure out some way to make them ready / unready |
1967 | | - // timeout after input, check for readiness, then trigger event? |
1968 | | - $j( _this.deedChooser ).bind( 'isReady', function() { |
1969 | | - $j( '#mwe-upwiz-stepdiv-deeds' ).enableNextButton(); |
1970 | | - } ); |
1971 | 1983 | |
1972 | | - $j( _this.deedChooser ).bind( 'isNotReady', function() { |
1973 | | - $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
1974 | | - } ); |
1975 | | -*/ |
1976 | | - |
1977 | | - |
1978 | 1984 | // DETAILS div |
| 1985 | + |
1979 | 1986 | $j( '#mwe-upwiz-stepdiv-details .mwe-upwiz-button-next' ).click( function() { |
1980 | 1987 | _this.detailsSubmit( function() { |
1981 | 1988 | _this.prefillThanksPage(); |
1982 | 1989 | _this.moveToStep('thanks'); |
1983 | 1990 | } ); |
1984 | 1991 | } ); |
| 1992 | + |
| 1993 | + |
1985 | 1994 | |
1986 | | - // add one to start |
| 1995 | + // WIZARD |
| 1996 | + |
| 1997 | + // add one upload field to start (this is the big one that asks you to upload something) |
1987 | 1998 | var upload = _this.newUpload( '#mwe-upwiz-add-file' ); |
1988 | 1999 | |
1989 | 2000 | // "select" the first step - highlight, make it visible, hide all others |
— | — | @@ -2086,12 +2097,7 @@ |
2087 | 2098 | _this.updateFileCounts(); |
2088 | 2099 | |
2089 | 2100 | 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 | | - |
| 2101 | + |
2096 | 2102 | // set up details |
2097 | 2103 | upload.details = new mw.UploadWizardDetails( upload, $j( '#mwe-upwiz-macro-files' )); |
2098 | 2104 | }, |
— | — | @@ -2108,9 +2114,6 @@ |
2109 | 2115 | removeUpload: function( upload ) { |
2110 | 2116 | var _this = this; |
2111 | 2117 | $j( upload ).unbind(); // everything |
2112 | | - if ( upload.deedChooser ) { |
2113 | | - upload.deedChooser.detach( upload ); |
2114 | | - } |
2115 | 2118 | upload.details.div.remove(); |
2116 | 2119 | upload.thanksDiv.remove(); |
2117 | 2120 | |
— | — | @@ -2421,116 +2424,294 @@ |
2422 | 2425 | }; |
2423 | 2426 | |
2424 | 2427 | mw.UploadWizardNullDeed = $j.extend( new mw.UploadWizardDeed(), { |
2425 | | - isReady: function() { return false; }, |
| 2428 | + validate: function() { |
| 2429 | + alert( gM( 'mwe-upwiz-deeds-need-deed', _this.uploads.length ) ); |
| 2430 | + return false; |
| 2431 | + } |
| 2432 | +} ); |
2426 | 2433 | |
2427 | | - setQuantity: function() { return; }, |
| 2434 | + |
| 2435 | +/** |
| 2436 | + * Set up the form and deed object for the deed option that says these uploads are all the user's own work. |
| 2437 | + */ |
| 2438 | +mw.UploadWizardDeedOwnWork = function( uploadCount ) { |
| 2439 | + uploadCount = uploadCount ? uploadCount : 1; |
2428 | 2440 | |
2429 | | - showValidationTips: function() { |
2430 | | - alert( gM( 'mwe-upwiz-deeds-need-deed', _this.uploads.length ) ); |
| 2441 | + var _this = new mw.UploadWizardDeed(); |
| 2442 | + |
| 2443 | + _this.authorInput = $j( '<input />') |
| 2444 | + .attr( { name: "author" } ) |
| 2445 | + .addClass( 'mwe-upwiz-sign' ); |
| 2446 | + |
| 2447 | + var licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
| 2448 | + _this.licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
| 2449 | + _this.licenseInput.setDefaultValues(); |
| 2450 | + |
| 2451 | + var $standardCheckbox, $customCheckbox; |
| 2452 | + |
| 2453 | + $standardCheckbox = $j( '<input type="checkbox" class="mwe-accept-deed mwe-checkbox-hang-indent" />' ).click( function() { |
| 2454 | + if ( $j( this ).is( ':checked' ) ) { |
| 2455 | + $customCheckbox.attr( 'checked', false ); |
| 2456 | + _this.licenseInput.setDefaultValues(); |
| 2457 | + } |
| 2458 | + } ); |
| 2459 | + |
| 2460 | + $customCheckbox = $j( '<input type="checkbox" class="mwe-accept-deed mwe-checkbox-hang-indent" />' ).click( function() { |
| 2461 | + if ( $j( this ).is( ':checked' ) ) { |
| 2462 | + $standardCheckbox.attr( 'checked', false ); |
| 2463 | + } |
| 2464 | + } ); |
| 2465 | + |
| 2466 | + var $standardDiv = $j( '<div />' ).append( |
| 2467 | + $standardCheckbox, |
| 2468 | + |
| 2469 | + $j( '<p class="mwe-checkbox-hang-indent-text"/>' ) |
| 2470 | + .html( gM( 'mwe-upwiz-source-ownwork-assert', |
| 2471 | + uploadCount, |
| 2472 | + '<input name="author" class="mwe-upwiz-sign" />' ) |
| 2473 | + ), |
| 2474 | + |
| 2475 | + $j( '<p class="mwe-checkbox-hang-indent-text mwe-small-print" />' ).html( |
| 2476 | + gM ( 'mwe-upwiz-source-ownwork-assert-note' ) |
| 2477 | + ) |
| 2478 | + ); |
| 2479 | + |
| 2480 | + var $toggleDiv = $j('<div />'); |
| 2481 | + |
| 2482 | + var $customDiv = $j('<div/>').append( |
| 2483 | + $customCheckbox, |
| 2484 | + |
| 2485 | + $j( '<p class="mwe-checkbox-hang-indent-text" />' ) |
| 2486 | + .html( gM( 'mwe-upwiz-source-ownwork-assert-custom', |
| 2487 | + uploadCount, |
| 2488 | + '<span class="mwe-custom-author-input"></span>' ) ), |
| 2489 | + |
| 2490 | + licenseInputDiv |
| 2491 | + ); |
| 2492 | + |
| 2493 | + _this.$formFields = $j( '<div class="mwe-upwiz-deed-form-internal" />' ).append( |
| 2494 | + $standardDiv, $toggleDiv, $customDiv |
| 2495 | + ); |
| 2496 | + |
| 2497 | + mw.UploadWizardUtil.makeFadingToggler( $standardDiv, $toggleDiv, $customDiv ); |
| 2498 | + |
| 2499 | + // if they select 'fewer options', and they have selected the deed in there, we should unselect it |
| 2500 | + $toggleDiv.bind( 'close', function(e) { |
| 2501 | + e.stopPropagation(); |
| 2502 | + if ( $customCheckbox.is( ':checked' ) ) { |
| 2503 | + $customCheckbox.attr( 'checked', false ); |
| 2504 | + } |
| 2505 | + } ); |
| 2506 | + |
| 2507 | + // have to add the author input this way -- gM() will flatten it to a string and we'll lose it as a dom object |
| 2508 | + _this.$formFields.find( '.mwe-custom-author-input' ).append( _this.authorInput ); |
| 2509 | + |
| 2510 | + // synchronize both username signatures |
| 2511 | + // set initial value to configured username |
| 2512 | + // if one changes all the others change (keyup event) |
| 2513 | + // |
| 2514 | + // also set tooltips ( the title, tipsy() ) |
| 2515 | + _this.$formFields.find( '.mwe-upwiz-sign' ) |
| 2516 | + .attr( { |
| 2517 | + title: gM( 'mwe-upwiz-tooltip-sign' ), |
| 2518 | + value: mw.getConfig( 'userName' ) |
| 2519 | + } ) |
| 2520 | + .tipsyPlus() |
| 2521 | + .keyup( function() { |
| 2522 | + var thisInput = this; |
| 2523 | + var thisVal = $j( thisInput ).val(); |
| 2524 | + $j.each( $j( '.mwe-upwiz-sign' ), function( i, input ) { |
| 2525 | + if (thisInput !== input) { |
| 2526 | + $j( input ).val( thisVal ); |
| 2527 | + } |
| 2528 | + } ); |
| 2529 | + } ); |
| 2530 | + |
| 2531 | + return $j.extend( _this, { |
| 2532 | + |
| 2533 | + name: 'ownwork', |
| 2534 | + |
| 2535 | + /** |
| 2536 | + * Is this correctly set, with side effects of causing errors to show in interface. |
| 2537 | + * @return boolean true if valid, false if not |
| 2538 | + */ |
| 2539 | + validate: function() { |
| 2540 | + return ( |
| 2541 | + ( $j( _this.selector ).find( '.mwe-accept-deed' ).is( ':checked' ) !== 0 ) |
| 2542 | + && |
| 2543 | + licenseInput.isSet() |
| 2544 | + ); |
| 2545 | + }, |
| 2546 | + |
| 2547 | + getSourceWikiText: function() { |
| 2548 | + return '{{own}}'; |
| 2549 | + }, |
| 2550 | + |
| 2551 | + getAuthorWikiText: function() { |
| 2552 | + return "[[User:" + mw.getConfig('userName') + '|' + $j( authorInput ).val() + ']]'; |
| 2553 | + }, |
| 2554 | + |
| 2555 | + |
| 2556 | + getLicenseWikiText: function() { |
| 2557 | + var wikiText = '{{self'; |
| 2558 | + $j.each( licenseInput.getTemplates(), function( i, template ) { |
| 2559 | + wikiText += '|' + template; |
| 2560 | + } ); |
| 2561 | + wikiText += '}}'; |
| 2562 | + return wikiText; |
| 2563 | + } |
| 2564 | + |
| 2565 | + } ); |
| 2566 | + |
| 2567 | +}; |
| 2568 | + |
| 2569 | + |
| 2570 | +mw.UploadWizardDeedThirdParty = function( uploadCount ) { |
| 2571 | + uploadCount = uploadCount ? uploadCount : 1; |
| 2572 | + |
| 2573 | + var _this = new mw.UploadWizardDeed(); |
| 2574 | + |
| 2575 | + _this.sourceInput = $j('<textarea class="mwe-source mwe-long-textarea" name="source" rows="1" cols="40"></textarea>' ) |
| 2576 | + .growTextArea() |
| 2577 | + .attr( 'title', gM( 'mwe-upwiz-tooltip-source' ) ) |
| 2578 | + .tipsyPlus(); |
| 2579 | + _this.authorInput = $j('<textarea class="mwe-author mwe-long-textarea" name="author" rows="1" cols="40"></textarea>' ) |
| 2580 | + .growTextArea() |
| 2581 | + .attr( 'title', gM( 'mwe-upwiz-tooltip-author' ) ) |
| 2582 | + .tipsyPlus(); |
| 2583 | + licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
| 2584 | + _this.licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
| 2585 | + _this.licenseInput.setDefaultValues(); |
| 2586 | + |
| 2587 | + _this.$formFields = $j( '<div class="mwe-upwiz-deed-form-internal"/>' ); |
| 2588 | + |
| 2589 | + if ( uploadCount > 1 ) { |
| 2590 | + _this.$formFields.append( $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-multiple-intro' ) ) ); |
2431 | 2591 | } |
2432 | | -} ); |
2433 | 2592 | |
| 2593 | + _this.$formFields.append ( |
| 2594 | + $j( '<div class="mwe-upwiz-source-thirdparty-custom-multiple-intro" />' ), |
| 2595 | + $j( '<div class="mwe-upwiz-thirdparty-fields" />' ) |
| 2596 | + .append( $j( '<label for="source"/>' ).text( gM( 'mwe-upwiz-source' ) ), |
| 2597 | + _this.sourceInput ), |
| 2598 | + $j( '<div class="mwe-upwiz-thirdparty-fields" />' ) |
| 2599 | + .append( $j( '<label for="author"/>' ).text( gM( 'mwe-upwiz-author' ) ), |
| 2600 | + _this.authorInput ), |
| 2601 | + $j( '<div class="mwe-upwiz-thirdparty-license" />' ) |
| 2602 | + .append( gM( 'mwe-upwiz-source-thirdparty-license', uploadCount ) ), |
| 2603 | + licenseInputDiv |
| 2604 | + ); |
2434 | 2605 | |
| 2606 | + return $j.extend( _this, mw.UploadWizardDeed.prototype, { |
| 2607 | + name: 'thirdparty', |
2435 | 2608 | |
| 2609 | + validate: function() { |
| 2610 | + return (! mw.isEmpty( $j( this.sourceInput ).val() ) ) |
| 2611 | + && (! mw.isEmpty( $j( this.authorInput ).val() ) ) |
| 2612 | + && this.licenseInput.isSet() |
| 2613 | + } |
| 2614 | + } ); |
| 2615 | +} |
2436 | 2616 | |
2437 | 2617 | |
| 2618 | + |
| 2619 | + |
2438 | 2620 | /** |
2439 | 2621 | * @param selector where to put this deed chooser |
2440 | 2622 | * @param isPlural whether this chooser applies to multiple files (changes messaging mostly) |
2441 | 2623 | */ |
2442 | | -mw.UploadWizardDeedChooser = function( selector ) { |
| 2624 | +mw.UploadWizardDeedChooser = function( selector, deeds, uploadCount ) { |
2443 | 2625 | var _this = this; |
2444 | | - _this.selector = selector; |
2445 | | - _this.deed = mw.UploadWizardNullDeed; |
| 2626 | + _this.$selector = $j( selector ); |
| 2627 | + _this.uploadCount = uploadCount ? uploadCount : 1; |
| 2628 | + |
2446 | 2629 | |
2447 | | - items = []; |
2448 | | - $j.each( [ 'ownwork', 'thirdparty' ], function (i, key) { |
2449 | | - var item = |
2450 | | - '<div class="mwe-upwiz-macro-deed-' + key + ' mwe-upwiz-deed">' |
| 2630 | + _this.$selector.append( '<div class="mwe-error"></div>' ); |
| 2631 | + |
| 2632 | + // name for radio button set |
| 2633 | + _this.name = 'deedChooser' + (mw.UploadWizardDeedChooser.prototype.widgetCount++).toString(); |
| 2634 | + |
| 2635 | + $j.each( deeds, function (i, deed) { |
| 2636 | + var id = _this.name + '-' + deed.name; |
| 2637 | + |
| 2638 | + var $deedInterface = $j( |
| 2639 | + '<div class="mwe-upwiz-deed mwe-upwiz-deed-' + deed.name + '">' |
2451 | 2640 | + '<div class="mwe-upwiz-deed-option-title">' |
2452 | | - + '<span class="mwe-upwiz-deed-header mwe-closed">' |
2453 | | - + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name"></a>' |
| 2641 | + + '<span class="mwe-upwiz-deed-header">' |
| 2642 | + + '<input id="' + id +'" name="' + _this.name + '" type="radio" value="' + deed.name + '">' |
| 2643 | + + '<label for="' + id + '" class="mwe-upwiz-deed-name">' |
| 2644 | + + gM( 'mwe-upwiz-source-' + deed.name, _this.uploadCount ) |
| 2645 | + + '</label>' |
| 2646 | + + '</input>' |
2454 | 2647 | + '</span>' |
2455 | | - + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
2456 | | - + '<span class="mwe-upwiz-deed-name"></span>' |
2457 | | - + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
2458 | | - + '</span>' |
| 2648 | + // + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
2459 | 2649 | + '</div>' |
2460 | | - + '<div class="mwe-upwiz-deed-form"></div>' |
| 2650 | + + '<div class="mwe-upwiz-deed-form">' |
2461 | 2651 | + '</div>' |
2462 | | - items.push(item); |
2463 | | - } ); |
| 2652 | + ); |
2464 | 2653 | |
2465 | | - $j( selector ).html( items.join('') ); |
| 2654 | + var $deedSelector = _this.$selector.append( $deedInterface ); |
2466 | 2655 | |
| 2656 | + $deedInterface.find( '.mwe-upwiz-deed-form' ).append( deed.$formFields ); |
| 2657 | + |
| 2658 | + $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).click( function() { |
| 2659 | + if ( $j( this ).is(':checked' ) ) { |
| 2660 | + _this.choose( deed ); |
| 2661 | + _this.showDeed( $deedInterface ); |
| 2662 | + } |
| 2663 | + } ); |
| 2664 | + |
| 2665 | + } ); |
| 2666 | + |
| 2667 | + /* |
2467 | 2668 | $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { |
2468 | 2669 | _this.choose( mw.UploadWizardNullDeed ); |
2469 | 2670 | _this.showDeedChoice(); |
2470 | 2671 | } ); |
| 2672 | + */ |
2471 | 2673 | |
2472 | 2674 | _this.choose( mw.UploadWizardNullDeed ); |
2473 | 2675 | _this.showDeedChoice(); |
2474 | 2676 | |
2475 | | - // set up the deed interfaces |
2476 | | - _this.deeds = { |
2477 | | - 'ownwork' : _this.setupDeedOwnWork(), |
2478 | | - 'thirdparty' : _this.setupDeedThirdParty() |
2479 | | - }; |
2480 | 2677 | |
2481 | | - _this.setQuantity(); |
2482 | 2678 | }; |
2483 | 2679 | |
2484 | 2680 | |
2485 | 2681 | mw.UploadWizardDeedChooser.prototype = { |
2486 | 2682 | |
2487 | | - isReady: function() { |
2488 | | - return ( typeof this.deed !== 'undefined' && this.deed.isReady() ); |
2489 | | - }, |
| 2683 | + /** |
| 2684 | + * How many deed choosers there are (important for creating unique ids, element names) |
| 2685 | + */ |
| 2686 | + widgetCount: 0, |
2490 | 2687 | |
2491 | | - count: 0, |
2492 | | - |
2493 | | - attach: function( upload ) { |
2494 | | - var _this = this; |
2495 | | - upload.deedChooser = _this; |
2496 | | - _this.count++; |
2497 | | - _this.setQuantity(); |
2498 | | - }, |
2499 | | - |
2500 | | - detach: function( upload ) { |
2501 | | - _this.count--; |
2502 | | - _this.setQuantity(); |
2503 | | - }, |
2504 | | - |
2505 | | - // modify various interface strings depending on singular, multiple deeds |
2506 | | - // XXX use PLURAL when possible |
2507 | | - setQuantity: function() { |
2508 | | - var _this = this; |
2509 | | - mw.log( "setting quantity of deed to " + _this.count ); |
2510 | | - $j.each( [ 'ownwork', 'thirdparty' ], function (i, key) { |
2511 | | - |
2512 | | - // fix the deed title that opens and closes |
2513 | | - $j( _this.selector ) |
2514 | | - .find( '.mwe-upwiz-macro-deed-' + key) |
2515 | | - .find( '.mwe-upwiz-deed-name' ) |
2516 | | - .html( gM( 'mwe-upwiz-source-' + key, _this.count ) ); |
2517 | | - |
2518 | | - // any other internal strings in the deed |
2519 | | - if ( _this.deeds[key] ) { |
2520 | | - _this.deeds[key].setQuantity( _this.count ); |
| 2688 | + /** |
| 2689 | + * Check if this form is filled out correctly, with side effects of showing error messages if invalid |
| 2690 | + * @return boolean; true if valid, false if not |
| 2691 | + */ |
| 2692 | + validate: function() { |
| 2693 | + var valid = (typeof this.deed === 'undefined') || this.deed.validate(); |
| 2694 | + if (!valid) { |
| 2695 | + if ( ( typeof this.deed === 'undefined' ) || this.deed === mw.UploadWizardNullDeed ) { /* highlight the main choices */ |
| 2696 | + /* this.selector.find( 'input[type=checkbox]. .mwe-/* add general select-a-deed message */ |
| 2697 | + alert( "no deed selected" ); |
2521 | 2698 | } |
2522 | | - |
2523 | | - } ); |
2524 | | - $j( _this ).trigger( 'setQuantityEvent' ); |
2525 | | - |
| 2699 | + } |
| 2700 | + return valid; |
2526 | 2701 | }, |
2527 | 2702 | |
| 2703 | + /** |
| 2704 | + * How many uploads this deed controls |
| 2705 | + */ |
| 2706 | + uploadCount: 0, |
| 2707 | + |
| 2708 | + |
2528 | 2709 | choose: function( deed ) { |
2529 | 2710 | var _this = this; |
2530 | 2711 | _this.deed = deed; |
2531 | 2712 | if ( deed === mw.UploadWizardNullDeed ) { |
2532 | 2713 | $j( _this ).trigger( 'chooseNullDeed' ); |
2533 | 2714 | //_this.trigger( 'isNotReady' ); |
2534 | | - $j( _this.selector ) |
| 2715 | + _this.$selector |
2535 | 2716 | .find( 'input.mwe-accept-deed' ) |
2536 | 2717 | .attr( 'checked', false ) |
2537 | 2718 | } else { |
— | — | @@ -2540,285 +2721,37 @@ |
2541 | 2722 | |
2542 | 2723 | /** |
2543 | 2724 | * Go back to original source choice. |
2544 | | - * Assumed that we are in details mode. |
2545 | 2725 | */ |
2546 | 2726 | showDeedChoice: function() { |
2547 | | - var _this = this; |
2548 | | - $j( _this.selector ).find( '.mwe-upwiz-deed-header.mwe-open' ).hide(); |
2549 | | - $j( _this.selector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).show(); |
2550 | | - $j( _this.selector ).find( '.mwe-upwiz-deed' ).maskSafeShow(); |
2551 | | - $j( _this.selector ).find( '.mwe-upwiz-deed-form' ).maskSafeHide(); |
2552 | | - }, |
| 2727 | + var $allDeeds = this.$selector.find( '.mwe-upwiz-deed' ); |
| 2728 | + this.deselectDeed( $allDeeds ); |
| 2729 | + // $allDeeds.fadeTo( 'fast', 1.0 ); //maskSafeShow(); |
| 2730 | + }, |
2553 | 2731 | |
2554 | | - /** |
2555 | | - * From the deed choice page, show a particular deed |
| 2732 | + /** |
| 2733 | + * From the deed choices, make a choice fade to the background a bit, hide the extended form |
2556 | 2734 | */ |
2557 | | - showDeed: function( deedSelector ) { |
2558 | | - $j( deedSelector ).find( '.mwe-upwiz-deed-header.mwe-open' ).show(); |
2559 | | - $j( deedSelector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).hide(); |
2560 | | - $j( deedSelector ).siblings().maskSafeHide(); |
2561 | | - $j( deedSelector ).find( '.mwe-upwiz-deed-form' ).maskSafeShow(); |
| 2735 | + deselectDeed: function( $deedSelector ) { |
| 2736 | + $deedSelector.removeClass( 'selected' ); |
| 2737 | + // $deedSelector.find( 'a.mwe-upwiz-macro-deeds-return' ).hide(); |
| 2738 | + $deedSelector.find( '.mwe-upwiz-deed-form' ).slideUp( 500 ); //.maskSafeHide(); |
2562 | 2739 | }, |
2563 | | - |
| 2740 | + |
2564 | 2741 | /** |
2565 | | - * Set up the form and deed object for the deed option that says these uploads are all the user's own work. |
| 2742 | + * From the deed choice page, show a particular deed |
2566 | 2743 | */ |
2567 | | - setupDeedOwnWork: function() { |
2568 | | - mw.log("setupdeed own work"); |
2569 | | - var _this = this; |
| 2744 | + showDeed: function( $deedSelector ) { |
| 2745 | + var $otherDeeds = $deedSelector.siblings().filter( '.mwe-upwiz-deed' ); |
| 2746 | + this.deselectDeed( $otherDeeds ); |
| 2747 | + // $siblings.fadeTo( 'fast', 0.5 ) // maskSafeHide(); |
2570 | 2748 | |
2571 | | - var authorInput = $j( '<input />') |
2572 | | - .attr( { name: "author" } ) |
2573 | | - .addClass( 'mwe-upwiz-sign' ); |
2574 | | - |
2575 | | - var licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
2576 | | - var licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
2577 | | - licenseInput.setDefaultValues(); |
2578 | | - |
2579 | | - var ownWorkDeed = $j.extend( new mw.UploadWizardDeed(), { |
2580 | | - |
2581 | | - licenseInput: licenseInput, |
2582 | | - |
2583 | | - isReady: function() { |
2584 | | - return ( |
2585 | | - ( $j( _this.selector ).find( '.mwe-accept-deed' ).is( ':checked' ) !== 0 ) |
2586 | | - && |
2587 | | - licenseInput.isSet() |
2588 | | - ); |
2589 | | - }, |
2590 | | - |
2591 | | - getSourceWikiText: function() { |
2592 | | - return '{{own}}'; |
2593 | | - }, |
2594 | | - |
2595 | | - getAuthorWikiText: function() { |
2596 | | - return "[[User:" + mw.getConfig('userName') + '|' + $j( authorInput ).val() + ']]'; |
2597 | | - }, |
2598 | | - |
2599 | | - |
2600 | | - getLicenseWikiText: function() { |
2601 | | - var wikiText = '{{self'; |
2602 | | - $j.each ( licenseInput.getTemplates(), function( i, template ) { |
2603 | | - wikiText += '|' + template; |
2604 | | - } ); |
2605 | | - wikiText += '}}'; |
2606 | | - return wikiText; |
2607 | | - }, |
2608 | | - |
2609 | | - createInterface: function( deedChooser ) { |
2610 | | - var _this = this; |
2611 | | - _this.deedChooser = deedChooser; |
2612 | | - |
2613 | | - var standardDiv = $j( '<div />' ) |
2614 | | - .append( |
2615 | | - $j( '<input />') |
2616 | | - .attr( { type: 'checkbox' } ) |
2617 | | - .click( function() { |
2618 | | - if ( $j( this ).is( ':checked' ) ) { |
2619 | | - $j( deedChooser.selector ) |
2620 | | - .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
2621 | | - .attr( 'checked', false ); |
2622 | | - _this.licenseInput.setDefaultValues(); |
2623 | | - deedChooser.choose( ownWorkDeed ); |
2624 | | - } else { |
2625 | | - deedChooser.choose( mw.UploadWizardNullDeed ); |
2626 | | - } |
2627 | | - } ) |
2628 | | - .addClass( 'mwe-upwiz-deed-accept-ownwork-default mwe-accept-deed mwe-checkbox-hang-indent' ), |
2629 | | - |
2630 | | - // text added in setQuantit |
2631 | | - $j( '<p class="mwe-upwiz-source-ownwork-assert mwe-checkbox-hang-indent-text"/>' ), |
2632 | | - |
2633 | | - $j( '<p />' ) |
2634 | | - .addClass( 'mwe-checkbox-hang-indent-text' ) |
2635 | | - .addClass( 'mwe-small-print' ) |
2636 | | - .html( gM ( 'mwe-upwiz-source-ownwork-assert-note' ) ) |
2637 | | - ); |
2638 | | - |
2639 | | - var toggleDiv = $j('<div />'); |
2640 | | - |
2641 | | - var customDiv = $j('<div/>') |
2642 | | - .append( |
2643 | | - $j( '<input />') |
2644 | | - .attr( { type: 'checkbox' } ) |
2645 | | - .click( function() { |
2646 | | - if ( $j( this ).is( ':checked' ) ) { |
2647 | | - $j( deedChooser.selector ) |
2648 | | - .find( '.mwe-upwiz-deed-accept-ownwork-default' ) |
2649 | | - .attr( 'checked', false ) |
2650 | | - deedChooser.choose( ownWorkDeed ); |
2651 | | - } else { |
2652 | | - deedChooser.choose( mw.UploadWizardNullDeed ); |
2653 | | - } |
2654 | | - } ) |
2655 | | - .addClass( 'mwe-upwiz-deed-accept-ownwork-custom mwe-accept-deed mwe-checkbox-hang-indent' ), |
2656 | | - $j( '<p class="mwe-upwiz-source-ownwork-assert-custom mwe-checkbox-hang-indent-text" />' ), |
2657 | | - licenseInputDiv |
2658 | | - ); |
2659 | | - |
2660 | | - $j( deedChooser.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' ) |
2661 | | - .append( $j( '<div class="mwe-upwiz-deed-form-internal" />' ) |
2662 | | - .append( standardDiv, |
2663 | | - toggleDiv, |
2664 | | - customDiv ) |
2665 | | - ); |
2666 | | - |
2667 | | - |
2668 | | - |
2669 | | - mw.UploadWizardUtil.makeFadingToggler( standardDiv, toggleDiv, customDiv ); |
2670 | | - |
2671 | | - // if they select 'fewer options', and they have selected the deed in there, we should unselect it |
2672 | | - $j( toggleDiv ).bind( 'close', function(e) { |
2673 | | - e.stopPropagation(); |
2674 | | - if ( $j( deedChooser.selector ).find( '.mwe-upwiz-deed-accept-ownwork-custom' ).is( ':checked' ) ) { |
2675 | | - $j( deedChooser.selector ) |
2676 | | - .find( '.mwe-upwiz-deed-accept-ownwork-custom' ) |
2677 | | - .attr( 'checked', false ); |
2678 | | - deedChooser.choose( mw.UploadWizardNullDeed ); |
2679 | | - } |
2680 | | - } ); |
2681 | | - |
2682 | | - _this.count = 1; |
2683 | | - _this.setQuantity(); |
2684 | | - |
2685 | | - |
2686 | | - }, |
2687 | | - |
2688 | | - |
2689 | | - setQuantity: function() { |
2690 | | - var _this = this; |
2691 | | - $j( _this.deedChooser.selector ) |
2692 | | - .find( 'p.mwe-upwiz-source-ownwork-assert' ) |
2693 | | - .html( gM( 'mwe-upwiz-source-ownwork-assert', |
2694 | | - _this.count, |
2695 | | - '<input name="author" class="mwe-upwiz-sign" />' ) |
2696 | | - ); |
2697 | | - |
2698 | | - $j( _this.deedChooser.selector ) |
2699 | | - .find( 'p.mwe-upwiz-source-ownwork-assert-custom' ) |
2700 | | - .html( gM( 'mwe-upwiz-source-ownwork-assert-custom', |
2701 | | - _this.count, |
2702 | | - '<span class="mwe-custom-author-input"></span>' ) ); |
2703 | | - |
2704 | | - // have to add the author input this way -- gM() will flatten it to a string and we'll lose it as a dom object |
2705 | | - $j( _this.deedChooser.selector ).find( '.mwe-custom-author-input' ).append( authorInput ); |
2706 | | - |
2707 | | - // synchronize both username signatures |
2708 | | - // set initial value to configured username |
2709 | | - // if one changes all the others change (keyup event) |
2710 | | - // |
2711 | | - // also set tooltips ( the title, tipsy() ) |
2712 | | - $j( _this.deedChooser.selector ).find( '.mwe-upwiz-sign' ) |
2713 | | - .attr( { |
2714 | | - title: gM( 'mwe-upwiz-tooltip-sign' ), |
2715 | | - value: mw.getConfig( 'userName' ) |
2716 | | - } ) |
2717 | | - .tipsyPlus() |
2718 | | - .keyup( function() { |
2719 | | - var thisInput = this; |
2720 | | - var thisVal = $j( thisInput ).val(); |
2721 | | - $j.each( $j( '.mwe-upwiz-sign' ), function( i, input ) { |
2722 | | - if (thisInput !== input) { |
2723 | | - $j( input ).val( thisVal ); |
2724 | | - } |
2725 | | - } ); |
2726 | | - } ); |
2727 | | - |
2728 | | - |
2729 | | - } |
2730 | | - } ); |
2731 | | - |
2732 | | - ownWorkDeed.createInterface( _this ); |
2733 | | - |
2734 | | - $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-header-link').click( |
2735 | | - function() { |
2736 | | - _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork' ) ); |
2737 | | - } |
2738 | | - ); |
2739 | | - |
2740 | | - return ownWorkDeed; |
2741 | | - |
| 2749 | + $deedSelector |
| 2750 | + .addClass('selected') |
| 2751 | + .fadeTo( 'fast', 1.0 ) |
| 2752 | + .find( '.mwe-upwiz-deed-form' ).slideDown( 500 ); // maskSafeShow(); |
| 2753 | + // $deedSelector.find( 'a.mwe-upwiz-macro-deeds-return' ).show(); |
2742 | 2754 | }, |
2743 | 2755 | |
2744 | | - setupDeedThirdParty: function() { |
2745 | | - var _this = this; |
2746 | | - var sourceInput = $j('<textarea class="mwe-source mwe-long-textarea" name="source" rows="1" cols="40"></textarea>' ) |
2747 | | - .growTextArea() |
2748 | | - .attr( 'title', gM( 'mwe-upwiz-tooltip-source' ) ) |
2749 | | - .tipsyPlus(); |
2750 | | - var authorInput = $j('<textarea class="mwe-author mwe-long-textarea" name="author" rows="1" cols="40"></textarea>' ) |
2751 | | - .growTextArea() |
2752 | | - .attr( 'title', gM( 'mwe-upwiz-tooltip-author' ) ) |
2753 | | - .tipsyPlus(); |
2754 | | - licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
2755 | | - licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
2756 | | - licenseInput.setDefaultValues(); |
2757 | | - |
2758 | | - var thirdPartyDeed = $j.extend( new mw.UploadWizardDeed(), { |
2759 | | - sourceInput: sourceInput, |
2760 | | - authorInput: authorInput, |
2761 | | - licenseInput: licenseInput, |
2762 | | - |
2763 | | - isReady: function() { |
2764 | | - return (! mw.isEmpty( $j( this.sourceInput ).val() ) ) |
2765 | | - && (! mw.isEmpty( $j( this.authorInput ).val() ) ) |
2766 | | - && this.licenseInput.isSet() |
2767 | | - }, |
2768 | | - |
2769 | | - createInterface: function( deedChooser ) { |
2770 | | - var _this = this; |
2771 | | - _this.deedChooser = deedChooser; |
2772 | | - |
2773 | | - $j( deedChooser.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ).append( |
2774 | | - $j( '<div class="mwe-upwiz-deed-form-internal"/>' ) |
2775 | | - .append( |
2776 | | - $j( '<div class="mwe-upwiz-source-thirdparty-custom-multiple-intro" />' ), |
2777 | | - $j( '<div class="mwe-upwiz-thirdparty-fields" />' ) |
2778 | | - .append( $j( '<label for="source"/>' ).text( gM( 'mwe-upwiz-source' ) ), |
2779 | | - sourceInput ), |
2780 | | - $j( '<div class="mwe-upwiz-thirdparty-fields" />' ) |
2781 | | - .append( $j( '<label for="author"/>' ).text( gM( 'mwe-upwiz-author' ) ), |
2782 | | - authorInput ), |
2783 | | - $j( '<div class="mwe-upwiz-thirdparty-license" />' ), |
2784 | | - licenseInputDiv |
2785 | | - ) |
2786 | | - ); |
2787 | | - |
2788 | | - _this.count = 1; |
2789 | | - _this.setQuantity(); |
2790 | | - |
2791 | | - }, |
2792 | | - |
2793 | | - setQuantity: function() { |
2794 | | - var _this = this; |
2795 | | - $j( _this.deedChooser.selector ) |
2796 | | - .find( 'div.mwe-upwiz-source-thirdparty-custom-multiple-intro' ) |
2797 | | - .html( _this.count > 1 ? gM( 'mwe-upwiz-source-thirdparty-custom-multiple-intro' ) : '' ); |
2798 | | - |
2799 | | - $j( _this.deedChooser.selector ) |
2800 | | - .find( 'div.mwe-upwiz-thirdparty-license' ) |
2801 | | - .text( gM( 'mwe-upwiz-source-thirdparty-license', _this.count ) ); |
2802 | | - }, |
2803 | | - |
2804 | | - showValidationTips: function() { |
2805 | | - // TBD |
2806 | | - } |
2807 | | - |
2808 | | - |
2809 | | - } ); |
2810 | | - |
2811 | | - thirdPartyDeed.createInterface( _this ); |
2812 | | - |
2813 | | - // set up the header |
2814 | | - $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-header-link').click( |
2815 | | - function() { |
2816 | | - _this.showDeed( $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty' ) ); |
2817 | | - _this.choose( thirdPartyDeed ); |
2818 | | - } |
2819 | | - ); |
2820 | | - |
2821 | | - return thirdPartyDeed; |
2822 | | - } |
2823 | 2756 | }; |
2824 | 2757 | |
2825 | 2758 | |
— | — | @@ -2976,6 +2909,7 @@ |
2977 | 2910 | }; |
2978 | 2911 | |
2979 | 2912 | |
| 2913 | + |
2980 | 2914 | /** |
2981 | 2915 | * jQuery extension. Makes a textarea automatically grow if you enter overflow |
2982 | 2916 | * (This feature was in the old Commons interface with a confusing arrow icon; it's nicer to make it automatic.) |
— | — | @@ -3091,7 +3025,6 @@ |
3092 | 3026 | return this.css( { 'height' : '0px', 'overflow' : 'hidden' } ); |
3093 | 3027 | }; |
3094 | 3028 | |
3095 | | -// XXX check overflow properties, is auto/auto not the right thing? |
3096 | 3029 | // may be causing scrollbar to appear when div changes size |
3097 | 3030 | // re-enable form fields (disabled so we did not tab through them when hidden) |
3098 | 3031 | jQuery.fn.maskSafeShow = function( options ) { |