History

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

Simon Legner committed 2 years ago

Commit 81c05511 parent a725a0a34 files · +83 −272Browse files

Unified · Split

34 files
  1. assets/javascripts/app/db.js +7 −12
  2. assets/javascripts/app/searcher.js +3 −13
  3. assets/javascripts/app/serviceworker.js +2 −3
  4. assets/javascripts/app/update_checker.js +3 −5
  5. assets/javascripts/debug.js +1 −1
  6. assets/javascripts/lib/events.js +4 −6
  7. assets/javascripts/views/content/content.js +5 −21
  8. assets/javascripts/views/content/entry_page.js +4 −11
  9. assets/javascripts/views/content/offline_page.js +0 −5
  10. assets/javascripts/views/content/root_page.js +0 −5
  11. assets/javascripts/views/content/settings_page.js +0 −6
  12. assets/javascripts/views/layout/document.js +0 −6
  13. assets/javascripts/views/layout/menu.js +1 −6
  14. assets/javascripts/views/layout/mobile.js +10 −18
  15. assets/javascripts/views/layout/path.js +0 −6
  16. assets/javascripts/views/layout/resizer.js +0 −7
  17. assets/javascripts/views/layout/settings.js +0 −9
  18. assets/javascripts/views/list/list_focus.js +1 −8
  19. assets/javascripts/views/list/list_fold.js +1 −4
  20. assets/javascripts/views/list/list_select.js +1 −2
  21. assets/javascripts/views/misc/notif.js +3 −8
  22. assets/javascripts/views/pages/base.js +5 −4
  23. assets/javascripts/views/pages/hidden.js +1 −2
  24. assets/javascripts/views/pages/jquery.js +1 −5
  25. assets/javascripts/views/pages/sqlite.js +0 −5
  26. assets/javascripts/views/search/search.js +8 −24
  27. assets/javascripts/views/search/search_scope.js +2 −9
  28. assets/javascripts/views/sidebar/doc_list.js +2 −11
  29. assets/javascripts/views/sidebar/doc_picker.js +1 −7
  30. assets/javascripts/views/sidebar/results.js +4 −9
  31. assets/javascripts/views/sidebar/sidebar.js +8 −22
  32. assets/javascripts/views/sidebar/sidebar_hover.js +1 −9
  33. assets/javascripts/views/sidebar/type_list.js +1 −3
  34. assets/javascripts/views/view.js +3 −0
