Added tag siblings suggestion synchronization
This commit is contained in:
parent
303f91e15c
commit
b693a5f4b3
1 changed files with 18 additions and 3 deletions
|
@ -174,6 +174,16 @@ App.Controls.TagInput = function($underlyingInput) {
|
||||||
$tagList.append($elem);
|
$tagList.append($elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function beforeTagRemoved(tagName) {
|
||||||
|
if (typeof(options.beforeTagRemoved) === 'function') {
|
||||||
|
options.beforeTagRemoved(tagName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterTagRemoved(tagName) {
|
||||||
|
refreshShownSiblings();
|
||||||
|
}
|
||||||
|
|
||||||
function beforeTagAdded(tagName) {
|
function beforeTagAdded(tagName) {
|
||||||
if (typeof(options.beforeTagAdded) === 'function') {
|
if (typeof(options.beforeTagAdded) === 'function') {
|
||||||
options.beforeTagAdded(tagName);
|
options.beforeTagAdded(tagName);
|
||||||
|
@ -188,6 +198,7 @@ App.Controls.TagInput = function($underlyingInput) {
|
||||||
flashTagYellow(impliedTagName);
|
flashTagYellow(impliedTagName);
|
||||||
});
|
});
|
||||||
showOrHideSuggestions(tagName);
|
showOrHideSuggestions(tagName);
|
||||||
|
refreshShownSiblings();
|
||||||
} else {
|
} else {
|
||||||
flashTagGreen(tagName);
|
flashTagGreen(tagName);
|
||||||
}
|
}
|
||||||
|
@ -205,10 +216,9 @@ App.Controls.TagInput = function($underlyingInput) {
|
||||||
var oldTagNames = getTags();
|
var oldTagNames = getTags();
|
||||||
var newTagNames = _.without(oldTagNames, tagName);
|
var newTagNames = _.without(oldTagNames, tagName);
|
||||||
if (newTagNames.length !== oldTagNames.length) {
|
if (newTagNames.length !== oldTagNames.length) {
|
||||||
if (typeof(options.beforeTagRemoved) === 'function') {
|
beforeTagRemoved(tagName);
|
||||||
options.beforeTagRemoved(tagName);
|
|
||||||
}
|
|
||||||
setTags(newTagNames);
|
setTags(newTagNames);
|
||||||
|
afterTagRemoved(tagName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,11 +305,16 @@ App.Controls.TagInput = function($underlyingInput) {
|
||||||
})).then(function(siblings) {
|
})).then(function(siblings) {
|
||||||
siblings = _.pluck(siblings, 'name');
|
siblings = _.pluck(siblings, 'name');
|
||||||
$siblings.data('lastTag', tagName);
|
$siblings.data('lastTag', tagName);
|
||||||
|
$siblings.data('siblings', siblings);
|
||||||
updateSuggestions($siblings, siblings);
|
updateSuggestions($siblings, siblings);
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshShownSiblings() {
|
||||||
|
updateSuggestions($siblings, $siblings.data('siblings'));
|
||||||
|
}
|
||||||
|
|
||||||
function updateSuggestions($target, siblings) {
|
function updateSuggestions($target, siblings) {
|
||||||
function filterSuggestions(sourceTagNames) {
|
function filterSuggestions(sourceTagNames) {
|
||||||
if (!sourceTagNames) {
|
if (!sourceTagNames) {
|
||||||
|
|
Loading…
Reference in a new issue