mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
typeahead: Support custom selection triggers in bootstrap typeahead.
We add support for triggering typeahead_completion on custom keyup events in addition to Tab and Enter. The function `this.trigger_selection` takes the keyup event as its argument and has the same `this` context as the other typeahead functions. This is being added to support partial completion of stream typeahead to directly start the topic_list typeahead.
This commit is contained in:
committed by
Tim Abbott
parent
63e200997d
commit
83cbd62ba1
@@ -28,6 +28,17 @@
|
||||
* choice.
|
||||
*
|
||||
* Our custom changes include all mentions of this.automated.
|
||||
*
|
||||
* 2. Custom selection triggers:
|
||||
*
|
||||
* This adds support for completing a typeahead on custom keyup input. By
|
||||
* default, we only support Tab and Enter to complete a typeahead, but we
|
||||
* have usecases where we want to complete using custom characters like: >.
|
||||
*
|
||||
* If `this.trigger_selection` returns true, we complete the typeahead and
|
||||
* pass the keyup event to the updater.
|
||||
*
|
||||
* Our custom changes include all mentions of this.trigger_selection.
|
||||
* ============================================================ */
|
||||
|
||||
!function($){
|
||||
@@ -51,6 +62,7 @@
|
||||
this.dropup = this.options.dropup
|
||||
this.fixed = this.options.fixed || false;
|
||||
this.automated = this.options.automated || this.automated;
|
||||
this.trigger_selection = this.options.trigger_selection || this.trigger_selection;
|
||||
|
||||
if (this.fixed) {
|
||||
this.$menu.css('position', 'fixed');
|
||||
@@ -86,6 +98,10 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
, trigger_selection: function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
, show: function () {
|
||||
var pos;
|
||||
|
||||
@@ -310,6 +326,10 @@
|
||||
break
|
||||
|
||||
default:
|
||||
if (this.trigger_selection(e)) {
|
||||
if (!this.shown) return;
|
||||
this.select(e);
|
||||
}
|
||||
this.lookup()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user