From 74802d284ab42ac182d10f20ac862b291d1e06c4 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 May 2011 16:32:03 +0200 Subject: [PATCH] make map zoom work while list has focus --- source/Ox.UI/js/Core/Ox.Keyboard.js | 4 +++- source/Ox.UI/js/List/Ox.List.js | 2 +- source/Ox.UI/js/List/Ox.TextList.js | 2 ++ source/Ox.UI/js/Map/Ox.ListMap.js | 12 ++++++++++++ source/Ox.UI/js/Map/Ox.Map.js | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Keyboard.js b/source/Ox.UI/js/Core/Ox.Keyboard.js index 804ded99..28654fef 100644 --- a/source/Ox.UI/js/Core/Ox.Keyboard.js +++ b/source/Ox.UI/js/Core/Ox.Keyboard.js @@ -89,7 +89,9 @@ focused !== null && Ox.UI.elements[focused].triggerEvent('keys', { keys: buffer }); - }, 250); + }, 25); + // fixme: used to be 250, but seemed too much. + // if it stays at 25, we may not need a timeout at all } } // clear the reset timeout even if the key didn't go into the buffer diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index 0ec8891c..67f9b0e2 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -1282,7 +1282,7 @@ Ox.List = function(options, self) { } else if (key == 'selected') { Ox.print('setOption selected', value) setSelected(value); - triggerSelectEvent(); + triggerSelectEvent(); // fixme: added to make text list find-as-you-type work, may break other things } else if (key == 'sort') { Ox.print('---sort---') updateSort(); diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index 55c65313..bbbf9c1a 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -485,12 +485,14 @@ Ox.TextList = function(options, self) { // fixme: works only if items are an array var query = data.keys, sort = self.options.sort[0]; + Ox.print('QUERY', query) Ox.forEach(self.options.items, function(item, i) { var value = ( sort.map ? sort.map(item[sort.key]) : item[sort.key] ).toLowerCase(); if (Ox.startsWith(value, query)) { that.$body.options({selected: [item[self.unique]]}); + Ox.print('QUERY', query, 'VALUE', value) return false; } }); diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 3a05a38d..0adbdd0e 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -244,6 +244,18 @@ Ox.ListMap = function(options, self) { .bindEvent({ 'delete': removeItem, init: initList, + key_0: function() { + self.$map.panToPlace(); + }, + key_equal: function() { + self.$map.zoom(1); + }, + key_minus: function() { + self.$map.zoom(-1); + }, + key_shift_0: function() { + self.$map.zoomToPlace(); + }, load: function() { that.triggerEvent('loadlist'); }, diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index 416c2f76..90b6e4e8 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -1137,7 +1137,7 @@ Ox.Map = function(options, self) { }; that.zoom = function(value) { - self.map.setZoom(value); + zoom(value); return that; };