diff --git a/demos/listmap2/js/listmap.js b/demos/listmap2/js/listmap.js index 0db24e4d..9ab5e4ab 100644 --- a/demos/listmap2/js/listmap.js +++ b/demos/listmap2/js/listmap.js @@ -1,5 +1,7 @@ Ox.load('UI', { debug: true, + hideScreen: true, + showScreen: true, theme: 'modern' }, function() { @@ -135,9 +137,19 @@ Ox.load('Geo', function() { width: window.innerWidth }) .bindEvent({ + addplace: function(data) { + Ox.print('addplace', data); + places.push(Ox.extend(data.place, { + geonameSort: getGeonameSort(data.place.geoname) + })); + }, geocode: function(event, data) { Ox.print(event) Ox.print(JSON.stringify(data)) + }, + removeplace: function(data) { + var i = Ox.getPositionById(places, data.id); + places.splice(i, 1); } }) .appendTo(Ox.UI.$body); diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index 8bc604b4..45cc585a 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -1213,6 +1213,7 @@ Ox.List = function(options, self) { clear(); self.requests.push(self.options.items({}, function(result) { var keys = {}; + Ox.print('INIT!!!', result.data) that.triggerEvent('init', result.data); self.rowLength = getRowLength(); self.pageLength = self.options.orientation == 'both' ? @@ -1320,7 +1321,7 @@ Ox.List = function(options, self) { addItems add item to list (pos, items) -> add items to list at position pos position to add items - items array of items ot add + items array of items to add @*/ that.addItems = function(pos, items) { var $items = [], diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index 5d2e2423..f39d4940 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -201,10 +201,16 @@ Ox.TextList = function(options, self) { } }) .bindEvent({ - edit: function(event, data) { + edit: function(data) { that.editCell(data.id, data.key); }, - select: function(event, data) { + init: function(data) { + // fixme: why does this never reach? + //Ox.print('INIT????') + //that.triggerEvent('init', data); + }, + select: function(data) { + Ox.print('SELECT????') self.options.selected = data.ids; } }) @@ -702,8 +708,10 @@ Ox.TextList = function(options, self) { } }; - // fixme: doesn't work, doesn't return that - that.closePreview = that.$body.closePreview; + that.closePreview = function() { + that.$body.closePreview(); + return that; + }; that.addItem = function(item) { /* diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 26591281..0c90b3d6 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -6,7 +6,6 @@ Ox.ListMap ListMap Object (options) -> ListMap Object (options, self) -> ListMap Object options Options object - addPlace height labels places @@ -20,7 +19,6 @@ Ox.ListMap = function(options, self) { var self = self || {}, that = Ox.Element({}, self) .defaults({ - addPlace: null, height: 256, labels: false, pageLength: 100, @@ -294,9 +292,11 @@ Ox.ListMap = function(options, self) { zoombar: true }) .bindEvent({ + /* addplace: function(event, data) { that.triggerEvent('addplace', data); }, + */ changeplace: function(event, data) { self.$placeForm.values(Ox.map(data, function(val, key) { // fixme: no size key anymore @@ -437,35 +437,10 @@ Ox.ListMap = function(options, self) { self.$map.newPlace(); self.$placeButton.options({title: 'Add Place'}) } else if (title == 'Add Place') { - var place = self.$placeForm.values(), - country = Ox.getCountryByGeoname(place.geoname); - place.countryCode = country ? country.code : ''; - self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe? - place.id = self.selectedPlace; - //if (Ox.isArray(self.options.places)) { - self.options.places.push(place); - self.$list.options({ - items: Ox.clone(self.options.places), - selected: [place.id] - }); - setStatus(); - //} - self.$map.addPlace(place); - self.$placeButton.options({title: 'Remove Place'}); - that.triggerEvent('addplace', {place: place}); + addPlace(); } else if (title == 'Remove Place') { - var index = Ox.getPositionById(self.options.places, self.selectedPlace); - //if (Ox.isArray(self.options.places)) { - 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'}); - that.triggerEvent('removeplace', {place: place}); + removePlace(); } - Ox.print('PLACES.LENGTH', self.options.places.length) - Ox.print('ITEMS.LENGTH', self.$list.options('items').length) } }) .appendTo(self.$placeStatusbar); @@ -486,6 +461,7 @@ Ox.ListMap = function(options, self) { ]; */ + /* if (!self.isAsync) { self.placesLength = self.options.places.length; setStatus(); @@ -495,6 +471,7 @@ Ox.ListMap = function(options, self) { setStatus(); }); } + */ that.$element.replaceWith( that.$element = Ox.SplitPanel({ @@ -559,8 +536,50 @@ Ox.ListMap = function(options, self) { }).$element ); - function initList(event, data) { - self.$status.html(data.items + ' place' + (data.items == 1 ? '' : 's')) + function addPlace() { + var place = self.$placeForm.values(), + country = Ox.getCountryByGeoname(place.geoname); + place.countryCode = country ? country.code : ''; + self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe? + place.id = self.selectedPlace; + if (!self.isAsync) { + self.options.places.push(place); + self.$list.options({ + items: Ox.clone(self.options.places), + selected: [place.id] + }); + //setStatus(); + } + self.$map.addPlace(place); + self.$placeButton.options({title: 'Remove Place'}); + that.triggerEvent('addplace', {place: place}); + if (self.isAsync) { + self.$list.reloadList().options({selected: [place.id]}); + } + } + + function removePlace() { + var index = Ox.getPositionById(self.options.places, self.selectedPlace); + if (!self.isAsync) { + 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'}); + that.triggerEvent('removeplace', {id: self.selectedPlace}); + if (self.isAsync) { + self.$list.options({selected: []}).reloadList(); + } + + } + + function initList(data) { + self.$status.html( + Ox.formatNumber(data.items) + ' Place' + ( + data.items == 1 ? '' : 's' + ) + ); } function openItem(event, data) { @@ -608,14 +627,6 @@ Ox.ListMap = function(options, self) { } } - function setStatus() { - self.$status.html( - Ox.formatNumber(self.placesLength) + ' Place' + ( - self.placesLength == 1 ? '' : 's' - ) - ); - } - function toFixed(val) { return Ox.isNumber(val) ? val.toFixed(8) : val; // fixme: why can a string be passed ?? }