1
0
Fork 0
forked from 0x2620/oxjs

self.setOption ~> that.update

This commit is contained in:
j 2012-05-28 19:35:41 +00:00
commit 005d50c389
56 changed files with 919 additions and 933 deletions

View file

@ -114,6 +114,48 @@ Ox.Map = function(options, self) {
// fixme: width, height
})
.options(options || {})
.update({
find: function() {
self.$findInput
.value(self.options.find)
.triggerEvent('submit', {value: self.options.find});
},
height: function() {
that.$element.css({height: self.options.height + 'px'});
that.resizeMap();
},
places: function() {
addPlaces();
getMapBounds(function(mapBounds) {
if (mapBounds) {
self.map.fitBounds(mapBounds);
} else {
self.map.setZoom(self.minZoom);
self.map.setCenter(new google.maps.LatLng(0, 0));
}
// fixme: the following is just a guess
self.boundsChanged = true;
mapChanged();
});
if (self.options.selected) {
if (getSelectedPlace()) {
selectPlace(self.options.selected);
} else {
self.options.selected = '';
}
}
},
selected: function() {
selectPlace(self.options.selected || null);
},
type: function() {
// ...
},
width: function() {
that.$element.css({width: self.options.width + 'px'});
that.resizeMap();
}
})
.addClass('OxMap')
.bindEvent({
gainfocus: function() {
@ -1402,41 +1444,6 @@ Ox.Map = function(options, self) {
place && self.map.fitBounds(place.bounds);
}
self.setOption = function(key, value) {
if (key == 'find') {
self.$findInput
.value(self.options.find)
.triggerEvent('submit', {value: self.options.find});
} else if (key == 'height' || key == 'width') {
that.$element.css(key, value + 'px');
that.resizeMap();
} else if (key == 'places') {
addPlaces();
getMapBounds(function(mapBounds) {
if (mapBounds) {
self.map.fitBounds(mapBounds);
} else {
self.map.setZoom(self.minZoom);
self.map.setCenter(new google.maps.LatLng(0, 0));
}
// fixme: the following is just a guess
self.boundsChanged = true;
mapChanged();
});
if (self.options.selected) {
if (getSelectedPlace()) {
selectPlace(self.options.selected);
} else {
self.options.selected = '';
}
}
} else if (key == 'selected') {
selectPlace(value || null);
} else if (key == 'type') {
}
};
/*@
addPlace <f> addPlace
(data) -> <u> add place to places