properly update list status

This commit is contained in:
rolux 2011-05-24 18:26:02 +02:00
parent 11e98db160
commit a48113684d

View file

@ -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 ??
}