Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -219,6 +219,7 @@ |
220 | 220 | 'mwe-upwiz-location', |
221 | 221 | 'mwe-upwiz-location-lat', |
222 | 222 | 'mwe-upwiz-location-lon', |
| 223 | + 'mwe-upwiz-location-alt', |
223 | 224 | 'mwe-upwiz-copyright-info', |
224 | 225 | 'mwe-upwiz-author', |
225 | 226 | 'mwe-upwiz-autoconverted', |
— | — | @@ -273,6 +274,9 @@ |
274 | 275 | 'mwe-upwiz-license-show-all', |
275 | 276 | 'mwe-upwiz-license-show-recommended', |
276 | 277 | 'mwe-upwiz-error-signature-blank', |
| 278 | + 'mwe-upwiz-error-latitude', |
| 279 | + 'mwe-upwiz-error-longitude', |
| 280 | + 'mwe-upwiz-error-altitude', |
277 | 281 | 'mwe-upwiz-error-signature-too-long', |
278 | 282 | 'mwe-upwiz-error-signature-too-short', |
279 | 283 | 'mwe-upwiz-error-signature-bad-chars', |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -125,6 +125,7 @@ |
126 | 126 | 'mwe-upwiz-location' => 'Location', |
127 | 127 | 'mwe-upwiz-location-lat' => 'Latitude', |
128 | 128 | 'mwe-upwiz-location-lon' => 'Longitude', |
| 129 | + 'mwe-upwiz-location-alt' => 'Altitude', |
129 | 130 | 'mwe-upwiz-copyright-info' => 'Release rights', |
130 | 131 | 'mwe-upwiz-author' => 'Author(s)', |
131 | 132 | 'mwe-upwiz-autoconverted' => 'This file was automatically converted to the $1 format', |
— | — | @@ -182,6 +183,9 @@ |
183 | 184 | 'mwe-upwiz-license-show-all' => 'Use a different license', |
184 | 185 | 'mwe-upwiz-license-show-recommended' => 'Use the recommended license', |
185 | 186 | 'mwe-upwiz-error-signature-blank' => 'You must sign the field below with your username or real name.', |
| 187 | + 'mwe-upwiz-error-latitude' => 'The latitude needs to be between -90 and 90.', |
| 188 | + 'mwe-upwiz-error-longitude' => 'The longitude needs to be between -180 and 180.', |
| 189 | + 'mwe-upwiz-error-altitude' => 'The altitude needs to be a number.', |
186 | 190 | 'mwe-upwiz-error-signature-too-long' => 'Your signature is too long. |
187 | 191 | Make it shorter than $1 {{PLURAL:$1|character|characters}}.', |
188 | 192 | 'mwe-upwiz-error-signature-too-short' => 'Your signature is too short. |
Index: trunk/extensions/UploadWizard/resources/uploadWizard.css |
— | — | @@ -712,5 +712,10 @@ |
713 | 713 | } |
714 | 714 | |
715 | 715 | .mwe-location-lon { |
| 716 | + float:left; |
716 | 717 | font-style:italic; |
717 | 718 | } |
| 719 | + |
| 720 | +.mwe-location-alt { |
| 721 | + font-style:italic; |
| 722 | +} |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -161,8 +161,11 @@ |
162 | 162 | |
163 | 163 | var latId = "location-latitude" + _this.upload.index; |
164 | 164 | var lonId = "location-longitude" + _this.upload.index; |
165 | | - _this.latInput = $j( '<input type="text" id="' + latId + '" name="' + latId + '" type="text" class="mwe-loc-lat" size="10"/>' ); |
166 | | - _this.lonInput = $j( '<input type="text" id="' + lonId + '" name="' + lonId + '" type="text" class="mwe-loc-lon" size="10"/>' ); |
| 165 | + var altId = "location-altitude" + _this.upload.index; |
| 166 | + |
| 167 | + _this.latInput = $j( '<input type="text" id="' + latId + '" name="' + latId + '" class="mwe-loc-lat" size="10"/>' ); |
| 168 | + _this.lonInput = $j( '<input type="text" id="' + lonId + '" name="' + lonId + '" class="mwe-loc-lon" size="10"/>' ); |
| 169 | + _this.altInput = $j( '<input type="text" id="' + altId + '" name="' + altId + '" class="mwe-loc-alt" size="10"/>' ); |
167 | 170 | |
168 | 171 | var latDiv = $j( '<div class="mwe-location-lat"></div>' ) |
169 | 172 | .append( $j ( '<div class="mwe-location-lat-label"></div>' ).append( gM( 'mwe-upwiz-location-lat' ) ) ) |
— | — | @@ -170,13 +173,20 @@ |
171 | 174 | var lonDiv = $j( '<div class="mwe-location-lon"></div>' ) |
172 | 175 | .append( $j ( '<div class="mwe-location-lon-label"></div>' ).append( gM( 'mwe-upwiz-location-lon' ) ) ) |
173 | 176 | .append( _this.lonInput ); |
| 177 | + var altDiv = $j( '<div class="mwe-location-alt"></div>' ) |
| 178 | + .append( $j ( '<div class="mwe-location-alt-label"></div>' ).append( gM( 'mwe-upwiz-location-alt' ) ) ) |
| 179 | + .append( _this.altInput ); |
174 | 180 | |
175 | 181 | var locationDiv = $j( '<div class="mwe-location"></div>' ) |
176 | 182 | .append( $j ('<div class="mwe-location-label"></div>' ) |
177 | 183 | .append( gM( 'mwe-upwiz-location' ) ) |
178 | 184 | .addHint( 'location' ) ) |
179 | | - .append( latDiv ) |
180 | | - .append( lonDiv ); |
| 185 | + .append( |
| 186 | + $j( '<div class="mwe-upwiz-details-input-error"><label class="mwe-validator-error" for="' + latId + '" generated="true"/></div>' ), |
| 187 | + $j( '<div class="mwe-upwiz-details-input-error"><label class="mwe-validator-error" for="' + lonId + '" generated="true"/></div>' ), |
| 188 | + $j( '<div class="mwe-upwiz-details-input-error"><label class="mwe-validator-error" for="' + altId + '" generated="true"/></div>' ), |
| 189 | + latDiv, lonDiv, altDiv |
| 190 | + ); |
181 | 191 | |
182 | 192 | $j( moreDetailsDiv ).append( |
183 | 193 | locationDiv, |
— | — | @@ -287,6 +297,31 @@ |
288 | 298 | } |
289 | 299 | } ); |
290 | 300 | } |
| 301 | + |
| 302 | + _this.latInput.rules( "add", { |
| 303 | + min: -90, |
| 304 | + max: 90, |
| 305 | + messages: { |
| 306 | + min: gM( 'mwe-upwiz-error-latitude' ), |
| 307 | + max: gM( 'mwe-upwiz-error-latitude' ) |
| 308 | + } |
| 309 | + } ); |
| 310 | + |
| 311 | + _this.lonInput.rules( "add", { |
| 312 | + min: -180, |
| 313 | + max: 180, |
| 314 | + messages: { |
| 315 | + min: gM( 'mwe-upwiz-error-longitude' ), |
| 316 | + max: gM( 'mwe-upwiz-error-longitude' ) |
| 317 | + } |
| 318 | + } ); |
| 319 | + |
| 320 | + _this.altInput.rules( "add", { |
| 321 | + number: true, |
| 322 | + messages: { |
| 323 | + number: gM( 'mwe-upwiz-error-altitude' ), |
| 324 | + } |
| 325 | + } ); |
291 | 326 | |
292 | 327 | mw.UploadWizardUtil.makeToggler( moreDetailsCtrlDiv, moreDetailsDiv ); |
293 | 328 | |
— | — | @@ -634,10 +669,20 @@ |
635 | 670 | * Leaving out altitude ref for now (for no good reason). |
636 | 671 | */ |
637 | 672 | prefillLocation: function() { |
638 | | - _this = this; |
| 673 | + var _this = this; |
| 674 | + |
639 | 675 | if ( _this.upload.imageinfo.metadata ) { |
640 | | - $j( _this.latInput ).val( _this.upload.imageinfo.metadata['gpslatitude'] ); |
641 | | - $j( _this.lonInput ).val( _this.upload.imageinfo.metadata['gpslongitude'] ); |
| 676 | + var m = _this.upload.imageinfo.metadata; |
| 677 | + |
| 678 | + if ( mw.isDefined( m['gpslatitude'] ) ) { |
| 679 | + $j( _this.latInput ).val( m['gpslatitude'] ); |
| 680 | + } |
| 681 | + if ( mw.isDefined( m['gpslongitude'] ) ) { |
| 682 | + $j( _this.lonInput ).val( m['gpslongitude'] ); |
| 683 | + } |
| 684 | + if ( mw.isDefined( m['gpsaltitude'] ) ) { |
| 685 | + $j( _this.altInput ).val( m['gpsaltitude'] ); |
| 686 | + } |
642 | 687 | } |
643 | 688 | }, |
644 | 689 | |
— | — | @@ -775,10 +820,16 @@ |
776 | 821 | } |
777 | 822 | |
778 | 823 | wikiText += "=={{int:filedesc}}==\n"; |
| 824 | + |
779 | 825 | var lat = $j.trim( $j( _this.latInput ).val() ); |
780 | 826 | var lon = $j.trim( $j( _this.lonInput ).val() ); |
781 | | - if( lat ){ //only add the tag if the data exists; assume that if lat exists, long will as well |
782 | | - wikiText += '{{Location dec|'+ lat + '|' + lon + '}}\n'; |
| 827 | + var alt = $j.trim( $j( _this.altInput ).val() ); |
| 828 | + |
| 829 | + // Do not require the altitude to be set, to prevent people from entering 0 |
| 830 | + // while it's actually unknown. |
| 831 | + // When none is provided, this will result in {{Location dec|int|int|}}. |
| 832 | + if( lat !== '' && lon !== '' ) { |
| 833 | + wikiText += '{{Location dec|'+ lat + '|' + lon + '|' + alt + '}}\n'; |
783 | 834 | } |
784 | 835 | |
785 | 836 | wikiText += '{{Information\n' + info + '}}\n\n'; |