@@ -100,10 +100,10 @@ $(document).ready(function(e) {
100
100
101
101
function resolveCoords ( fromStr , toStr ) {
102
102
routingLayer . clearLayers ( ) ;
103
- if ( fromStr != ghRequest . from . input )
103
+ if ( fromStr !== ghRequest . from . input || ! ghRequest . from . isResolved ( ) )
104
104
ghRequest . from = new GHInput ( fromStr ) ;
105
105
106
- if ( toStr != ghRequest . to . input )
106
+ if ( toStr !== ghRequest . to . input || ! ghRequest . to . isResolved ( ) )
107
107
ghRequest . to = new GHInput ( toStr ) ;
108
108
109
109
if ( ghRequest . from . lat && ghRequest . to . lat ) {
@@ -260,7 +260,7 @@ function resolve(fromOrTo, point) {
260
260
return getInfoFromLocation ( point ) . done ( function ( ) {
261
261
$ ( "#" + fromOrTo + "Input" ) . val ( point . input ) ;
262
262
if ( point . resolvedText )
263
- $ ( "#" + fromOrTo + "Found" ) . html ( point . resolvedText ) ;
263
+ $ ( "#" + fromOrTo + "Found" ) . html ( point . resolvedText ) ;
264
264
265
265
$ ( "#" + fromOrTo + "Flag" ) . show ( ) ;
266
266
$ ( "#" + fromOrTo + "Indicator" ) . hide ( ) ;
@@ -566,25 +566,25 @@ function initForm() {
566
566
e . preventDefault ( ) ;
567
567
} ) ;
568
568
569
+ // use keyup instead keypress otherwise the val() calls could contain partial values
569
570
// if FROM will be submitted
570
- $ ( '#fromInput' ) . keypress ( function ( e ) {
571
+ $ ( '#fromInput' ) . keyup ( function ( e ) {
571
572
if ( e . which == 13 ) {
572
573
var from = $ ( "#fromInput" ) . val ( )
573
574
var to = $ ( "#toInput" ) . val ( ) ;
574
575
// do not resolve 'to'
575
- if ( to == "To" ) {
576
- if ( from != ghRequest . from . input )
577
- ghRequest . from = new GHInput ( from ) ;
576
+ if ( to == "To" ) {
577
+ ghRequest . from = new GHInput ( from ) ;
578
578
$ . when ( resolveFrom ( ) ) . done ( function ( ) {
579
579
focus ( ghRequest . from ) ;
580
- } ) ;
580
+ } ) ;
581
581
} else
582
582
resolveCoords ( from , to ) ;
583
583
}
584
584
} ) ;
585
585
586
586
// if TO will be submitted
587
- $ ( '#toInput' ) . keypress ( function ( e ) {
587
+ $ ( '#toInput' ) . keyup ( function ( e ) {
588
588
if ( e . which == 13 ) {
589
589
var from = $ ( "#fromInput" ) . val ( ) ;
590
590
if ( from == "From" ) {
0 commit comments