ReferenceError: Must call super constructor in derived class before accessing 'this'

pull/1441/head
Simon Legner 1 year ago
parent a725a0aabb
commit 81c0551d35

@ -19,10 +19,6 @@
} }
constructor() { constructor() {
this.onOpenSuccess = this.onOpenSuccess.bind(this);
this.onOpenError = this.onOpenError.bind(this);
this.checkForCorruptedDocs = this.checkForCorruptedDocs.bind(this);
this.deleteCorruptedDocs = this.deleteCorruptedDocs.bind(this);
this.versionMultipler = $.isIE() ? 1e5 : 1e9; this.versionMultipler = $.isIE() ? 1e5 : 1e9;
this.useIndexedDB = this.useIndexedDB(); this.useIndexedDB = this.useIndexedDB();
this.callbacks = []; this.callbacks = [];
@ -45,9 +41,9 @@
NAME, NAME,
VERSION * this.versionMultipler + this.userVersion(), VERSION * this.versionMultipler + this.userVersion(),
); );
req.onsuccess = this.onOpenSuccess; req.onsuccess = (event) => this.onOpenSuccess(event);
req.onerror = this.onOpenError; req.onerror = (event) => this.onOpenError(event);
req.onupgradeneeded = this.onUpgradeNeeded; req.onupgradeneeded = (event) => this.onUpgradeNeeded(event);
} catch (error) { } catch (error) {
this.fail("exception", error); this.fail("exception", error);
} }
@ -378,8 +374,7 @@
load(entry, onSuccess, onError) { load(entry, onSuccess, onError) {
if (this.shouldLoadWithIDB(entry)) { if (this.shouldLoadWithIDB(entry)) {
onError = this.loadWithXHR.bind(this, entry, onSuccess, onError); return this.loadWithIDB(entry, onSuccess, () => this.loadWithXHR(entry, onSuccess, onError));
return this.loadWithIDB(entry, onSuccess, onError);
} else { } else {
return this.loadWithXHR(entry, onSuccess, onError); return this.loadWithXHR(entry, onSuccess, onError);
} }
@ -440,7 +435,7 @@
mode: "readonly", mode: "readonly",
}); });
txn.oncomplete = () => { txn.oncomplete = () => {
setTimeout(this.checkForCorruptedDocs, 50); setTimeout(() => this.checkForCorruptedDocs(), 50);
}; };
const req = txn.objectStore("docs").openCursor(); const req = txn.objectStore("docs").openCursor();
@ -486,7 +481,7 @@
} }
if (docs.length === 0) { if (docs.length === 0) {
setTimeout(this.deleteCorruptedDocs, 0); setTimeout(() => this.deleteCorruptedDocs(), 0);
return; return;
} }
@ -497,7 +492,7 @@
}); });
txn.oncomplete = () => { txn.oncomplete = () => {
if (this.corruptedDocs.length > 0) { if (this.corruptedDocs.length > 0) {
setTimeout(this.deleteCorruptedDocs, 0); setTimeout(() => this.deleteCorruptedDocs(), 0);
} }
}; };

