From a17ce6aeeeb1ed2d5ac951d6a59ef58ac96dbd7c Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 10 Feb 2021 07:47:06 -0800 Subject: [PATCH] js: Convert static/js/feedback_widget.js to ES6 module. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 1 - static/js/bundles/app.js | 1 - static/js/feedback_widget.js | 18 +++++++----------- static/js/global.d.ts | 1 - static/js/hotkey.js | 2 ++ static/js/muting_ui.js | 2 ++ static/js/zcommand.js | 2 ++ 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8dfe9a348a..580bdaa103 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -169,7 +169,6 @@ "echo": false, "emoji_picker": false, "favicon": false, - "feedback_widget": false, "flatpickr": false, "floating_recipient_bar": false, "gear_menu": false, diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index 11823172b7..fb773e8ed6 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -20,7 +20,6 @@ import "../keydown_util"; import "../rtl"; import "../fold_dict"; import "../scroll_util"; -import "../feedback_widget"; import "../localstorage"; import "../drafts"; import "../input_pill"; diff --git a/static/js/feedback_widget.js b/static/js/feedback_widget.js index 7601939d22..4b7b890be8 100644 --- a/static/js/feedback_widget.js +++ b/static/js/feedback_widget.js @@ -1,6 +1,4 @@ -"use strict"; - -const render_feedback_container = require("../templates/feedback_container.hbs"); +import render_feedback_container from "../templates/feedback_container.hbs"; /* @@ -104,15 +102,15 @@ function set_up_handlers() { }); } -exports.is_open = function () { +export function is_open() { return meta.opened; -}; +} -exports.dismiss = function () { +export function dismiss() { animate.fadeOut(); -}; +} -exports.show = function (opts) { +export function show(opts) { if (!opts.populate) { blueslip.error("programmer needs to supply populate callback."); return; @@ -135,6 +133,4 @@ exports.show = function (opts) { opts.populate(meta.$container.find(".feedback_content")); animate.fadeIn(); -}; - -window.feedback_widget = exports; +} diff --git a/static/js/global.d.ts b/static/js/global.d.ts index c9748f67df..290e7544f2 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -42,7 +42,6 @@ declare let echo: any; declare let emoji: any; declare let emoji_picker: any; declare let favicon: any; -declare let feedback_widget: any; declare let floating_recipient_bar: any; declare let gear_menu: any; declare let hashchange: any; diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 0c70530df0..f873f58846 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -2,6 +2,8 @@ const emoji = require("../shared/js/emoji"); +const feedback_widget = require("./feedback_widget"); + function do_narrow_action(action) { action(current_msg_list.selected_id(), {trigger: "hotkey"}); return true; diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index 7130d583a0..ccfc9c088c 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -3,6 +3,8 @@ const render_muted_topic_ui_row = require("../templates/muted_topic_ui_row.hbs"); const render_topic_muted = require("../templates/topic_muted.hbs"); +const feedback_widget = require("./feedback_widget"); + function timestamp_ms() { return Date.now(); } diff --git a/static/js/zcommand.js b/static/js/zcommand.js index 4223043c36..0069f7e80e 100644 --- a/static/js/zcommand.js +++ b/static/js/zcommand.js @@ -2,6 +2,8 @@ const marked = require("../third/marked/lib/marked"); +const feedback_widget = require("./feedback_widget"); + /* What in the heck is a zcommand?