This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 9b78da36e9f25b5c6102b8ffefdd57f3ec11f462 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue May 23 11:37:19 2017 +0200 factorisé le desenregistrement des tag sur le bus --- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 7 +------ pollen-ui-riot-js/src/main/web/js/UIHelper.js | 7 +++++++ .../src/main/web/tag/HeaderI18n.tag.html | 6 +----- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 23 +++++----------------- .../src/main/web/tag/PollenErrorManager.tag.html | 6 +----- .../src/main/web/tag/PollenHeader.tag.html | 6 +----- .../src/main/web/tag/PollenWaiter.tag.html | 4 ++-- .../src/main/web/tag/UserProfile.tag.html | 7 +------ .../src/main/web/tag/poll/ChoiceView.tag.html | 7 +------ .../src/main/web/tag/poll/Comments.tag.html | 6 +----- .../src/main/web/tag/poll/Podium.tag.html | 6 +----- .../src/main/web/tag/poll/Poll.tag.html | 6 +----- .../src/main/web/tag/poll/Results.tag.html | 6 +----- .../src/main/web/tag/poll/Votes.tag.html | 6 +----- .../src/main/web/tag/popup/QrCodeButton.tag.html | 6 +----- .../web/tag/voterList/VoterListActions.tag.html | 6 +----- 16 files changed, 27 insertions(+), 88 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js index e12c445..d062aa2 100644 --- a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js @@ -18,8 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -let bus = require("./PollenBus.js"); - module.exports = { installBundle(session, value, callback) { @@ -37,10 +35,7 @@ module.exports = { console.error("Error in generateBundle for " + value, e); } }; - bus.on("locale", onLocalChange); - this.on("before-unmount", () => { - bus.off("locale", onLocalChange); - }); + this.listen("locale", onLocalChange); }, generateBundle(locale, value) { diff --git a/pollen-ui-riot-js/src/main/web/js/UIHelper.js b/pollen-ui-riot-js/src/main/web/js/UIHelper.js index 30c41ff..db12de5 100644 --- a/pollen-ui-riot-js/src/main/web/js/UIHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/UIHelper.js @@ -53,5 +53,12 @@ module.exports = { bus: require("./PollenBus.js"), + listen(events, callback) { + this.bus.on(events, callback); + this.on("before-unmount", () => { + this.bus.off(events, callback); + }); + }, + DATETIME_INPUT_PATTERN: "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}" }; diff --git a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag.html b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag.html index 177c019..400a433 100644 --- a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag.html @@ -48,11 +48,7 @@ this.update(); }; - this.bus.off("locale", this.onLocaleChange); - - this.on("before-unmount", () => { - this.bus.off("locale", this.onLocaleChange); - }); + this.listen("locale", this.onLocaleChange); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index 396b0de..bc6aade 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -61,7 +61,7 @@ require("./favoriteList/FavoriteList.tag.html"); document.title = this._l("pollen_title") + this._l(this.pageTitle); }; - this.bus.on("pageChanged", (title) => { + this.listen("pageChanged", (title) => { this.bus.trigger("closeSignIn"); this.pageTitle = title; this.updatePageTitle(); @@ -83,11 +83,10 @@ require("./favoriteList/FavoriteList.tag.html"); this.on("mount", () => { this.showInfoMessages(session.locale); - this.bus.on("locale", this.onLocaleChange); - }); - - this.on("before-unmount", () => { - this.bus.off("locale", this.onLocaleChange); + this.listen("locale", this.onLocaleChange); + this.listen("unauthorize", this.refs.signIn.open); + this.listen("signIn", this.refs.signIn.open); + this.listen("closeSignIn", this.refs.signIn.close); }); let route = require("riot-route"); @@ -232,18 +231,6 @@ require("./favoriteList/FavoriteList.tag.html"); riot.mount(this.refs.content, "home"); }); - this.bus.on("unauthorize", () => { - this.refs.signIn.open(); - }); - - this.bus.on("signIn", () => { - this.refs.signIn.open(); - }); - - this.bus.on("closeSignIn", () => { - this.refs.signIn.close(); - }); - window.onkeydown = e => { if (e.keyCode === 27) { this.bus.trigger("escape"); diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html index 288854c..97531e9 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html @@ -32,11 +32,7 @@ }; this.on("mount", () => { - this.bus.on("error", this.handleErrors); - }); - - this.on("before-unmount", () => { - this.bus.off("error", this.handleErrors); + this.listen("error", this.handleErrors); }); this.closeError = (errorId) => (e) => { diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html index d4b19d7..3e6a140 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/PollenHeader.tag.html @@ -88,11 +88,7 @@ require("./HeaderI18n.tag.html"); this.update(); }; - this.bus.on("user", this.onUserChange); - - this.on("before-unmount", () => { - this.bus.off("user", this.onUserChange); - }); + this.listen("user", this.onUserChange); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html index e59fd7e..4571cea 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/PollenWaiter.tag.html @@ -5,14 +5,14 @@ NProgress.configure({ parent: "#" + this.opts.parentId}); let inProgress = new Set(); - this.bus.on("loading", event => { + this.listen("loading", event => { inProgress.add(event); if (inProgress.size === 1) { NProgress.start(); } }); - this.bus.on("loaded", event => { + this.listen("loaded", event => { setTimeout(() => { inProgress.delete(event); NProgress.inc(); diff --git a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html index 30c5a7a..0b5951b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html @@ -174,12 +174,7 @@ } }; - this.bus.on("user", this.onUserChange); - - this.on("before-unmount", () => { - this.bus.off("user", this.onUserChange); - }); - + this.listen("user", this.onUserChange); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceView.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceView.tag.html index 029c758..0cbb354 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceView.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/ChoiceView.tag.html @@ -94,12 +94,7 @@ } }; - this.bus.on("escape", this.onEscape); - - this.on("before-unmount", () => { - this.bus.off("escape", this.onEscape); - }); - + this.listen("escape", this.onEscape); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html index 8cd17f3..688da5b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html @@ -174,7 +174,7 @@ require("./CommentPopup.tag.html"); this.update(); }; - this.bus.on("poll", this.onPollChange); + this.listen("poll", this.onPollChange); this.orderDesc = true; @@ -225,10 +225,6 @@ require("./CommentPopup.tag.html"); window.scrollTo(0, document.body.scrollHeight); }; - this.on("before-unmount", () => { - this.bus.off("poll", this.onPollChange); - }); - </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html index 3bffe60..0263ebe 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html @@ -29,11 +29,7 @@ require("./ChoiceView.tag.html"); this.update(); }; - this.bus.on("poll", this.onPollChange); - - this.on("before-unmount", () => { - this.bus.off("poll", this.onPollChange); - }); + this.listen("poll", this.onPollChange); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html index 6d56136..000f4ac 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html @@ -195,7 +195,7 @@ require("../popup/QrCodeButton.tag.html"); } }; - this.bus.on("poll", this.onPollChange); + this.listen("poll", this.onPollChange); this.poll.init(this.opts.pollId, this.opts.voteId, this.opts.permission).catch((error) => { this.bus.trigger("error", new Error(this._l(error.status))); }); @@ -233,10 +233,6 @@ require("../popup/QrCodeButton.tag.html"); document.execCommand("copy"); }; - this.on("before-unmount", () => { - this.bus.off("poll", this.onPollChange); - }); - this.toggleHelp = () => { this.showVoteCountingTypeHelper = !this.showVoteCountingTypeHelper; }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html index de5131d..18f4221 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html @@ -44,11 +44,7 @@ require("./Podium.tag.html"); this.update(); }; - this.bus.on("poll", this.onPollChange); - - this.on("before-unmount", () => { - this.bus.off("poll", this.onPollChange); - }); + this.listen("poll", this.onPollChange); </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html index 1384bde..d5e23dc 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html @@ -224,7 +224,7 @@ require("./Podium.tag.html"); this.update(); }; - this.bus.on("poll", this.onPollChange); + this.listen("poll", this.onPollChange); this.showVotes = false; this.voteId = null; @@ -382,10 +382,6 @@ require("./Podium.tag.html"); this.showVotes = false; }; - this.on("before-unmount", () => { - this.bus.off("poll", this.onPollChange); - }); - </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/QrCodeButton.tag.html b/pollen-ui-riot-js/src/main/web/tag/popup/QrCodeButton.tag.html index 19c2065..f5db835 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/QrCodeButton.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/popup/QrCodeButton.tag.html @@ -31,11 +31,7 @@ require("../QrCode.tag.html"); this.update(); }; - this.bus.on("escape", this.close); - - this.on("before-unmount", () => { - this.bus.off("escape", this.close); - }); + this.listen("escape", this.close); </script> <style> .o-modal{ diff --git a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html index a25cca1..37a3015 100644 --- a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html @@ -83,11 +83,7 @@ this.update(); }; - this.bus.on("user", this.onUserChange); - - this.on("before-unmount", () => { - this.bus.off("user", this.onUserChange); - }); + this.listen("user", this.onUserChange); this.addMember = () => { this.parent.expandable().then(() => { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.