|
@@ -700,6 +700,7 @@ jQuery('#typeahead-{$fName}').typeahead({
|
|
|
dataAttr: 'typespecial',
|
|
dataAttr: 'typespecial',
|
|
|
// preload: true,
|
|
// preload: true,
|
|
|
options: {$optionsJson},
|
|
options: {$optionsJson},
|
|
|
|
|
+ preload: true,
|
|
|
render: {
|
|
render: {
|
|
|
item: function(item, escape) {
|
|
item: function(item, escape) {
|
|
|
//console.log('item', item);
|
|
//console.log('item', item);
|
|
@@ -743,15 +744,23 @@ jQuery('#typeahead-{$fName}').typeahead({
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- score: function(search) {
|
|
|
|
|
- var score = this.getScoreFunction(search);
|
|
|
|
|
|
|
+ score: function(query) {
|
|
|
|
|
+ var score = this.getScoreFunction(query);
|
|
|
return function(item) {
|
|
return function(item) {
|
|
|
- //console.log('score:item:', item, ', score:', score(item));
|
|
|
|
|
- return score(item);// score(item) * (1 + Math.min(item.watchers / 100, 1));
|
|
|
|
|
|
|
+ var retScore = 0, lName = item.name.toLowerCase(), lQuery = query.toLowerCase();
|
|
|
|
|
+ if (q + ':' == lName.substr(0, lQuery.length + 1)) {
|
|
|
|
|
+ retScore = 100;
|
|
|
|
|
+ } else if (lName.search(lowerQ) > -1) {
|
|
|
|
|
+ retScore = 90 - lName.search(lQuery);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ retScore = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ //console.log('score: q(', q, ') , retScore(', retScore, '), score:', score(item), 'item.name:', item.name, ' item.id:', item.id);
|
|
|
|
|
+ return retScore;
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
load: function(query, callback) {
|
|
load: function(query, callback) {
|
|
|
- if (!query.length) return callback();
|
|
|
|
|
|
|
+ //if (!query.length) return callback();
|
|
|
$.ajax({
|
|
$.ajax({
|
|
|
url: 'index-ajax.php?_cls=TableAjax&_zasobID={$tblID}&_task=TYPESPECIAL&fldID={$this->fldID}',
|
|
url: 'index-ajax.php?_cls=TableAjax&_zasobID={$tblID}&_task=TYPESPECIAL&fldID={$this->fldID}',
|
|
|
data: 'q=' + encodeURIComponent(query),
|
|
data: 'q=' + encodeURIComponent(query),
|