Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from FriendsOfTrowel/feature/javascript-events
Browse files Browse the repository at this point in the history
dispatch events in javascript workflow
  • Loading branch information
Loïc Goyet authored Jun 19, 2017
2 parents 1bde563 + 0c335b6 commit d1b1ef3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
21 changes: 18 additions & 3 deletions dest/javascript/alerts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dest/javascript/alerts.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dest/javascript/alerts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/javascript/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@ class TrowelAlert {
constructor(element) {
this.element = element;
this.timesCollection = [].slice.call(this.element.querySelectorAll('[data-alert="times"]'));
return this.listener();

this.events = this.events();
this.listener();
this.element.dispatchEvent(this.events.mounted);
return;
}

events() {
const mounted = new Event('trowel.alert.mounted');
const remove = new Event('trowel.alert.remove');
const removed = new Event('trowel.alert.removed');

return { mounted, remove, removed };
}

removeAlert() {
return this.element.remove();
this.element.dispatchEvent(this.events.remove);
this.element.remove();
this.element.dispatchEvent(this.events.removed);
return;
}

listener() {
Expand Down

0 comments on commit d1b1ef3

Please sign in to comment.