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