add getMatches option to ListMap
This commit is contained in:
parent
aca33124d0
commit
2555dbb4ea
1 changed files with 36 additions and 0 deletions
|
@ -21,6 +21,7 @@ Ox.ListMap = function(options, self) {
|
|||
.defaults({
|
||||
addPlace: null,
|
||||
editPlace: null,
|
||||
getMatches: null,
|
||||
height: 256,
|
||||
labels: false,
|
||||
pageLength: 100,
|
||||
|
@ -539,6 +540,19 @@ Ox.ListMap = function(options, self) {
|
|||
.css({margin: '4px 0 4px 0'})
|
||||
.appendTo(self.$placeForm);
|
||||
|
||||
if (self.options.getMatches) {
|
||||
self.$matchesInput = Ox.Input({
|
||||
disabled: true,
|
||||
id: 'matches',
|
||||
label: 'Matches',
|
||||
labelWidth: 80,
|
||||
type: 'int',
|
||||
width: 240
|
||||
})
|
||||
.css({margin: '8px 0 4px 0'})
|
||||
.appendTo(self.$placeForm);
|
||||
}
|
||||
|
||||
self.$placeStatusbar = Ox.Bar({
|
||||
size: 24
|
||||
});
|
||||
|
@ -725,6 +739,9 @@ Ox.ListMap = function(options, self) {
|
|||
});
|
||||
}
|
||||
});
|
||||
if (keys.indexOf('name') > -1 || keys.indexOf('alternativeNames') > -1) {
|
||||
updateMatches();
|
||||
}
|
||||
}
|
||||
|
||||
function initList(data) {
|
||||
|
@ -790,6 +807,7 @@ Ox.ListMap = function(options, self) {
|
|||
self.$placeForm.values(place).show();
|
||||
self.$areaKmInput.options({value: Ox.formatArea(place.area)});
|
||||
self.$placeButton.options({title: isResult ? 'Add Place' : 'Remove Place'}).show();
|
||||
updateMatches();
|
||||
} else {
|
||||
self.selectedPlace = null;
|
||||
self.$placeTitle.hide();
|
||||
|
@ -823,6 +841,24 @@ Ox.ListMap = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function updateMatches() {
|
||||
var names, place;
|
||||
if (self.options.getMatches) {
|
||||
place = self.$placeForm.values();
|
||||
names = Ox.filter(Ox.merge([place.name], place.alternativeNames), function(name) {
|
||||
return name !== '';
|
||||
});
|
||||
Ox.print('names', names);
|
||||
if (names.length) {
|
||||
self.options.getMatches(names, function(matches) {
|
||||
self.$matchesInput.options({value: matches});
|
||||
});
|
||||
} else {
|
||||
self.$matchesInput.options({value: 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@
|
||||
setOption <f> setOption
|
||||
@*/
|
||||
|
|
Loading…
Reference in a new issue