fix bugs in Ox.MapEditor

This commit is contained in:
rlx 2012-06-30 15:01:43 +00:00
parent ee23db5876
commit 146078e7ce

View file

@ -360,7 +360,9 @@ Ox.MapEditor = function(options, self) {
that.triggerEvent('loadlist'); that.triggerEvent('loadlist');
}, },
open: openItem, open: openItem,
select: selectItem select: function(data) {
selectItem(data);
}
}); });
// if loaded with selection, set map and form // if loaded with selection, set map and form
@ -419,7 +421,7 @@ Ox.MapEditor = function(options, self) {
self.$map.resizeMap(); // fixme: don't need event self.$map.resizeMap(); // fixme: don't need event
}, },
*/ */
selectplace: selectPlace select: selectPlace
}); });
self.$placeTitlebar = Ox.Bar({ self.$placeTitlebar = Ox.Bar({
@ -994,12 +996,12 @@ Ox.MapEditor = function(options, self) {
function selectItem(data, place) { function selectItem(data, place) {
// Select item in list // Select item in list
Ox.Log('Map', 'selectItem', data, place);
var isUndefined, selectedPlace; var isUndefined, selectedPlace;
self.options.selected = data.ids.length ? data.ids[0] : ''; self.options.selected = data.ids.length ? data.ids[0] : '';
place = place || ( place = place || (
self.options.selected self.options.selected
? self.$list.value(self.options.selected) : {} ? self.$list.value(self.options.selected)
: {}
); );
isUndefined = !!self.options.selected && !place.type; isUndefined = !!self.options.selected && !place.type;
selectedPlace = self.options.selected && !isUndefined selectedPlace = self.options.selected && !isUndefined
@ -1035,7 +1037,6 @@ Ox.MapEditor = function(options, self) {
function selectPlace(place) { function selectPlace(place) {
// Select place on map // Select place on map
Ox.Log('Map', 'selectPlace', place)
var isResult = !!place.id && place.id[0] == '_', var isResult = !!place.id && place.id[0] == '_',
isUndefined = !!self.options.selected isUndefined = !!self.options.selected
&& !self.$list.value(self.options.selected, 'type'); && !self.$list.value(self.options.selected, 'type');