make listmap trigger add/remove place events

This commit is contained in:
rolux 2011-05-28 10:15:50 +02:00
parent fada9f8a0c
commit 96b597d324

View file

@ -407,20 +407,27 @@ Ox.ListMap = function(options, self) {
place.countryCode = country ? country.code : ''; place.countryCode = country ? country.code : '';
self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe? self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe?
place.id = self.selectedPlace; place.id = self.selectedPlace;
self.options.places.push(place); if (Ox.isArray(self.options.place)) {
//self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place; self.options.places.push(place);
self.$list.options({
items: Ox.clone(self.options.places),
selected: [place.id]
});
setStatus();
}
self.$map.addPlace(place); self.$map.addPlace(place);
self.$list.options({items: Ox.clone(self.options.places)}); self.$placeButton.options({title: 'Remove Place'});
self.$list.options({selected: [place.id]}); that.triggerEvent('addplace', {place: place});
setStatus();
self.$placeButton.options({title: 'Remove Place'})
} else if (title == 'Remove Place') { } else if (title == 'Remove Place') {
var index = Ox.getPositionById(self.options.places, self.selectedPlace); var index = Ox.getPositionById(self.options.places, self.selectedPlace);
self.options.places.splice(index, 1); if (Ox.isArray(self.options.place)) {
self.$list.options({items: Ox.clone(self.options.places)}); self.options.places.splice(index, 1);
setStatus(); self.$list.options({items: Ox.clone(self.options.places)});
setStatus();
}
self.$map.removePlace(); self.$map.removePlace();
self.$placeButton.options({title: 'Add Place'}); self.$placeButton.options({title: 'Add Place'});
that.triggerEvent('removeplace', {place: place});
} }
Ox.print('PLACES.LENGTH', self.options.places.length) Ox.print('PLACES.LENGTH', self.options.places.length)
Ox.print('ITEMS.LENGTH', self.$list.options('items').length) Ox.print('ITEMS.LENGTH', self.$list.options('items').length)