mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
typeahead: Fix no-jquery/variable-pattern.
This commit is contained in:
@@ -349,32 +349,32 @@ import {get_string_diff} from "../../src/util";
|
|||||||
render(final_items, matching_items) {
|
render(final_items, matching_items) {
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
||||||
const items = $(final_items).map((_index, item) => {
|
const $items = $(final_items).map((_index, item) => {
|
||||||
const i = $(that.options.item).data("typeahead-value", item);
|
const $i = $(that.options.item).data("typeahead-value", item);
|
||||||
const item_html = i.find("a").html(that.highlighter(item));
|
const $item_html = $i.find("a").html(that.highlighter(item));
|
||||||
|
|
||||||
const option_label_html = that.option_label(matching_items, item);
|
const option_label_html = that.option_label(matching_items, item);
|
||||||
|
|
||||||
if (option_label_html) {
|
if (option_label_html) {
|
||||||
item_html.append(option_label_html).addClass("typeahead-option-label");
|
$item_html.append(option_label_html).addClass("typeahead-option-label");
|
||||||
}
|
}
|
||||||
return i[0];
|
return $i[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
items.first().addClass("active");
|
$items.first().addClass("active");
|
||||||
this.$menu.html(items);
|
this.$menu.html($items);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
const active = this.$menu.find(".active").removeClass("active");
|
const $active = this.$menu.find(".active").removeClass("active");
|
||||||
let next = active.next();
|
let $next = $active.next();
|
||||||
|
|
||||||
if (!next.length) {
|
if (!$next.length) {
|
||||||
next = $(this.$menu.find("li")[0]);
|
$next = $(this.$menu.find("li")[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
next.addClass("active");
|
$next.addClass("active");
|
||||||
|
|
||||||
if (this.options.naturalSearch) {
|
if (this.options.naturalSearch) {
|
||||||
this.set_value();
|
this.set_value();
|
||||||
@@ -382,14 +382,14 @@ import {get_string_diff} from "../../src/util";
|
|||||||
},
|
},
|
||||||
|
|
||||||
prev() {
|
prev() {
|
||||||
const active = this.$menu.find(".active").removeClass("active");
|
const $active = this.$menu.find(".active").removeClass("active");
|
||||||
let prev = active.prev();
|
let $prev = $active.prev();
|
||||||
|
|
||||||
if (!prev.length) {
|
if (!$prev.length) {
|
||||||
prev = this.$menu.find("li").last();
|
$prev = this.$menu.find("li").last();
|
||||||
}
|
}
|
||||||
|
|
||||||
prev.addClass("active");
|
$prev.addClass("active");
|
||||||
|
|
||||||
if (this.options.naturalSearch) {
|
if (this.options.naturalSearch) {
|
||||||
this.set_value();
|
this.set_value();
|
||||||
|
|||||||
Reference in New Issue
Block a user