diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-18 14:58:22 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-08-18 15:15:32 -0300 |
commit | 7b7e5f1a6fd5926670917af735b2eda75fa332ee (patch) | |
tree | e7fafb4a782514a4b35179a077357f5efa2f604c /web-ui/app | |
parent | 0ef62a242c8b8bb5a39dc5d4b1fc75123e9f70d8 (diff) |
Duda/Patrick #8: reseting tag shortcuts before loading them again
Diffstat (limited to 'web-ui/app')
-rw-r--r-- | web-ui/app/js/page/events.js | 5 | ||||
-rw-r--r-- | web-ui/app/js/tags/ui/tag_list.js | 7 | ||||
-rw-r--r-- | web-ui/app/js/tags/ui/tag_shortcut.js | 13 |
3 files changed, 21 insertions, 4 deletions
diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js index 6b39096c..c5c239e5 100644 --- a/web-ui/app/js/page/events.js +++ b/web-ui/app/js/page/events.js @@ -114,7 +114,10 @@ define(function () { tags: { want: 'tags:want', received: 'tags:received', - teardown: 'tags:teardown' + teardown: 'tags:teardown', + shortcuts: { + teardown: 'tags:shortcuts:teardown' + } }, route: { toUrl: 'route:toUrl' diff --git a/web-ui/app/js/tags/ui/tag_list.js b/web-ui/app/js/tags/ui/tag_list.js index 02eee7f8..22b1e77b 100644 --- a/web-ui/app/js/tags/ui/tag_list.js +++ b/web-ui/app/js/tags/ui/tag_list.js @@ -56,13 +56,20 @@ define( this.trigger(list, events.tags.teardown); list.empty(); }.bind(this)); + } + this.resetShortcuts = function () { + $('#tags-shortcuts').empty(); + this.trigger(document, events.tags.shortcuts.teardown); + }; + this.renderTagList = function(tags) { var defaultList = this.select('defaultTagList'); var customList = this.select('customTagList'); resetTagList.bind(this, [defaultList, customList]).call(); + this.resetShortcuts(); tags.forEach(function (tag) { renderTag.bind(this, tag, defaultList, customList).call(); diff --git a/web-ui/app/js/tags/ui/tag_shortcut.js b/web-ui/app/js/tags/ui/tag_shortcut.js index 6e5c6960..59556794 100644 --- a/web-ui/app/js/tags/ui/tag_shortcut.js +++ b/web-ui/app/js/tags/ui/tag_shortcut.js @@ -3,10 +3,11 @@ define( 'flight/lib/component', 'views/templates', 'page/events', - 'tags/ui/tag_base' + 'tags/ui/tag_base', + 'flight/lib/utils' ], - function (describeComponent, templates, events, tagBase) { + function (describeComponent, templates, events, tagBase, utils) { var TagShortcut = describeComponent(tagShortcut, tagBase); @@ -20,7 +21,6 @@ define( function tagShortcut() { - this.renderAndAttach = function (parent, options) { var linkTo = options.linkTo; @@ -58,9 +58,16 @@ define( this.$node.addClass('selected'); }; + this.doTeardown = function () { + if (!jQuery.contains(document, this.$node[0])) { + this.teardown(); + } + }; + this.after('initialize', function () { this.on('click', function () { this.attr.trigger.triggerSelect(); }); this.on(document, events.ui.tag.select, this.selectTag); + this.on(document, events.tags.shortcuts.teardown, this.doTeardown); }); } |