diff options
author | Duda Dornelles <dudassdornelles@gmail.com> | 2015-01-07 11:36:43 -0200 |
---|---|---|
committer | Duda Dornelles <dudassdornelles@gmail.com> | 2015-01-07 11:36:43 -0200 |
commit | 2bcc7203073d71814483b0d6ba797c187048fc1e (patch) | |
tree | 082eaf4f95433a229a99d22969a56bd90211a4fa /web-ui/app/js/tags/ui/tag_list.js | |
parent | b4bd74e59313cb40638d954a2369a0c9650d75f7 (diff) | |
parent | b0720edaa0d51ee9e807495fa536d890d332c50d (diff) |
Merge pull request #223 from pixelated-project/refactoring-events
Refactoring events on web-ui left-pane
Diffstat (limited to 'web-ui/app/js/tags/ui/tag_list.js')
-rw-r--r-- | web-ui/app/js/tags/ui/tag_list.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/web-ui/app/js/tags/ui/tag_list.js b/web-ui/app/js/tags/ui/tag_list.js index 850a5fab..0c483abb 100644 --- a/web-ui/app/js/tags/ui/tag_list.js +++ b/web-ui/app/js/tags/ui/tag_list.js @@ -20,10 +20,11 @@ define( 'tags/ui/tag', 'views/templates', 'page/events', - 'tags/ui/tag_shortcut' + 'tags/ui/tag_shortcut', + 'page/router/url_params' ], - function(defineComponent, Tag, templates, events, TagShortcut) { + function(defineComponent, Tag, templates, events, TagShortcut, urlParams) { 'use strict'; var ICON_FOR = { @@ -55,13 +56,13 @@ define( }); this.renderShortcut = function (tag, tagComponent) { - return TagShortcut.appendedTo($('#tags-shortcuts'), { linkTo: tag, trigger: tagComponent}); + return TagShortcut.appendedTo($('#tags-shortcuts'), { tag: tag, trigger: tagComponent, currentTag: this.getCurrentTag()}); }; function renderTag(tag, defaultList, customList) { var list = tag.default ? defaultList : customList; - var tagComponent = Tag.appendedTo(list, {tag: tag}); + var tagComponent = Tag.appendedTo(list, {tag: tag, currentTag: this.getCurrentTag()}); if (_.contains(_.keys(ORDER), tag.name)) { tagComponent.attr.shortcut = this.renderShortcut(tag, tagComponent); } @@ -84,20 +85,23 @@ define( var defaultList = this.select('defaultTagList'); var customList = this.select('customTagList'); - resetTagList.bind(this, [defaultList, customList]).call(); + resetTagList.call(this, [defaultList, customList]); this.resetShortcuts(); tags.forEach(function (tag) { - renderTag.bind(this, tag, defaultList, customList).call(); + renderTag.call(this, tag, defaultList, customList); }.bind(this)); }; - this.loadTagList = function(ev, data) { + this.displayTags = function(ev, data) { this.renderTagList(_.sortBy(data.tags, tagOrder)); - this.trigger(document, events.ui.tags.loaded, { tag: this.attr.currentTag, skipMailListRefresh: data.skipMailListRefresh}); }; - this.saveTag = function(ev, data) { + this.getCurrentTag = function () { + return this.attr.currentTag || urlParams.getTag(); + }; + + this.updateCurrentTag = function(ev, data) { this.attr.currentTag = data.tag; }; @@ -106,8 +110,8 @@ define( }; this.after('initialize', function() { - this.on(document, events.ui.tagList.load, this.loadTagList); - this.on(document, events.ui.tag.selected, this.saveTag); + this.on(document, events.tags.received, this.displayTags); + this.on(document, events.ui.tag.select, this.updateCurrentTag); this.renderTagListTemplate(); }); } |