@ -215,12 +215,7 @@ function scoreFuzzyMatch() {
} }
constructor(options) { constructor(options) {
this.match = this.match.bind(this); this.options = $.extend({}, DEFAULTS, options || {});
this.matchChunks = this.matchChunks.bind(this);
if (options == null) {
options = {};
}
this.options = $.extend({}, DEFAULTS, options);
} }
find(data, attr, q) { find(data, attr, q) {
@ -307,10 +302,10 @@ function scoreFuzzyMatch() {
this.matchChunk(); this.matchChunk();
if (this.cursor === this.dataLength || this.scoredEnough()) { if (this.cursor === this.dataLength || this.scoredEnough()) {
this.delay(this.match); this.delay(() => this.match());
this.sendResults(); this.sendResults();
} else { } else {
this.delay(this.matchChunks); this.delay(() => this.matchChunks());
} }
} }
@ -410,11 +405,6 @@ function scoreFuzzyMatch() {
})(); })();
app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher { app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {
constructor(...args) {
this.match = this.match.bind(this);
super(...args);
}
match() { match() {
if (this.matcher) { if (this.matcher) {
if (!this.allResults) { if (!this.allResults) {

@ -16,7 +16,6 @@ app.ServiceWorker = class ServiceWorker {
} }
constructor() { constructor() {
this.onUpdateFound = this.onUpdateFound.bind(this);
this.onStateChange = this.onStateChange.bind(this); this.onStateChange = this.onStateChange.bind(this);
this.registration = null; this.registration = null;
this.notifyUpdate = true; this.notifyUpdate = true;
@ -51,12 +50,12 @@ app.ServiceWorker = class ServiceWorker {
updateRegistration(registration) { updateRegistration(registration) {
this.registration = registration; this.registration = registration;
$.on(this.registration, "updatefound", this.onUpdateFound); $.on(this.registration, "updatefound", () => this.onUpdateFound());
} }
onUpdateFound() { onUpdateFound() {
if (this.installingRegistration) { if (this.installingRegistration) {
$.off(this.installingRegistration, "statechange", this.onStateChange()); $.off(this.installingRegistration, "statechange", this.onStateChange);
} }
this.installingRegistration = this.registration.installing; this.installingRegistration = this.registration.installing;
$.on(this.installingRegistration, "statechange", this.onStateChange); $.on(this.installingRegistration, "statechange", this.onStateChange);

@ -7,16 +7,14 @@
*/ */
app.UpdateChecker = class UpdateChecker { app.UpdateChecker = class UpdateChecker {
constructor() { constructor() {
this.checkDocs = this.checkDocs.bind(this);
this.onFocus = this.onFocus.bind(this);
this.lastCheck = Date.now(); this.lastCheck = Date.now();
$.on(window, "focus", this.onFocus); $.on(window, "focus", () => this.onFocus());
if (app.serviceWorker != null) { if (app.serviceWorker != null) {
app.serviceWorker.on("updateready", this.onUpdateReady); app.serviceWorker.on("updateready", () => this.onUpdateReady());
} }
setTimeout(this.checkDocs, 0); setTimeout(() => this.checkDocs(), 0);
} }
check() { check() {

@ -110,7 +110,7 @@ this.viewTree = function (view, level, visited) {
`%c ${Array(level + 1).join(" ")}${ `%c ${Array(level + 1).join(" ")}${
view.constructor.name view.constructor.name
}: ${!!view.activated}`, }: ${!!view.activated}`,
"color:" + ((view.activated && "green") || "red") "color:" + ((view.activated && "green") || "red"),
); );
for (var key of Object.keys(view || {})) { for (var key of Object.keys(view || {})) {

@ -48,14 +48,12 @@ class Events {
} }
trigger(event, ...args) { trigger(event, ...args) {
let callbacks;
this.eventInProgress = { name: event, args }; this.eventInProgress = { name: event, args };
if ( const callbacks = this._callbacks?.[event];
(callbacks = this._callbacks != null ? this._callbacks[event] : undefined) if (callbacks) {
) { for (let callback of Array.from(callbacks.slice(0))) {
for (var callback of Array.from(callbacks.slice(0))) {
if (typeof callback === "function") { if (typeof callback === "function") {
callback(...Array.from(args || [])); callback(...args);
} }
} }
} }

@ -13,24 +13,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.Content = class Content extends app.View { app.views.Content = class Content extends app.View {
constructor(...args) {
this.scrollToTop = this.scrollToTop.bind(this);
this.scrollToBottom = this.scrollToBottom.bind(this);
this.scrollStepUp = this.scrollStepUp.bind(this);
this.scrollStepDown = this.scrollStepDown.bind(this);
this.scrollPageUp = this.scrollPageUp.bind(this);
this.scrollPageDown = this.scrollPageDown.bind(this);
this.onReady = this.onReady.bind(this);
this.onBootError = this.onBootError.bind(this);
this.onEntryLoading = this.onEntryLoading.bind(this);
this.onEntryLoaded = this.onEntryLoaded.bind(this);
this.beforeRoute = this.beforeRoute.bind(this);
this.afterRoute = this.afterRoute.bind(this);
this.onClick = this.onClick.bind(this);
this.onAltF = this.onAltF.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.el = "._content"; this.el = "._content";
this.loadingClass = "_content-loading"; this.loadingClass = "_content-loading";
@ -68,10 +50,12 @@ app.views.Content = class Content extends app.View {
this.entryPage = new app.views.EntryPage(); this.entryPage = new app.views.EntryPage();
this.entryPage this.entryPage
.on("loading", this.onEntryLoading) .on("loading", () => this.onEntryLoading())
.on("loaded", this.onEntryLoaded); .on("loaded", () => this.onEntryLoaded());
app.on("ready", this.onReady).on("bootError", this.onBootError); app
.on("ready", () => this.onReady())
.on("bootError", () => this.onBootError());
} }
show(view) { show(view) {

@ -13,16 +13,6 @@
(function () { (function () {
let LINKS = undefined; let LINKS = undefined;
app.views.EntryPage = class EntryPage extends app.View { app.views.EntryPage = class EntryPage extends app.View {
constructor(...args) {
this.beforeRoute = this.beforeRoute.bind(this);
this.onSuccess = this.onSuccess.bind(this);
this.onError = this.onError.bind(this);
this.onClick = this.onClick.bind(this);
this.onAltC = this.onAltC.bind(this);
this.onAltO = this.onAltO.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_page"; this.className = "_page";
this.errorClass = "_page-error"; this.errorClass = "_page-error";
@ -182,7 +172,10 @@
load() { load() {
this.loading(); this.loading();
this.xhr = this.entry.loadFile(this.onSuccess, this.onError); this.xhr = this.entry.loadFile(
(response) => this.onSuccess(response),
() => this.onError(),
);
} }
abort() { abort() {

@ -9,11 +9,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.OfflinePage = class OfflinePage extends app.View { app.views.OfflinePage = class OfflinePage extends app.View {
constructor(...args) {
this.onClick = this.onClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_static"; this.className = "_static";

@ -8,11 +8,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.RootPage = class RootPage extends app.View { app.views.RootPage = class RootPage extends app.View {
constructor(...args) {
this.onClick = this.onClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.events = { click: "onClick" }; this.events = { click: "onClick" };
} }

@ -10,12 +10,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.SettingsPage = class SettingsPage extends app.View { app.views.SettingsPage = class SettingsPage extends app.View {
constructor(...args) {
this.onChange = this.onChange.bind(this);
this.onClick = this.onClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_static"; this.className = "_static";

@ -9,12 +9,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.Document = class Document extends app.View { app.views.Document = class Document extends app.View {
constructor(...args) {
this.afterRoute = this.afterRoute.bind(this);
this.onVisibilityChange = this.onVisibilityChange.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.el = document; this.el = document;

@ -7,11 +7,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.Menu = class Menu extends app.View { app.views.Menu = class Menu extends app.View {
constructor(...args) {
this.onGlobalClick = this.onGlobalClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.el = "._menu"; this.el = "._menu";
this.activeClass = "active"; this.activeClass = "active";
@ -20,7 +15,7 @@ app.views.Menu = class Menu extends app.View {
} }
init() { init() {
$.on(document.body, "click", this.onGlobalClick); $.on(document.body, "click", (event) => this.onGlobalClick(event));
} }
onClick(event) { onClick(event) {

@ -54,44 +54,36 @@ app.views.Mobile = class Mobile extends app.View {
} }
constructor() { constructor() {
this.showSidebar = this.showSidebar.bind(this);
this.hideSidebar = this.hideSidebar.bind(this);
this.onClickBack = this.onClickBack.bind(this);
this.onClickForward = this.onClickForward.bind(this);
this.onClickToggleSidebar = this.onClickToggleSidebar.bind(this);
this.onClickDocPickerTab = this.onClickDocPickerTab.bind(this);
this.onClickSettingsTab = this.onClickSettingsTab.bind(this);
this.onTapSearch = this.onTapSearch.bind(this);
this.onEscape = this.onEscape.bind(this);
this.afterRoute = this.afterRoute.bind(this);
this.el = document.documentElement;
super(...arguments); super(...arguments);
this.el = document.documentElement;
} }
init() { init() {
$.on($("._search"), "touchend", this.onTapSearch); $.on($("._search"), "touchend", () => this.onTapSearch());
this.toggleSidebar = $("button[data-toggle-sidebar]"); this.toggleSidebar = $("button[data-toggle-sidebar]");
this.toggleSidebar.removeAttribute("hidden"); this.toggleSidebar.removeAttribute("hidden");
$.on(this.toggleSidebar, "click", this.onClickToggleSidebar); $.on(this.toggleSidebar, "click", () => this.onClickToggleSidebar());
this.back = $("button[data-back]"); this.back = $("button[data-back]");
this.back.removeAttribute("hidden"); this.back.removeAttribute("hidden");
$.on(this.back, "click", this.onClickBack); $.on(this.back, "click", () => this.onClickBack());
this.forward = $("button[data-forward]"); this.forward = $("button[data-forward]");
this.forward.removeAttribute("hidden"); this.forward.removeAttribute("hidden");
$.on(this.forward, "click", this.onClickForward); $.on(this.forward, "click", () => this.onClickForward());
this.docPickerTab = $('button[data-tab="doc-picker"]'); this.docPickerTab = $('button[data-tab="doc-picker"]');
this.docPickerTab.removeAttribute("hidden"); this.docPickerTab.removeAttribute("hidden");
$.on(this.docPickerTab, "click", this.onClickDocPickerTab); $.on(this.docPickerTab, "click", (event) =>
this.onClickDocPickerTab(event),
);
this.settingsTab = $('button[data-tab="settings"]'); this.settingsTab = $('button[data-tab="settings"]');
this.settingsTab.removeAttribute("hidden"); this.settingsTab.removeAttribute("hidden");
$.on(this.settingsTab, "click", this.onClickSettingsTab); $.on(this.settingsTab, "click", (event) => this.onClickSettingsTab(event));
app.document.sidebar.search.on("searching", this.showSidebar); app.document.sidebar.search.on("searching", () => this.showSidebar());
this.activate(); this.activate();
} }

@ -8,12 +8,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.Path = class Path extends app.View { app.views.Path = class Path extends app.View {
constructor(...args) {
this.onClick = this.onClick.bind(this);
this.afterRoute = this.afterRoute.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_path"; this.className = "_path";
this.attributes = { role: "complementary" }; this.attributes = { role: "complementary" };

@ -11,13 +11,6 @@
let MIN = undefined; let MIN = undefined;
let MAX = undefined; let MAX = undefined;
app.views.Resizer = class Resizer extends app.View { app.views.Resizer = class Resizer extends app.View {
constructor(...args) {
this.onDragStart = this.onDragStart.bind(this);
this.onDrag = this.onDrag.bind(this);
this.onDragEnd = this.onDragEnd.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_resizer"; this.className = "_resizer";

@ -13,15 +13,6 @@
(function () { (function () {
let SIDEBAR_HIDDEN_LAYOUT = undefined; let SIDEBAR_HIDDEN_LAYOUT = undefined;
app.views.Settings = class Settings extends app.View { app.views.Settings = class Settings extends app.View {
constructor(...args) {
this.onChange = this.onChange.bind(this);
this.onEnter = this.onEnter.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.onImport = this.onImport.bind(this);
this.onClick = this.onClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden"; SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden";

@ -25,15 +25,8 @@ app.views.ListFocus = class ListFocus extends app.View {
} }
constructor(el) { constructor(el) {
this.blur = this.blur.bind(this);
this.onDown = this.onDown.bind(this);
this.onUp = this.onUp.bind(this);
this.onLeft = this.onLeft.bind(this);
this.onEnter = this.onEnter.bind(this);
this.onSuperEnter = this.onSuperEnter.bind(this);
this.onClick = this.onClick.bind(this);
this.el = el;
super(...arguments); super(...arguments);
this.el = el;
this.focusOnNextFrame = $.framify(this.focus, this); this.focusOnNextFrame = $.framify(this.focus, this);
} }

@ -23,11 +23,8 @@ app.views.ListFold = class ListFold extends app.View {
} }
constructor(el) { constructor(el) {
this.onLeft = this.onLeft.bind(this);
this.onRight = this.onRight.bind(this);
this.onClick = this.onClick.bind(this);
this.el = el;
super(...arguments); super(...arguments);
this.el = el;
} }
open(el) { open(el) {

@ -16,9 +16,8 @@ app.views.ListSelect = class ListSelect extends app.View {
} }
constructor(el) { constructor(el) {
this.onClick = this.onClick.bind(this);
this.el = el;
super(...arguments); super(...arguments);
this.el = el;
} }
deactivate() { deactivate() {

@ -13,20 +13,15 @@ app.views.Notif = class Notif extends app.View {
this.activeClass = "_in"; this.activeClass = "_in";
this.attributes = { role: "alert" }; this.attributes = { role: "alert" };
this.defautOptions = { autoHide: 15000 }; this.defaultOptions = { autoHide: 15000 };
this.events = { click: "onClick" }; this.events = { click: "onClick" };
} }
constructor(type, options) { constructor(type, options) {
this.onClick = this.onClick.bind(this);
this.type = type;
if (options == null) {
options = {};
}
this.options = options;
this.options = $.extend({}, this.constructor.defautOptions, this.options);
super(...arguments); super(...arguments);
this.type = type;
this.options = $.extend({}, this.constructor.defaultOptions, options || {});
} }
init() { init() {

@ -10,10 +10,9 @@
*/ */
app.views.BasePage = class BasePage extends app.View { app.views.BasePage = class BasePage extends app.View {
constructor(el, entry) { constructor(el, entry) {
this.paintCode = this.paintCode.bind(this); super(...arguments);
this.el = el; this.el = el;
this.entry = entry; this.entry = entry;
super(...arguments);
} }
deactivate() { deactivate() {
@ -40,7 +39,9 @@ app.views.BasePage = class BasePage extends app.View {
this.delay(this.afterRender); this.delay(this.afterRender);
} }
if (this.highlightNodes.length > 0) { if (this.highlightNodes.length > 0) {
$.requestAnimationFrame(() => $.requestAnimationFrame(this.paintCode)); $.requestAnimationFrame(() =>
$.requestAnimationFrame(() => this.paintCode()),
);
} }
} }
@ -80,7 +81,7 @@ app.views.BasePage = class BasePage extends app.View {
} }
if (this.highlightNodes.length > 0) { if (this.highlightNodes.length > 0) {
$.requestAnimationFrame(this.paintCode); $.requestAnimationFrame(() => this.paintCode());
} }
this.previousTiming = timing; this.previousTiming = timing;
} }

@ -12,10 +12,9 @@ app.views.HiddenPage = class HiddenPage extends app.View {
} }
constructor(el, entry) { constructor(el, entry) {
this.onClick = this.onClick.bind(this); super(...arguments);
this.el = el; this.el = el;
this.entry = entry; this.entry = entry;
super(...arguments);
} }
init() { init() {

@ -11,11 +11,6 @@
//= require views/pages/base //= require views/pages/base
app.views.JqueryPage = class JqueryPage extends app.views.BasePage { app.views.JqueryPage = class JqueryPage extends app.views.BasePage {
constructor(...args) {
this.onIframeLoaded = this.onIframeLoaded.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.demoClassName = "_jquery-demo"; this.demoClassName = "_jquery-demo";
} }
@ -24,6 +19,7 @@ app.views.JqueryPage = class JqueryPage extends app.views.BasePage {
// Prevent jQuery Mobile's demo iframes from scrolling the page // Prevent jQuery Mobile's demo iframes from scrolling the page
for (var iframe of Array.from(this.findAllByTag("iframe"))) { for (var iframe of Array.from(this.findAllByTag("iframe"))) {
iframe.style.display = "none"; iframe.style.display = "none";
this.onIframeLoaded = this.onIframeLoaded.bind(this);
$.on(iframe, "load", this.onIframeLoaded); $.on(iframe, "load", this.onIframeLoaded);
} }

@ -9,11 +9,6 @@
//= require views/pages/base //= require views/pages/base
app.views.SqlitePage = class SqlitePage extends app.views.BasePage { app.views.SqlitePage = class SqlitePage extends app.views.BasePage {
constructor(...args) {
this.onClick = this.onClick.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.events = { click: "onClick" }; this.events = { click: "onClick" };
} }

@ -13,24 +13,6 @@
let SEARCH_PARAM = undefined; let SEARCH_PARAM = undefined;
let HASH_RGX = undefined; let HASH_RGX = undefined;
app.views.Search = class Search extends app.View { app.views.Search = class Search extends app.View {
constructor(...args) {
this.focus = this.focus.bind(this);
this.autoFocus = this.autoFocus.bind(this);
this.onWindowFocus = this.onWindowFocus.bind(this);
this.onReady = this.onReady.bind(this);
this.onInput = this.onInput.bind(this);
this.searchUrl = this.searchUrl.bind(this);
this.google = this.google.bind(this);
this.stackoverflow = this.stackoverflow.bind(this);
this.duckduckgo = this.duckduckgo.bind(this);
this.onResults = this.onResults.bind(this);
this.onEnd = this.onEnd.bind(this);
this.onClick = this.onClick.bind(this);
this.onScopeChange = this.onScopeChange.bind(this);
this.afterRoute = this.afterRoute.bind(this);
super(...args);
}
static initClass() { static initClass() {
SEARCH_PARAM = app.config.search_param; SEARCH_PARAM = app.config.search_param;
@ -64,13 +46,15 @@
this.addSubview((this.scope = new app.views.SearchScope(this.el))); this.addSubview((this.scope = new app.views.SearchScope(this.el)));
this.searcher = new app.Searcher(); this.searcher = new app.Searcher();
this.searcher.on("results", this.onResults).on("end", this.onEnd); this.searcher
.on("results", (results) => this.onResults(results))
.on("end", () => this.onEnd());
this.scope.on("change", this.onScopeChange); this.scope.on("change", () => this.onScopeChange());
app.on("ready", this.onReady); app.on("ready", () => this.onReady());
$.on(window, "hashchange", this.searchUrl); $.on(window, "hashchange", () => this.searchUrl());
$.on(window, "focus", this.onWindowFocus); $.on(window, "focus", (event) => this.onWindowFocus(event));
} }
focus() { focus() {
@ -247,7 +231,7 @@
if (context.hash) { if (context.hash) {
this.delay(this.searchUrl); this.delay(this.searchUrl);
} }
$.requestAnimationFrame(this.autoFocus); $.requestAnimationFrame(() => this.autoFocus());
} }
extractHashValue() { extractHashValue() {

@ -33,15 +33,8 @@
} }
constructor(el) { constructor(el) {
this.onResults = this.onResults.bind(this);
this.reset = this.reset.bind(this);
this.doScopeSearch = this.doScopeSearch.bind(this);
this.onClick = this.onClick.bind(this);
this.onKeydown = this.onKeydown.bind(this);
this.onTextInput = this.onTextInput.bind(this);
this.afterRoute = this.afterRoute.bind(this);
this.el = el;
super(...arguments); super(...arguments);
this.el = el;
} }
init() { init() {
@ -51,7 +44,7 @@
fuzzy_min_length: 2, fuzzy_min_length: 2,
max_results: 1, max_results: 1,
}); });
this.searcher.on("results", this.onResults); this.searcher.on("results", (results) => this.onResults(results));
} }
getScope() { getScope() {

@ -9,16 +9,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.DocList = class DocList extends app.View { app.views.DocList = class DocList extends app.View {
constructor(...args) {
this.render = this.render.bind(this);
this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this);
this.onClick = this.onClick.bind(this);
this.onEnabled = this.onEnabled.bind(this);
this.afterRoute = this.afterRoute.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_list"; this.className = "_list";
this.attributes = { role: "navigation" }; this.attributes = { role: "navigation" };
@ -44,7 +34,7 @@ app.views.DocList = class DocList extends app.View {
this.addSubview((this.listFold = new app.views.ListFold(this.el))); this.addSubview((this.listFold = new app.views.ListFold(this.el)));
this.addSubview((this.listSelect = new app.views.ListSelect(this.el))); this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
app.on("ready", this.render); app.on("ready", () => this.render());
} }
activate() { activate() {
@ -248,6 +238,7 @@ app.views.DocList = class DocList extends app.View {
$.stopEvent(event); $.stopEvent(event);
const doc = app.disabledDocs.findBy("slug", slug); const doc = app.disabledDocs.findBy("slug", slug);
if (doc) { if (doc) {
this.onEnabled = this.onEnabled.bind(this);
app.enableDoc(doc, this.onEnabled, this.onEnabled); app.enableDoc(doc, this.onEnabled, this.onEnabled);
} }
} }

@ -11,13 +11,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.DocPicker = class DocPicker extends app.View { app.views.DocPicker = class DocPicker extends app.View {
constructor(...args) {
this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.onDOMFocus = this.onDOMFocus.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.className = "_list _list-picker"; this.className = "_list _list-picker";
@ -34,6 +27,7 @@ app.views.DocPicker = class DocPicker extends app.View {
activate() { activate() {
if (super.activate(...arguments)) { if (super.activate(...arguments)) {
this.render(); this.render();
this.onDOMFocus = this.onDOMFocus.bind(this);
$.on(this.el, "focus", this.onDOMFocus, true); $.on(this.el, "focus", this.onDOMFocus, true);
} }
} }

@ -18,14 +18,9 @@ app.views.Results = class Results extends app.View {
} }
constructor(sidebar, search) { constructor(sidebar, search) {
this.onResults = this.onResults.bind(this); super(...arguments);
this.onNoResults = this.onNoResults.bind(this);
this.onClear = this.onClear.bind(this);
this.afterRoute = this.afterRoute.bind(this);
this.onClick = this.onClick.bind(this);
this.sidebar = sidebar; this.sidebar = sidebar;
this.search = search; this.search = search;
super(...arguments);
} }
deactivate() { deactivate() {
@ -39,9 +34,9 @@ app.views.Results = class Results extends app.View {
this.addSubview((this.listSelect = new app.views.ListSelect(this.el))); this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
this.search this.search
.on("results", this.onResults) .on("results", (entries, flags) => this.onResults(entries, flags))
.on("noresults", this.onNoResults) .on("noresults", () => this.onNoResults())
.on("clear", this.onClear); .on("clear", () => this.onClear());
} }
onResults(entries, flags) { onResults(entries, flags) {

@ -10,23 +10,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/ */
app.views.Sidebar = class Sidebar extends app.View { app.views.Sidebar = class Sidebar extends app.View {
constructor(...args) {
this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
this.resetHover = this.resetHover.bind(this);
this.showResults = this.showResults.bind(this);
this.onReady = this.onReady.bind(this);
this.onScopeChange = this.onScopeChange.bind(this);
this.onSearching = this.onSearching.bind(this);
this.onSearchClear = this.onSearchClear.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onSelect = this.onSelect.bind(this);
this.onClick = this.onClick.bind(this);
this.onAltR = this.onAltR.bind(this);
this.onEscape = this.onEscape.bind(this);
this.afterRoute = this.afterRoute.bind(this);
super(...args);
}
static initClass() { static initClass() {
this.el = "._sidebar"; this.el = "._sidebar";
@ -51,14 +34,16 @@ app.views.Sidebar = class Sidebar extends app.View {
this.addSubview((this.search = new app.views.Search())); this.addSubview((this.search = new app.views.Search()));
this.search this.search
.on("searching", this.onSearching) .on("searching", () => this.onSearching())
.on("clear", this.onSearchClear) .on("clear", () => this.onSearchClear())
.scope.on("change", this.onScopeChange); .scope.on("change", (newDoc, previousDoc) =>
this.onScopeChange((newDoc, previousDoc)),
);
this.results = new app.views.Results(this, this.search); this.results = new app.views.Results(this, this.search);
this.docList = new app.views.DocList(); this.docList = new app.views.DocList();
app.on("ready", this.onReady); app.on("ready", () => this.onReady());
$.on(document.documentElement, "mouseleave", () => this.hide()); $.on(document.documentElement, "mouseleave", () => this.hide());
$.on(document.documentElement, "mouseenter", () => $.on(document.documentElement, "mouseenter", () =>
@ -85,13 +70,14 @@ app.views.Sidebar = class Sidebar extends app.View {
if (options.forceNoHover !== false && !this.hasClass("no-hover")) { if (options.forceNoHover !== false && !this.hasClass("no-hover")) {
this.addClass("no-hover"); this.addClass("no-hover");
this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
$.on(window, "mousemove", this.resetHoverOnMouseMove); $.on(window, "mousemove", this.resetHoverOnMouseMove);
} }
} }
resetHoverOnMouseMove() { resetHoverOnMouseMove() {
$.off(window, "mousemove", this.resetHoverOnMouseMove); $.off(window, "mousemove", this.resetHoverOnMouseMove);
return $.requestAnimationFrame(this.resetHover); return $.requestAnimationFrame(() => this.resetHover());
} }
resetHover() { resetHover() {

@ -26,19 +26,11 @@ app.views.SidebarHover = class SidebarHover extends app.View {
} }
constructor(el) { constructor(el) {
this.position = this.position.bind(this); super(...arguments);
this.onFocus = this.onFocus.bind(this);
this.onBlur = this.onBlur.bind(this);
this.onMouseover = this.onMouseover.bind(this);
this.onMouseout = this.onMouseout.bind(this);
this.onScroll = this.onScroll.bind(this);
this.onClick = this.onClick.bind(this);
this.onRoute = this.onRoute.bind(this);
this.el = el; this.el = el;
if (!isPointerEventsSupported()) { if (!isPointerEventsSupported()) {
delete this.constructor.events.mouseover; delete this.constructor.events.mouseover;
} }
super(...arguments);
} }
show(el) { show(el) {

@ -21,10 +21,8 @@ app.views.TypeList = class TypeList extends app.View {
} }
constructor(doc) { constructor(doc) {
this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this);
this.doc = doc;
super(...arguments); super(...arguments);
this.doc = doc;
} }
init() { init() {

@ -174,6 +174,7 @@ app.View = class View {
if (this.constructor.events) { if (this.constructor.events) {
for (name in this.constructor.events) { for (name in this.constructor.events) {
method = this.constructor.events[name]; method = this.constructor.events[name];
this[method] = this[method].bind(this);
this.onDOM(name, this[method]); this.onDOM(name, this[method]);
} }
} }
@ -181,6 +182,7 @@ app.View = class View {
if (this.constructor.routes) { if (this.constructor.routes) {
for (name in this.constructor.routes) { for (name in this.constructor.routes) {
method = this.constructor.routes[name]; method = this.constructor.routes[name];
this[method] = this[method].bind(this);
app.router.on(name, this[method]); app.router.on(name, this[method]);
} }
} }
@ -188,6 +190,7 @@ app.View = class View {
if (this.constructor.shortcuts) { if (this.constructor.shortcuts) {
for (name in this.constructor.shortcuts) { for (name in this.constructor.shortcuts) {
method = this.constructor.shortcuts[name]; method = this.constructor.shortcuts[name];
this[method] = this[method].bind(this);
app.shortcuts.on(name, this[method]); app.shortcuts.on(name, this[method]);
} }
} }

Loading…
Cancel
Save