Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to show all suggestions #227

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dist/bloodhound.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.3.1
* typeahead.js 1.3.2
* https://github.com/corejavascript/typeahead.js
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -159,7 +159,7 @@
noop: function() {}
};
}();
var VERSION = "1.3.1";
var VERSION = "1.3.2";
var tokenizers = function() {
"use strict";
return {
Expand Down Expand Up @@ -864,6 +864,12 @@
return that.search(query, sync);
}
},
__ttAdapterAll: function ttAdapterAll() {
var that = this;
return function() {
return that.index.all();
};
},
_loadPrefetch: function loadPrefetch() {
var that = this, deferred, serialized;
deferred = $.Deferred();
Expand Down
4 changes: 2 additions & 2 deletions dist/bloodhound.min.js

Large diffs are not rendered by default.

32 changes: 30 additions & 2 deletions dist/typeahead.bundle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.3.1
* typeahead.js 1.3.2
* https://github.com/corejavascript/typeahead.js
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -159,7 +159,7 @@
noop: function() {}
};
}();
var VERSION = "1.3.1";
var VERSION = "1.3.2";
var tokenizers = function() {
"use strict";
return {
Expand Down Expand Up @@ -864,6 +864,12 @@
return that.search(query, sync);
}
},
__ttAdapterAll: function ttAdapterAll() {
var that = this;
return function() {
return that.index.all();
};
},
_loadPrefetch: function loadPrefetch() {
var that = this, deferred, serialized;
deferred = $.Deferred();
Expand Down Expand Up @@ -1681,6 +1687,7 @@
this.displayFn = getDisplayFn(o.display || o.displayKey);
this.templates = getTemplates(o.templates, this.displayFn);
this.source = o.source.__ttAdapter ? o.source.__ttAdapter() : o.source;
this.sourceAll = o.source.__ttAdapterAll ? o.source.__ttAdapterAll() : o.source;
this.async = _.isUndefined(o.async) ? this.source.length > 2 : !!o.async;
this._resetLastSuggestion();
this.$el = $(o.node).attr("role", "presentation").addClass(this.classes.dataset).addClass(this.classes.dataset + "-" + this.name);
Expand Down Expand Up @@ -1825,6 +1832,10 @@
}
}
},
showAllSuggestions: function showAllSuggestions() {
this._empty();
this._overwrite("", this.sourceAll());
},
cancel: $.noop,
clear: function clear() {
this._empty();
Expand Down Expand Up @@ -2009,6 +2020,13 @@
function destroyDataset(dataset) {
dataset.destroy();
}
},
showAllSuggestions: function showAllSuggestions() {
_.each(this.datasets, showAllSuggestions);
return true;
function showAllSuggestions(dataset) {
dataset.showAllSuggestions();
}
}
});
return Menu;
Expand Down Expand Up @@ -2388,6 +2406,10 @@
destroy: function destroy() {
this.input.destroy();
this.menu.destroy();
},
showAllSuggestions: function showAllSuggestions() {
this.menu.showAllSuggestions();
return this;
}
});
return Typeahead;
Expand Down Expand Up @@ -2563,6 +2585,12 @@
typeahead.destroy();
});
return this;
},
showAllSuggestions: function showAllSuggestions() {
ttEach(this, function(t) {
t.showAllSuggestions();
});
return this;
}
};
$.fn.typeahead = function(method) {
Expand Down
6 changes: 3 additions & 3 deletions dist/typeahead.bundle.min.js

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion dist/typeahead.jquery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.3.1
* typeahead.js 1.3.2
* https://github.com/corejavascript/typeahead.js
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -734,6 +734,7 @@
this.displayFn = getDisplayFn(o.display || o.displayKey);
this.templates = getTemplates(o.templates, this.displayFn);
this.source = o.source.__ttAdapter ? o.source.__ttAdapter() : o.source;
this.sourceAll = o.source.__ttAdapterAll ? o.source.__ttAdapterAll() : o.source;
this.async = _.isUndefined(o.async) ? this.source.length > 2 : !!o.async;
this._resetLastSuggestion();
this.$el = $(o.node).attr("role", "presentation").addClass(this.classes.dataset).addClass(this.classes.dataset + "-" + this.name);
Expand Down Expand Up @@ -878,6 +879,10 @@
}
}
},
showAllSuggestions: function showAllSuggestions() {
this._empty();
this._overwrite("", this.sourceAll());
},
cancel: $.noop,
clear: function clear() {
this._empty();
Expand Down Expand Up @@ -1062,6 +1067,13 @@
function destroyDataset(dataset) {
dataset.destroy();
}
},
showAllSuggestions: function showAllSuggestions() {
_.each(this.datasets, showAllSuggestions);
return true;
function showAllSuggestions(dataset) {
dataset.showAllSuggestions();
}
}
});
return Menu;
Expand Down Expand Up @@ -1441,6 +1453,10 @@
destroy: function destroy() {
this.input.destroy();
this.menu.destroy();
},
showAllSuggestions: function showAllSuggestions() {
this.menu.showAllSuggestions();
return this;
}
});
return Typeahead;
Expand Down Expand Up @@ -1616,6 +1632,12 @@
typeahead.destroy();
});
return this;
},
showAllSuggestions: function showAllSuggestions() {
ttEach(this, function(t) {
t.showAllSuggestions();
});
return this;
}
};
$.fn.typeahead = function(method) {
Expand Down
4 changes: 2 additions & 2 deletions dist/typeahead.jquery.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/bloodhound/bloodhound.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ var Bloodhound = (function() {
}
},

__ttAdapterAll: function ttAdapterAll() {
var that = this;
return function () {
return that.index.all();
}
},

// ### private

_loadPrefetch: function loadPrefetch() {
Expand Down
6 changes: 6 additions & 0 deletions src/typeahead/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var Dataset = (function() {
// use duck typing to see if source is a bloodhound instance by checking
// for the __ttAdapter property; otherwise assume it is a function
this.source = o.source.__ttAdapter ? o.source.__ttAdapter() : o.source;
this.sourceAll = o.source.__ttAdapterAll ? o.source.__ttAdapterAll() : o.source;

// if the async option is undefined, inspect the source signature as
// a hint to figuring out of the source will return async suggestions
Expand Down Expand Up @@ -281,6 +282,11 @@ var Dataset = (function() {
}
},

showAllSuggestions: function showAllSuggestions() {
this._empty();
this._overwrite('', this.sourceAll());
},

// cancel function gets set in #update
cancel: $.noop,

Expand Down
8 changes: 8 additions & 0 deletions src/typeahead/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ var Menu = (function() {
_.each(this.datasets, destroyDataset);

function destroyDataset(dataset) { dataset.destroy(); }
},

showAllSuggestions: function showAllSuggestions() {
_.each(this.datasets, showAllSuggestions);
return true;
function showAllSuggestions(dataset) {
dataset.showAllSuggestions();
}
}
});

Expand Down
7 changes: 7 additions & 0 deletions src/typeahead/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@
});

return this;
},

showAllSuggestions: function showAllSuggestions() {
ttEach(this, function(t) {
t.showAllSuggestions();
});
return this;
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ var Typeahead = (function() {
destroy: function destroy() {
this.input.destroy();
this.menu.destroy();
},

showAllSuggestions: function showAllSuggestions() {
this.menu.showAllSuggestions();
return this;
}
});

Expand Down