validate, places
This commit is contained in:
parent
af8244a173
commit
e821a81aa9
|
@ -1987,23 +1987,23 @@ 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) {
|
||||
item.element.bindEvent({
|
||||
validate: function(event, data) {
|
||||
validate(i, data.valid);
|
||||
});
|
||||
Ox.Event.bind(id, 'blur', function(event, data) {
|
||||
},
|
||||
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) {
|
||||
},
|
||||
submit: function(event, data) {
|
||||
self.formIsValid && that.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -4666,15 +4666,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) {
|
||||
|
@ -7292,6 +7290,7 @@ requires
|
|||
geocoder: new google.maps.Geocoder(),
|
||||
selected: -1
|
||||
});
|
||||
if (Ox.isObject(self.options.places[0])) {
|
||||
$.each(self.options.places, function(i, place) {
|
||||
place.bounds = getBounds(),
|
||||
place.center = place.bounds.getCenter();
|
||||
|
@ -7308,19 +7307,36 @@ requires
|
|||
);
|
||||
}
|
||||
});
|
||||
Ox.print('loadMap');
|
||||
Ox.print(self.bounds)
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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.bounds.getCenter(),
|
||||
center: self.center,
|
||||
disableDefaultUI: true,
|
||||
mapTypeId: google.maps.MapTypeId[self.options.type.toUpperCase()],
|
||||
zoom: 0
|
||||
zoom: self.zoom
|
||||
})
|
||||
});
|
||||
if (self.bounds) {
|
||||
self.map.fitBounds(self.bounds);
|
||||
self.center = self.map.getCenter();
|
||||
// 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) {
|
||||
|
@ -7328,6 +7344,8 @@ requires
|
|||
});
|
||||
resize();
|
||||
that.gainFocus();
|
||||
}
|
||||
|
||||
|
||||
function canContain(outerBounds, innerBounds) {
|
||||
var outerSpan = outerBounds.toSpan(),
|
||||
|
@ -7602,7 +7620,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])
|
||||
|
@ -7648,15 +7666,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);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user