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