From c350c47195e66052057061451a8313aaf3f97d69 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 30 Nov 2014 11:31:40 +0100 Subject: [PATCH] Added showing tag suggestions on click --- public_html/js/Controls/TagInput.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/public_html/js/Controls/TagInput.js b/public_html/js/Controls/TagInput.js index 42a7c82d..2e9d51a5 100644 --- a/public_html/js/Controls/TagInput.js +++ b/public_html/js/Controls/TagInput.js @@ -187,7 +187,7 @@ App.Controls.TagInput = function($underlyingInput) { addTag(impliedTagName); flashTagYellow(impliedTagName); }); - showOrHideSuggestions(tag.suggestions); + showOrHideSuggestions(tagName); } else { flashTagGreen(tagName); } @@ -262,7 +262,8 @@ App.Controls.TagInput = function($underlyingInput) { $tagLink.text(tagName); $tagLink.click(function(e) { e.preventDefault(); - showOrHideTagSiblings(tagName); + showOrHideSiblings(tagName); + showOrHideSuggestions(tagName); }); $elem.append($tagLink); @@ -276,19 +277,20 @@ App.Controls.TagInput = function($underlyingInput) { return $elem; } - function showOrHideSuggestions(suggestedTagNames) { - if (_.size(suggestedTagNames) === 0) { - return; - } - - var suggestions = filterSuggestions(suggestedTagNames); - if (suggestions.length > 0) { - attachTagsToSuggestionList($suggestions.find('ul'), suggestions); - $suggestions.slideDown('fast'); + function showOrHideSuggestions(tagName) { + var tag = getExportedTag(tagName); + if (tag && _.size(tag.suggestions) > 0) { + var suggestions = filterSuggestions(tag.suggestions); + if (suggestions.length > 0) { + attachTagsToSuggestionList($suggestions.find('ul'), suggestions); + $suggestions.slideDown('fast'); + return; + } } + $suggestions.slideUp('fast'); } - function showOrHideTagSiblings(tagName) { + function showOrHideSiblings(tagName) { if ($siblings.data('lastTag') === tagName && $siblings.is(':visible')) { $siblings.slideUp('fast'); $siblings.data('lastTag', null);