Auto-complete location input rather than discarding input
authorAlexander Ebert <ebert@woltlab.com>
Sun, 2 Feb 2014 23:12:09 +0000 (00:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 2 Feb 2014 23:12:09 +0000 (00:12 +0100)
Additionally replaced some magic numbers with $.ui.keyCode constants

wcfsetup/install/files/js/WCF.Location.js
wcfsetup/install/files/js/WCF.js

index 68cc0593938c40c1deec8b3c0880d339d218158b..c8ca727bfd59521acdc865a101ab9dc425937951 100644 (file)
@@ -375,22 +375,22 @@ WCF.Location.GoogleMaps.LocationSearch = WCF.Search.Base.extend({
        _keyUp: function(event) {
                // handle arrow keys and return key
                switch (event.which) {
-                       case 37: // arrow-left
-                       case 39: // arrow-right
+                       case $.ui.keyCode.LEFT:
+                       case $.ui.keyCode.RIGHT:
                                return;
                        break;
                        
-                       case 38: // arrow up
+                       case $.ui.keyCode.UP:
                                this._selectPreviousItem();
                                return;
                        break;
                        
-                       case 40: // arrow down
+                       case $.ui.keyCode.DOWN:
                                this._selectNextItem();
                                return;
                        break;
                        
-                       case 13: // return key
+                       case $.ui.keyCode.ENTER:
                                return this._selectElement(event);
                        break;
                }
@@ -529,7 +529,7 @@ WCF.Location.GoogleMaps.LocationInput = Class.extend({
                this._marker.setPosition(data.location);
                WCF.Location.GoogleMaps.Util.focusMarker(this._marker);
                
-               $(this._searchInput).val('');
+               $(this._searchInput).val(data.label);
        }
 });
 
index bd7107723cbd9341a729ac34bc69fb2523fa23f4..0d989cfa8df80e47e21007c73b04253f9ca01eca 100755 (executable)
@@ -5619,8 +5619,8 @@ WCF.Search.Base = Class.extend({
                var $searchString = $.trim(this._searchInput.val());
                if (this._commaSeperated) {
                        var $keyCode = event.keyCode || event.which;
-                       if ($keyCode == 188) {
-                               // ignore event if char is 188 = ,
+                       if ($keyCode == $.ui.keyCode.COMMA) {
+                               // ignore event if char is ','
                                return '';
                        }