Removed a way to repeat a tag in uploaded post
This commit is contained in:
parent
d20fe3d95a
commit
b5d6e4837d
1 changed files with 13 additions and 6 deletions
|
@ -440,6 +440,15 @@ App.Presenters.PostUploadPresenter = function(
|
|||
};
|
||||
}
|
||||
|
||||
function getTagIndex(post, tag) {
|
||||
var tags = jQuery.map(post.tags, String.toLowerCase);
|
||||
return tags.indexOf(tag.toLowerCase());
|
||||
}
|
||||
|
||||
function hasTag(post, tag) {
|
||||
return getTagIndex(post, tag) !== -1;
|
||||
}
|
||||
|
||||
function getCombinedPost(posts) {
|
||||
var combinedPost = _.extend({}, getDefaultPost());
|
||||
if (posts.length === 0) {
|
||||
|
@ -449,7 +458,7 @@ App.Presenters.PostUploadPresenter = function(
|
|||
|
||||
var tagFilter = function(post) {
|
||||
return function(tag) {
|
||||
return post.tags.indexOf(tag) !== -1;
|
||||
return hasTag(post, tag);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -496,8 +505,7 @@ App.Presenters.PostUploadPresenter = function(
|
|||
|
||||
function addTagToPosts(posts, tag) {
|
||||
jQuery.each(posts, function(i, post) {
|
||||
var index = post.tags.indexOf(tag);
|
||||
if (index === -1) {
|
||||
if (!hasTag(post, tag)) {
|
||||
post.tags.push(tag);
|
||||
}
|
||||
postChanged(post);
|
||||
|
@ -506,9 +514,8 @@ App.Presenters.PostUploadPresenter = function(
|
|||
|
||||
function removeTagFromPosts(posts, tag) {
|
||||
jQuery.each(posts, function(i, post) {
|
||||
var index = post.tags.indexOf(tag);
|
||||
if (index !== -1) {
|
||||
post.tags.splice(index, 1);
|
||||
if (hasTag(post, tag)) {
|
||||
post.tags.splice(getTagIndex(post, tag), 1);
|
||||
}
|
||||
postChanged(post);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue