r84053 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84052‎ | r84053 | r84054 >
Date:20:29, 15 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added click handler for googlemaps3 input
Modified paths:
  • /branches/SemanticMaps0.8/includes/forminputs/jquery.mapforminput.js (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/OpenLayers/jquery.openlayersinput.js (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js
@@ -29,6 +29,13 @@
3030
3131 this.mapDiv.googlemaps( options );
3232
 33+ google.maps.event.addListener( this.mapDiv.map, 'click', function( event ) {
 34+ var location = { lat: event.latLng.lat(), lon: event.latLng.lng() };
 35+ self.mapDiv.map.panTo( event.latLng );
 36+ self.showCoordinate( location );
 37+ self.input.attr( 'value', semanticMaps.buildInputValue( [ location ] ) );
 38+ } );
 39+
3340 return this;
3441
3542 }; })( jQuery );
\ No newline at end of file
Index: branches/SemanticMaps0.8/includes/services/OpenLayers/jquery.openlayersinput.js
@@ -48,7 +48,7 @@
4949
5050 self.mapDiv.map.panTo( location );
5151
52 - $( '#' + mapDivId + '_values' ).attr( 'value', semanticMaps.buildInputValue( [ normalProjectionLocation ] ) );
 52+ self.input.attr( 'value', semanticMaps.buildInputValue( [ normalProjectionLocation ] ) );
5353 };
5454
5555 this.projectAndShowLocation = function( location, title ) {
Index: branches/SemanticMaps0.8/includes/forminputs/jquery.mapforminput.js
@@ -23,7 +23,7 @@
2424
2525 var self = this;
2626
27 - var input = $( '<input />' ).attr( {
 27+ this.input = $( '<input />' ).attr( {
2828 'type': 'text',
2929 'name': options.inputname,
3030 'id': mapDivId + '_values',
@@ -34,7 +34,7 @@
3535 var updateButton = $( '<button />' ).text( mediaWiki.msg( 'semanticmaps-updatemap' ) );
3636
3737 updateButton.click( function() {
38 - var locations = coord.split( $( '#' + mapDivId + '_values' ).attr( 'value' ) );
 38+ var locations = coord.split( this.input.attr( 'value' ) );
3939 var location = coord.parse( locations[0] );
4040
4141 if ( location !== false ) {
@@ -44,13 +44,13 @@
4545 return false;
4646 } );
4747
48 - input.keypress( function( event ) {
 48+ this.input.keypress( function( event ) {
4949 if ( event.which == '13' ) {
5050 updateButton.click();
5151 }
5252 } );
5353
54 - var geofield = $( '<input />' ).attr( {
 54+ this.geofield = $( '<input />' ).attr( {
5555 'type': 'text',
5656 'id': mapDivId + '_geofield',
5757 'value': mediaWiki.msg( 'semanticmaps_enteraddresshere' ),
@@ -58,14 +58,14 @@
5959 'size': options.fieldsize
6060 } );
6161
62 - geofield.focus( function() {
 62+ this.geofield.focus( function() {
6363 if ( this.value == mediaWiki.msg( 'semanticmaps_enteraddresshere' ) ) {
6464 this.value = '';
6565 $( this ).css( 'color', '' );
6666 }
6767 } );
6868
69 - geofield.blur( function() {
 69+ this.geofield.blur( function() {
7070 if ( this.value == '' ) {
7171 this.value = mediaWiki.msg( 'semanticmaps_enteraddresshere' );
7272 $( this ).css( 'color', 'darkgray' );
@@ -75,11 +75,11 @@
7676 var geoButton = $( '<button />' ).text( mediaWiki.msg( 'semanticmaps_lookupcoordinates' ) );
7777
7878 geoButton.click( function() {
79 - self.geocodeAddress( $( '#' + mapDivId + '_geofield' ).attr( 'value' ) );
 79+ self.geocodeAddress( this.geofield.attr( 'value' ) );
8080 return false;
8181 } );
8282
83 - geofield.keypress( function( event ) {
 83+ this.geofield.keypress( function( event ) {
8484 if ( event.which == '13' ) {
8585 geoButton.click();
8686 }
@@ -97,11 +97,11 @@
9898 this.mapDiv = mapDiv;
9999
100100 if ( this.showCoordinate ) {
101 - this.html( $( '<p />' ).append( input ).append( updateButton ) );
 101+ this.html( $( '<p />' ).append( this.input ).append( updateButton ) );
102102 }
103103
104104 if ( this.geocodeAddress ) {
105 - this.append( $( '<p />' ).append( geofield ).append( geoButton ) );
 105+ this.append( $( '<p />' ).append( this.geofield ).append( geoButton ) );
106106 }
107107
108108 this.append( mapDiv );

Status & tagging log