fix autocomplete function
This commit is contained in:
parent
7588e81f71
commit
f381c6d786
1 changed files with 24 additions and 28 deletions
|
@ -19,9 +19,7 @@ pandora.ui.findElement = function() {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
pandora.$ui.findInput.options({
|
pandora.$ui.findInput.focusInput(true);
|
||||||
autocomplete: autocompleteFunction()
|
|
||||||
}).focusInput(true);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
] : [], [
|
] : [], [
|
||||||
|
@ -116,12 +114,12 @@ pandora.ui.findElement = function() {
|
||||||
margin: '4px'
|
margin: '4px'
|
||||||
});
|
});
|
||||||
function autocompleteFunction() {
|
function autocompleteFunction() {
|
||||||
return pandora.user.ui.find.conditions.length ? function(value, callback) {
|
var key = !that
|
||||||
var elementValue = that.value(),
|
? pandora.user.ui._findState.key
|
||||||
key = elementValue[pandora.user.ui._list ? 1 : 0],
|
: that.value()[pandora.user.ui._list ? 1 : 0],
|
||||||
findKey = Ox.getObjectById(pandora.site.findKeys, key);
|
findKey = Ox.getObjectById(pandora.site.findKeys, key);
|
||||||
|
return findKey.autocomplete ? function(value, callback) {
|
||||||
value === '' && Ox.Log('', 'Warning: autocomplete function should never be called with empty value');
|
value === '' && Ox.Log('', 'Warning: autocomplete function should never be called with empty value');
|
||||||
if (findKey.autocomplete) {
|
|
||||||
pandora.api.autocomplete({
|
pandora.api.autocomplete({
|
||||||
key: key,
|
key: key,
|
||||||
query: {
|
query: {
|
||||||
|
@ -131,23 +129,21 @@ pandora.ui.findElement = function() {
|
||||||
operator: '&'
|
operator: '&'
|
||||||
},
|
},
|
||||||
range: [0, 20],
|
range: [0, 20],
|
||||||
sort: [{key: 'votes', operator: '-'}],
|
sort: findKey.autocompleteSort,
|
||||||
value: value
|
value: value
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
callback(result.data.items);
|
callback(result.data.items);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
callback([]);
|
|
||||||
}
|
|
||||||
} : null;
|
} : null;
|
||||||
}
|
}
|
||||||
that.updateElement = function() {
|
that.updateElement = function() {
|
||||||
var findState = pandora.user.ui._findState;
|
var findState = pandora.user.ui._findState;
|
||||||
pandora.$ui.findSelect.value(findState.key);
|
pandora.$ui.findSelect.value(findState.key);
|
||||||
pandora.$ui.findInput.options(
|
pandora.$ui.findInput.options(
|
||||||
findState.key == 'advanced'
|
findState.key == 'advanced' ? {
|
||||||
? {placeholder: Ox._('Edit Query...'), value: ''}
|
placeholder: Ox._('Edit Query...'),
|
||||||
: {
|
value: ''
|
||||||
|
} : {
|
||||||
autocomplete: autocompleteFunction(),
|
autocomplete: autocompleteFunction(),
|
||||||
placeholder: '',
|
placeholder: '',
|
||||||
value: findState.value
|
value: findState.value
|
||||||
|
|
Loading…
Reference in a new issue