make focus work for element with id == 0; some fixes for map
This commit is contained in:
parent
ee027fb760
commit
925904527e
1 changed files with 79 additions and 38 deletions
|
@ -428,8 +428,10 @@ requires
|
|||
88: 'x',
|
||||
89: 'y',
|
||||
90: 'z',
|
||||
91: 'meta.left',
|
||||
92: 'meta.right',
|
||||
//91: 'meta.left',
|
||||
//92: 'meta.right',
|
||||
91: 'meta',
|
||||
92: 'meta',
|
||||
93: 'select',
|
||||
96: '0.numpad',
|
||||
97: '1.numpad',
|
||||
|
@ -538,7 +540,7 @@ requires
|
|||
buffer += key == 'SPACE' ? ' ' : key;
|
||||
bufferTime = time;
|
||||
}
|
||||
focused && $elements[focused].triggerEvent('key_' + key);
|
||||
focused !== null && $elements[focused].triggerEvent('key_' + key);
|
||||
if (['down', 'space', 'up'].indexOf(key) > -1 && !$elements[focused].hasClass('OxInput')) {
|
||||
// prevent chrome from scrolling
|
||||
return false;
|
||||
|
@ -7129,9 +7131,9 @@ requires
|
|||
}
|
||||
|
||||
function getSelectedIds() {
|
||||
Ox.print('gSI', self.selected, self.$items)
|
||||
//Ox.print('gSI', self.selected, self.$items)
|
||||
return $.map(self.selected, function(pos) {
|
||||
Ox.print('....', pos, self.options.unique, self.$items[pos].options('data')[self.options.unique])
|
||||
//Ox.print('....', pos, self.options.unique, self.$items[pos].options('data')[self.options.unique])
|
||||
return self.$items[pos].options('data')[self.options.unique];
|
||||
});
|
||||
}
|
||||
|
@ -9276,7 +9278,7 @@ requires
|
|||
}
|
||||
|
||||
function selectPlace(event, data) {
|
||||
Ox.print('selectPlace', data.id)
|
||||
Ox.print('selectPlace', data, data.id)
|
||||
data.id[0] != '_' && self.$list.options({
|
||||
selected: data.id ? [data.id] : []
|
||||
});
|
||||
|
@ -9339,6 +9341,7 @@ requires
|
|||
key_down: function() {
|
||||
pan(0, 1);
|
||||
},
|
||||
key_l: toggleLabels,
|
||||
key_left: function() {
|
||||
pan(-1, 0);
|
||||
},
|
||||
|
@ -9346,19 +9349,28 @@ requires
|
|||
pan(1, 0);
|
||||
},
|
||||
key_0: reset,
|
||||
key_meta: function() {
|
||||
self.metaKey = true;
|
||||
$(document).one({
|
||||
keyup: function() {
|
||||
self.metaKey = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
key_minus: function() {
|
||||
zoom(-1);
|
||||
},
|
||||
key_equal: function() {
|
||||
zoom(1);
|
||||
},
|
||||
key_enter: focusOnPlace,
|
||||
key_enter: panToPlace,
|
||||
key_shift_enter: zoomToPlace,
|
||||
key_escape: function() {
|
||||
selectPlace('');
|
||||
}
|
||||
});
|
||||
|
||||
self.metaKey = false;
|
||||
self.resultPlace = null;
|
||||
|
||||
if (self.options.toolbar) {
|
||||
|
@ -9390,7 +9402,7 @@ requires
|
|||
self.$map = new Ox.Element('div')
|
||||
.css({
|
||||
width: self.options.width + 'px',
|
||||
height: getMapHeight()
|
||||
height: getMapHeight() + 'px'
|
||||
})
|
||||
.appendTo(that);
|
||||
|
||||
|
@ -9529,12 +9541,6 @@ requires
|
|||
}
|
||||
}
|
||||
|
||||
function focusOnPlace() {
|
||||
if (self.options.selected > -1) {
|
||||
self.map.panTo(self.options.places[self.options.selected].center);
|
||||
}
|
||||
}
|
||||
|
||||
function getPlaceById(id) {
|
||||
var place = Ox.getObjectById(self.places, id);
|
||||
if (!place && self.resultPlace && self.resultPlace.id == id) {
|
||||
|
@ -9597,12 +9603,10 @@ requires
|
|||
}
|
||||
|
||||
function getMapHeight() {
|
||||
return (
|
||||
self.options.height -
|
||||
return self.options.height -
|
||||
self.options.statusbar * 24 -
|
||||
self.options.toolbar * 24 -
|
||||
self.options.zoombar * 16
|
||||
) + 'px';
|
||||
self.options.zoombar * 16;
|
||||
}
|
||||
|
||||
function getMapType() {
|
||||
|
@ -9624,6 +9628,9 @@ requires
|
|||
self.geocoder = new google.maps.Geocoder();
|
||||
self.places = [];
|
||||
self.options.places.forEach(function(place, i) {
|
||||
if (Ox.isUndefined(place.id)) {
|
||||
place.id = Ox.uid();
|
||||
}
|
||||
self.places[i] = Place(Ox.clone(place));
|
||||
if (i == 0) {
|
||||
Ox.print('0000', self.places[i].bounds, self.places[i].bounds.union)
|
||||
|
@ -9631,7 +9638,10 @@ requires
|
|||
Ox.print('$$$$', self.bounds)
|
||||
}
|
||||
self.bounds = i == 0 ?
|
||||
self.places[i].bounds :
|
||||
new google.maps.LatLngBounds(
|
||||
new google.maps.LatLng(self.places[i].south, self.places[i].west),
|
||||
new google.maps.LatLng(self.places[i].north, self.places[i].east)
|
||||
) :
|
||||
self.bounds.union(self.places[i].bounds);
|
||||
});
|
||||
self.center = self.bounds ? self.bounds.getCenter() : new google.maps.LatLng(0, 0);
|
||||
|
@ -9639,6 +9649,7 @@ requires
|
|||
self.map = new google.maps.Map(self.$map.$element[0], {
|
||||
center: self.center,
|
||||
disableDefaultUI: true,
|
||||
disableDoubleClickZoom: true,
|
||||
mapTypeId: google.maps.MapTypeId[getMapType()],
|
||||
zoom: self.zoom
|
||||
});
|
||||
|
@ -9657,9 +9668,16 @@ requires
|
|||
}
|
||||
|
||||
function pan(x, y) {
|
||||
self.map.panBy(x * 256, y * 256);
|
||||
self.map.panBy(x * self.options.width / 2, y * getMapHeight() / 2);
|
||||
};
|
||||
|
||||
function panToPlace() {
|
||||
Ox.print('panToPlace:', self.options.selected)
|
||||
if (self.options.selected !== null) {
|
||||
self.map.panTo(getPlaceById(self.options.selected).center);
|
||||
}
|
||||
}
|
||||
|
||||
function removePlace(id) {
|
||||
|
||||
}
|
||||
|
@ -9680,10 +9698,22 @@ requires
|
|||
place = getPlaceById(id);
|
||||
place && place.select();
|
||||
}
|
||||
if (id) {
|
||||
//self.map.setCenter(place.center);
|
||||
/*
|
||||
if (
|
||||
self.map.getBounds().contains(place.bounds.getSouthWest()) &&
|
||||
self.map.getBounds().contains(place.bounds.getNorthEast())
|
||||
) {
|
||||
} else {
|
||||
self.map.fitBounds(place.bounds);
|
||||
}
|
||||
*/
|
||||
}
|
||||
self.options.selected = id;
|
||||
self.selected = id;
|
||||
setStatus();
|
||||
that.triggerEvent('select', place);
|
||||
//that.triggerEvent('select', place);
|
||||
/*
|
||||
that.triggerEvent('select', {
|
||||
id: self.options.selected
|
||||
|
@ -9738,8 +9768,9 @@ requires
|
|||
}
|
||||
|
||||
function zoomToPlace() {
|
||||
if (self.options.selected > -1) {
|
||||
self.map.fitBounds(self.options.places[self.options.selected].bounds);
|
||||
Ox.print('zoomToPlace')
|
||||
if (self.options.selected !== null) {
|
||||
self.map.fitBounds(getPlaceById(self.options.selected).bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9748,25 +9779,35 @@ requires
|
|||
position: place.center,
|
||||
title: place.name
|
||||
}),
|
||||
selected = false;
|
||||
selected = false,
|
||||
timeout = 0;
|
||||
setOptions();
|
||||
Ox.print('MARKER', marker)
|
||||
function click(event) {
|
||||
// fixme: metaKey used to work
|
||||
/*
|
||||
Ox.print('click event', event, 'metakey', event.metaKey, 'selected', selected)
|
||||
if (event.metaKey == selected) {
|
||||
selected = !event.metaKey;
|
||||
selectPlace(selected ? place.id : '');
|
||||
}
|
||||
*/
|
||||
selected = !selected;
|
||||
selectPlace(selected ? place.id : '');
|
||||
function click() {
|
||||
var metaKey = self.metaKey;
|
||||
timeout = setTimeout(function() {
|
||||
Ox.print('$$$$ CLICK', metaKey, selected)
|
||||
if (!selected) {
|
||||
selected = true;
|
||||
selectPlace(place.id);
|
||||
} else if (!metaKey) {
|
||||
panToPlace(place);
|
||||
} else {
|
||||
selected = false;
|
||||
selectPlace(null);
|
||||
}
|
||||
}, 250);
|
||||
Ox.print('$$$$ TIMEOUT')
|
||||
}
|
||||
function dblclick() {
|
||||
Ox.print('PLACE.BOUNDS', place.bounds)
|
||||
self.bounds = place.bounds;
|
||||
self.map.fitBounds(self.bounds);
|
||||
Ox.print('$$$$ DBLCLICK', timeout)
|
||||
clearTimeout(timeout);
|
||||
if (!selected) {
|
||||
selected = true;
|
||||
selectPlace(place.id);
|
||||
}
|
||||
self.map.fitBounds(place.bounds);
|
||||
return false;
|
||||
}
|
||||
function setOptions() {
|
||||
marker.setOptions({
|
||||
|
|
Loading…
Reference in a new issue