From db6f68681adafc7d5414c48ca0fcf55301fb0f76 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Tue, 21 Feb 2012 11:20:03 +0000 Subject: [PATCH] in annotation panel, make links to define/edit places/events work (fixes #561) --- source/Ox.UI/js/Calendar/Ox.ListCalendar.js | 6 +- source/Ox.UI/js/Map/Ox.ListMap.js | 10 ++- source/Ox.UI/js/Map/Ox.Map.js | 80 +++++++++++---------- 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/source/Ox.UI/js/Calendar/Ox.ListCalendar.js b/source/Ox.UI/js/Calendar/Ox.ListCalendar.js index 8b5e8d93..07f8c586 100644 --- a/source/Ox.UI/js/Calendar/Ox.ListCalendar.js +++ b/source/Ox.UI/js/Calendar/Ox.ListCalendar.js @@ -269,7 +269,6 @@ Ox.ListCalendar = function(options, self) { return !!event.type; }), height: self.options.height, - selected: self.options.selected, showControls: self.options.showControls, showToolbar: true, showZoombar: true, @@ -544,6 +543,11 @@ Ox.ListCalendar = function(options, self) { .$element ); + // if loaded with selection, set calendar and form + self.options.selected && self.$list.triggerEvent({ + select: {ids: [self.options.selected]} + }); + function addEvent() { Ox.Log('Calendar', 'ADD', self.$calendar.getBounds()) var bounds = self.$calendar.getBounds(), diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index c7f9ec81..971fb4da 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -355,6 +355,15 @@ Ox.ListMap = function(options, self) { select: selectItem }); + // if loaded with selection, set map and form + self.options.selected && self.$list.bindEventOnce({ + load: function() { + self.$list.triggerEvent({ + select: {ids: [self.options.selected]} + }); + } + }); + self.$listStatusbar = Ox.Bar({ size: 16 }); @@ -369,7 +378,6 @@ Ox.ListMap = function(options, self) { findPlaceholder: 'Find on Map', height: self.options.height, places: self.options.places, - selected: self.options.selected, //statusbar: true, showControls: self.options.showControls, showLabels: self.options.showLabels, diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index 51806c79..e8ed05b7 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -1141,47 +1141,53 @@ Ox.Map = function(options, self) { function selectPlace(id, zoom) { Ox.print('SELECT PLACE', id) // id can be null (deselect) - var place, - selected = getSelectedMarker(); - Ox.Log('Map', 'Ox.Map selectPlace()', id, selected); - if (id != selected) { - place = getPlaceById(selected); - place && place.deselect(); - if (id !== null) { - place = getPlaceById(id); - if (place) { - select(); - } else { - // async && place doesn't exist yet - self.options.places({ - keys: self.placeKeys, - query: { - conditions: [ - {key: 'id', value: id, operator: '=='} - ], - operator: '&' - } - }, function(result) { - if (result.data.items.length) { - place = new Ox.MapPlace(Ox.extend({ - map: that - }, result.data.items[0])).add(); - self.places.push(place); - select(); - if (zoom) { - zoomToPlace(); - } else { - panToPlace(); + var place, selected = getSelectedMarker(); + if (!self.loaded) { + setTimeout(function() { + selectPlace(id, zoom) + }, 1000); + } else { + Ox.Log('Map', 'Ox.Map selectPlace()', id, selected); + if (id != selected) { + place = getPlaceById(selected); + place && place.deselect(); + if (id !== null) { + place = getPlaceById(id); + if (place) { + select(); + } else { + // async && place doesn't exist yet + self.options.places({ + keys: self.placeKeys, + query: { + conditions: [ + {key: 'id', value: id, operator: '=='} + ], + operator: '&' } - } - }); + }, function(result) { + if (result.data.items.length) { + place = new Ox.MapPlace(Ox.extend({ + map: that + }, result.data.items[0])).add(); + self.places.push(place); + select(); + if (zoom) { + zoomToPlace(); + } else { + panToPlace(); + } + } + }); + } + } else { + place = null; + select(); } - } else { - place = null; - select(); } } function select() { + Ox.print('select...', place) place && place.select(); self.options.selected = id; setPlaceControls(place); @@ -1418,7 +1424,7 @@ Ox.Map = function(options, self) { } } } else if (key == 'selected') { - self.loaded && selectPlace(value || null); + selectPlace(value || null); } else if (key == 'type') { }