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;
};
/*@
Ox.reverseGeoname <f> 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);

View file

@ -284,7 +284,7 @@ Ox.ListMap = function(options, self) {
self.$placeTitleFlag = $('<img>')
.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();