This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js: repositories remaining refactoring
- Loading branch information
1 parent
84472e1
commit ad5da31
Showing
7 changed files
with
93 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/assets/javascripts/modules/repositories/components/comment-form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
const COMMENT_BODY = '#comment_body'; | ||
|
||
class CommentForm extends BaseComponent { | ||
elements() { | ||
this.$commentBody = this.$el.find(COMMENT_BODY); | ||
} | ||
|
||
toggle() { | ||
this.$el.toggle(400, 'swing', () => { | ||
const visible = this.$el.is(':visible'); | ||
|
||
if (visible) { | ||
this.$commentBody.focus(); | ||
} | ||
|
||
layout_resizer(); | ||
}); | ||
} | ||
} | ||
|
||
export default CommentForm; |
24 changes: 24 additions & 0 deletions
24
app/assets/javascripts/modules/repositories/components/comments-panel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import CommentForm from '../components/comment-form'; | ||
|
||
class CommentsPanel extends BaseComponent { | ||
elements() { | ||
this.$toggle = this.$el.find('.add-comment'); | ||
this.$commentForm = this.$el.find('.comment-form'); | ||
} | ||
|
||
events() { | ||
this.$toggle.on('click', () => this.toggle()); | ||
} | ||
|
||
mount() { | ||
this.form = new CommentForm(this.$commentForm); | ||
} | ||
|
||
toggle() { | ||
this.form.toggle(); | ||
} | ||
} | ||
|
||
export default CommentsPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters