listmap bugfixes

This commit is contained in:
rolux 2011-05-24 18:22:37 +02:00
parent 9967d31396
commit 11e98db160
2 changed files with 15 additions and 19 deletions

View file

@ -155,16 +155,10 @@ Ox.load.Geo = function(options, callback) {
return country; return country;
}; };
/*@ Ox.getImageByGeoname = function(type, size, geoname) {
Ox.reverseGeoname <f> Reverses a geoname var country = Ox.getCountryByGeoname(geoname),
@*/ code = country ? country.code : 'NTHH';
Ox.reverseGeoname = function(geoname) { return Ox.PATH + 'Ox.Geo/png/' + type + 's/' + size + '/' + code + '.png';
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');
}; };
callback(true); callback(true);

View file

@ -284,7 +284,7 @@ Ox.ListMap = function(options, self) {
self.$placeTitleFlag = $('<img>') self.$placeTitleFlag = $('<img>')
.addClass('OxFlag') .addClass('OxFlag')
.attr({ .attr({
src: Ox.PATH + 'Ox.Geo/png/icons/16/NTHH.png' src: Ox.getImageByGeoname('icon', 16, '')
}) })
.css({float: 'left', margin: '4px 0 0 4px'}) .css({float: 'left', margin: '4px 0 0 4px'})
.appendTo(self.$placeTitle); .appendTo(self.$placeTitle);
@ -318,13 +318,16 @@ Ox.ListMap = function(options, self) {
change: function(data) { change: function(data) {
var geoname = data.value, var geoname = data.value,
country = Ox.getCountryByGeoname(geoname), country = Ox.getCountryByGeoname(geoname),
countryCode = country ? country.code : 'NTHH', countryCode = country ? country.code : '',
isResult = self.selectedPlace[0] == '_'; isResult = self.selectedPlace[0] == '_';
//Ox.getObjectById(self.options.places, self.selectedPlace).geoname = geoname; Ox.print('IS RESULT?', isResult, self.selectedPlace)
!isResult && self.$list.value(self.selectedPlace, 'geoname', geoname); if (!isResult) {
self.$list.value(self.selectedPlace, 'geoname', geoname);
self.$list.value(self.selectedPlace, 'countryCode', countryCode);
}
//self.$map.value(self.selectedPlace, 'geoname', geoname); //self.$map.value(self.selectedPlace, 'geoname', geoname);
self.$placeTitleFlag.attr({ self.$placeTitleFlag.attr({
src: Ox.PATH + 'Ox.Geo/png/icons/16/' + countryCode + '.png' src: Ox.getImageByGeoname('icon', 16, geoname)
}); });
self.$placeTitleName.options({title: geoname}); self.$placeTitleName.options({title: geoname});
} }
@ -400,7 +403,8 @@ Ox.ListMap = function(options, self) {
var place = self.$placeForm.values(), var place = self.$placeForm.values(),
country = Ox.getCountryByGeoname(place.geoname); country = Ox.getCountryByGeoname(place.geoname);
place.countryCode = country ? country.code : ''; 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.push(place);
//self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place; //self.options.places[Ox.getPositionById(self.options.places, self.selectedPlace)] = place;
self.$map.addPlace(place); self.$map.addPlace(place);
@ -571,8 +575,6 @@ Ox.ListMap = function(options, self) {
} }
function selectPlace(place) { function selectPlace(place) {
var country = place.id ? Ox.getCountryByGeoname(place.geoname) : '',
code = country ? country.code : 'NTHH';
if (place.id) { if (place.id) {
isResult = place.id[0] == '_'; isResult = place.id[0] == '_';
//isResult && self.options.places.push(place); //isResult && self.options.places.push(place);
@ -581,7 +583,7 @@ Ox.ListMap = function(options, self) {
selected: place.id ? [place.id] : [] selected: place.id ? [place.id] : []
}); });
self.$placeTitleFlag.attr({ 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.$placeTitleName.options({title: place.geoname || ''});
self.$placeTitle.show(); self.$placeTitle.show();