From 7ab9f9423004adf1df9cc1be1b2a5ae7eade4a95 Mon Sep 17 00:00:00 2001 From: Alexandre Pretto Nunes Date: Wed, 17 Dec 2014 19:19:25 -0200 Subject: Separate auto-refresh for mails and tags, and start moving away from having the left_pane_dispatcher as a middleman --- web-ui/app/js/tags/ui/tag_base.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'web-ui/app/js/tags/ui/tag_base.js') diff --git a/web-ui/app/js/tags/ui/tag_base.js b/web-ui/app/js/tags/ui/tag_base.js index 9b2a06a9..9dc1ccbb 100644 --- a/web-ui/app/js/tags/ui/tag_base.js +++ b/web-ui/app/js/tags/ui/tag_base.js @@ -34,6 +34,33 @@ define(['views/i18n', 'page/events'], function(i18n, events) { return _.include(TOTAL_BADGE, tag.name) ? 'total' : 'unread'; }; + this.doUnselect = function () { + this.$node.removeClass('selected'); + }; + + this.doSelect = function () { + this.$node.addClass('selected'); + }; + + this.selectTag = function (ev, data) { + this.attr.currentTag = data.tag; + if (data.tag === this.attr.tag.name) { + this.doSelect(); + } + else { + this.doUnselect(); + } + }; + + this.selectTagAll = function () { + this.selectTag(null, {tag: 'all'}); + }; + + this.after('initialize', function () { + this.on(document, events.ui.tag.select, this.selectTag); + this.on(document, events.search.perform, this.selectTagAll); + this.on(document, events.search.empty, this.selectTagAll); + }); } return tagBase; -- cgit v1.2.3