Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js |
— | — | @@ -1058,6 +1058,15 @@ |
1059 | 1059 | .append( $j( '<div class="mwe-upwiz-details-input"></div>' ).append( _this.titleInput ) ) |
1060 | 1060 | .append( _this.titleErrorDiv ); |
1061 | 1061 | |
| 1062 | + _this.deedDiv = $j( '<div class="mwe-upwiz-custom-deed" />' ); |
| 1063 | + |
| 1064 | + _this.copyrightInfoFieldset = $j('<fieldset class="mwe-fieldset mwe-upwiz-copyright-info"></fieldset>') |
| 1065 | + .hide() |
| 1066 | + .append( |
| 1067 | + $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-copyright-info' ) ), |
| 1068 | + _this.deedDiv |
| 1069 | + ); |
| 1070 | + |
1062 | 1071 | _this.moreDetailsDiv = $j('<div class="mwe-more-details"></div>').maskSafeHide(); |
1063 | 1072 | |
1064 | 1073 | _this.moreDetailsCtrlDiv = $j( '<div class="mwe-upwiz-details-more-options"></div>' ); |
— | — | @@ -1088,26 +1097,7 @@ |
1089 | 1098 | ) |
1090 | 1099 | ); |
1091 | 1100 | |
1092 | | - var copyrightInfoFieldset = $j('<fieldset class="mwe-fieldset"></fieldset>') |
1093 | | - .append( |
1094 | | - $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-copyright-info' ) ), |
1095 | | - $j( '<div class="mwe-upwiz-copyright-info" />' ).append( |
1096 | | - $j( '<label />' ).append ( |
1097 | | - $j( '<input type="radio" name="custom-deed" value="macro" />' ), |
1098 | | - gM( 'mwe-copyright-macro' ) ), |
1099 | | - $j( '<label />' ).append ( |
1100 | | - $j( '<input type="radio" name="custom-deed" value="custom" />' ), |
1101 | | - gM( 'mwe-copyright-custom' ) ) ), |
1102 | | - $j( '<div class="mwe-upwiz-custom-deed" />' ) |
1103 | | - ); |
1104 | | - |
1105 | | - $j( copyrightInfoFieldset ).find( 'input[name="custom-deed"]' ).change( function() { |
1106 | | - var value = $j( copyrightInfoFieldset ).find( 'input[name="custom-deed"]:checked' ).val(); |
1107 | | - _this.toggleCustomDeed( value === 'custom' ); |
1108 | | - } ); |
1109 | 1101 | |
1110 | | - $j( copyrightInfoFieldset ).find( 'input[value="macro"]' ).attr( 'checked', true ); |
1111 | | - |
1112 | 1102 | |
1113 | 1103 | var aboutFileFieldset = $j('<fieldset class="mwe-fieldset"></fieldset>') |
1114 | 1104 | .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-about-format' ) ) ) |
— | — | @@ -1129,16 +1119,16 @@ |
1130 | 1120 | .append( $j( _this.dataDiv ) |
1131 | 1121 | .append( _this.descriptionsContainerDiv ) |
1132 | 1122 | .append( _this.titleContainerDiv ) |
| 1123 | + .append( _this.copyrightInfoFieldset ) |
1133 | 1124 | .append( _this.moreDetailsCtrlDiv ) |
1134 | 1125 | .append( $j( _this.moreDetailsDiv ) |
1135 | 1126 | .append( aboutThisWorkFieldset ) |
1136 | | - .append( copyrightInfoFieldset ) |
1137 | | - .append( aboutFileFieldset ) |
| 1127 | + //.append( aboutFileFieldset ) |
1138 | 1128 | .append( otherInformationDiv ) |
1139 | 1129 | ) |
1140 | 1130 | ); |
1141 | 1131 | |
1142 | | - mw.UploadWizardUtil.makeMoreToggler( _this.moreDetailsCtrlDiv, _this.moreDetailsDiv); |
| 1132 | + mw.UploadWizardUtil.makeMoreToggler( _this.moreDetailsCtrlDiv, _this.moreDetailsDiv ); |
1143 | 1133 | |
1144 | 1134 | _this.addDescription(); |
1145 | 1135 | $j( containerDiv ).append( _this.div ); |
— | — | @@ -1151,19 +1141,20 @@ |
1152 | 1142 | /** |
1153 | 1143 | * toggles whether we use the 'macro' deed or our own |
1154 | 1144 | */ |
1155 | | - toggleCustomDeed: function( isUsingCustomDeed ) { |
| 1145 | + useCustomDeedChooser: function() { |
1156 | 1146 | var _this = this; |
1157 | | - var deedDiv = $j( _this.div ).find( '.mwe-upwiz-custom-deed' ); |
1158 | | - if ( isUsingCustomDeed ) { |
1159 | | - _this.upload.wizardDeedChooser = _this.upload.deedChooser; |
1160 | | - _this.upload.deedChooser = new mw.UploadWizardDeedChooser( deedDiv ); |
1161 | | - } else { |
1162 | | - _this.upload.deedChooser = _this.upload.wizardDeedChooser; |
1163 | | - deedDiv.empty(); |
1164 | | - } |
| 1147 | + _this.copyrightInfoFieldset.show(); |
| 1148 | + _this.upload.wizardDeedChooser = _this.upload.deedChooser; |
| 1149 | + _this.upload.deedChooser = new mw.UploadWizardDeedChooser( _this.deedDiv ); |
1165 | 1150 | }, |
1166 | 1151 | |
| 1152 | + useDeedChooser: function( deedChooser ) { |
| 1153 | + var _this = this; |
| 1154 | + _this.upload.deedChooser = deedChooser; |
| 1155 | + _this.deedDiv.empty(); |
| 1156 | + }, |
1167 | 1157 | |
| 1158 | + |
1168 | 1159 | /** |
1169 | 1160 | * Sets the filename from the title plus this upload's extension. |
1170 | 1161 | */ |
— | — | @@ -1860,7 +1851,7 @@ |
1861 | 1852 | + '<div id="mwe-upwiz-progress" class="ui-helper-clearfix"></div>' |
1862 | 1853 | + '</div>' |
1863 | 1854 | + '<div class="mwe-upwiz-buttons"/>' |
1864 | | - + '<button class="mwe-upwiz-button-next" disabled="true" />' |
| 1855 | + + '<button class="mwe-upwiz-button-next" />' |
1865 | 1856 | + '</div>' |
1866 | 1857 | + '</div>' |
1867 | 1858 | |
— | — | @@ -1870,7 +1861,7 @@ |
1871 | 1862 | + '<div id="mwe-upwiz-deeds" class="ui-helper-clearfix"></div>' |
1872 | 1863 | + '<div id="mwe-upwiz-deeds-custom" class="ui-helper-clearfix"></div>' |
1873 | 1864 | + '<div class="mwe-upwiz-buttons"/>' |
1874 | | - + '<button class="mwe-upwiz-button-next" disabled="true" />' |
| 1865 | + + '<button class="mwe-upwiz-button-next" />' |
1875 | 1866 | + '</div>' |
1876 | 1867 | + '</div>' |
1877 | 1868 | |
— | — | @@ -1883,7 +1874,7 @@ |
1884 | 1875 | + '<div id="mwe-upwiz-macro-files"></div>' |
1885 | 1876 | + '</div>' |
1886 | 1877 | + '<div class="mwe-upwiz-buttons"/>' |
1887 | | - + '<button class="mwe-upwiz-button-next" disabled="true" />' |
| 1878 | + + '<button class="mwe-upwiz-button-next" />' |
1888 | 1879 | + '</div>' |
1889 | 1880 | + '</div>' |
1890 | 1881 | |
— | — | @@ -1925,7 +1916,8 @@ |
1926 | 1917 | } ); |
1927 | 1918 | |
1928 | 1919 | $j( '#mwe-upwiz-deeds-custom' ).append( |
1929 | | - $j( '<div id="mwe-upwiz-deeds-later" style="hidden"/>' ) |
| 1920 | + $j( '<div id="mwe-upwiz-deeds-later" />' ) |
| 1921 | + .hide() |
1930 | 1922 | .append( $j( '<label>' ) |
1931 | 1923 | .append( |
1932 | 1924 | $j( '<input />') |
— | — | @@ -1935,6 +1927,7 @@ |
1936 | 1928 | if ( $j( this ).is( ':checked' ) ) { |
1937 | 1929 | _this.deedChooser.showDeedChoice(); |
1938 | 1930 | _this.deedChooser.choose( customDeed ); |
| 1931 | + _this.deedChooser.trigger( 'isReady' ); |
1939 | 1932 | } else { |
1940 | 1933 | _this.deedChooser.choose( mw.UploadWizardNullDeed ); |
1941 | 1934 | } |
— | — | @@ -1944,8 +1937,9 @@ |
1945 | 1938 | ) |
1946 | 1939 | ); |
1947 | 1940 | |
1948 | | - $j( _this.deedChooser ).bind( 'setQuantity', function() { |
1949 | | - if ( _this.count > 1 ) { |
| 1941 | + $j( _this.deedChooser ).bind( 'setQuantityEvent', function() { |
| 1942 | + mw.log( "checking this deedchooser count " + _this.deedChooser.count ); |
| 1943 | + if ( _this.deedChooser.count > 1 ) { |
1950 | 1944 | $j( '#mwe-upwiz-deeds-later' ).show(); |
1951 | 1945 | } else { |
1952 | 1946 | $j( '#mwe-upwiz-deeds-later' ).hide(); |
— | — | @@ -1958,24 +1952,40 @@ |
1959 | 1953 | _this.moveToStep('details'); |
1960 | 1954 | } ); |
1961 | 1955 | |
| 1956 | + // XXX perhaps we should defer this until we click next |
1962 | 1957 | $j( _this.deedChooser ).bind( 'chooseDeed', function() { |
1963 | | - $j( '#mwe-upwiz-stepdiv-deeds' ).enableNextButton(); |
1964 | 1958 | var isCustom = ( _this.deedChooser.deed === customDeed ); |
1965 | 1959 | $j.each( _this.uploads, function( i, upload ) { |
1966 | | - upload.details.toggleCustomDeed( isCustom ); |
| 1960 | + if (isCustom) { |
| 1961 | + upload.details.useCustomDeedChooser(); |
| 1962 | + } else { |
| 1963 | + upload.details.useDeedChooser( _this.deedChooser ); |
| 1964 | + } |
1967 | 1965 | } ); |
1968 | 1966 | } ); |
1969 | 1967 | |
| 1968 | + // XXX perhaps we should defer this until we click next |
1970 | 1969 | $j( _this.deedChooser ).bind( 'chooseNullDeed', function() { |
1971 | | - $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
1972 | 1970 | $j.each( _this.uploads, function( i, upload ) { |
1973 | | - upload.details.toggleCustomDeed( false ); |
| 1971 | + upload.details.deedChooser = _this.deedChooser; |
1974 | 1972 | } ); |
| 1973 | + // $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
1975 | 1974 | } ); |
1976 | 1975 | |
| 1976 | + /* |
| 1977 | + // XXX figure out some way to make them ready / unready |
| 1978 | + // timeout after input, check for readiness, then trigger event? |
| 1979 | + $j( _this.deedChooser ).bind( 'isReady', function() { |
| 1980 | + $j( '#mwe-upwiz-stepdiv-deeds' ).enableNextButton(); |
| 1981 | + } ); |
1977 | 1982 | |
| 1983 | + $j( _this.deedChooser ).bind( 'isNotReady', function() { |
| 1984 | + $j( '#mwe-upwiz-stepdiv-deeds' ).disableNextButton(); |
| 1985 | + } ); |
| 1986 | +*/ |
| 1987 | + |
1978 | 1988 | // DETAILS div |
1979 | | - $j( '#mwe-upwiz-stepdiv-details' ).click( function() { |
| 1989 | + $j( '#mwe-upwiz-stepdiv-details .mwe-upwiz-button-next' ).click( function() { |
1980 | 1990 | _this.detailsSubmit( function() { |
1981 | 1991 | _this.prefillThanksPage(); |
1982 | 1992 | _this.moveToStep('thanks'); |
— | — | @@ -2461,7 +2471,7 @@ |
2462 | 2472 | 'thirdparty' : _this.setupDeedThirdParty() |
2463 | 2473 | }; |
2464 | 2474 | |
2465 | | - _this.setQuantity(1); |
| 2475 | + _this.setQuantity(); |
2466 | 2476 | }; |
2467 | 2477 | |
2468 | 2478 | |
— | — | @@ -2501,6 +2511,7 @@ |
2502 | 2512 | } |
2503 | 2513 | |
2504 | 2514 | } ); |
| 2515 | + $j( _this ).trigger( 'setQuantityEvent' ); |
2505 | 2516 | |
2506 | 2517 | }, |
2507 | 2518 | |
— | — | @@ -2509,6 +2520,7 @@ |
2510 | 2521 | _this.deed = deed; |
2511 | 2522 | if ( deed === mw.UploadWizardNullDeed ) { |
2512 | 2523 | $j( _this ).trigger( 'chooseNullDeed' ); |
| 2524 | + //_this.trigger( 'isNotReady' ); |
2513 | 2525 | $j( _this.selector ) |
2514 | 2526 | .find( 'input.mwe-accept-deed' ) |
2515 | 2527 | .attr( 'checked', false ) |
— | — | @@ -3086,7 +3098,8 @@ |
3087 | 3099 | $j.fn.notify = function ( message ) { |
3088 | 3100 | // could do something here with Chrome's in-browser growl-like notifications. |
3089 | 3101 | // play a sound? |
3090 | | - alert( message ); |
| 3102 | + // if the current tab does not have focus, use an alert? |
| 3103 | + // alert( message ); |
3091 | 3104 | }; |
3092 | 3105 | |
3093 | 3106 | $j.fn.enableNextButton = function() { |