A platform for community discussion. Free, open, simple.
DEV: apply coding standards to plugins (#10594)
Joffrey JAFFEUXbf88410126f7
diff --git a/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6 b/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6index 24ee6e1e195..a0867791311 100644--- a/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6+++ b/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6@@ -2,15 +2,15 @@ import I18n from "I18n";import { withPluginApi } from "discourse/lib/plugin-api";function initializeDetails(api) {- api.decorateCooked($elem => $("details", $elem), {- id: "discourse-details"+ api.decorateCooked(($elem) => $("details", $elem), {+ id: "discourse-details",});api.addToolbarPopupMenuOptionsCallback(() => {return {action: "insertDetails",icon: "caret-right",- label: "details.title"+ label: "details.title",};});@@ -23,8 +23,8 @@ function initializeDetails(api) {"details_text",{ multiline: false });- }- }+ },+ },});}@@ -33,5 +33,5 @@ export default {initialize() {withPluginApi("0.8.7", initializeDetails);- }+ },};diff --git a/plugins/discourse-details/assets/javascripts/lib/discourse-markdown/details.js.es6 b/plugins/discourse-details/assets/javascripts/lib/discourse-markdown/details.js.es6index 93b5b7bf305..7ad6077673a 100644--- a/plugins/discourse-details/assets/javascripts/lib/discourse-markdown/details.js.es6+++ b/plugins/discourse-details/assets/javascripts/lib/discourse-markdown/details.js.es6@@ -1,6 +1,6 @@const rule = {tag: "details",- before: function(state, tagInfo) {+ before: function (state, tagInfo) {const attrs = tagInfo.attrs;state.push("bbcode_open", "details", 1);state.push("bbcode_open", "summary", 1);@@ -11,9 +11,9 @@ const rule = {state.push("bbcode_close", "summary", -1);},- after: function(state) {+ after: function (state) {state.push("bbcode_close", "details", -1);- }+ },};export function setup(helper) {@@ -22,10 +22,10 @@ export function setup(helper) {"summary[title]","details","details[open]",- "details.elided"+ "details.elided",]);- helper.registerPlugin(md => {+ helper.registerPlugin((md) => {md.block.bbcode.ruler.push("details", rule);});}diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6index dd4050ee712..e304337903f 100644--- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6@@ -40,27 +40,27 @@ export default Component.extend({timezones: [],formats: (this.siteSettings.discourse_local_dates_default_formats || "").split("|")- .filter(f => f),+ .filter((f) => f),timezone: moment.tz.guess(),- date: moment().format(this.dateFormat)+ date: moment().format(this.dateFormat),});},didInsertElement() {this._super(...arguments);- this._setupPicker().then(picker => {+ this._setupPicker().then((picker) => {this._picker = picker;this.send("focusFrom");});},@observes("markup")- _renderPreview: discourseDebounce(function() {+ _renderPreview: discourseDebounce(function () {const markup = this.markup;if (markup) {- cookAsync(markup).then(result => {+ cookAsync(markup).then((result) => {this.set("currentPreview", result);schedule("afterRender", () =>this.$(".preview .discourse-local-date").applyLocalDates()@@ -121,7 +121,7 @@ export default Component.extend({time,dateTime,format,- range: isRange ? "start" : false+ range: isRange ? "start" : false,});},@@ -154,7 +154,7 @@ export default Component.extend({time,dateTime,format,- range: isRange ? "end" : false+ range: isRange ? "end" : false,});},@@ -164,7 +164,7 @@ export default Component.extend({recurring,timezones,timezone,- format+ format,});},@@ -177,7 +177,7 @@ export default Component.extend({return EmberObject.create({from: fromConfig,to: toConfig,- options+ options,});},@@ -198,18 +198,15 @@ export default Component.extend({@computed("currentUserTimezone")formatedCurrentUserTimezone(timezone) {- return timezone- .replace("_", " ")- .replace("Etc/", "")- .split("/");+ return timezone.replace("_", " ").replace("Etc/", "").split("/");},@computed("formats")previewedFormats(formats) {- return formats.map(format => {+ return formats.map((format) => {return {format: format,- preview: moment().format(format)+ preview: moment().format(format),};});},@@ -221,36 +218,36 @@ export default Component.extend({return [{name: I18n.t(`${key}.every_day`),- id: "1.days"+ id: "1.days",},{name: I18n.t(`${key}.every_week`),- id: "1.weeks"+ id: "1.weeks",},{name: I18n.t(`${key}.every_two_weeks`),- id: "2.weeks"+ id: "2.weeks",},{name: I18n.t(`${key}.every_month`),- id: "1.months"+ id: "1.months",},{name: I18n.t(`${key}.every_two_months`),- id: "2.months"+ id: "2.months",},{name: I18n.t(`${key}.every_three_months`),- id: "3.months"+ id: "3.months",},{name: I18n.t(`${key}.every_six_months`),- id: "6.months"+ id: "6.months",},{name: I18n.t(`${key}.every_year`),- id: "1.years"- }+ id: "1.years",+ },];},@@ -360,7 +357,7 @@ export default Component.extend({cancel() {this._closeModal();- }+ },},_setTimeIfValid(time, key) {@@ -375,7 +372,7 @@ export default Component.extend({},_setupPicker() {- return new Promise(resolve => {+ return new Promise((resolve) => {loadScript("/javascripts/pikaday.js").then(() => {const options = {field: this.$(`.fake-input`)[0],@@ -391,9 +388,9 @@ export default Component.extend({nextMonth: I18n.t("dates.next_month"),months: moment.months(),weekdays: moment.weekdays(),- weekdaysShort: moment.weekdaysMin()+ weekdaysShort: moment.weekdaysMin(),},- onSelect: date => {+ onSelect: (date) => {const formattedDate = moment(date).format("YYYY-MM-DD");if (this.fromSelected) {@@ -403,7 +400,7 @@ export default Component.extend({if (this.toSelected) {this.set("toDate", formattedDate);}- }+ },};resolve(new Pikaday(options));@@ -434,5 +431,5 @@ export default Component.extend({_closeModal() {const composer = Discourse.__container__.lookup("controller:composer");composer.send("closeModal");- }+ },});diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/controllers/discourse-local-dates-create-modal.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/controllers/discourse-local-dates-create-modal.js.es6index 103ac02adcd..a27b641a9bc 100644--- a/plugins/discourse-local-dates/assets/javascripts/discourse/controllers/discourse-local-dates-create-modal.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/discourse/controllers/discourse-local-dates-create-modal.js.es6@@ -17,5 +17,5 @@ export default Controller.extend(ModalFunctionality, {);localDatesBtn && localDatesBtn.focus();});- }+ },});diff --git a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6 b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6index 7b3faee0c3c..7ed27566352 100644--- a/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/initializers/discourse-local-dates.js.es6@@ -13,18 +13,18 @@ const DATE_TEMPLATE = `function initializeDiscourseLocalDates(api) {api.decorateCooked(- $elem => $(".discourse-local-date", $elem).applyLocalDates(),+ ($elem) => $(".discourse-local-date", $elem).applyLocalDates(),{ id: "discourse-local-date" });- api.onToolbarCreate(toolbar => {+ api.onToolbarCreate((toolbar) => {toolbar.addButton({title: "discourse_local_dates.title",id: "local-dates",group: "extras",icon: "calendar-alt",- sendAction: event =>- toolbar.context.send("insertDiscourseLocalDate", event)+ sendAction: (event) =>+ toolbar.context.send("insertDiscourseLocalDate", event),});});@@ -32,10 +32,10 @@ function initializeDiscourseLocalDates(api) {actions: {insertDiscourseLocalDate(toolbarEvent) {showModal("discourse-local-dates-create-modal").setProperties({- toolbarEvent+ toolbarEvent,});- }- }+ },+ },});}@@ -45,8 +45,8 @@ export default {initialize(container) {const siteSettings = container.lookup("site-settings:main");if (siteSettings.discourse_local_dates_enabled) {- $.fn.applyLocalDates = function() {- return this.each(function() {+ $.fn.applyLocalDates = function () {+ return this.each(function () {const opts = {};const dataset = this.dataset;opts.time = dataset.time;@@ -70,7 +70,7 @@ export default {moment.tz.guess()).build();- const htmlPreviews = localDateBuilder.previews.map(preview => {+ const htmlPreviews = localDateBuilder.previews.map((preview) => {const previewNode = document.createElement("div");previewNode.classList.add("preview");if (preview.current) {@@ -92,7 +92,7 @@ export default {const previewsNode = document.createElement("div");previewsNode.classList.add("locale-dates-previews");- htmlPreviews.forEach(htmlPreview =>+ htmlPreviews.forEach((htmlPreview) =>previewsNode.appendChild(htmlPreview));@@ -110,5 +110,5 @@ export default {withPluginApi("0.8.8", initializeDiscourseLocalDates);}- }+ },};diff --git a/plugins/discourse-local-dates/assets/javascripts/lib/date-with-zone-helper.js.es6 b/plugins/discourse-local-dates/assets/javascripts/lib/date-with-zone-helper.js.es6index 9ffc6edb173..eacbcba47f1 100644--- a/plugins/discourse-local-dates/assets/javascripts/lib/date-with-zone-helper.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/lib/date-with-zone-helper.js.es6@@ -25,7 +25,7 @@ export default class DateWithZoneHelper {"day","hour","minute",- "second"+ "second",]),this.timezone);@@ -79,7 +79,7 @@ export default class DateWithZoneHelper {minute: datetime.minute(),second: datetime.second(),timezone,- localTimezone+ localTimezone,});}diff --git a/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6 b/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6index d4e526c787a..f954cf5c684 100644--- a/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6@@ -10,7 +10,7 @@ function addLocalDate(buffer, matches, state) {format: null,timezones: null,displayedTimezone: null,- countdown: null+ countdown: null,};const matchString = matches[1].replace(/„|“/g, '"');@@ -64,14 +64,14 @@ function addLocalDate(buffer, matches, state) {if (config.countdown) {token.attrs.push(["data-countdown",- state.md.utils.escapeHtml(config.countdown)+ state.md.utils.escapeHtml(config.countdown),]);}if (config.calendar) {token.attrs.push(["data-calendar",- state.md.utils.escapeHtml(config.calendar)+ state.md.utils.escapeHtml(config.calendar),]);}@@ -81,25 +81,25 @@ function addLocalDate(buffer, matches, state) {) {token.attrs.push(["data-displayed-timezone",- state.md.utils.escapeHtml(config.displayedTimezone)+ state.md.utils.escapeHtml(config.displayedTimezone),]);}if (config.timezones) {- const timezones = config.timezones.split("|").filter(timezone => {+ const timezones = config.timezones.split("|").filter((timezone) => {return moment.tz.names().includes(timezone);});token.attrs.push(["data-timezones",- state.md.utils.escapeHtml(timezones.join("|"))+ state.md.utils.escapeHtml(timezones.join("|")),]);}if (config.timezone && moment.tz.names().includes(config.timezone)) {token.attrs.push(["data-timezone",- state.md.utils.escapeHtml(config.timezone)+ state.md.utils.escapeHtml(config.timezone),]);dateTime = moment.tz(dateTime, config.timezone);} else {@@ -109,7 +109,7 @@ function addLocalDate(buffer, matches, state) {if (config.recurring) {token.attrs.push(["data-recurring",- state.md.utils.escapeHtml(config.recurring)+ state.md.utils.escapeHtml(config.recurring),]);}@@ -141,7 +141,7 @@ export function setup(helper) {helper.whiteList(["span.discourse-local-date","span[data-*]",- "span[aria-label]"+ "span[aria-label]",]);helper.registerOptions((opts, siteSettings) => {@@ -152,10 +152,10 @@ export function setup(helper) {] = !!siteSettings.discourse_local_dates_enabled;});- helper.registerPlugin(md => {+ helper.registerPlugin((md) => {const rule = {matcher: /\[date(=.+?)\]/,- onMatch: addLocalDate+ onMatch: addLocalDate,};md.core.textPostProcess.ruler.push("discourse-local-dates", rule);diff --git a/plugins/discourse-local-dates/assets/javascripts/lib/local-date-builder.js.es6 b/plugins/discourse-local-dates/assets/javascripts/lib/local-date-builder.js.es6index f75f0b68825..2f4ca8eeb43 100644--- a/plugins/discourse-local-dates/assets/javascripts/lib/local-date-builder.js.es6+++ b/plugins/discourse-local-dates/assets/javascripts/lib/local-date-builder.js.es6@@ -23,10 +23,10 @@ export default class LocalDateBuilder {}build() {- const [year, month, day] = this.date.split("-").map(x => parseInt(x, 10));+ const [year, month, day] = this.date.split("-").map((x) => parseInt(x, 10));const [hour, minute, second] = (this.time || "").split(":")- .map(x => (x ? parseInt(x, 10) : undefined));+ .map((x) => (x ? parseInt(x, 10) : undefined));let displayedTimezone;if (this.time) {@@ -44,7 +44,7 @@ export default class LocalDateBuilder {minute,second,timezone: this.timezone,- localTimezone: this.localTimezone+ localTimezone: this.localTimezone,});if (this.recurring) {@@ -66,13 +66,13 @@ export default class LocalDateBuilder {moment.tz(this.localTimezone).isAfter(localDate.datetime),formated: this._applyFormatting(localDate, displayedTimezone),previews,- textPreview: this._generateTextPreviews(previews)+ textPreview: this._generateTextPreviews(previews),};}_generateTextPreviews(previews) {return previews- .map(preview => {+ .map((preview) => {const formatedZone = this._zoneWithoutPrefix(preview.timezone);return `${formatedZone} ${preview.formated}`;})@@ -83,7 +83,7 @@ export default class LocalDateBuilder {const previewedTimezones = [];const timezones = this.timezones.filter(- timezone => !this._isEqualZones(timezone, this.localTimezone)+ (timezone) => !this._isEqualZones(timezone, this.localTimezone));previewedTimezones.push({@@ -96,7 +96,7 @@ export default class LocalDateBuilder {this.localTimezone),this.time- )+ ),});if (@@ -104,12 +104,12 @@ export default class LocalDateBuilder {displayedTimezone === this.localTimezone &&this.timezone !== displayedTimezone &&!this._isEqualZones(displayedTimezone, this.timezone) &&- !this.timezones.any(t => this._isEqualZones(t, this.timezone))+ !this.timezones.any((t) => this._isEqualZones(t, this.timezone))) {timezones.unshift(this.timezone);}- timezones.forEach(timezone => {+ timezones.forEach((timezone) => {if (this._isEqualZones(timezone, displayedTimezone)) {return;}@@ -127,7 +127,7 @@ export default class LocalDateBuilder {timezone),this.time- )+ ),});});@@ -158,7 +158,7 @@ export default class LocalDateBuilder {return [startRange.format("LLLL"),RANGE_SEPARATOR,- endRange.format("LLLL")+ endRange.format("LLLL"),].join(" ");}}@@ -209,19 +209,19 @@ export default class LocalDateBuilder {sameDay: this._translateCalendarKey(time, "today"),nextDay: this._translateCalendarKey(time, "tomorrow"),lastDay: this._translateCalendarKey(time, "yesterday"),- sameElse: "L"+ sameElse: "L",};}_translateCalendarKey(time, key) {const translated = I18n.t(`discourse_local_dates.relative_dates.${key}`, {- time: "LT"+ time: "LT",});if (time) {return translated.split("LT")- .map(w => `[${w}]`)+ .map((w) => `[${w}]`).join("LT");} else {return `[${translated.replace(" LT", "")}]`;@@ -229,10 +229,7 @@ export default class LocalDateBuilder {}_formatTimezone(timezone) {- return timezone- .replace("_", " ")- .replace("Etc/", "")- .split("/");+ return timezone.replace("_", " ").replace("Etc/", "").split("/");}_zoneWithoutPrefix(timezone) {diff --git a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6 b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6index cc4c3d1bc13..09a180bc9a1 100644--- a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6+++ b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6@@ -10,7 +10,7 @@ function initialize(api) {didInsertElement() {this._super(...arguments);this.dispatch("header:search-context-trigger", "header");- }+ },});api.modifyClass("model:post", {@@ -22,21 +22,21 @@ function initialize(api) {if (this.user_id === discobotUserId && !this.bookmarked) {return ajax("/bookmarks", {type: "POST",- data: { post_id: this.id }- }).then(response => {+ data: { post_id: this.id },+ }).then((response) => {this.setProperties({"topic.bookmarked": true,bookmarked: true,- bookmark_id: response.id+ bookmark_id: response.id,});this.appEvents.trigger("post-stream:refresh", { id: this.id });});}return this._super();- }+ },});- api.attachWidgetAction("header", "headerSearchContextTrigger", function() {+ api.attachWidgetAction("header", "headerSearchContextTrigger", function () {if (this.site.mobileView) {this.state.skipSearchContext = false;} else {@@ -59,5 +59,5 @@ export default {const siteSettings = container.lookup("site-settings:main");if (siteSettings.discourse_narrative_bot_enabled)withPluginApi("0.8.7", initialize);- }+ },};diff --git a/plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6index 39e7e8ebf77..398eaa17a34 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/components/composer-presence-display.js.es6@@ -4,14 +4,14 @@ import { equal, gt } from "@ember/object/computed";import { inject as service } from "@ember/service";import discourseComputed, {observes,- on+ on,} from "discourse-common/utils/decorators";import {REPLYING,CLOSED,EDITING,COMPOSER_TYPE,- KEEP_ALIVE_DURATION_SECONDS+ KEEP_ALIVE_DURATION_SECONDS,} from "discourse/plugins/discourse-presence/discourse/lib/presence";import { REPLY, EDIT } from "discourse/models/composer";@@ -74,7 +74,7 @@ export default Component.extend({state: action === EDIT ? EDITING : REPLYING,whisper: this.get("model.whisper"),postId: this.get("model.post.id"),- presenceStaffOnly: this.get("model._presenceStaffOnly")+ presenceStaffOnly: this.get("model._presenceStaffOnly"),};this._prevPublishData = data;@@ -118,5 +118,5 @@ export default Component.extend({cancel(this._throttle);this._throttle = null;}- }+ },});diff --git a/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6index b64fd93c38e..4600eef460a 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/components/topic-presence-display.js.es6@@ -23,5 +23,5 @@ export default Component.extend({@on("willDestroyElement")_destroyed() {this.presenceManager.unsubscribe(this.get("topic.id"), TOPIC_TYPE);- }+ },});diff --git a/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6index 1bc90d93ca4..7b1fb0058f0 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/lib/presence.js.es6@@ -44,7 +44,7 @@ const Presence = EmberObject.extend({this.setProperties({users: [],editingUsers: [],- subscribers: new Set()+ subscribers: new Set(),});},@@ -52,7 +52,7 @@ const Presence = EmberObject.extend({if (this.subscribers.size === 0) {this.messageBus.subscribe(this.channel,- message => {+ (message) => {const { user, state } = message;if (this.get("currentUser.id") === user.id) return;@@ -62,7 +62,7 @@ const Presence = EmberObject.extend({break;case EDITING:this._appendUser(this.editingUsers, user, {- post_id: parseInt(message.post_id, 10)+ post_id: parseInt(message.post_id, 10),});break;case CLOSED:@@ -87,7 +87,7 @@ const Presence = EmberObject.extend({this.setProperties({users: [],- editingUsers: []+ editingUsers: [],});}@@ -104,7 +104,7 @@ const Presence = EmberObject.extend({const data = {state,- topic_id: this.topicId+ topic_id: this.topicId,};if (whisper) {@@ -121,22 +121,22 @@ const Presence = EmberObject.extend({return ajax("/presence/publish", {type: "POST",- data+ data,});},_removeUser(user) {- [this.users, this.editingUsers].forEach(users => {+ [this.users, this.editingUsers].forEach((users) => {const existingUser = users.findBy("id", user.id);if (existingUser) users.removeObject(existingUser);});},_cleanUpUsers() {- [this.users, this.editingUsers].forEach(users => {+ [this.users, this.editingUsers].forEach((users) => {const staleUsers = [];- users.forEach(user => {+ users.forEach((user) => {if (user.last_seen <= Date.now() - BUFFER_DURATION_SECONDS * 1000) {staleUsers.push(user);}@@ -152,7 +152,7 @@ const Presence = EmberObject.extend({let existingUser;let usersLength = 0;- users.forEach(u => {+ users.forEach((u) => {if (u.id === user.id) {existingUser = u;}@@ -204,7 +204,7 @@ const Presence = EmberObject.extend({if (!this._timer) {this.set("_timer", this._scheduleTimer(callback));}- }+ },});export default Presence;diff --git a/plugins/discourse-presence/assets/javascripts/discourse/services/presence-manager.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/services/presence-manager.js.es6index 11b6c9e5e75..3968289c54c 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/services/presence-manager.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/services/presence-manager.js.es6@@ -1,6 +1,6 @@import Service from "@ember/service";import Presence, {- CLOSED+ CLOSED,} from "discourse/plugins/discourse-presence/discourse/lib/presence";const PresenceManager = Service.extend({@@ -10,7 +10,7 @@ const PresenceManager = Service.extend({this._super(...arguments);this.setProperties({- presences: {}+ presences: {},});},@@ -49,7 +49,7 @@ const PresenceManager = Service.extend({},cleanUpPresence(type) {- Object.keys(this.presences).forEach(key => {+ Object.keys(this.presences).forEach((key) => {this.publish(key, CLOSED);this.unsubscribe(key, type);});@@ -61,12 +61,12 @@ const PresenceManager = Service.extend({messageBus: this.messageBus,siteSettings: this.siteSettings,currentUser: this.currentUser,- topicId+ topicId,});}return this.presences[topicId];- }+ },});export default PresenceManager;diff --git a/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/composer-fields/presence.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/composer-fields/presence.js.es6index 5165da1a212..75ca86b4a4a 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/composer-fields/presence.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/composer-fields/presence.js.es6@@ -1,5 +1,5 @@export default {shouldRender(_, component) {return component.siteSettings.presence_enabled;- }+ },};diff --git a/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/topic-above-footer-buttons/presence.js.es6 b/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/topic-above-footer-buttons/presence.js.es6index 5165da1a212..75ca86b4a4a 100644--- a/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/topic-above-footer-buttons/presence.js.es6+++ b/plugins/discourse-presence/assets/javascripts/discourse/templates/connectors/topic-above-footer-buttons/presence.js.es6@@ -1,5 +1,5 @@export default {shouldRender(_, component) {return component.siteSettings.presence_enabled;- }+ },};diff --git a/plugins/lazy-yt/assets/javascripts/initializers/lazyYT.js.es6 b/plugins/lazy-yt/assets/javascripts/initializers/lazyYT.js.es6index 3d913e77c02..16c63d01d26 100644--- a/plugins/lazy-yt/assets/javascripts/initializers/lazyYT.js.es6+++ b/plugins/lazy-yt/assets/javascripts/initializers/lazyYT.js.es6@@ -3,9 +3,9 @@ import { withPluginApi } from "discourse/lib/plugin-api";export default {name: "apply-lazyYT",initialize() {- withPluginApi("0.1", api => {+ withPluginApi("0.1", (api) => {api.decorateCooked(- $elem => {+ ($elem) => {const iframes = $(".lazyYT", $elem);if (iframes.length === 0) {return;@@ -21,11 +21,11 @@ export default {if (postId) {api.preventCloak(postId);}- }+ },});},{ id: "discourse-lazyyt" });});- }+ },};diff --git a/plugins/lazy-yt/assets/javascripts/lazyYT.js b/plugins/lazy-yt/assets/javascripts/lazyYT.jsindex 101196b6c21..c211db581dc 100644--- a/plugins/lazy-yt/assets/javascripts/lazyYT.js+++ b/plugins/lazy-yt/assets/javascripts/lazyYT.js@@ -11,7 +11,7 @@**/-(function($) {+(function ($) {"use strict";function setUp($el, settings) {@@ -91,7 +91,7 @@$el.css({- "padding-bottom": padding_bottom+ "padding-bottom": padding_bottom,}).html(innerHtml.join(""));@@ -123,7 +123,7 @@id,"/",thumb_img,- '">'+ '">',].join("")));@@ -132,7 +132,7 @@$thumb = $el.find(".ytp-thumbnail").addClass("lazyYT-image-loaded")- .on("click", function(e) {+ .on("click", function (e) {e.preventDefault();if (@@ -156,15 +156,15 @@});}- $.fn.lazyYT = function(newSettings) {+ $.fn.lazyYT = function (newSettings) {var defaultSettings = {default_ratio: "16:9",callback: null, // ToDO execute callback if given- container_class: "lazyYT-container"+ container_class: "lazyYT-container",};var settings = $.extend(defaultSettings, newSettings);- return this.each(function() {+ return this.each(function () {var $el = $(this).addClass(settings.container_class);setUp($el, settings);});diff --git a/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6 b/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6index ea9a34559dc..96e93c3a870 100644--- a/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6+++ b/plugins/poll/assets/javascripts/components/poll-breakdown-chart.js.es6@@ -86,9 +86,9 @@ export default Component.extend({// TODO: It's a workaround for Chart.js' terrible hover styling.// It will break on non-white backgrounds.// Should be updated after #10341 lands- hoverBorderColor: "#fff"- }- ]+ hoverBorderColor: "#fff",+ },+ ],},options: {plugins: {@@ -98,13 +98,13 @@ export default Component.extend({borderRadius: 2,font: {family: getComputedStyle(document.body).fontFamily,- size: 16+ size: 16,},padding: {top: 2,right: 6,bottom: 2,- left: 6+ left: 6,},formatter(votes) {if (displayMode !== "percentage") {@@ -112,12 +112,12 @@ export default Component.extend({}const percent = I18n.toNumber((votes / totalVotes) * 100.0, {- precision: 1+ precision: 1,});return `${percent}%`;- }- }+ },+ },},responsive: true,aspectRatio: 1.1,@@ -131,15 +131,15 @@ export default Component.extend({const sliceIndex = activeElements[0]._index;const optionIndex = Object.keys(this._optionToSlice).find(- option => this._optionToSlice[option] === sliceIndex+ (option) => this._optionToSlice[option] === sliceIndex);// Clear the array to avoid issues in Chart.jsactiveElements.length = 0;this.setHighlightedOption(Number(optionIndex));- }- }+ },+ },};},@@ -178,5 +178,5 @@ export default Component.extend({this._previousHighlightedSliceIndex = sliceIndex;meta.controller.setHoverStyle(slice);this._chart.draw();- }+ },});diff --git a/plugins/poll/assets/javascripts/components/poll-breakdown-option.js.es6 b/plugins/poll/assets/javascripts/components/poll-breakdown-option.js.es6index f1816b13f95..0a02c79c6e4 100644--- a/plugins/poll/assets/javascripts/components/poll-breakdown-option.js.es6+++ b/plugins/poll/assets/javascripts/components/poll-breakdown-option.js.es6@@ -57,5 +57,5 @@ export default Component.extend({} else {this.onMouseOut();}- }+ },});diff --git a/plugins/poll/assets/javascripts/controllers/poll-breakdown.js.es6 b/plugins/poll/assets/javascripts/controllers/poll-breakdown.js.es6index f5cb61bcba4..6a47eeeaa93 100644--- a/plugins/poll/assets/javascripts/controllers/poll-breakdown.js.es6+++ b/plugins/poll/assets/javascripts/controllers/poll-breakdown.js.es6@@ -17,7 +17,7 @@ export default Controller.extend(ModalFunctionality, {@discourseComputed("model.groupableUserFields")groupableUserFields(fields) {- return fields.map(field => {+ return fields.map((field) => {const transformed = field.split("_").filter(Boolean);if (transformed.length > 1) {@@ -51,17 +51,17 @@ export default Controller.extend(ModalFunctionality, {data: {post_id: this.model.post.id,poll_name: this.model.poll.name,- user_field_name: this.groupedBy- }+ user_field_name: this.groupedBy,+ },})- .catch(error => {+ .catch((error) => {if (error) {popupAjaxError(error);} else {bootbox.alert(I18n.t("poll.error_while_fetching_voters"));}})- .then(result => {+ .then((result) => {if (this.isDestroying || this.isDestroyed) {return;}@@ -79,5 +79,5 @@ export default Controller.extend(ModalFunctionality, {@actiononSelectPanel(panel) {this.set("displayMode", panel.id);- }+ },});diff --git a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6index 7c2c9e11180..54965041da6 100644--- a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6+++ b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6@@ -18,12 +18,12 @@ export default Controller.extend({pollChartTypes: [{name: I18n.t("poll.ui_builder.poll_chart_type.bar"),- value: BAR_CHART_TYPE+ value: BAR_CHART_TYPE,},{name: I18n.t("poll.ui_builder.poll_chart_type.pie"),- value: PIE_CHART_TYPE- }+ value: PIE_CHART_TYPE,+ },],pollType: null,@@ -39,16 +39,16 @@ export default Controller.extend({return [{name: I18n.t("poll.ui_builder.poll_type.regular"),- value: regularPollType+ value: regularPollType,},{name: I18n.t("poll.ui_builder.poll_type.number"),- value: numberPollType+ value: numberPollType,},{name: I18n.t("poll.ui_builder.poll_type.multiple"),- value: multiplePollType- }+ value: multiplePollType,+ },];},@@ -72,21 +72,21 @@ export default Controller.extend({let options = [{name: I18n.t("poll.ui_builder.poll_result.always"),- value: alwaysPollResult+ value: alwaysPollResult,},{name: I18n.t("poll.ui_builder.poll_result.vote"),- value: votePollResult+ value: votePollResult,},{name: I18n.t("poll.ui_builder.poll_result.closed"),- value: closedPollResult- }+ value: closedPollResult,+ },];if (this.get("currentUser.staff")) {options.push({name: I18n.t("poll.ui_builder.poll_result.staff"),- value: staffPollResult+ value: staffPollResult,});}return options;@@ -95,7 +95,7 @@ export default Controller.extend({@discourseComputed("site.groups")siteGroups(groups) {return groups- .map(g => {+ .map((g) => {// prevents group "everyone" to be listedif (g.id !== 0) {return { name: g.name };@@ -130,7 +130,7 @@ export default Controller.extend({let length = 0;- pollOptions.split("\n").forEach(option => {+ pollOptions.split("\n").forEach((option) => {if (option.length !== 0) length += 1;});@@ -267,7 +267,7 @@ export default Controller.extend({output += `${pollHeader}\n`;if (pollOptions.length > 0 && !isNumber) {- pollOptions.split("\n").forEach(option => {+ pollOptions.split("\n").forEach((option) => {if (option.length !== 0) output += `* ${option}\n`;});}@@ -299,7 +299,7 @@ export default Controller.extend({if (pollMin >= pollMax) {options = {failed: true,- reason: I18n.t("poll.ui_builder.help.invalid_values")+ reason: I18n.t("poll.ui_builder.help.invalid_values"),};}@@ -313,7 +313,7 @@ export default Controller.extend({if (pollStep < 1) {options = {failed: true,- reason: I18n.t("poll.ui_builder.help.min_step_value")+ reason: I18n.t("poll.ui_builder.help.min_step_value"),};}@@ -327,7 +327,7 @@ export default Controller.extend({if (disableInsert) {options = {failed: true,- reason: I18n.t("poll.ui_builder.help.options_count")+ reason: I18n.t("poll.ui_builder.help.options_count"),};}@@ -335,9 +335,9 @@ export default Controller.extend({},_comboboxOptions(startIndex, endIndex) {- return [...Array(endIndex - startIndex).keys()].map(number => ({+ return [...Array(endIndex - startIndex).keys()].map((number) => ({value: number + startIndex,- name: number + startIndex+ name: number + startIndex,}));},@@ -353,12 +353,8 @@ export default Controller.extend({chartType: BAR_CHART_TYPE,pollResult: this.alwaysPollResult,pollGroups: null,- date: moment()- .add(1, "day")- .format("YYYY-MM-DD"),- time: moment()- .add(1, "hour")- .format("HH:mm")+ date: moment().add(1, "day").format("YYYY-MM-DD"),+ time: moment().add(1, "hour").format("HH:mm"),});},@@ -367,6 +363,6 @@ export default Controller.extend({this.toolbarEvent.addText(this.pollOutput);this.send("closeModal");this._setupPoll();- }- }+ },+ },});diff --git a/plugins/poll/assets/javascripts/initializers/add-poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/initializers/add-poll-ui-builder.js.es6index eae72fff0b0..d920848db99 100644--- a/plugins/poll/assets/javascripts/initializers/add-poll-ui-builder.js.es6+++ b/plugins/poll/assets/javascripts/initializers/add-poll-ui-builder.js.es6@@ -22,8 +22,8 @@ function initializePollUIBuilder(api) {actions: {showPollBuilder() {showModal("poll-ui-builder").set("toolbarEvent", this.toolbarEvent);- }- }+ },+ },});api.addToolbarPopupMenuOptionsCallback(() => {@@ -31,7 +31,7 @@ function initializePollUIBuilder(api) {action: "showPollBuilder",icon: "chart-bar",label: "poll.ui_builder.title",- condition: "canBuildPoll"+ condition: "canBuildPoll",};});}@@ -41,5 +41,5 @@ export default {initialize() {withPluginApi("0.8.7", initializePollUIBuilder);- }+ },};diff --git a/plugins/poll/assets/javascripts/initializers/extend-for-poll.js.es6 b/plugins/poll/assets/javascripts/initializers/extend-for-poll.js.es6index 25bfb5fc8b9..d8a2262b807 100644--- a/plugins/poll/assets/javascripts/initializers/extend-for-poll.js.es6+++ b/plugins/poll/assets/javascripts/initializers/extend-for-poll.js.es6@@ -10,7 +10,7 @@ function initializePolls(api) {api.modifyClass("controller:topic", {subscribe() {this._super(...arguments);- this.messageBus.subscribe("/polls/" + this.get("model.id"), msg => {+ this.messageBus.subscribe("/polls/" + this.get("model.id"), (msg) => {const post = this.get("model.postStream").findLoadedPost(msg.post_id);if (post) {post.set("polls", msg.polls);@@ -20,14 +20,14 @@ function initializePolls(api) {unsubscribe() {this.messageBus.unsubscribe("/polls/*");this._super(...arguments);- }+ },});let _glued = [];let _interval = null;function rerender() {- _glued.forEach(g => g.queueRerender());+ _glued.forEach((g) => g.queueRerender());}api.modifyClass("model:post", {@@ -40,7 +40,7 @@ function initializePolls(api) {const polls = this.polls;if (polls) {this._polls = this._polls || {};- polls.forEach(p => {+ polls.forEach((p) => {const existing = this._polls[p.name];if (existing) {this._polls[p.name].setProperties(p);@@ -51,7 +51,7 @@ function initializePolls(api) {this.set("pollsObject", this._polls);rerender();}- }+ },});function attachPolls($elem, helper) {@@ -81,7 +81,7 @@ function initializePolls(api) {pollPost = post.quoted[quotedId];pollPost = EmberObject.create(pollPost);poll = EmberObject.create(- pollPost.polls.find(p => p.name === pollName)+ pollPost.polls.find((p) => p.name === pollName));vote = pollPost.polls_votes || {};vote = vote[pollName] || [];@@ -98,7 +98,7 @@ function initializePolls(api) {.poll_groupable_user_fields || "").split("|")- .filter(Boolean)+ .filter(Boolean),};const glue = new WidgetGlue("discourse-poll", register, attrs);glue.appendTo(pollElem);@@ -113,7 +113,7 @@ function initializePolls(api) {_interval = null;}- _glued.forEach(g => g.cleanUp());+ _glued.forEach((g) => g.cleanUp());_glued = [];}@@ -127,5 +127,5 @@ export default {initialize() {withPluginApi("0.8.7", initializePolls);- }+ },};diff --git a/plugins/poll/assets/javascripts/lib/chart-colors.js.es6 b/plugins/poll/assets/javascripts/lib/chart-colors.js.es6index 4821931fcd4..1b526ff6f83 100644--- a/plugins/poll/assets/javascripts/lib/chart-colors.js.es6+++ b/plugins/poll/assets/javascripts/lib/chart-colors.js.es6@@ -9,7 +9,7 @@ export function getColors(count, palette) {25: [220, 237, 200],50: [66, 179, 213],75: [26, 39, 62],- 100: [0, 0, 0]+ 100: [0, 0, 0],};break;case "warm":@@ -18,7 +18,7 @@ export function getColors(count, palette) {25: [254, 235, 101],50: [228, 82, 27],75: [77, 52, 47],- 100: [0, 0, 0]+ 100: [0, 0, 0],};break;}diff --git a/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6 b/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6index 61fc52f0f37..10a0adf476f 100644--- a/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6+++ b/plugins/poll/assets/javascripts/lib/discourse-markdown/poll.js.es6@@ -15,7 +15,7 @@ const WHITELISTED_ATTRIBUTES = ["groups","status","step",- "type"+ "type",];function replaceToken(tokens, target, list) {@@ -84,14 +84,14 @@ function invalidPoll(state, tag) {const rule = {tag: "poll",- before: function(state, tagInfo, raw) {+ before: function (state, tagInfo, raw) {let token = state.push("text", "", 0);token.content = raw;token.bbcode_attrs = tagInfo.attrs;token.bbcode_type = "poll_open";},- after: function(state, openToken, raw) {+ after: function (state, openToken, raw) {let items = getListItems(state.tokens, openToken);if (!items) {return invalidPoll(state, raw);@@ -106,7 +106,7 @@ const rule = {attributes.push([DATA_PREFIX + "status", "open"]);}- WHITELISTED_ATTRIBUTES.forEach(name => {+ WHITELISTED_ATTRIBUTES.forEach((name) => {if (attrs[name]) {attributes.push([DATA_PREFIX + name, attrs[name]]);}@@ -221,7 +221,7 @@ const rule = {state.push("poll_close", "div", -1);state.push("poll_close", "div", -1);state.push("poll_close", "div", -1);- }+ },};function newApiInit(helper) {@@ -230,7 +230,7 @@ function newApiInit(helper) {opts.pollMaximumOptions = siteSettings.poll_maximum_options;});- helper.registerPlugin(md => {+ helper.registerPlugin((md) => {md.block.bbcode.ruler.push("poll", rule);});}@@ -247,7 +247,7 @@ export function setup(helper) {"span.info-label","a.button.cast-votes","a.button.toggle-results",- "li[data-*]"+ "li[data-*]",]);newApiInit(helper);diff --git a/plugins/poll/assets/javascripts/lib/even-round.js.es6 b/plugins/poll/assets/javascripts/lib/even-round.js.es6index 1dd388562e3..0558b3943a6 100644--- a/plugins/poll/assets/javascripts/lib/even-round.js.es6+++ b/plugins/poll/assets/javascripts/lib/even-round.js.es6@@ -1,10 +1,10 @@// works as described on http://stackoverflow.com/a/13483710function sumsUpTo100(percentages) {- return percentages.map(p => Math.floor(p)).reduce((a, b) => a + b) === 100;+ return percentages.map((p) => Math.floor(p)).reduce((a, b) => a + b) === 100;}-export default function(percentages) {- var decimals = percentages.map(a => a % 1);+export default function (percentages) {+ var decimals = percentages.map((a) => a % 1);const sumOfDecimals = Math.ceil(decimals.reduce((a, b) => a + b));// compensate error by adding 1 to n items with the greatest decimal partfor (let i = 0, max = decimals.length; i < sumOfDecimals && i < max; i++) {@@ -24,5 +24,5 @@ export default function(percentages) {if (sumsUpTo100(percentages)) break;}- return percentages.map(p => Math.floor(p));+ return percentages.map((p) => Math.floor(p));}diff --git a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6index 68aff3bdd73..5fae26fa3e4 100644--- a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6+++ b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6@@ -26,12 +26,12 @@ function optionHtml(option) {function infoTextHtml(text) {return new RawHtml({- html: `<span class="info-text">${text}</span>`+ html: `<span class="info-text">${text}</span>`,});}function _fetchVoters(data) {- return ajax("/polls/voters.json", { data }).catch(error => {+ return ajax("/polls/voters.json", { data }).catch((error) => {if (error) {popupAjaxError(error);} else {@@ -42,16 +42,16 @@ function _fetchVoters(data) {function checkUserGroups(user, poll) {const pollGroups =- poll && poll.groups && poll.groups.split(",").map(g => g.toLowerCase());+ poll && poll.groups && poll.groups.split(",").map((g) => g.toLowerCase());if (!pollGroups) {return true;}const userGroups =- user && user.groups && user.groups.map(g => g.name.toLowerCase());+ user && user.groups && user.groups.map((g) => g.name.toLowerCase());- return userGroups && pollGroups.some(g => userGroups.includes(g));+ return userGroups && pollGroups.some((g) => userGroups.includes(g));}createWidget("discourse-poll-option", {@@ -82,12 +82,12 @@ createWidget("discourse-poll-option", {if ($(e.target).closest("a").length === 0) {this.sendWidgetAction("toggleOption", this.attrs.option);}- }+ },});createWidget("discourse-poll-load-more", {tagName: "div.poll-voters-toggle-expand",- buildKey: attrs => `load-more-${attrs.optionId}`,+ buildKey: (attrs) => `load-more-${attrs.optionId}`,defaultState() {return { loading: false };@@ -108,18 +108,18 @@ createWidget("discourse-poll-load-more", {return this.sendWidgetAction("loadMore").finally(() => (state.loading = false));- }+ },});createWidget("discourse-poll-voters", {tagName: "ul.poll-voters-list",- buildKey: attrs => `poll-voters-${attrs.optionId}`,+ buildKey: (attrs) => `poll-voters-${attrs.optionId}`,defaultState() {return {loaded: "new",voters: [],- page: 1+ page: 1,};},@@ -133,8 +133,8 @@ createWidget("discourse-poll-voters", {post_id: attrs.postId,poll_name: attrs.pollName,option_id: attrs.optionId,- page: state.page- }).then(result => {+ page: state.page,+ }).then((result) => {state.loaded = "loaded";state.page += 1;@@ -143,9 +143,11 @@ createWidget("discourse-poll-voters", {? result.voters: result.voters[attrs.optionId];- const existingVoters = new Set(state.voters.map(voter => voter.username));+ const existingVoters = new Set(+ state.voters.map((voter) => voter.username)+ );- newVoters.forEach(voter => {+ newVoters.forEach((voter) => {if (!existingVoters.has(voter.username)) {existingVoters.add(voter.username);state.voters.push(voter);@@ -165,13 +167,13 @@ createWidget("discourse-poll-voters", {state.voters = attrs.voters;}- const contents = state.voters.map(user => {+ const contents = state.voters.map((user) => {return h("li", [avatarFor("tiny", {username: user.username,- template: user.avatar_template+ template: user.avatar_template,}),- " "+ " ",]);});@@ -180,12 +182,12 @@ createWidget("discourse-poll-voters", {}return h("div.poll-voters", contents);- }+ },});createWidget("discourse-poll-standard-results", {tagName: "ul.results",- buildKey: attrs => `poll-standard-results-${attrs.id}`,+ buildKey: (attrs) => `poll-standard-results-${attrs.id}`,defaultState() {return { loaded: false };@@ -196,8 +198,8 @@ createWidget("discourse-poll-standard-results", {return _fetchVoters({post_id: attrs.post.id,- poll_name: attrs.poll.get("name")- }).then(result => {+ poll_name: attrs.poll.get("name"),+ }).then((result) => {state.voters = result.voters;this.scheduleRerender();});@@ -233,7 +235,7 @@ createWidget("discourse-poll-standard-results", {const percentages =voters === 0? Array(ordered.length).fill(0)- : ordered.map(o => (100 * o.votes) / voters);+ : ordered.map((o) => (100 * o.votes) / voters);const rounded = attrs.isMultiple? percentages.map(Math.floor)@@ -265,7 +267,7 @@ createWidget("discourse-poll-standard-results", {optionId: option.id,pollName: poll.get("name"),totalVotes: option.votes,- voters: (state.voters && state.voters[option.id]) || []+ voters: (state.voters && state.voters[option.id]) || [],}));}@@ -273,11 +275,11 @@ createWidget("discourse-poll-standard-results", {return h("li", { className: `${chosen ? "chosen" : ""}` }, contents);});}- }+ },});createWidget("discourse-poll-number-results", {- buildKey: attrs => `poll-number-results-${attrs.id}`,+ buildKey: (attrs) => `poll-number-results-${attrs.id}`,defaultState() {return { loaded: false };@@ -288,8 +290,8 @@ createWidget("discourse-poll-number-results", {return _fetchVoters({post_id: attrs.post.id,- poll_name: attrs.poll.get("name")- }).then(result => {+ poll_name: attrs.poll.get("name"),+ }).then((result) => {state.voters = result.voters;this.scheduleRerender();});@@ -309,7 +311,7 @@ createWidget("discourse-poll-number-results", {h("div.poll-results-number-rating",new RawHtml({ html: `<span>${averageRating}</span>` })- )+ ),];if (poll.get("public")) {@@ -324,13 +326,13 @@ createWidget("discourse-poll-number-results", {voters: state.voters || [],postId: attrs.post.id,pollName: poll.get("name"),- pollType: poll.get("type")+ pollType: poll.get("type"),}));}return contents;- }+ },});createWidget("discourse-poll-container", {@@ -362,11 +364,11 @@ createWidget("discourse-poll-container", {contents.push(h("ul",- options.map(option => {+ options.map((option) => {return this.attach("discourse-poll-option", {option,isMultiple: attrs.isMultiple,- vote: attrs.vote+ vote: attrs.vote,});}))@@ -374,7 +376,7 @@ createWidget("discourse-poll-container", {return contents;}- }+ },});createWidget("discourse-poll-info", {@@ -390,11 +392,11 @@ createWidget("discourse-poll-info", {if (max < options) {return I18n.t("poll.multiple.help.between_min_and_max_options", {min,- max+ max,});} else {return I18n.t("poll.multiple.help.at_least_min_options", {- count: min+ count: min,});}} else if (max <= options) {@@ -409,8 +411,8 @@ createWidget("discourse-poll-info", {const contents = [h("p", [h("span.info-number", count.toString()),- h("span.info-label", I18n.t("poll.voters", { count }))- ])+ h("span.info-label", I18n.t("poll.voters", { count })),+ ]),];if (attrs.isMultiple) {@@ -425,7 +427,7 @@ createWidget("discourse-poll-info", {h("span.info-label",I18n.t("poll.total_votes", { count: totalVotes })- )+ ),]));} else {@@ -450,7 +452,7 @@ createWidget("discourse-poll-info", {}return contents;- }+ },});function clearPieChart(id) {@@ -478,9 +480,9 @@ createWidget("discourse-poll-pie-canvas", {buildAttributes(attrs) {return {- id: `poll-results-chart-${attrs.id}`+ id: `poll-results-chart-${attrs.id}`,};- }+ },});createWidget("discourse-poll-pie-chart", {@@ -499,7 +501,7 @@ createWidget("discourse-poll-pie-chart", {label: "poll.group-results.label",title: "poll.group-results.title",icon: "far-eye",- action: "showBreakdown"+ action: "showBreakdown",});contents.push(button);@@ -511,37 +513,37 @@ createWidget("discourse-poll-pie-chart", {contents.push(h(`div#poll-results-legend-${attrs.id}.pie-chart-legends`));return contents;- }+ },});function pieChartConfig(data, labels, opts = {}) {const aspectRatio = "aspectRatio" in opts ? opts.aspectRatio : 2.2;- const strippedLabels = labels.map(l => stripHtml(l));+ const strippedLabels = labels.map((l) => stripHtml(l));return {type: PIE_CHART_TYPE,data: {datasets: [{data,- backgroundColor: getColors(data.length)- }+ backgroundColor: getColors(data.length),+ },],- labels: strippedLabels+ labels: strippedLabels,},options: {responsive: true,aspectRatio,animation: { duration: 0 },legend: { display: false },- legendCallback: function(chart) {+ legendCallback: function (chart) {let legends = "";for (let i = 0; i < labels.length; i++) {legends += `<div class="legend"><span class="swatch" style="background-color:${chart.data.datasets[0].backgroundColor[i]}"></span>${labels[i]}</div>`;}return legends;- }- }+ },+ },};}@@ -576,7 +578,7 @@ createWidget("discourse-poll-buttons", {label: "poll.cast-votes.label",title: "poll.cast-votes.title",disabled: castVotesDisabled,- action: "castVotes"+ action: "castVotes",}));contents.push(" ");@@ -590,7 +592,7 @@ createWidget("discourse-poll-buttons", {title: "poll.hide-results.title",icon: "far-eye-slash",disabled: hideResultsDisabled,- action: "toggleResults"+ action: "toggleResults",}));} else {@@ -608,7 +610,7 @@ createWidget("discourse-poll-buttons", {title: "poll.show-results.title",icon: "far-eye",disabled: poll.get("voters") === 0,- action: "toggleResults"+ action: "toggleResults",}));}@@ -622,7 +624,7 @@ createWidget("discourse-poll-buttons", {title: "poll.export-results.title",icon: "download",disabled: poll.voters === 0,- action: "exportResults"+ action: "exportResults",}));}@@ -643,7 +645,7 @@ createWidget("discourse-poll-buttons", {contents.push(new RawHtml({- html: `<span class="info-text" title="${title}">${label}</span>`+ html: `<span class="info-text" title="${title}">${label}</span>`,}));}@@ -662,7 +664,7 @@ createWidget("discourse-poll-buttons", {label: "poll.open.label",title: "poll.open.title",icon: "unlock-alt",- action: "toggleStatus"+ action: "toggleStatus",}));}@@ -673,19 +675,19 @@ createWidget("discourse-poll-buttons", {label: "poll.close.label",title: "poll.close.title",icon: "lock",- action: "toggleStatus"+ action: "toggleStatus",}));}}return contents;- }+ },});export default createWidget("discourse-poll", {tagName: "div",- buildKey: attrs => `poll-${attrs.id}`,+ buildKey: (attrs) => `poll-${attrs.id}`,buildAttributes(attrs) {let cssClasses = "poll";@@ -693,7 +695,7 @@ export default createWidget("discourse-poll", {return {class: cssClasses,"data-poll-name": attrs.poll.get("name"),- "data-poll-type": attrs.poll.get("type")+ "data-poll-type": attrs.poll.get("type"),};},@@ -724,13 +726,13 @@ export default createWidget("discourse-poll", {isMultiple: this.isMultiple(),max: this.max(),min: this.min(),- showResults+ showResults,});return h("div", [this.attach("discourse-poll-container", newAttrs),this.attach("discourse-poll-info", newAttrs),- this.attach("discourse-poll-buttons", newAttrs)+ this.attach("discourse-poll-buttons", newAttrs),]);},@@ -801,7 +803,7 @@ export default createWidget("discourse-poll", {I18n.t(this.isClosed() ? "poll.open.confirm" : "poll.close.confirm"),I18n.t("no_value"),I18n.t("yes_value"),- confirmed => {+ (confirmed) => {if (confirmed) {state.loading = true;const status = this.isClosed() ? "open" : "closed";@@ -811,8 +813,8 @@ export default createWidget("discourse-poll", {data: {post_id: post.get("id"),poll_name: poll.get("name"),- status- }+ status,+ },}).then(() => {poll.set("status", status);@@ -821,7 +823,7 @@ export default createWidget("discourse-poll", {}this.scheduleRerender();})- .catch(error => {+ .catch((error) => {if (error) {popupAjaxError(error);} else {@@ -852,17 +854,17 @@ export default createWidget("discourse-poll", {// needed for data-explorer route compatibilityparams: JSON.stringify({poll_name: attrs.poll.name,- post_id: attrs.post.id.toString() // needed for data-explorer route compatibility+ post_id: attrs.post.id.toString(), // needed for data-explorer route compatibility}),explain: false,limit: 1000000,- download: 1- }+ download: 1,+ },})- .then(csvContent => {+ .then((csvContent) => {const downloadLink = document.createElement("a");const blob = new Blob([csvContent], {- type: "text/csv;charset=utf-8;"+ type: "text/csv;charset=utf-8;",});downloadLink.href = URL.createObjectURL(blob);downloadLink.setAttribute(@@ -872,7 +874,7 @@ export default createWidget("discourse-poll", {downloadLink.click();downloadLink.remove();})- .catch(error => {+ .catch((error) => {if (error) {popupAjaxError(error);} else {@@ -926,8 +928,8 @@ export default createWidget("discourse-poll", {data: {post_id: attrs.post.id,poll_name: attrs.poll.get("name"),- options: attrs.vote- }+ options: attrs.vote,+ },}).then(({ poll }) => {attrs.poll.setProperties(poll);@@ -942,7 +944,7 @@ export default createWidget("discourse-poll", {}}})- .catch(error => {+ .catch((error) => {if (error) {popupAjaxError(error);} else {@@ -959,8 +961,8 @@ export default createWidget("discourse-poll", {model: this.attrs,panels: [{ id: "percentage", title: "poll.breakdown.percentage" },- { id: "count", title: "poll.breakdown.count" }- ]+ { id: "count", title: "poll.breakdown.count" },+ ],});- }+ },});