assets/javascripts/app/db.js+7−12
@@ -19,10 +19,6 @@ · 18 unmodified lines
19 }19 }
20 20
21 constructor() {21 constructor() {
22 this.onOpenSuccess = this.onOpenSuccess.bind(this);
23 this.onOpenError = this.onOpenError.bind(this);
24 this.checkForCorruptedDocs = this.checkForCorruptedDocs.bind(this);
25 this.deleteCorruptedDocs = this.deleteCorruptedDocs.bind(this);
26 this.versionMultipler = $.isIE() ? 1e5 : 1e9;22 this.versionMultipler = $.isIE() ? 1e5 : 1e9;
27 this.useIndexedDB = this.useIndexedDB();23 this.useIndexedDB = this.useIndexedDB();
28 this.callbacks = [];24 this.callbacks = [];
@@ -45,9 +41,9 @@ · 16 unmodified lines
45 NAME,41 NAME,
46 VERSION * this.versionMultipler + this.userVersion(),42 VERSION * this.versionMultipler + this.userVersion(),
47 );43 );
48 req.onsuccess = this.onOpenSuccess;44 req.onsuccess = (event) => this.onOpenSuccess(event);
49 req.onerror = this.onOpenError;45 req.onerror = (event) => this.onOpenError(event);
50 req.onupgradeneeded = this.onUpgradeNeeded;46 req.onupgradeneeded = (event) => this.onUpgradeNeeded(event);
51 } catch (error) {47 } catch (error) {
52 this.fail("exception", error);48 this.fail("exception", error);
53 }49 }
@@ -378,8 +374,7 @@ · 324 unmodified lines
378 374
379 load(entry, onSuccess, onError) {375 load(entry, onSuccess, onError) {
380 if (this.shouldLoadWithIDB(entry)) {376 if (this.shouldLoadWithIDB(entry)) {
381 onError = this.loadWithXHR.bind(this, entry, onSuccess, onError);377 return this.loadWithIDB(entry, onSuccess, () => this.loadWithXHR(entry, onSuccess, onError));
382 return this.loadWithIDB(entry, onSuccess, onError);
383 } else {378 } else {
384 return this.loadWithXHR(entry, onSuccess, onError);379 return this.loadWithXHR(entry, onSuccess, onError);
385 }380 }
@@ -440,7 +435,7 @@ · 54 unmodified lines
440 mode: "readonly",435 mode: "readonly",
441 });436 });
442 txn.oncomplete = () => {437 txn.oncomplete = () => {
443 setTimeout(this.checkForCorruptedDocs, 50);438 setTimeout(() => this.checkForCorruptedDocs(), 50);
444 };439 };
445 440
446 const req = txn.objectStore("docs").openCursor();441 const req = txn.objectStore("docs").openCursor();
@@ -486,7 +481,7 @@ · 39 unmodified lines
486 }481 }
487 482
488 if (docs.length === 0) {483 if (docs.length === 0) {
489 setTimeout(this.deleteCorruptedDocs, 0);484 setTimeout(() => this.deleteCorruptedDocs(), 0);
490 return;485 return;
491 }486 }
492 487
@@ -497,7 +492,7 @@ · 4 unmodified lines
497 });492 });
498 txn.oncomplete = () => {493 txn.oncomplete = () => {
499 if (this.corruptedDocs.length > 0) {494 if (this.corruptedDocs.length > 0) {
500 setTimeout(this.deleteCorruptedDocs, 0);495 setTimeout(() => this.deleteCorruptedDocs(), 0);
501 }496 }
502 };497 };
503 498
assets/javascripts/app/searcher.js+3−13
@@ -215,12 +215,7 @@ function scoreFuzzyMatch() { · 214 unmodified lines
215 }215 }
216 216
217 constructor(options) {217 constructor(options) {
218 this.match = this.match.bind(this);218 this.options = $.extend({}, DEFAULTS, options || {});
219 this.matchChunks = this.matchChunks.bind(this);
220 if (options == null) {
221 options = {};
222 }
223 this.options = $.extend({}, DEFAULTS, options);
224 }219 }
225 220
226 find(data, attr, q) {221 find(data, attr, q) {
@@ -307,10 +302,10 @@ function scoreFuzzyMatch() { · 80 unmodified lines
307 this.matchChunk();302 this.matchChunk();
308 303
309 if (this.cursor === this.dataLength || this.scoredEnough()) {304 if (this.cursor === this.dataLength || this.scoredEnough()) {
310 this.delay(this.match);305 this.delay(() => this.match());
311 this.sendResults();306 this.sendResults();
312 } else {307 } else {
313 this.delay(this.matchChunks);308 this.delay(() => this.matchChunks());
314 }309 }
315 }310 }
316 311
@@ -410,11 +405,6 @@ function scoreFuzzyMatch() { · 93 unmodified lines
410})();405})();
411 406
412app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {407app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {
413 constructor(...args) {
414 this.match = this.match.bind(this);
415 super(...args);
416 }
417
418 match() {408 match() {
419 if (this.matcher) {409 if (this.matcher) {
420 if (!this.allResults) {410 if (!this.allResults) {
assets/javascripts/app/serviceworker.js+2−3
@@ -16,7 +16,6 @@ app.ServiceWorker = class ServiceWorker { · 15 unmodified lines
16 }16 }
17 17
18 constructor() {18 constructor() {
19 this.onUpdateFound = this.onUpdateFound.bind(this);
20 this.onStateChange = this.onStateChange.bind(this);19 this.onStateChange = this.onStateChange.bind(this);
21 this.registration = null;20 this.registration = null;
22 this.notifyUpdate = true;21 this.notifyUpdate = true;
@@ -51,12 +50,12 @@ app.ServiceWorker = class ServiceWorker { · 28 unmodified lines
51 50
52 updateRegistration(registration) {51 updateRegistration(registration) {
53 this.registration = registration;52 this.registration = registration;
54 $.on(this.registration, "updatefound", this.onUpdateFound);53 $.on(this.registration, "updatefound", () => this.onUpdateFound());
55 }54 }
56 55
57 onUpdateFound() {56 onUpdateFound() {
58 if (this.installingRegistration) {57 if (this.installingRegistration) {
59 $.off(this.installingRegistration, "statechange", this.onStateChange());58 $.off(this.installingRegistration, "statechange", this.onStateChange);
60 }59 }
61 this.installingRegistration = this.registration.installing;60 this.installingRegistration = this.registration.installing;
62 $.on(this.installingRegistration, "statechange", this.onStateChange);61 $.on(this.installingRegistration, "statechange", this.onStateChange);
assets/javascripts/app/update_checker.js+3−5
@@ -7,16 +7,14 @@ · 6 unmodified lines
7 */7 */
8app.UpdateChecker = class UpdateChecker {8app.UpdateChecker = class UpdateChecker {
9 constructor() {9 constructor() {
10 this.checkDocs = this.checkDocs.bind(this);
11 this.onFocus = this.onFocus.bind(this);
12 this.lastCheck = Date.now();10 this.lastCheck = Date.now();
13 11
14 $.on(window, "focus", this.onFocus);12 $.on(window, "focus", () => this.onFocus());
15 if (app.serviceWorker != null) {13 if (app.serviceWorker != null) {
16 app.serviceWorker.on("updateready", this.onUpdateReady);14 app.serviceWorker.on("updateready", () => this.onUpdateReady());
17 }15 }
18 16
19 setTimeout(this.checkDocs, 0);17 setTimeout(() => this.checkDocs(), 0);
20 }18 }
21 19
22 check() {20 check() {
assets/javascripts/debug.js+1−1
@@ -110,7 +110,7 @@ this.viewTree = function (view, level, visited) { · 109 unmodified lines
110 `%c ${Array(level + 1).join(" ")}${110 `%c ${Array(level + 1).join(" ")}${
111 view.constructor.name111 view.constructor.name
112 }: ${!!view.activated}`,112 }: ${!!view.activated}`,
113 "color:" + ((view.activated && "green") || "red")113 "color:" + ((view.activated && "green") || "red"),
114 );114 );
115 115
116 for (var key of Object.keys(view || {})) {116 for (var key of Object.keys(view || {})) {
assets/javascripts/lib/events.js+4−6
@@ -48,14 +48,12 @@ class Events { · 47 unmodified lines
48 }48 }
49 49
50 trigger(event, ...args) {50 trigger(event, ...args) {
51 let callbacks;
52 this.eventInProgress = { name: event, args };51 this.eventInProgress = { name: event, args };
53 if (52 const callbacks = this._callbacks?.[event];
54 (callbacks = this._callbacks != null ? this._callbacks[event] : undefined)53 if (callbacks) {
55 ) {54 for (let callback of Array.from(callbacks.slice(0))) {
56 for (var callback of Array.from(callbacks.slice(0))) {
57 if (typeof callback === "function") {55 if (typeof callback === "function") {
58 callback(...Array.from(args || []));56 callback(...args);
59 }57 }
60 }58 }
61 }59 }
assets/javascripts/views/content/content.js+5−21
@@ -13,24 +13,6 @@ · 12 unmodified lines
13 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md13 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
14 */14 */
15app.views.Content = class Content extends app.View {15app.views.Content = class Content extends app.View {
16 constructor(...args) {
17 this.scrollToTop = this.scrollToTop.bind(this);
18 this.scrollToBottom = this.scrollToBottom.bind(this);
19 this.scrollStepUp = this.scrollStepUp.bind(this);
20 this.scrollStepDown = this.scrollStepDown.bind(this);
21 this.scrollPageUp = this.scrollPageUp.bind(this);
22 this.scrollPageDown = this.scrollPageDown.bind(this);
23 this.onReady = this.onReady.bind(this);
24 this.onBootError = this.onBootError.bind(this);
25 this.onEntryLoading = this.onEntryLoading.bind(this);
26 this.onEntryLoaded = this.onEntryLoaded.bind(this);
27 this.beforeRoute = this.beforeRoute.bind(this);
28 this.afterRoute = this.afterRoute.bind(this);
29 this.onClick = this.onClick.bind(this);
30 this.onAltF = this.onAltF.bind(this);
31 super(...args);
32 }
33
34 static initClass() {16 static initClass() {
35 this.el = "._content";17 this.el = "._content";
36 this.loadingClass = "_content-loading";18 this.loadingClass = "_content-loading";
@@ -68,10 +50,12 @@ app.views.Content = class Content extends app.View { · 31 unmodified lines
68 this.entryPage = new app.views.EntryPage();50 this.entryPage = new app.views.EntryPage();
69 51
70 this.entryPage52 this.entryPage
71 .on("loading", this.onEntryLoading)53 .on("loading", () => this.onEntryLoading())
72 .on("loaded", this.onEntryLoaded);54 .on("loaded", () => this.onEntryLoaded());
73 55
74 app.on("ready", this.onReady).on("bootError", this.onBootError);56 app
57 .on("ready", () => this.onReady())
58 .on("bootError", () => this.onBootError());
75 }59 }
76 60
77 show(view) {61 show(view) {
assets/javascripts/views/content/entry_page.js+4−11
@@ -13,16 +13,6 @@ · 12 unmodified lines
13(function () {13(function () {
14 let LINKS = undefined;14 let LINKS = undefined;
15 app.views.EntryPage = class EntryPage extends app.View {15 app.views.EntryPage = class EntryPage extends app.View {
16 constructor(...args) {
17 this.beforeRoute = this.beforeRoute.bind(this);
18 this.onSuccess = this.onSuccess.bind(this);
19 this.onError = this.onError.bind(this);
20 this.onClick = this.onClick.bind(this);
21 this.onAltC = this.onAltC.bind(this);
22 this.onAltO = this.onAltO.bind(this);
23 super(...args);
24 }
25
26 static initClass() {16 static initClass() {
27 this.className = "_page";17 this.className = "_page";
28 this.errorClass = "_page-error";18 this.errorClass = "_page-error";
@@ -182,7 +172,10 @@ · 153 unmodified lines
182 172
183 load() {173 load() {
184 this.loading();174 this.loading();
185 this.xhr = this.entry.loadFile(this.onSuccess, this.onError);175 this.xhr = this.entry.loadFile(
176 (response) => this.onSuccess(response),
177 () => this.onError(),
178 );
186 }179 }
187 180
188 abort() {181 abort() {
assets/javascripts/views/content/offline_page.js+0−5
@@ -9,11 +9,6 @@ · 8 unmodified lines
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */10 */
11app.views.OfflinePage = class OfflinePage extends app.View {11app.views.OfflinePage = class OfflinePage extends app.View {
12 constructor(...args) {
13 this.onClick = this.onClick.bind(this);
14 super(...args);
15 }
16
17 static initClass() {12 static initClass() {
18 this.className = "_static";13 this.className = "_static";
19 14
assets/javascripts/views/content/root_page.js+0−5
@@ -8,11 +8,6 @@ · 7 unmodified lines
8 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md8 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
9 */9 */
10app.views.RootPage = class RootPage extends app.View {10app.views.RootPage = class RootPage extends app.View {
11 constructor(...args) {
12 this.onClick = this.onClick.bind(this);
13 super(...args);
14 }
15
16 static initClass() {11 static initClass() {
17 this.events = { click: "onClick" };12 this.events = { click: "onClick" };
18 }13 }
assets/javascripts/views/content/settings_page.js+0−6
@@ -10,12 +10,6 @@ · 9 unmodified lines
10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
11 */11 */
12app.views.SettingsPage = class SettingsPage extends app.View {12app.views.SettingsPage = class SettingsPage extends app.View {
13 constructor(...args) {
14 this.onChange = this.onChange.bind(this);
15 this.onClick = this.onClick.bind(this);
16 super(...args);
17 }
18
19 static initClass() {13 static initClass() {
20 this.className = "_static";14 this.className = "_static";
21 15
assets/javascripts/views/layout/document.js+0−6
@@ -9,12 +9,6 @@ · 8 unmodified lines
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */10 */
11app.views.Document = class Document extends app.View {11app.views.Document = class Document extends app.View {
12 constructor(...args) {
13 this.afterRoute = this.afterRoute.bind(this);
14 this.onVisibilityChange = this.onVisibilityChange.bind(this);
15 super(...args);
16 }
17
18 static initClass() {12 static initClass() {
19 this.el = document;13 this.el = document;
20 14
assets/javascripts/views/layout/menu.js+1−6
@@ -7,11 +7,6 @@ · 6 unmodified lines
7 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md7 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
8 */8 */
9app.views.Menu = class Menu extends app.View {9app.views.Menu = class Menu extends app.View {
10 constructor(...args) {
11 this.onGlobalClick = this.onGlobalClick.bind(this);
12 super(...args);
13 }
14
15 static initClass() {10 static initClass() {
16 this.el = "._menu";11 this.el = "._menu";
17 this.activeClass = "active";12 this.activeClass = "active";
@@ -20,7 +15,7 @@ app.views.Menu = class Menu extends app.View { · 2 unmodified lines
20 }15 }
21 16
22 init() {17 init() {
23 $.on(document.body, "click", this.onGlobalClick);18 $.on(document.body, "click", (event) => this.onGlobalClick(event));
24 }19 }
25 20
26 onClick(event) {21 onClick(event) {
assets/javascripts/views/layout/mobile.js+10−18
@@ -54,44 +54,36 @@ app.views.Mobile = class Mobile extends app.View { · 53 unmodified lines
54 }54 }
55 55
56 constructor() {56 constructor() {
57 this.showSidebar = this.showSidebar.bind(this);
58 this.hideSidebar = this.hideSidebar.bind(this);
59 this.onClickBack = this.onClickBack.bind(this);
60 this.onClickForward = this.onClickForward.bind(this);
61 this.onClickToggleSidebar = this.onClickToggleSidebar.bind(this);
62 this.onClickDocPickerTab = this.onClickDocPickerTab.bind(this);
63 this.onClickSettingsTab = this.onClickSettingsTab.bind(this);
64 this.onTapSearch = this.onTapSearch.bind(this);
65 this.onEscape = this.onEscape.bind(this);
66 this.afterRoute = this.afterRoute.bind(this);
67 this.el = document.documentElement;
68 super(...arguments);57 super(...arguments);
58 this.el = document.documentElement;
69 }59 }
70 60
71 init() {61 init() {
72 $.on($("._search"), "touchend", this.onTapSearch);62 $.on($("._search"), "touchend", () => this.onTapSearch());
73 63
74 this.toggleSidebar = $("button[data-toggle-sidebar]");64 this.toggleSidebar = $("button[data-toggle-sidebar]");
75 this.toggleSidebar.removeAttribute("hidden");65 this.toggleSidebar.removeAttribute("hidden");
76 $.on(this.toggleSidebar, "click", this.onClickToggleSidebar);66 $.on(this.toggleSidebar, "click", () => this.onClickToggleSidebar());
77 67
78 this.back = $("button[data-back]");68 this.back = $("button[data-back]");
79 this.back.removeAttribute("hidden");69 this.back.removeAttribute("hidden");
80 $.on(this.back, "click", this.onClickBack);70 $.on(this.back, "click", () => this.onClickBack());
81 71
82 this.forward = $("button[data-forward]");72 this.forward = $("button[data-forward]");
83 this.forward.removeAttribute("hidden");73 this.forward.removeAttribute("hidden");
84 $.on(this.forward, "click", this.onClickForward);74 $.on(this.forward, "click", () => this.onClickForward());
85 75
86 this.docPickerTab = $('button[data-tab="doc-picker"]');76 this.docPickerTab = $('button[data-tab="doc-picker"]');
87 this.docPickerTab.removeAttribute("hidden");77 this.docPickerTab.removeAttribute("hidden");
88 $.on(this.docPickerTab, "click", this.onClickDocPickerTab);78 $.on(this.docPickerTab, "click", (event) =>
79 this.onClickDocPickerTab(event),
80 );
89 81
90 this.settingsTab = $('button[data-tab="settings"]');82 this.settingsTab = $('button[data-tab="settings"]');
91 this.settingsTab.removeAttribute("hidden");83 this.settingsTab.removeAttribute("hidden");
92 $.on(this.settingsTab, "click", this.onClickSettingsTab);84 $.on(this.settingsTab, "click", (event) => this.onClickSettingsTab(event));
93 85
94 app.document.sidebar.search.on("searching", this.showSidebar);86 app.document.sidebar.search.on("searching", () => this.showSidebar());
95 87
96 this.activate();88 this.activate();
97 }89 }
assets/javascripts/views/layout/path.js+0−6
@@ -8,12 +8,6 @@ · 7 unmodified lines
8 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md8 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
9 */9 */
10app.views.Path = class Path extends app.View {10app.views.Path = class Path extends app.View {
11 constructor(...args) {
12 this.onClick = this.onClick.bind(this);
13 this.afterRoute = this.afterRoute.bind(this);
14 super(...args);
15 }
16
17 static initClass() {11 static initClass() {
18 this.className = "_path";12 this.className = "_path";
19 this.attributes = { role: "complementary" };13 this.attributes = { role: "complementary" };
assets/javascripts/views/layout/resizer.js+0−7
@@ -11,13 +11,6 @@ · 10 unmodified lines
11 let MIN = undefined;11 let MIN = undefined;
12 let MAX = undefined;12 let MAX = undefined;
13 app.views.Resizer = class Resizer extends app.View {13 app.views.Resizer = class Resizer extends app.View {
14 constructor(...args) {
15 this.onDragStart = this.onDragStart.bind(this);
16 this.onDrag = this.onDrag.bind(this);
17 this.onDragEnd = this.onDragEnd.bind(this);
18 super(...args);
19 }
20
21 static initClass() {14 static initClass() {
22 this.className = "_resizer";15 this.className = "_resizer";
23 16
assets/javascripts/views/layout/settings.js+0−9
@@ -13,15 +13,6 @@ · 12 unmodified lines
13(function () {13(function () {
14 let SIDEBAR_HIDDEN_LAYOUT = undefined;14 let SIDEBAR_HIDDEN_LAYOUT = undefined;
15 app.views.Settings = class Settings extends app.View {15 app.views.Settings = class Settings extends app.View {
16 constructor(...args) {
17 this.onChange = this.onChange.bind(this);
18 this.onEnter = this.onEnter.bind(this);
19 this.onSubmit = this.onSubmit.bind(this);
20 this.onImport = this.onImport.bind(this);
21 this.onClick = this.onClick.bind(this);
22 super(...args);
23 }
24
25 static initClass() {16 static initClass() {
26 SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden";17 SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden";
27 18
assets/javascripts/views/list/list_focus.js+1−8
@@ -25,15 +25,8 @@ app.views.ListFocus = class ListFocus extends app.View { · 24 unmodified lines
25 }25 }
26 26
27 constructor(el) {27 constructor(el) {
28 this.blur = this.blur.bind(this);
29 this.onDown = this.onDown.bind(this);
30 this.onUp = this.onUp.bind(this);
31 this.onLeft = this.onLeft.bind(this);
32 this.onEnter = this.onEnter.bind(this);
33 this.onSuperEnter = this.onSuperEnter.bind(this);
34 this.onClick = this.onClick.bind(this);
35 this.el = el;
36 super(...arguments);28 super(...arguments);
29 this.el = el;
37 this.focusOnNextFrame = $.framify(this.focus, this);30 this.focusOnNextFrame = $.framify(this.focus, this);
38 }31 }
39 32
assets/javascripts/views/list/list_fold.js+1−4
@@ -23,11 +23,8 @@ app.views.ListFold = class ListFold extends app.View { · 22 unmodified lines
23 }23 }
24 24
25 constructor(el) {25 constructor(el) {
26 this.onLeft = this.onLeft.bind(this);
27 this.onRight = this.onRight.bind(this);
28 this.onClick = this.onClick.bind(this);
29 this.el = el;
30 super(...arguments);26 super(...arguments);
27 this.el = el;
31 }28 }
32 29
33 open(el) {30 open(el) {
assets/javascripts/views/list/list_select.js+1−2
@@ -16,9 +16,8 @@ app.views.ListSelect = class ListSelect extends app.View { · 15 unmodified lines
16 }16 }
17 17
18 constructor(el) {18 constructor(el) {
19 this.onClick = this.onClick.bind(this);
20 this.el = el;
21 super(...arguments);19 super(...arguments);
20 this.el = el;
22 }21 }
23 22
24 deactivate() {23 deactivate() {
assets/javascripts/views/misc/notif.js+3−8
@@ -13,20 +13,15 @@ app.views.Notif = class Notif extends app.View { · 12 unmodified lines
13 this.activeClass = "_in";13 this.activeClass = "_in";
14 this.attributes = { role: "alert" };14 this.attributes = { role: "alert" };
15 15
16 this.defautOptions = { autoHide: 15000 };16 this.defaultOptions = { autoHide: 15000 };
17 17
18 this.events = { click: "onClick" };18 this.events = { click: "onClick" };
19 }19 }
20 20
21 constructor(type, options) {21 constructor(type, options) {
22 this.onClick = this.onClick.bind(this);
23 this.type = type;
24 if (options == null) {
25 options = {};
26 }
27 this.options = options;
28 this.options = $.extend({}, this.constructor.defautOptions, this.options);
29 super(...arguments);22 super(...arguments);
23 this.type = type;
24 this.options = $.extend({}, this.constructor.defaultOptions, options || {});
30 }25 }
31 26
32 init() {27 init() {
assets/javascripts/views/pages/base.js+5−4
@@ -10,10 +10,9 @@ · 9 unmodified lines
10 */10 */
11app.views.BasePage = class BasePage extends app.View {11app.views.BasePage = class BasePage extends app.View {
12 constructor(el, entry) {12 constructor(el, entry) {
13 this.paintCode = this.paintCode.bind(this);13 super(...arguments);
14 this.el = el;14 this.el = el;
15 this.entry = entry;15 this.entry = entry;
16 super(...arguments);
17 }16 }
18 17
19 deactivate() {18 deactivate() {
@@ -40,7 +39,9 @@ app.views.BasePage = class BasePage extends app.View { · 20 unmodified lines
40 this.delay(this.afterRender);39 this.delay(this.afterRender);
41 }40 }
42 if (this.highlightNodes.length > 0) {41 if (this.highlightNodes.length > 0) {
43 $.requestAnimationFrame(() => $.requestAnimationFrame(this.paintCode));42 $.requestAnimationFrame(() =>
43 $.requestAnimationFrame(() => this.paintCode()),
44 );
44 }45 }
45 }46 }
46 47
@@ -80,7 +81,7 @@ app.views.BasePage = class BasePage extends app.View { · 33 unmodified lines
80 }81 }
81 82
82 if (this.highlightNodes.length > 0) {83 if (this.highlightNodes.length > 0) {
83 $.requestAnimationFrame(this.paintCode);84 $.requestAnimationFrame(() => this.paintCode());
84 }85 }
85 this.previousTiming = timing;86 this.previousTiming = timing;
86 }87 }
assets/javascripts/views/pages/hidden.js+1−2
@@ -12,10 +12,9 @@ app.views.HiddenPage = class HiddenPage extends app.View { · 11 unmodified lines
12 }12 }
13 13
14 constructor(el, entry) {14 constructor(el, entry) {
15 this.onClick = this.onClick.bind(this);15 super(...arguments);
16 this.el = el;16 this.el = el;
17 this.entry = entry;17 this.entry = entry;
18 super(...arguments);
19 }18 }
20 19
21 init() {20 init() {
assets/javascripts/views/pages/jquery.js+1−5
@@ -11,11 +11,6 @@ · 10 unmodified lines
11//= require views/pages/base11//= require views/pages/base
12 12
13app.views.JqueryPage = class JqueryPage extends app.views.BasePage {13app.views.JqueryPage = class JqueryPage extends app.views.BasePage {
14 constructor(...args) {
15 this.onIframeLoaded = this.onIframeLoaded.bind(this);
16 super(...args);
17 }
18
19 static initClass() {14 static initClass() {
20 this.demoClassName = "_jquery-demo";15 this.demoClassName = "_jquery-demo";
21 }16 }
@@ -24,6 +19,7 @@ app.views.JqueryPage = class JqueryPage extends app.views.BasePage { · 2 unmodified lines
24 // Prevent jQuery Mobile's demo iframes from scrolling the page19 // Prevent jQuery Mobile's demo iframes from scrolling the page
25 for (var iframe of Array.from(this.findAllByTag("iframe"))) {20 for (var iframe of Array.from(this.findAllByTag("iframe"))) {
26 iframe.style.display = "none";21 iframe.style.display = "none";
22 this.onIframeLoaded = this.onIframeLoaded.bind(this);
27 $.on(iframe, "load", this.onIframeLoaded);23 $.on(iframe, "load", this.onIframeLoaded);
28 }24 }
29 25
assets/javascripts/views/pages/sqlite.js+0−5
@@ -9,11 +9,6 @@ · 8 unmodified lines
9//= require views/pages/base9//= require views/pages/base
10 10
11app.views.SqlitePage = class SqlitePage extends app.views.BasePage {11app.views.SqlitePage = class SqlitePage extends app.views.BasePage {
12 constructor(...args) {
13 this.onClick = this.onClick.bind(this);
14 super(...args);
15 }
16
17 static initClass() {12 static initClass() {
18 this.events = { click: "onClick" };13 this.events = { click: "onClick" };
19 }14 }
assets/javascripts/views/search/search.js+8−24
@@ -13,24 +13,6 @@ · 12 unmodified lines
13 let SEARCH_PARAM = undefined;13 let SEARCH_PARAM = undefined;
14 let HASH_RGX = undefined;14 let HASH_RGX = undefined;
15 app.views.Search = class Search extends app.View {15 app.views.Search = class Search extends app.View {
16 constructor(...args) {
17 this.focus = this.focus.bind(this);
18 this.autoFocus = this.autoFocus.bind(this);
19 this.onWindowFocus = this.onWindowFocus.bind(this);
20 this.onReady = this.onReady.bind(this);
21 this.onInput = this.onInput.bind(this);
22 this.searchUrl = this.searchUrl.bind(this);
23 this.google = this.google.bind(this);
24 this.stackoverflow = this.stackoverflow.bind(this);
25 this.duckduckgo = this.duckduckgo.bind(this);
26 this.onResults = this.onResults.bind(this);
27 this.onEnd = this.onEnd.bind(this);
28 this.onClick = this.onClick.bind(this);
29 this.onScopeChange = this.onScopeChange.bind(this);
30 this.afterRoute = this.afterRoute.bind(this);
31 super(...args);
32 }
33
34 static initClass() {16 static initClass() {
35 SEARCH_PARAM = app.config.search_param;17 SEARCH_PARAM = app.config.search_param;
36 18
@@ -64,13 +46,15 @@ · 27 unmodified lines
64 this.addSubview((this.scope = new app.views.SearchScope(this.el)));46 this.addSubview((this.scope = new app.views.SearchScope(this.el)));
65 47
66 this.searcher = new app.Searcher();48 this.searcher = new app.Searcher();
67 this.searcher.on("results", this.onResults).on("end", this.onEnd);49 this.searcher
50 .on("results", (results) => this.onResults(results))
51 .on("end", () => this.onEnd());
68 52
69 this.scope.on("change", this.onScopeChange);53 this.scope.on("change", () => this.onScopeChange());
70 54
71 app.on("ready", this.onReady);55 app.on("ready", () => this.onReady());
72 $.on(window, "hashchange", this.searchUrl);56 $.on(window, "hashchange", () => this.searchUrl());
73 $.on(window, "focus", this.onWindowFocus);57 $.on(window, "focus", (event) => this.onWindowFocus(event));
74 }58 }
75 59
76 focus() {60 focus() {
@@ -247,7 +231,7 @@ · 170 unmodified lines
247 if (context.hash) {231 if (context.hash) {
248 this.delay(this.searchUrl);232 this.delay(this.searchUrl);
249 }233 }
250 $.requestAnimationFrame(this.autoFocus);234 $.requestAnimationFrame(() => this.autoFocus());
251 }235 }
252 236
253 extractHashValue() {237 extractHashValue() {
assets/javascripts/views/search/search_scope.js+2−9
@@ -33,15 +33,8 @@ · 32 unmodified lines
33 }33 }
34 34
35 constructor(el) {35 constructor(el) {
36 this.onResults = this.onResults.bind(this);
37 this.reset = this.reset.bind(this);
38 this.doScopeSearch = this.doScopeSearch.bind(this);
39 this.onClick = this.onClick.bind(this);
40 this.onKeydown = this.onKeydown.bind(this);
41 this.onTextInput = this.onTextInput.bind(this);
42 this.afterRoute = this.afterRoute.bind(this);
43 this.el = el;
44 super(...arguments);36 super(...arguments);
37 this.el = el;
45 }38 }
46 39
47 init() {40 init() {
@@ -51,7 +44,7 @@ · 3 unmodified lines
51 fuzzy_min_length: 2,44 fuzzy_min_length: 2,
52 max_results: 1,45 max_results: 1,
53 });46 });
54 this.searcher.on("results", this.onResults);47 this.searcher.on("results", (results) => this.onResults(results));
55 }48 }
56 49
57 getScope() {50 getScope() {
assets/javascripts/views/sidebar/doc_list.js+2−11
@@ -9,16 +9,6 @@ · 8 unmodified lines
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */10 */
11app.views.DocList = class DocList extends app.View {11app.views.DocList = class DocList extends app.View {
12 constructor(...args) {
13 this.render = this.render.bind(this);
14 this.onOpen = this.onOpen.bind(this);
15 this.onClose = this.onClose.bind(this);
16 this.onClick = this.onClick.bind(this);
17 this.onEnabled = this.onEnabled.bind(this);
18 this.afterRoute = this.afterRoute.bind(this);
19 super(...args);
20 }
21
22 static initClass() {12 static initClass() {
23 this.className = "_list";13 this.className = "_list";
24 this.attributes = { role: "navigation" };14 this.attributes = { role: "navigation" };
@@ -44,7 +34,7 @@ app.views.DocList = class DocList extends app.View { · 19 unmodified lines
44 this.addSubview((this.listFold = new app.views.ListFold(this.el)));34 this.addSubview((this.listFold = new app.views.ListFold(this.el)));
45 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));35 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
46 36
47 app.on("ready", this.render);37 app.on("ready", () => this.render());
48 }38 }
49 39
50 activate() {40 activate() {
@@ -248,6 +238,7 @@ app.views.DocList = class DocList extends app.View { · 197 unmodified lines
248 $.stopEvent(event);238 $.stopEvent(event);
249 const doc = app.disabledDocs.findBy("slug", slug);239 const doc = app.disabledDocs.findBy("slug", slug);
250 if (doc) {240 if (doc) {
241 this.onEnabled = this.onEnabled.bind(this);
251 app.enableDoc(doc, this.onEnabled, this.onEnabled);242 app.enableDoc(doc, this.onEnabled, this.onEnabled);
252 }243 }
253 }244 }
assets/javascripts/views/sidebar/doc_picker.js+1−7
@@ -11,13 +11,6 @@ · 10 unmodified lines
11 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md11 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
12 */12 */
13app.views.DocPicker = class DocPicker extends app.View {13app.views.DocPicker = class DocPicker extends app.View {
14 constructor(...args) {
15 this.onMouseDown = this.onMouseDown.bind(this);
16 this.onMouseUp = this.onMouseUp.bind(this);
17 this.onDOMFocus = this.onDOMFocus.bind(this);
18 super(...args);
19 }
20
21 static initClass() {14 static initClass() {
22 this.className = "_list _list-picker";15 this.className = "_list _list-picker";
23 16
@@ -34,6 +27,7 @@ app.views.DocPicker = class DocPicker extends app.View { · 10 unmodified lines
34 activate() {27 activate() {
35 if (super.activate(...arguments)) {28 if (super.activate(...arguments)) {
36 this.render();29 this.render();
30 this.onDOMFocus = this.onDOMFocus.bind(this);
37 $.on(this.el, "focus", this.onDOMFocus, true);31 $.on(this.el, "focus", this.onDOMFocus, true);
38 }32 }
39 }33 }
assets/javascripts/views/sidebar/results.js+4−9
@@ -18,14 +18,9 @@ app.views.Results = class Results extends app.View { · 17 unmodified lines
18 }18 }
19 19
20 constructor(sidebar, search) {20 constructor(sidebar, search) {
21 this.onResults = this.onResults.bind(this);21 super(...arguments);
22 this.onNoResults = this.onNoResults.bind(this);
23 this.onClear = this.onClear.bind(this);
24 this.afterRoute = this.afterRoute.bind(this);
25 this.onClick = this.onClick.bind(this);
26 this.sidebar = sidebar;22 this.sidebar = sidebar;
27 this.search = search;23 this.search = search;
28 super(...arguments);
29 }24 }
30 25
31 deactivate() {26 deactivate() {
@@ -39,9 +34,9 @@ app.views.Results = class Results extends app.View { · 7 unmodified lines
39 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));34 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
40 35
41 this.search36 this.search
42 .on("results", this.onResults)37 .on("results", (entries, flags) => this.onResults(entries, flags))
43 .on("noresults", this.onNoResults)38 .on("noresults", () => this.onNoResults())
44 .on("clear", this.onClear);39 .on("clear", () => this.onClear());
45 }40 }
46 41
47 onResults(entries, flags) {42 onResults(entries, flags) {
assets/javascripts/views/sidebar/sidebar.js+8−22
@@ -10,23 +10,6 @@ · 9 unmodified lines
10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md10 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
11 */11 */
12app.views.Sidebar = class Sidebar extends app.View {12app.views.Sidebar = class Sidebar extends app.View {
13 constructor(...args) {
14 this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
15 this.resetHover = this.resetHover.bind(this);
16 this.showResults = this.showResults.bind(this);
17 this.onReady = this.onReady.bind(this);
18 this.onScopeChange = this.onScopeChange.bind(this);
19 this.onSearching = this.onSearching.bind(this);
20 this.onSearchClear = this.onSearchClear.bind(this);
21 this.onFocus = this.onFocus.bind(this);
22 this.onSelect = this.onSelect.bind(this);
23 this.onClick = this.onClick.bind(this);
24 this.onAltR = this.onAltR.bind(this);
25 this.onEscape = this.onEscape.bind(this);
26 this.afterRoute = this.afterRoute.bind(this);
27 super(...args);
28 }
29
30 static initClass() {13 static initClass() {
31 this.el = "._sidebar";14 this.el = "._sidebar";
32 15
@@ -51,14 +34,16 @@ app.views.Sidebar = class Sidebar extends app.View { · 18 unmodified lines
51 this.addSubview((this.search = new app.views.Search()));34 this.addSubview((this.search = new app.views.Search()));
52 35
53 this.search36 this.search
54 .on("searching", this.onSearching)37 .on("searching", () => this.onSearching())
55 .on("clear", this.onSearchClear)38 .on("clear", () => this.onSearchClear())
56 .scope.on("change", this.onScopeChange);39 .scope.on("change", (newDoc, previousDoc) =>
40 this.onScopeChange((newDoc, previousDoc)),
41 );
57 42
58 this.results = new app.views.Results(this, this.search);43 this.results = new app.views.Results(this, this.search);
59 this.docList = new app.views.DocList();44 this.docList = new app.views.DocList();
60 45
61 app.on("ready", this.onReady);46 app.on("ready", () => this.onReady());
62 47
63 $.on(document.documentElement, "mouseleave", () => this.hide());48 $.on(document.documentElement, "mouseleave", () => this.hide());
64 $.on(document.documentElement, "mouseenter", () =>49 $.on(document.documentElement, "mouseenter", () =>
@@ -85,13 +70,14 @@ app.views.Sidebar = class Sidebar extends app.View { · 20 unmodified lines
85 70
86 if (options.forceNoHover !== false && !this.hasClass("no-hover")) {71 if (options.forceNoHover !== false && !this.hasClass("no-hover")) {
87 this.addClass("no-hover");72 this.addClass("no-hover");
73 this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
88 $.on(window, "mousemove", this.resetHoverOnMouseMove);74 $.on(window, "mousemove", this.resetHoverOnMouseMove);
89 }75 }
90 }76 }
91 77
92 resetHoverOnMouseMove() {78 resetHoverOnMouseMove() {
93 $.off(window, "mousemove", this.resetHoverOnMouseMove);79 $.off(window, "mousemove", this.resetHoverOnMouseMove);
94 return $.requestAnimationFrame(this.resetHover);80 return $.requestAnimationFrame(() => this.resetHover());
95 }81 }
96 82
97 resetHover() {83 resetHover() {
assets/javascripts/views/sidebar/sidebar_hover.js+1−9
@@ -26,19 +26,11 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 25 unmodified lines
26 }26 }
27 27
28 constructor(el) {28 constructor(el) {
29 this.position = this.position.bind(this);29 super(...arguments);
30 this.onFocus = this.onFocus.bind(this);
31 this.onBlur = this.onBlur.bind(this);
32 this.onMouseover = this.onMouseover.bind(this);
33 this.onMouseout = this.onMouseout.bind(this);
34 this.onScroll = this.onScroll.bind(this);
35 this.onClick = this.onClick.bind(this);
36 this.onRoute = this.onRoute.bind(this);
37 this.el = el;30 this.el = el;
38 if (!isPointerEventsSupported()) {31 if (!isPointerEventsSupported()) {
39 delete this.constructor.events.mouseover;32 delete this.constructor.events.mouseover;
40 }33 }
41 super(...arguments);
42 }34 }
43 35
44 show(el) {36 show(el) {
assets/javascripts/views/sidebar/type_list.js+1−3
@@ -21,10 +21,8 @@ app.views.TypeList = class TypeList extends app.View { · 20 unmodified lines
21 }21 }
22 22
23 constructor(doc) {23 constructor(doc) {
24 this.onOpen = this.onOpen.bind(this);
25 this.onClose = this.onClose.bind(this);
26 this.doc = doc;
27 super(...arguments);24 super(...arguments);
25 this.doc = doc;
28 }26 }
29 27
30 init() {28 init() {
assets/javascripts/views/view.js+3−0
@@ -174,6 +174,7 @@ app.View = class View { · 173 unmodified lines
174 if (this.constructor.events) {174 if (this.constructor.events) {
175 for (name in this.constructor.events) {175 for (name in this.constructor.events) {
176 method = this.constructor.events[name];176 method = this.constructor.events[name];
177 this[method] = this[method].bind(this);
177 this.onDOM(name, this[method]);178 this.onDOM(name, this[method]);
178 }179 }
179 }180 }
@@ -181,6 +182,7 @@ app.View = class View { · 1 unmodified line
181 if (this.constructor.routes) {182 if (this.constructor.routes) {
182 for (name in this.constructor.routes) {183 for (name in this.constructor.routes) {
183 method = this.constructor.routes[name];184 method = this.constructor.routes[name];
185 this[method] = this[method].bind(this);
184 app.router.on(name, this[method]);186 app.router.on(name, this[method]);
185 }187 }
186 }188 }
@@ -188,6 +190,7 @@ app.View = class View { · 1 unmodified line
188 if (this.constructor.shortcuts) {190 if (this.constructor.shortcuts) {
189 for (name in this.constructor.shortcuts) {191 for (name in this.constructor.shortcuts) {
190 method = this.constructor.shortcuts[name];192 method = this.constructor.shortcuts[name];
193 this[method] = this[method].bind(this);
191 app.shortcuts.on(name, this[method]);194 app.shortcuts.on(name, this[method]);
192 }195 }
193 }196 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t