Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js: Convert static/js/search_pill_widget.js to ES6 module.
Anders Kaseorg2a49ce1b6ca9
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 32e0b52c583..91e1c8053bf 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -147,7 +147,6 @@"page_params": false,"pointer": false,"realm_night_logo": false,- "search_pill_widget": false,"settings_profile_fields": false,"stream_list": false,"StripeCheckout": false,diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.jsindex a82e2bd9c2a..09886b65701 100644--- a/frontend_tests/node_tests/narrow_activate.js+++ b/frontend_tests/node_tests/narrow_activate.js@@ -45,7 +45,7 @@ rewiremock("../../static/js/typing_events").with(typing_events);const ui_util = {__esModule: true};rewiremock("../../static/js/ui_util").with(ui_util);const unread_ops = set_global("unread_ops", {});-set_global("search_pill_widget", {+rewiremock("../../static/js/search_pill_widget").with({widget: {clear() {return true;diff --git a/frontend_tests/node_tests/search.js b/frontend_tests/node_tests/search.jsindex 0a4f508cb01..6207fc831f0 100644--- a/frontend_tests/node_tests/search.js+++ b/frontend_tests/node_tests/search.js@@ -26,7 +26,7 @@ rewiremock("../../static/js/ui_util").with({place_caret_at_end: noop,});const narrow = set_global("narrow", {});-set_global("search_pill_widget", {+rewiremock("../../static/js/search_pill_widget").with({widget: {getByID: () => true,},diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.jsindex e713815e4ae..c5595bab120 100644--- a/frontend_tests/node_tests/ui_init.js+++ b/frontend_tests/node_tests/ui_init.js@@ -113,7 +113,6 @@ rewiremock.enable();const util = zrequire("util");-zrequire("search_pill_widget");zrequire("unread");const upload = zrequire("upload");const compose = zrequire("compose");diff --git a/static/js/bundles/app.js b/static/js/bundles/app.jsindex a8007a71333..c765146648a 100644--- a/static/js/bundles/app.js+++ b/static/js/bundles/app.js@@ -38,7 +38,6 @@ import "../dropdown_list_widget";import "../settings_profile_fields";import "../settings";import "../ui_init";-import "../search_pill_widget";import "../desktop_integration";// Import stylesdiff --git a/static/js/global.d.ts b/static/js/global.d.tsindex 179ce508ad3..62458bee5dd 100644--- a/static/js/global.d.ts+++ b/static/js/global.d.ts@@ -19,7 +19,6 @@ declare let message_list: any;declare let narrow: any;declare let page_params: any;declare let pointer: any;-declare let search_pill_widget: any;declare let settings_profile_fields: any;declare let stream_list: any;declare let subs: any;diff --git a/static/js/narrow.js b/static/js/narrow.jsindex 48c95cefc9c..db13da509a0 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -20,6 +20,7 @@ const recent_topics = require("./recent_topics");const resize = require("./resize");const search = require("./search");const search_pill = require("./search_pill");+const search_pill_widget = require("./search_pill_widget");const stream_data = require("./stream_data");const stream_topic_history = require("./stream_topic_history");const top_left_corner = require("./top_left_corner");diff --git a/static/js/search.js b/static/js/search.jsindex fb685db33b4..9031478c8c9 100644--- a/static/js/search.js+++ b/static/js/search.js@@ -2,6 +2,7 @@ import {Filter} from "./filter";import * as message_view_header from "./message_view_header";import * as narrow_state from "./narrow_state";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 ui_util from "./ui_util";diff --git a/static/js/search_pill_widget.js b/static/js/search_pill_widget.jsindex 3865f28ed66..442d0dfa116 100644--- a/static/js/search_pill_widget.js+++ b/static/js/search_pill_widget.js@@ -1,22 +1,20 @@-"use strict";+import * as hashchange from "./hashchange";+import * as search_pill from "./search_pill";-const hashchange = require("./hashchange");-const search_pill = require("./search_pill");+export let widget;-exports.initialize = function () {+export function initialize() {if (!page_params.search_pills_enabled) {return;}const container = $("#search_arrows");- exports.widget = search_pill.create_pills(container);+ widget = search_pill.create_pills(container);- exports.widget.onPillRemove(() => {- if (exports.widget.items().length === 0) {+ widget.onPillRemove(() => {+ if (widget.items().length === 0) {hashchange.go_to_location("");}});- exports.widget.createPillonPaste(() => false);-};--window.search_pill_widget = exports;+ widget.createPillonPaste(() => false);+}diff --git a/static/js/ui_init.js b/static/js/ui_init.jsindex 556a3b17a1e..ae495ad1f07 100644--- a/static/js/ui_init.js+++ b/static/js/ui_init.js@@ -45,6 +45,7 @@ import * as resize from "./resize";import * as rows from "./rows";import * as scroll_bar from "./scroll_bar";import * as search from "./search";+import * as search_pill_widget from "./search_pill_widget";import * as sent_messages from "./sent_messages";import * as server_events from "./server_events";import * as settings_panel_menu from "./settings_panel_menu";