diff --git a/client/js/controllers/comments_controller.js b/client/js/controllers/comments_controller.js index a140599..e6c3ccb 100644 --- a/client/js/controllers/comments_controller.js +++ b/client/js/controllers/comments_controller.js @@ -30,7 +30,7 @@ class CommentsController { canViewPosts: api.hasPrivilege('posts:view'), }); const view = new CommentsPageView(pageCtx); - view.addEventListener('change', e => this._evtChange(e)); + view.addEventListener('submit', e => this._evtUpdate(e)); view.addEventListener('score', e => this._evtScore(e)); view.addEventListener('delete', e => this._evtDelete(e)); return view; @@ -38,7 +38,7 @@ class CommentsController { }); } - _evtChange(e) { + _evtUpdate(e) { // TODO: disable form e.detail.comment.text = e.detail.text; e.detail.comment.save() diff --git a/client/js/controllers/post_controller.js b/client/js/controllers/post_controller.js index 6701a17..e11027e 100644 --- a/client/js/controllers/post_controller.js +++ b/client/js/controllers/post_controller.js @@ -46,6 +46,7 @@ class PostController { canCreateComments: api.hasPrivilege('comments:create'), parameters: parameters, }); + if (this._view.sidebarControl) { this._view.sidebarControl.addEventListener( 'favorite', e => this._evtFavoritePost(e)); @@ -58,21 +59,23 @@ class PostController { this._view.sidebarControl.addEventListener( 'change', e => this._evtPostChange(e)); this._view.sidebarControl.addEventListener( - 'submit', e => this._evtPostEdit(e)); + 'submit', e => this._evtUpdatePost(e)); this._view.sidebarControl.addEventListener( - 'feature', e => this._evtPostFeature(e)); + 'feature', e => this._evtFeaturePost(e)); this._view.sidebarControl.addEventListener( - 'delete', e => this._evtPostDelete(e)); + 'delete', e => this._evtDeletePost(e)); } + if (this._view.commentFormControl) { this._view.commentFormControl.addEventListener( 'change', e => this._evtCommentChange(e)); this._view.commentFormControl.addEventListener( 'submit', e => this._evtCreateComment(e)); } + if (this._view.commentListControl) { this._view.commentListControl.addEventListener( - 'change', e => this._evtUpdateComment(e)); + 'submit', e => this._evtUpdateComment(e)); this._view.commentListControl.addEventListener( 'score', e => this._evtScoreComment(e)); this._view.commentListControl.addEventListener( @@ -104,7 +107,7 @@ class PostController { settings.save(browsingSettings); } - _evtPostFeature(e) { + _evtFeaturePost(e) { this._view.sidebarControl.disableForm(); this._view.sidebarControl.clearMessages(); e.detail.post.feature() @@ -117,7 +120,7 @@ class PostController { }); } - _evtPostDelete(e) { + _evtDeletePost(e) { this._view.sidebarControl.disableForm(); this._view.sidebarControl.clearMessages(); e.detail.post.delete() @@ -131,7 +134,7 @@ class PostController { }); } - _evtPostEdit(e) { + _evtUpdatePost(e) { this._view.sidebarControl.disableForm(); this._view.sidebarControl.clearMessages(); const post = e.detail.post; diff --git a/client/js/controllers/settings_controller.js b/client/js/controllers/settings_controller.js index a4fb183..2b087eb 100644 --- a/client/js/controllers/settings_controller.js +++ b/client/js/controllers/settings_controller.js @@ -11,10 +11,10 @@ class SettingsController { this._view = new SettingsView({ settings: settings.get(), }); - this._view.addEventListener('change', e => this._evtChange(e)); + this._view.addEventListener('submit', e => this._evtSubmit(e)); } - _evtChange(e) { + _evtSubmit(e) { this._view.clearMessages(); settings.save(e.detail); this._view.showSuccess('Settings saved.'); diff --git a/client/js/controllers/tag_controller.js b/client/js/controllers/tag_controller.js index 73f57e0..9eeff35 100644 --- a/client/js/controllers/tag_controller.js +++ b/client/js/controllers/tag_controller.js @@ -36,7 +36,7 @@ class TagController { categories: categories, }); - this._view.addEventListener('change', e => this._evtChange(e)); + this._view.addEventListener('submit', e => this._evtUpdate(e)); this._view.addEventListener('merge', e => this._evtMerge(e)); this._view.addEventListener('delete', e => this._evtDelete(e)); }, errorMessage => { @@ -51,7 +51,7 @@ class TagController { } } - _evtChange(e) { + _evtUpdate(e) { this._view.clearMessages(); this._view.disableForm(); if (e.detail.names !== undefined) { diff --git a/client/js/controllers/user_controller.js b/client/js/controllers/user_controller.js index aa12a98..20f8c99 100644 --- a/client/js/controllers/user_controller.js +++ b/client/js/controllers/user_controller.js @@ -51,7 +51,7 @@ class UserController { canDelete: api.hasPrivilege(`users:delete:${infix}`), ranks: ranks, }); - this._view.addEventListener('change', e => this._evtChange(e)); + this._view.addEventListener('submit', e => this._evtUpdate(e)); this._view.addEventListener('delete', e => this._evtDelete(e)); }, errorMessage => { this._view = new EmptyView(); @@ -66,7 +66,7 @@ class UserController { } } - _evtChange(e) { + _evtUpdate(e) { this._view.clearMessages(); this._view.disableForm(); const isLoggedIn = api.isLoggedIn(e.detail.user); diff --git a/client/js/controls/comment_control.js b/client/js/controls/comment_control.js index b926870..83fee15 100644 --- a/client/js/controls/comment_control.js +++ b/client/js/controls/comment_control.js @@ -39,7 +39,7 @@ class CommentControl extends events.EventTarget { this._hostNode.querySelector('.comment-form-container'), this._comment, true); - events.proxyEvent(this._formControl, this, 'submit', 'change'); + events.proxyEvent(this._formControl, this, 'submit'); this._installScore(); } diff --git a/client/js/controls/comment_list_control.js b/client/js/controls/comment_list_control.js index 33888e0..e09fffc 100644 --- a/client/js/controls/comment_list_control.js +++ b/client/js/controls/comment_list_control.js @@ -35,7 +35,7 @@ class CommentListControl extends events.EventTarget { const commentListItemNode = document.createElement('li'); const commentControl = new CommentControl( commentListItemNode, comment); - events.proxyEvent(commentControl, this, 'change'); + events.proxyEvent(commentControl, this, 'submit'); events.proxyEvent(commentControl, this, 'score'); events.proxyEvent(commentControl, this, 'delete'); this._commentIdToNode[comment.id] = commentListItemNode; diff --git a/client/js/views/comments_page_view.js b/client/js/views/comments_page_view.js index 60a15c1..2722bd6 100644 --- a/client/js/views/comments_page_view.js +++ b/client/js/views/comments_page_view.js @@ -19,7 +19,7 @@ class CommentsPageView extends events.EventTarget { `.comments-container[data-for="${post.id}"]`), post.comments, true); - events.proxyEvent(commentListControl, this, 'change'); + events.proxyEvent(commentListControl, this, 'submit'); events.proxyEvent(commentListControl, this, 'score'); events.proxyEvent(commentListControl, this, 'delete'); } diff --git a/client/js/views/posts_header_view.js b/client/js/views/posts_header_view.js index 717afaa..ef0000c 100644 --- a/client/js/views/posts_header_view.js +++ b/client/js/views/posts_header_view.js @@ -37,8 +37,8 @@ class PostsHeaderView { } }); - for (let safetyButton of this._safetyButtonNodes) { - safetyButton.addEventListener( + for (let safetyButtonNode of this._safetyButtonNodes) { + safetyButtonNode.addEventListener( 'click', e => this._evtSafetyButtonClick(e)); } this._searchFormNode.addEventListener( diff --git a/client/js/views/settings_view.js b/client/js/views/settings_view.js index f8c83a0..39a83ed 100644 --- a/client/js/views/settings_view.js +++ b/client/js/views/settings_view.js @@ -28,7 +28,7 @@ class SettingsView extends events.EventTarget { _evtSubmit(e) { e.preventDefault(); - this.dispatchEvent(new CustomEvent('change', { + this.dispatchEvent(new CustomEvent('submit', { detail: { upscaleSmallPosts: this._find('upscale-small-posts').checked, endlessScroll: this._find('endless-scroll').checked, diff --git a/client/js/views/tag_view.js b/client/js/views/tag_view.js index db90dc5..26f0491 100644 --- a/client/js/views/tag_view.js +++ b/client/js/views/tag_view.js @@ -35,7 +35,7 @@ class TagView extends events.EventTarget { this._view = new TagEditView(ctx); this._view.addEventListener('submit', e => { this.dispatchEvent( - new CustomEvent('change', {detail: e.detail})); + new CustomEvent('submit', {detail: e.detail})); }); } else if (ctx.section === 'merge') { this._view = new TagMergeView(ctx); diff --git a/client/js/views/user_view.js b/client/js/views/user_view.js index cb86820..5ef03dc 100644 --- a/client/js/views/user_view.js +++ b/client/js/views/user_view.js @@ -36,7 +36,7 @@ class UserView extends events.EventTarget { this._view = new UserEditView(ctx); this._view.addEventListener('submit', e => { this.dispatchEvent( - new CustomEvent('change', {detail: e.detail})); + new CustomEvent('submit', {detail: e.detail})); }); } else if (ctx.section == 'delete') { this._view = new UserDeleteView(ctx);