js: Convert static/js/search_pill_widget.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:28:13 -08:00 committed by Tim Abbott
parent 1a8422b152
commit 2a49ce1b6c
10 changed files with 14 additions and 17 deletions

View File

@ -147,7 +147,6 @@
"page_params": false, "page_params": false,
"pointer": false, "pointer": false,
"realm_night_logo": false, "realm_night_logo": false,
"search_pill_widget": false,
"settings_profile_fields": false, "settings_profile_fields": false,
"stream_list": false, "stream_list": false,
"StripeCheckout": false, "StripeCheckout": false,

View File

@ -45,7 +45,7 @@ rewiremock("../../static/js/typing_events").with(typing_events);
const ui_util = {__esModule: true}; const ui_util = {__esModule: true};
rewiremock("../../static/js/ui_util").with(ui_util); rewiremock("../../static/js/ui_util").with(ui_util);
const unread_ops = set_global("unread_ops", {}); const unread_ops = set_global("unread_ops", {});
set_global("search_pill_widget", { rewiremock("../../static/js/search_pill_widget").with({
widget: { widget: {
clear() { clear() {
return true; return true;

View File

@ -26,7 +26,7 @@ rewiremock("../../static/js/ui_util").with({
place_caret_at_end: noop, place_caret_at_end: noop,
}); });
const narrow = set_global("narrow", {}); const narrow = set_global("narrow", {});
set_global("search_pill_widget", { rewiremock("../../static/js/search_pill_widget").with({
widget: { widget: {
getByID: () => true, getByID: () => true,
}, },

View File

@ -113,7 +113,6 @@ rewiremock.enable();
const util = zrequire("util"); const util = zrequire("util");
zrequire("search_pill_widget");
zrequire("unread"); zrequire("unread");
const upload = zrequire("upload"); const upload = zrequire("upload");
const compose = zrequire("compose"); const compose = zrequire("compose");

View File

@ -38,7 +38,6 @@ import "../dropdown_list_widget";
import "../settings_profile_fields"; import "../settings_profile_fields";
import "../settings"; import "../settings";
import "../ui_init"; import "../ui_init";
import "../search_pill_widget";
import "../desktop_integration"; import "../desktop_integration";
// Import styles // Import styles

View File

@ -19,7 +19,6 @@ declare let message_list: any;
declare let narrow: any; declare let narrow: any;
declare let page_params: any; declare let page_params: any;
declare let pointer: any; declare let pointer: any;
declare let search_pill_widget: any;
declare let settings_profile_fields: any; declare let settings_profile_fields: any;
declare let stream_list: any; declare let stream_list: any;
declare let subs: any; declare let subs: any;

View File

@ -20,6 +20,7 @@ const recent_topics = require("./recent_topics");
const resize = require("./resize"); const resize = require("./resize");
const search = require("./search"); const search = require("./search");
const search_pill = require("./search_pill"); const search_pill = require("./search_pill");
const search_pill_widget = require("./search_pill_widget");
const stream_data = require("./stream_data"); const stream_data = require("./stream_data");
const stream_topic_history = require("./stream_topic_history"); const stream_topic_history = require("./stream_topic_history");
const top_left_corner = require("./top_left_corner"); const top_left_corner = require("./top_left_corner");

View File

@ -2,6 +2,7 @@ import {Filter} from "./filter";
import * as message_view_header from "./message_view_header"; import * as message_view_header from "./message_view_header";
import * as narrow_state from "./narrow_state"; import * as narrow_state from "./narrow_state";
import * as search_pill from "./search_pill"; import * as search_pill from "./search_pill";
import * as search_pill_widget from "./search_pill_widget";
import * as search_suggestion from "./search_suggestion"; import * as search_suggestion from "./search_suggestion";
import * as ui_util from "./ui_util"; import * as ui_util from "./ui_util";

View File

@ -1,22 +1,20 @@
"use strict"; import * as hashchange from "./hashchange";
import * as search_pill from "./search_pill";
const hashchange = require("./hashchange"); export let widget;
const search_pill = require("./search_pill");
exports.initialize = function () { export function initialize() {
if (!page_params.search_pills_enabled) { if (!page_params.search_pills_enabled) {
return; return;
} }
const container = $("#search_arrows"); const container = $("#search_arrows");
exports.widget = search_pill.create_pills(container); widget = search_pill.create_pills(container);
exports.widget.onPillRemove(() => { widget.onPillRemove(() => {
if (exports.widget.items().length === 0) { if (widget.items().length === 0) {
hashchange.go_to_location(""); hashchange.go_to_location("");
} }
}); });
exports.widget.createPillonPaste(() => false); widget.createPillonPaste(() => false);
}; }
window.search_pill_widget = exports;

View File

@ -45,6 +45,7 @@ import * as resize from "./resize";
import * as rows from "./rows"; import * as rows from "./rows";
import * as scroll_bar from "./scroll_bar"; import * as scroll_bar from "./scroll_bar";
import * as search from "./search"; import * as search from "./search";
import * as search_pill_widget from "./search_pill_widget";
import * as sent_messages from "./sent_messages"; import * as sent_messages from "./sent_messages";
import * as server_events from "./server_events"; import * as server_events from "./server_events";
import * as settings_panel_menu from "./settings_panel_menu"; import * as settings_panel_menu from "./settings_panel_menu";