From a48113684d1f943c55a8eba055b3eece3913ca66 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 May 2011 18:26:02 +0200 Subject: [PATCH] properly update list status --- source/Ox.UI/js/Map/Ox.ListMap.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index c7661e38..046a1b22 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -272,8 +272,8 @@ Ox.ListMap = function(options, self) { self.$status = Ox.Element() .css({paddingTop: '2px', margin: 'auto', fontSize: '9px', textAlign: 'center'}) - .html(self.options.places.length + ' Place' + (self.options.places.length == 1 ? '' : 's')) .appendTo(self.$listStatusbar); + setStatus(); self.$placeTitlebar = Ox.Bar({ size: 24 @@ -410,11 +410,13 @@ Ox.ListMap = function(options, self) { self.$map.addPlace(place); self.$list.options({items: Ox.clone(self.options.places)}); self.$list.options({selected: [place.id]}); + setStatus(); self.$placeButton.options({title: 'Remove Place'}) } else if (title == 'Remove Place') { var index = Ox.getPositionById(self.options.places, self.selectedPlace); self.options.places.splice(index, 1); self.$list.options({items: Ox.clone(self.options.places)}); + setStatus(); self.$map.removePlace(); self.$placeButton.options({title: 'Add Place'}); } @@ -601,6 +603,14 @@ Ox.ListMap = function(options, self) { } } + function setStatus() { + self.$status.html( + self.options.places.length + ' Place' + ( + self.options.places.length == 1 ? '' : 's' + ) + ); + } + function toFixed(val) { return Ox.isNumber(val) ? val.toFixed(8) : val; // fixme: why can a string be passed ?? }