From 0f72ef3963ecfebe94aa3a706c4342cd530128b3 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 21 Oct 2013 14:48:28 +0200 Subject: [PATCH] Closed #48 --- public_html/media/js/core.js | 22 ++++++++++++++++++++++ public_html/media/js/post-view.js | 9 +++------ public_html/media/js/upload.js | 9 +++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/public_html/media/js/core.js b/public_html/media/js/core.js index 69f7b7d9..98c0179d 100644 --- a/public_html/media/js/core.js +++ b/public_html/media/js/core.js @@ -179,3 +179,25 @@ $(function() } }); }); + +function getTagItOptions() +{ + return { + caseSensitive: false, + autocomplete: + { + source: + function(request, response) + { + var term = request.term.toLowerCase(); + var results = $.grep(this.options.availableTags, function(a) + { + return a.toLowerCase().indexOf(term) != -1; + }); + if (!this.options.allowDuplicates) + results = this._subtractArray(results, this.assignedTags()); + response(results); + }, + } + }; +} diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js index 54dfd4db..2f005923 100644 --- a/public_html/media/js/post-view.js +++ b/public_html/media/js/post-view.js @@ -14,12 +14,9 @@ $(function() { tags = data['tags']; - var tagItOptions = - { - caseSensitive: true, - availableTags: tags, - placeholderText: $('.tags input').attr('placeholder') - }; + var tagItOptions = getTagItOptions(); + tagItOptions.availableTags = tags; + tagItOptions.placeholderText = $('.tags input').attr('placeholder'); $('.tags input').tagit(tagItOptions); e.preventDefault(); diff --git a/public_html/media/js/upload.js b/public_html/media/js/upload.js index 14c03d7f..34d26269 100644 --- a/public_html/media/js/upload.js +++ b/public_html/media/js/upload.js @@ -158,12 +158,9 @@ $(function() $('.posts').append(postDom); postDom.show(); - var tagItOptions = - { - caseSensitive: true, - availableTags: tags, - placeholderText: $('.tags input').attr('placeholder') - }; + var tagItOptions = getTagItOptions(); + tagItOptions.availableTags = tags; + tagItOptions.placeholderText = $('.tags input').attr('placeholder'); $('.tags input', postDom).tagit(tagItOptions); if (!file.type.match('image.*'))