r90309 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90308‎ | r90309 | r90310 >
Date:19:15, 17 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed display of geocoding field for openlayers input when no geonames service available and fixed keypress cancelation issue causing form submission when it should not
Modified paths:
  • /trunk/extensions/SemanticMaps/includes/forminputs/jquery.mapforminput.js (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/services/OpenLayers/jquery.openlayersinput.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/services/OpenLayers/jquery.openlayersinput.js
@@ -60,30 +60,32 @@
6161 this.projectAndShowLocation( new OpenLayers.LonLat( coordinate.lon, coordinate.lat ), '' );
6262 };
6363
64 - this.geocodeAddress = function( address ) {
65 - $.getJSON(
66 - 'http://api.geonames.org/searchJSON?callback=?',
67 - {
68 - 'q': address,
69 - 'username': options.geonamesusername,
70 - //'formatted': 'true',
71 - 'maxRows': 1
72 - },
73 - function( data ) {
74 - if ( data.totalResultsCount ) {
75 - if ( data.totalResultsCount > 0 ) {
76 - self.projectAndShowLocation( new OpenLayers.LonLat( data.geonames[0].lng, data.geonames[0].lat ), address );
 64+ if ( options.geonamesusername != '' ) {
 65+ this.geocodeAddress = function( address ) {
 66+ $.getJSON(
 67+ 'http://api.geonames.org/searchJSON?callback=?',
 68+ {
 69+ 'q': address,
 70+ 'username': options.geonamesusername,
 71+ //'formatted': 'true',
 72+ 'maxRows': 1
 73+ },
 74+ function( data ) {
 75+ if ( data.totalResultsCount ) {
 76+ if ( data.totalResultsCount > 0 ) {
 77+ self.projectAndShowLocation( new OpenLayers.LonLat( data.geonames[0].lng, data.geonames[0].lat ), address );
 78+ }
 79+ else {
 80+ // TODO: notify no result
 81+ }
7782 }
7883 else {
79 - // TODO: notify no result
 84+ // TODO: error
8085 }
8186 }
82 - else {
83 - // TODO: error
84 - }
85 - }
86 - );
87 - };
 87+ );
 88+ };
 89+ }
8890
8991 this.mapforminput( mapDivId, options );
9092
Index: trunk/extensions/SemanticMaps/includes/forminputs/jquery.mapforminput.js
@@ -69,6 +69,7 @@
7070
7171 this.input.keypress( function( event ) {
7272 if ( event.which == '13' ) {
 73+ event.preventDefault();
7374 updateButton.click();
7475 }
7576 } );
@@ -104,6 +105,7 @@
105106
106107 this.geofield.keypress( function( event ) {
107108 if ( event.which == '13' ) {
 109+ event.preventDefault();
108110 geoButton.click();
109111 }
110112 } );