Index: trunk/extensions/UploadWizard/styles/uploadWizard.css |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | |
281 | 281 | /* XXX add spinner gif instead, maybe */ |
282 | 282 | .busy { |
283 | | - background: yellow; |
| 283 | + /* background: yellow; */ |
284 | 284 | } |
285 | 285 | |
286 | 286 | .mwe-upwiz-stepdiv { |
— | — | @@ -361,6 +361,11 @@ |
362 | 362 | float: left; |
363 | 363 | } |
364 | 364 | |
| 365 | +.mwe-upwiz-details-input.mwe-error { |
| 366 | + float: none; |
| 367 | + margin-left: 9em; |
| 368 | +} |
| 369 | + |
365 | 370 | .mwe-upwiz-desc-lang-select { |
366 | 371 | width: 130px; |
367 | 372 | font-family: sans-serif; |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | 'mwe-upwiz-ok' => 'OK', |
91 | 91 | 'mwe-upwiz-cancel' => 'Cancel', |
92 | 92 | 'mwe-upwiz-change' => '(change)', |
| 93 | + 'mwe-upwiz-fileexists-replace' => 'A file with the title "$1" exists already. Please change your title to something unique.', |
93 | 94 | 'mwe-upwiz-fileexists' => 'A file with this name exists already. |
94 | 95 | Please check <b><tt>$1</tt></b> if you are not sure if you want to replace it.', |
95 | 96 | 'mwe-upwiz-thumbnail-more' => 'Enlarge', |
Index: trunk/extensions/UploadWizard/js/mw.UploadWizard.js |
— | — | @@ -1079,15 +1079,16 @@ |
1080 | 1080 | spinner: function(bool) { _this.toggleDestinationBusy(bool); }, |
1081 | 1081 | preprocess: function( name ) { return _this.getFilenameFromTitle(); }, // XXX this is no longer a pre-process |
1082 | 1082 | processResult: function( result ) { _this.processDestinationCheck( result ); } |
1083 | | - } ) |
1084 | | - ; |
| 1083 | + } ); |
1085 | 1084 | |
1086 | | - _this.titleErrorDiv = $j('<div></div>'); |
| 1085 | + _this.titleErrorDiv = $j('<div class="mwe-upwiz-details-input mwe-error"></div>'); |
1087 | 1086 | |
1088 | 1087 | _this.titleContainerDiv = $j('<div class="mwe-upwiz-details-label-input ui-helper-clearfix"></div>') |
1089 | | - .append( $j( '<div class="mwe-upwiz-details-label"></div>' ).append( gM( 'mwe-upwiz-title' ) ) ) |
1090 | | - .append( $j( '<div class="mwe-upwiz-details-input"></div>' ).append( _this.titleInput ) ) |
1091 | | - .append( _this.titleErrorDiv ); |
| 1088 | + .append( |
| 1089 | + _this.titleErrorDiv, |
| 1090 | + $j( '<div class="mwe-upwiz-details-label"></div>' ).append( gM( 'mwe-upwiz-title' ) ), |
| 1091 | + $j( '<div class="mwe-upwiz-details-input"></div>' ).append( _this.titleInput ) |
| 1092 | + ) |
1092 | 1093 | |
1093 | 1094 | _this.deedDiv = $j( '<div class="mwe-upwiz-custom-deed" />' ); |
1094 | 1095 | |
— | — | @@ -1154,6 +1155,38 @@ |
1155 | 1156 | mw.UploadWizardDetails.prototype = { |
1156 | 1157 | |
1157 | 1158 | /** |
| 1159 | + * check entire form for validity |
| 1160 | + */ |
| 1161 | + // return boolean if we are ready to go. |
| 1162 | + // side effect: add error text to the page for fields in an incorrect state. |
| 1163 | + valid: function() { |
| 1164 | + var _this = this; |
| 1165 | + // at least one description -- never mind, we are disallowing removal of first description |
| 1166 | + // all the descriptions -- check min & max length |
| 1167 | + |
| 1168 | + // the title |
| 1169 | + var titleInputValid = $j( _this.titleInput ).data( 'valid' ); |
| 1170 | + if ( typeof titleInputValid == 'undefined' ) { |
| 1171 | + alert( "please wait, still checking the title for uniqueness..." ); |
| 1172 | + return false; |
| 1173 | + } |
| 1174 | + |
| 1175 | + return titleInputValid; |
| 1176 | + |
| 1177 | + // length restrictions |
| 1178 | + // not already taken |
| 1179 | + |
| 1180 | + // the license, if any |
| 1181 | + |
| 1182 | + // pop open the 'more-options' if the date is bad |
| 1183 | + // the date |
| 1184 | + // other information |
| 1185 | + // no validation required |
| 1186 | + }, |
| 1187 | + |
| 1188 | + |
| 1189 | + |
| 1190 | + /** |
1158 | 1191 | * toggles whether we use the 'macro' deed or our own |
1159 | 1192 | */ |
1160 | 1193 | useCustomDeedChooser: function() { |
— | — | @@ -1196,6 +1229,7 @@ |
1197 | 1230 | var _this = this; |
1198 | 1231 | if (busy) { |
1199 | 1232 | _this.titleInput.addClass( "busy" ); |
| 1233 | + $j( _this.titleInput ).data( 'valid', undefined ); |
1200 | 1234 | } else { |
1201 | 1235 | _this.titleInput.removeClass( "busy" ); |
1202 | 1236 | } |
— | — | @@ -1212,18 +1246,24 @@ |
1213 | 1247 | var _this = this; |
1214 | 1248 | |
1215 | 1249 | if ( result.isUnique ) { |
| 1250 | + $j( _this.titleInput ).data( 'valid', true ); |
1216 | 1251 | _this.titleErrorDiv.hide().empty(); |
1217 | 1252 | _this.ignoreWarningsInput = undefined; |
1218 | 1253 | return; |
1219 | 1254 | } |
1220 | 1255 | |
| 1256 | + $j( _this.titleInput ).data( 'valid', false ); |
| 1257 | + |
1221 | 1258 | // result is NOT unique |
1222 | 1259 | var title = result.title; |
1223 | 1260 | var img = result.img; |
1224 | 1261 | var href = result.href; |
1225 | 1262 | |
| 1263 | + _this.titleErrorDiv.html( gM( 'mwe-upwiz-fileexists-replace', result.title ) ).show(); |
| 1264 | + |
| 1265 | + /* temporarily commenting out the full thumbnail etc. thing. For now, we just want the user to change |
| 1266 | + to a different name |
1226 | 1267 | _this.ignoreWarningsInput = $j("<input />").attr( { type: 'checkbox', name: 'ignorewarnings' } ); |
1227 | | - |
1228 | 1268 | var $fileAlreadyExists = $j('<div />') |
1229 | 1269 | .append( |
1230 | 1270 | gM( 'mwe-upwiz-fileexists', |
— | — | @@ -1296,7 +1336,9 @@ |
1297 | 1337 | ) |
1298 | 1338 | ) |
1299 | 1339 | ).show(); |
| 1340 | + */ |
1300 | 1341 | |
| 1342 | + |
1301 | 1343 | }, |
1302 | 1344 | |
1303 | 1345 | /** |
— | — | @@ -1617,8 +1659,7 @@ |
1618 | 1660 | |
1619 | 1661 | /** |
1620 | 1662 | * Check if we are ready to post wikitext |
1621 | | - */ |
1622 | | - valid: function() { |
| 1663 | + deedValid: function() { |
1623 | 1664 | var _this = this; |
1624 | 1665 | return _this.upload.deedChooser.deed.valid(); |
1625 | 1666 | |
— | — | @@ -1626,6 +1667,7 @@ |
1627 | 1668 | // where we can then check on |
1628 | 1669 | // perhaps as simple as _this.issues or _this.agenda |
1629 | 1670 | }, |
| 1671 | + */ |
1630 | 1672 | |
1631 | 1673 | /** |
1632 | 1674 | * Post wikitext as edited here, to the file |
— | — | @@ -2014,9 +2056,11 @@ |
2015 | 2057 | if ( i < lastUploadIndex ) { |
2016 | 2058 | upload.details.div.css( 'border-bottom', '1px solid #e0e0e0' ); |
2017 | 2059 | } |
| 2060 | + |
| 2061 | + upload.details.titleInput.checkUnique(); |
2018 | 2062 | } ); |
2019 | 2063 | |
2020 | | - _this.moveToStep('details'); |
| 2064 | + _this.moveToStep( 'details' ); |
2021 | 2065 | } |
2022 | 2066 | } ); |
2023 | 2067 | |
— | — | @@ -2026,10 +2070,12 @@ |
2027 | 2071 | $j( '#mwe-upwiz-stepdiv-details .mwe-upwiz-button-next' ) |
2028 | 2072 | .append( gM( 'mwe-upwiz-next-details' ) ) |
2029 | 2073 | .click( function() { |
2030 | | - _this.detailsSubmit( function() { |
2031 | | - _this.prefillThanksPage(); |
2032 | | - _this.moveToStep('thanks'); |
2033 | | - } ); |
| 2074 | + if ( _this.detailsValid() ) { |
| 2075 | + _this.detailsSubmit( function() { |
| 2076 | + _this.prefillThanksPage(); |
| 2077 | + _this.moveToStep( 'thanks' ); |
| 2078 | + } ); |
| 2079 | + } |
2034 | 2080 | } ); |
2035 | 2081 | |
2036 | 2082 | |
— | — | @@ -2316,7 +2362,21 @@ |
2317 | 2363 | |
2318 | 2364 | }, |
2319 | 2365 | |
| 2366 | + |
2320 | 2367 | /** |
| 2368 | + * are all the details valid? |
| 2369 | + * @return boolean |
| 2370 | + */ |
| 2371 | + detailsValid: function() { |
| 2372 | + var _this = this; |
| 2373 | + var valid = true; |
| 2374 | + $j.each( _this.uploads, function(i, upload) { |
| 2375 | + valid &= upload.details.valid(); |
| 2376 | + } ); |
| 2377 | + return valid; |
| 2378 | + }, |
| 2379 | + |
| 2380 | + /** |
2321 | 2381 | * Submit all edited details and other metadata |
2322 | 2382 | * Works just like startUploads -- parallel simultaneous submits with progress bar. |
2323 | 2383 | */ |
— | — | @@ -2917,7 +2977,7 @@ |
2918 | 2978 | * @return typical title as would appear on MediaWiki |
2919 | 2979 | */ |
2920 | 2980 | pathToTitle: function ( filename ) { |
2921 | | - return mw.ucfirst( filename.replace(/ /g, '_' ) ); |
| 2981 | + return mw.ucfirst( $j.trim( filename ).replace(/ /g, '_' ) ); |
2922 | 2982 | }, |
2923 | 2983 | |
2924 | 2984 | /** |
— | — | @@ -2926,7 +2986,7 @@ |
2927 | 2987 | * @return plausible local filename, with spaces changed to underscores. |
2928 | 2988 | */ |
2929 | 2989 | titleToPath: function ( title ) { |
2930 | | - return mw.ucfirst( title.replace(/_/g, ' ' ) ); |
| 2990 | + return mw.ucfirst( $j.trim( title ).replace(/_/g, ' ' ) ); |
2931 | 2991 | }, |
2932 | 2992 | |
2933 | 2993 | /** |
Index: trunk/extensions/UploadWizard/js/mw.DestinationChecker.js |
— | — | @@ -188,6 +188,7 @@ |
189 | 189 | _this.cachedResult[name] = result; |
190 | 190 | _this.processResult( result ); |
191 | 191 | } |
| 192 | + |
192 | 193 | } ); |
193 | 194 | } |
194 | 195 | |
— | — | @@ -201,7 +202,9 @@ |
202 | 203 | $.fn.destinationChecked = function( options ) { |
203 | 204 | var _this = this; |
204 | 205 | options.selector = _this; |
205 | | - new mw.DestinationChecker( options ); |
| 206 | + var checker = new mw.DestinationChecker( options ); |
| 207 | + // this should really be done with triggers |
| 208 | + _this.checkUnique = function() { checker.checkUnique(); }; |
206 | 209 | return _this; |
207 | 210 | }; |
208 | 211 | } )( jQuery ); |