From adb302f8011e7161bb2874bd49cdbac5c79d09c3 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 20 Oct 2021 14:28:49 +0200 Subject: [PATCH] DEV: drops jquery usage un admin-report-chart (#14661) --- .../addon/components/admin-report-chart.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/admin-report-chart.js b/app/assets/javascripts/admin/addon/components/admin-report-chart.js index 7711ca8d3dc..1c4ad1caa3a 100644 --- a/app/assets/javascripts/admin/addon/components/admin-report-chart.js +++ b/app/assets/javascripts/admin/addon/components/admin-report-chart.js @@ -5,6 +5,7 @@ import loadScript from "discourse/lib/load-script"; import { makeArray } from "discourse-common/lib/helpers"; import { number } from "discourse/lib/formatter"; import { schedule } from "@ember/runloop"; +import { bind } from "discourse-common/utils/decorators"; export default Component.extend({ classNames: ["admin-report-chart"], @@ -12,23 +13,16 @@ export default Component.extend({ total: 0, options: null, - init() { - this._super(...arguments); - - this.resizeHandler = () => - discourseDebounce(this, this._scheduleChartRendering, 500); - }, - didInsertElement() { this._super(...arguments); - $(window).on("resize.chart", this.resizeHandler); + window.addEventListener("resize", this._resizeHandler); }, willDestroyElement() { this._super(...arguments); - $(window).off("resize.chart", this.resizeHandler); + window.removeEventListener("resize", this._resizeHandler); this._resetChart(); }, @@ -179,4 +173,9 @@ export default Component.extend({ _applyChartGrouping(model, data, options) { return Report.collapse(model, data, options.chartGrouping); }, + + @bind + _resizeHandler() { + discourseDebounce(this, this._scheduleChartRendering, 500); + }, });