merge changes from dev

This commit is contained in:
j 2010-12-06 18:43:01 +01:00
commit 79bbc1d75a

View File

@ -1929,24 +1929,24 @@ requires
});
$.each(self.options.items, function(i, item) {
var id = item.element.options('id');
that.append(self.$items[i] = new Ox.FormItem(item))
.append(self.$messages[i] = new Ox.Element().addClass('OxFormMessage'));
// fixme: use widget.bindEvent()
Ox.Event.bind(id, 'validate', function(event, data) {
validate(i, data.valid);
});
Ox.Event.bind(id, 'blur', function(event, data) {
validate(i, data.valid);
if (data.valid) {
self.$messages[i].html('').hide();
} else {
self.$messages[i].html(data.message).show();
}
});
Ox.Event.bind(id, 'submit', function(event, data) {
self.formIsValid && that.submit();
});
item.element.bindEvent({
validate: function(event, data) {
validate(i, data.valid);
},
blur: function(event, data) {
validate(i, data.valid);
if (data.valid) {
self.$messages[i].html('').hide();
} else {
self.$messages[i].html(data.message).show();
}
},
submit: function(event, data) {
self.formIsValid && that.submit();
}
});
});
function getItemPositionById(id) {
@ -4620,15 +4620,13 @@ requires
function findPlace(event, data) {
Ox.print('findPlace', data);
self.$map.find(data.value, function(location) {
if (location) {
that.$label.html(location.name.formatted);
}
self.$map.find(data.value, function(place) {
place && that.$label.html(place.geoname);
})
}
function onSelect(event, data) {
that.$label.html(data.name.formatted);
that.$label.html(data.geoname);
}
function onZoom(event, data) {
@ -7244,42 +7242,62 @@ requires
geocoder: new google.maps.Geocoder(),
selected: -1
});
$.each(self.options.places, function(i, place) {
place.bounds = getBounds(),
place.center = place.bounds.getCenter();
$.extend(place, {
marker: new Marker(place),
polygon: new Polygon(place)
if (Ox.isObject(self.options.places[0])) {
$.each(self.options.places, function(i, place) {
place.bounds = getBounds(),
place.center = place.bounds.getCenter();
$.extend(place, {
marker: new Marker(place),
polygon: new Polygon(place)
});
self.bounds = i == 0 ? getBounds() : self.bounds.union(place.bounds);
self.options.places[i] = place;
function getBounds() {
return new google.maps.LatLngBounds(
new google.maps.LatLng(place.points.southwest[0], place.points.southwest[1]),
new google.maps.LatLng(place.points.northeast[0], place.points.northeast[1])
);
}
});
loadMap();
} else {
self.counter = 0;
$.each(self.options.places, function(i, place) {
getLocationByName(place, function(place) {
Ox.print(self.counter, i, place);
self.options.places[i] = place;
if (self.counter++ == self.options.places.length - 1) {
loadMap();
}
});
});
self.bounds = i == 0 ? getBounds() : self.bounds.union(place.bounds);
self.options.places[i] = place;
function getBounds() {
return new google.maps.LatLngBounds(
new google.maps.LatLng(place.points.southwest[0], place.points.southwest[1]),
new google.maps.LatLng(place.points.northeast[0], place.points.northeast[1])
);
}
function loadMap() {
self.center = self.bounds ? self.bounds.getCenter() : new google.maps.LatLng(0, 0);
self.zoom = 1;
$.extend(self, {
map: new google.maps.Map(that.$element[0], {
center: self.center,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId[self.options.type.toUpperCase()],
zoom: self.zoom
})
});
if (self.bounds) {
self.map.fitBounds(self.bounds);
// self.center = self.map.getCenter();
self.zoom = self.map.getZoom();
}
});
Ox.print('loadMap');
Ox.print(self.bounds)
$.extend(self, {
map: new google.maps.Map(that.$element[0], {
center: self.bounds.getCenter(),
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId[self.options.type.toUpperCase()],
zoom: 0
})
});
self.map.fitBounds(self.bounds);
self.center = self.map.getCenter();
self.zoom = self.map.getZoom();
google.maps.event.addListener(self.map, 'click', click);
google.maps.event.addListener(self.map, 'zoom_changed', zoomChanged);
$.each(self.options.places, function(i, place) {
place.marker.add();
});
resize();
that.gainFocus();
google.maps.event.addListener(self.map, 'click', click);
google.maps.event.addListener(self.map, 'zoom_changed', zoomChanged);
$.each(self.options.places, function(i, place) {
place.marker.add();
});
resize();
that.gainFocus();
}
function canContain(outerBounds, innerBounds) {
var outerSpan = outerBounds.toSpan(),
@ -7554,7 +7572,7 @@ requires
};
}
function Rectangle(area) {
function Rectangle(area) { // fixme: not used
var latlng = {
sw: new google.maps.LatLng(area[0][0], area[0][1]),
ne: new google.maps.LatLng(area[1][0], area[1][1])
@ -7600,15 +7618,15 @@ requires
};
that.find = function(name, callback) {
getLocationByName(name, function(location) {
if (location) {
getLocationByName(name, function(place) {
if (place) {
//self.marker = location.marker.add();
self.polygon && self.polygon.remove();
self.polygon = location.polygon.add();
self.bounds = location.bounds;
self.polygon = place.polygon.add();
self.bounds = place.bounds;
self.map.fitBounds(self.bounds);
}
callback(location);
callback(place);
});
};