Skip to content

Commit

Permalink
Fix app.View constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Aug 2, 2023
1 parent 917a8b6 commit 845709b
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 165 deletions.
33 changes: 17 additions & 16 deletions assets/javascripts/views/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.Content = class Content extends app.View {
constructor(...args) {
super(...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);
constructor() {
super();
}

static initClass() {
Expand All @@ -50,6 +36,21 @@ app.views.Content = class Content extends app.View {
}

init() {
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);

this.scrollEl = app.isMobile()
? document.scrollingElement || document.body
: this.el;
Expand Down
17 changes: 9 additions & 8 deletions assets/javascripts/views/content/entry_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@
(function () {
let LINKS = undefined;
app.views.EntryPage = class EntryPage extends app.View {
constructor(...args) {
super(...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);
constructor() {
super();
}

static initClass() {
Expand All @@ -40,6 +34,13 @@
}

init() {
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);

this.cacheMap = {};
this.cacheStack = [];
}
Expand Down
9 changes: 6 additions & 3 deletions assets/javascripts/views/content/offline_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.OfflinePage = class OfflinePage extends app.View {
constructor(...args) {
super(...args);
this.onClick = this.onClick.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -20,6 +19,10 @@ app.views.OfflinePage = class OfflinePage extends app.View {
};
}

init() {
this.onClick = this.onClick.bind(this);
}

deactivate() {
if (super.deactivate(...arguments)) {
this.empty();
Expand Down
4 changes: 2 additions & 2 deletions assets/javascripts/views/content/root_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.RootPage = class RootPage extends app.View {
constructor(...args) {
super(...args);
constructor() {
super();
this.onClick = this.onClick.bind(this);
}

Expand Down
11 changes: 7 additions & 4 deletions assets/javascripts/views/content/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.SettingsPage = class SettingsPage extends app.View {
constructor(...args) {
super(...args);
this.onChange = this.onChange.bind(this);
this.onClick = this.onClick.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -22,6 +20,11 @@ app.views.SettingsPage = class SettingsPage extends app.View {
};
}

init() {
this.onChange = this.onChange.bind(this);
this.onClick = this.onClick.bind(this);
}

render() {
this.html(this.tmpl("settingsPage", this.currentSettings()));
}
Expand Down
9 changes: 5 additions & 4 deletions assets/javascripts/views/layout/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.Document = class Document extends app.View {
constructor(...args) {
super(...args);
this.afterRoute = this.afterRoute.bind(this);
this.onVisibilityChange = this.onVisibilityChange.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -28,6 +26,9 @@ app.views.Document = class Document extends app.View {
}

init() {
this.afterRoute = this.afterRoute.bind(this);
this.onVisibilityChange = this.onVisibilityChange.bind(this);

this.addSubview(
(this.menu = new app.views.Menu()),
this.addSubview((this.sidebar = new app.views.Sidebar()))
Expand Down
7 changes: 4 additions & 3 deletions assets/javascripts/views/layout/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.Menu = class Menu extends app.View {
constructor(...args) {
super(...args);
this.onGlobalClick = this.onGlobalClick.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -17,6 +16,8 @@ app.views.Menu = class Menu extends app.View {
}

init() {
this.onGlobalClick = this.onGlobalClick.bind(this);

$.on(document.body, "click", this.onGlobalClick);
}

Expand Down
6 changes: 3 additions & 3 deletions assets/javascripts/views/layout/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ app.views.Mobile = class Mobile extends app.View {

constructor() {
super(document.documentElement);
}

init() {
this.showSidebar = this.showSidebar.bind(this);
this.hideSidebar = this.hideSidebar.bind(this);
this.onClickBack = this.onClickBack.bind(this);
Expand All @@ -62,10 +65,7 @@ app.views.Mobile = class Mobile extends app.View {
this.onTapSearch = this.onTapSearch.bind(this);
this.onEscape = this.onEscape.bind(this);
this.afterRoute = this.afterRoute.bind(this);
this.el = document.documentElement;
}

init() {
$.on($("._search"), "touchend", this.onTapSearch);

this.toggleSidebar = $("button[data-toggle-sidebar]");
Expand Down
11 changes: 7 additions & 4 deletions assets/javascripts/views/layout/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
app.views.Path = class Path extends app.View {
constructor(...args) {
super(...args);
this.onClick = this.onClick.bind(this);
this.afterRoute = this.afterRoute.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -20,6 +18,11 @@ app.views.Path = class Path extends app.View {
this.routes = { after: "afterRoute" };
}

init() {
this.onClick = this.onClick.bind(this);
this.afterRoute = this.afterRoute.bind(this);
}

render(...args) {
this.html(this.tmpl("path", ...Array.from(args)));
this.show();
Expand Down
11 changes: 6 additions & 5 deletions assets/javascripts/views/layout/resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
let MIN = undefined;
let MAX = undefined;
app.views.Resizer = class Resizer extends app.View {
constructor(...args) {
super(...args);
this.onDragStart = this.onDragStart.bind(this);
this.onDrag = this.onDrag.bind(this);
this.onDragEnd = this.onDragEnd.bind(this);
constructor() {
super();
}

static initClass() {
Expand All @@ -32,6 +29,10 @@
}

init() {
this.onDragStart = this.onDragStart.bind(this);
this.onDrag = this.onDrag.bind(this);
this.onDragEnd = this.onDragEnd.bind(this);

this.el.setAttribute("draggable", "true");
this.appendTo($("._app"));
}
Expand Down
15 changes: 8 additions & 7 deletions assets/javascripts/views/layout/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@
(function () {
let SIDEBAR_HIDDEN_LAYOUT = undefined;
app.views.Settings = class Settings extends app.View {
constructor(...args) {
super(...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);
constructor() {
super();
}

static initClass() {
Expand All @@ -41,6 +36,12 @@
}

init() {
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);

this.addSubview((this.docPicker = new app.views.DocPicker()));
}

Expand Down
4 changes: 3 additions & 1 deletion assets/javascripts/views/list/list_focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ app.views.ListFocus = class ListFocus extends app.View {

constructor(el) {
super(el);
}

init() {
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;
this.focusOnNextFrame = $.framify(this.focus, this);
}

Expand Down
4 changes: 3 additions & 1 deletion assets/javascripts/views/list/list_fold.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ app.views.ListFold = class ListFold extends app.View {

constructor(el) {
super(el);
}

init() {
this.onLeft = this.onLeft.bind(this);
this.onRight = this.onRight.bind(this);
this.onClick = this.onClick.bind(this);
this.el = el;
}

open(el) {
Expand Down
4 changes: 3 additions & 1 deletion assets/javascripts/views/list/list_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ app.views.ListSelect = class ListSelect extends app.View {

constructor(el) {
super(el);
}

init() {
this.onClick = this.onClick.bind(this);
this.el = el;
}

deactivate() {
Expand Down
15 changes: 7 additions & 8 deletions assets/javascripts/views/list/paginated_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
}

constructor(data) {
super(...arguments);
let base;
super(undefined, { data, entries: data });
}

init() {
this.onClick = this.onClick.bind(this);
this.data = data;
if (
(base = this.constructor.events || (this.constructor.events = {}))
.click == null
) {
base.click = "onClick";
this.constructor.events = this.constructor.events || {};
if (this.constructor.events.click == null) {
this.constructor.events.click = "onClick";
}
}

Expand Down
4 changes: 1 addition & 3 deletions assets/javascripts/views/misc/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ app.views.Notice = class Notice extends app.View {
}

constructor(type, ...rest) {
super(...arguments);
this.type = type;
[...this.args] = Array.from(rest);
super(undefined, { type, args: rest });
}

init() {
Expand Down
12 changes: 4 additions & 8 deletions assets/javascripts/views/misc/notif.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ app.views.Notif = class Notif extends app.View {
}

constructor(type, options) {
super(...arguments);
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(undefined, { type, options: options || {} });
}

init() {
this.onClick = this.onClick.bind(this);
this.options = $.extend({}, this.constructor.defautOptions, this.options);

this.show();
}

Expand Down
7 changes: 4 additions & 3 deletions assets/javascripts/views/pages/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*/
app.views.BasePage = class BasePage extends app.View {
constructor(el, entry) {
super(el);
super(el, { entry });
}

init() {
this.paintCode = this.paintCode.bind(this);
this.el = el;
this.entry = entry;
}

deactivate() {
Expand Down
Loading

0 comments on commit 845709b

Please sign in to comment.