diff --git a/assets/javascripts/views/layout/settings.js b/assets/javascripts/views/layout/settings.js index 677d11fb..201de0b8 100644 --- a/assets/javascripts/views/layout/settings.js +++ b/assets/javascripts/views/layout/settings.js @@ -1,127 +1,109 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -/* - * decaffeinate suggestions: - * DS101: Remove unnecessary use of Array.from - * DS102: Remove unnecessary code created because of implicit returns - * DS205: Consider reworking code to avoid use of IIFEs - * DS206: Consider reworking classes to avoid initClass - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md - */ -(function () { - let SIDEBAR_HIDDEN_LAYOUT = undefined; - app.views.Settings = class Settings extends app.View { - static initClass() { - SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden"; - - this.el = "._settings"; - - this.elements = { - sidebar: "._sidebar", - saveBtn: 'button[type="submit"]', - backBtn: "button[data-back]", - }; - - this.events = { - import: "onImport", - change: "onChange", - submit: "onSubmit", - click: "onClick", - }; - - this.shortcuts = { enter: "onEnter" }; - } +app.views.Settings = class Settings extends app.View { + static SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden"; - init() { - this.addSubview((this.docPicker = new app.views.DocPicker())); - } + static el = "._settings"; - activate() { - if (super.activate(...arguments)) { - this.render(); - document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT); - } - } + static elements = { + sidebar: "._sidebar", + saveBtn: 'button[type="submit"]', + backBtn: "button[data-back]", + }; - deactivate() { - if (super.deactivate(...arguments)) { - this.resetClass(); - this.docPicker.detach(); - if (app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)) { - document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT); - } + static events = { + import: "onImport", + change: "onChange", + submit: "onSubmit", + click: "onClick", + }; + + static shortcuts = { enter: "onEnter" }; + + init() { + this.addSubview((this.docPicker = new app.views.DocPicker())); + } + + activate() { + if (super.activate(...arguments)) { + this.render(); + document.body.classList.remove(Settings.SIDEBAR_HIDDEN_LAYOUT); + } + } + + deactivate() { + if (super.deactivate(...arguments)) { + this.resetClass(); + this.docPicker.detach(); + if (app.settings.hasLayout(Settings.SIDEBAR_HIDDEN_LAYOUT)) { + document.body.classList.add(Settings.SIDEBAR_HIDDEN_LAYOUT); } } + } - render() { - this.docPicker.appendTo(this.sidebar); - this.refreshElements(); - this.addClass("_in"); - } + render() { + this.docPicker.appendTo(this.sidebar); + this.refreshElements(); + this.addClass("_in"); + } - save(options) { - if (options == null) { - options = {}; + save(options) { + if (options == null) { + options = {}; + } + if (!this.saving) { + let docs; + this.saving = true; + + if (options.import) { + docs = app.settings.getDocs(); + } else { + docs = this.docPicker.getSelectedDocs(); + app.settings.setDocs(docs); } - if (!this.saving) { - let docs; - this.saving = true; - - if (options.import) { - docs = app.settings.getDocs(); - } else { - docs = this.docPicker.getSelectedDocs(); - app.settings.setDocs(docs); - } - - this.saveBtn.textContent = "Saving\u2026"; - const disabledDocs = new app.collections.Docs( - (() => { - const result = []; - for (var doc of Array.from(app.docs.all())) { - if (docs.indexOf(doc.slug) === -1) { - result.push(doc); - } + + this.saveBtn.textContent = "Saving\u2026"; + const disabledDocs = new app.collections.Docs( + (() => { + const result = []; + for (var doc of app.docs.all()) { + if (docs.indexOf(doc.slug) === -1) { + result.push(doc); } - return result; - })(), - ); - disabledDocs.uninstall(function () { - app.db.migrate(); - return app.reload(); - }); - } + } + return result; + })(), + ); + disabledDocs.uninstall(function () { + app.db.migrate(); + return app.reload(); + }); } + } - onChange() { - this.addClass("_dirty"); - } + onChange() { + this.addClass("_dirty"); + } - onEnter() { - this.save(); - } + onEnter() { + this.save(); + } - onSubmit(event) { - event.preventDefault(); - this.save(); - } + onSubmit(event) { + event.preventDefault(); + this.save(); + } - onImport() { - this.addClass("_dirty"); - this.save({ import: true }); - } + onImport() { + this.addClass("_dirty"); + this.save({ import: true }); + } - onClick(event) { - if (event.which !== 1) { - return; - } - if (event.target === this.backBtn) { - $.stopEvent(event); - app.router.show("/"); - } + onClick(event) { + if (event.which !== 1) { + return; } - }; - app.views.Settings.initClass(); - return app.views.Settings; -})(); + if (event.target === this.backBtn) { + $.stopEvent(event); + app.router.show("/"); + } + } +};