From 11e98db160b7542578e927936e5044e9a30dfc51 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 May 2011 18:22:37 +0200 Subject: [PATCH] listmap bugfixes --- source/Ox.Geo/Ox.Geo.js | 14 ++++---------- source/Ox.UI/js/Map/Ox.ListMap.js | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/source/Ox.Geo/Ox.Geo.js b/source/Ox.Geo/Ox.Geo.js index 9b2a1a92..a7b46669 100644 --- a/source/Ox.Geo/Ox.Geo.js +++ b/source/Ox.Geo/Ox.Geo.js @@ -155,16 +155,10 @@ Ox.load.Geo = function(options, callback) { return country; }; - /*@ - Ox.reverseGeoname Reverses a geoname - @*/ - Ox.reverseGeoname = function(geoname) { - return geoname - .replace('Bonaire, Saint Eustatius and Saba', 'Bonaire Saint Eustatius and Saba') - .split(', ') - .reverse() - .join(', ') - .replace('Bonaire Saint Eustatius and Saba', 'Bonaire, Saint Eustatius and Saba'); + Ox.getImageByGeoname = function(type, size, geoname) { + var country = Ox.getCountryByGeoname(geoname), + code = country ? country.code : 'NTHH'; + return Ox.PATH + 'Ox.Geo/png/' + type + 's/' + size + '/' + code + '.png'; }; callback(true); diff --git a/source/Ox.UI/js/Map/Ox.ListMap.js b/source/Ox.UI/js/Map/Ox.ListMap.js index 0c5a4e2d..c7661e38 100644 --- a/source/Ox.UI/js/Map/Ox.ListMap.js +++ b/source/Ox.UI/js/Map/Ox.ListMap.js @@ -284,7 +284,7 @@ Ox.ListMap = function(options, self) { self.$placeTitleFlag = $('') .addClass('OxFlag') .attr({ - src: Ox.PATH + 'Ox.Geo/png/icons/16/NTHH.png' + src: Ox.getImageByGeoname('icon', 16, '') }) .css({float: 'left', margin: '4px 0 0 4px'}) .appendTo(self.$placeTitle); @@ -318,13 +318,16 @@ Ox.ListMap = function(options, self) { change: function(data) { var geoname = data.value, country = Ox.getCountryByGeoname(geoname), - countryCode = country ? country.code : 'NTHH', + countryCode = country ? country.code : '', isResult = self.selectedPlace[0] == '_'; - //Ox.getObjectById(self.options.places, self.selectedPlace).geoname = geoname; - !isResult && self.$list.value(self.selectedPlace, 'geoname', geoname); + Ox.print('IS RESULT?', isResult, self.selectedPlace) + if (!isResult) { + self.$list.value(self.selectedPlace, 'geoname', geoname); + self.$list.value(self.selectedPlace, 'countryCode', countryCode); + } //self.$map.value(self.selectedPlace, 'geoname', geoname); self.$placeTitleFlag.attr({ - src: Ox.PATH + 'Ox.Geo/png/icons/16/' + countryCode + '.png' + src: Ox.getImageByGeoname('icon', 16, geoname) }); self.$placeTitleName.options({title: geoname}); } @@ -400,7 +403,8 @@ Ox.ListMap = function(options, self) { var place = self.$placeForm.values(), country = Ox.getCountryByGeoname(place.geoname); place.countryCode = country ? country.code : ''; - place.id = self.selectedPlace.substr(1); // fixme: safe? + self.selectedPlace = self.selectedPlace.substr(1); // fixme: safe? + place.id = self.selectedPlace; self.options.places.push(place); //self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place; self.$map.addPlace(place); @@ -571,8 +575,6 @@ Ox.ListMap = function(options, self) { } function selectPlace(place) { - var country = place.id ? Ox.getCountryByGeoname(place.geoname) : '', - code = country ? country.code : 'NTHH'; if (place.id) { isResult = place.id[0] == '_'; //isResult && self.options.places.push(place); @@ -581,7 +583,7 @@ Ox.ListMap = function(options, self) { selected: place.id ? [place.id] : [] }); self.$placeTitleFlag.attr({ - src: Ox.PATH + 'Ox.Geo/png/icons/16/' + code + '.png' + src: Ox.getImageByGeoname('icon', 16, place.geoname) }); self.$placeTitleName.options({title: place.geoname || ''}); self.$placeTitle.show();