Merge commit '8a2550e7d5cd19e25616087052915e1c9978e0ad'

This commit is contained in:
Eldon Koyle
2016-01-05 17:35:26 -07:00
32 changed files with 547 additions and 559 deletions
+8 -1
View File
@@ -20,6 +20,7 @@ var Bloodhound = (function() {
this.sorter = o.sorter;
this.identify = o.identify;
this.sufficient = o.sufficient;
this.indexRemote = o.indexRemote;
this.local = o.local;
this.remote = o.remote ? new Remote(o.remote) : null;
@@ -132,6 +133,9 @@ var Bloodhound = (function() {
search: function search(query, sync, async) {
var that = this, local;
sync = sync || _.noop;
async = async || _.noop;
local = this.sorter(this.index.search(query));
// return a copy to guarantee no changes within this scope
@@ -159,7 +163,10 @@ var Bloodhound = (function() {
}) && nonDuplicates.push(r);
});
async && async(nonDuplicates);
// #1148: Should Bloodhound index remote datums?
that.indexRemote && that.add(nonDuplicates);
async(nonDuplicates);
}
},
@@ -15,7 +15,9 @@ var oParser = (function() {
identify: _.stringify,
datumTokenizer: null,
queryTokenizer: null,
matchAnyQueryToken: false,
sufficient: 5,
indexRemote: false,
sorter: null,
local: [],
prefetch: null,
+1
View File
@@ -14,6 +14,7 @@ var Remote = (function() {
this.url = o.url;
this.prepare = o.prepare;
this.transform = o.transform;
this.indexResponse = o.indexResponse;
this.transport = new Transport({
cache: o.cache,
+6 -3
View File
@@ -22,6 +22,7 @@ var SearchIndex = window.SearchIndex = (function() {
this.identify = o.identify || _.stringify;
this.datumTokenizer = o.datumTokenizer;
this.queryTokenizer = o.queryTokenizer;
this.matchAnyQueryToken = o.matchAnyQueryToken;
this.reset();
}
@@ -78,7 +79,7 @@ var SearchIndex = window.SearchIndex = (function() {
var node, chars, ch, ids;
// previous tokens didn't share any matches
if (matches && matches.length === 0) {
if (matches && matches.length === 0 && !that.matchAnyQueryToken) {
return false;
}
@@ -96,8 +97,10 @@ var SearchIndex = window.SearchIndex = (function() {
// break early if we find out there are no possible matches
else {
matches = [];
return false;
if (!that.matchAnyQueryToken) {
matches = [];
return false;
}
}
});
+1 -1
View File
@@ -269,8 +269,8 @@ var Dataset = (function() {
// do not render the suggestions as they've become outdated
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;
that.async && that.trigger('asyncReceived', query);
}
+2
View File
@@ -103,6 +103,7 @@ var Menu = (function() {
onSelectableClick = _.bind(this._onSelectableClick, this);
this.$node.on('click.tt', this.selectors.selectable, onSelectableClick);
this.$node.on('mouseover', this.selectors.selectable, function(){ that.setCursor($(this)) });
_.each(this.datasets, function(dataset) {
dataset
@@ -121,6 +122,7 @@ var Menu = (function() {
},
open: function open() {
this.$node.scrollTop(0);
this.$node.addClass(this.classes.open);
},
+3 -3
View File
@@ -159,7 +159,7 @@
return success;
},
// mirror jQuery#val functionality: reads opearte on first match,
// mirror jQuery#val functionality: reads operate on first match,
// write operates on all matches
val: function val(newVal) {
var query;
@@ -170,7 +170,7 @@
}
else {
ttEach(this, function(t) { t.setVal(newVal); });
ttEach(this, function(t) { t.setVal(_.toStr(newVal)); });
return this;
}
},
@@ -186,7 +186,7 @@
};
$.fn.typeahead = function(method) {
// methods that should only act on intialized typeaheads
// methods that should only act on initialized typeaheads
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
}
+2 -2
View File
@@ -192,13 +192,13 @@ var Typeahead = (function() {
_onLeftKeyed: function onLeftKeyed() {
if (this.dir === 'rtl' && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onRightKeyed: function onRightKeyed() {
if (this.dir === 'ltr' && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},