Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Commit

Permalink
Merge fc895fd into b812a44
Browse files Browse the repository at this point in the history
  • Loading branch information
stoimen committed Jan 20, 2015
2 parents b812a44 + fc895fd commit a6a17ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/tags-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* When this flag is true, addOnEnter, addOnComma, addOnSpace, addOnBlur and
* allowLeftoverText values are ignored.
* @param {boolean=} [spellcheck=true] Flag indicating whether the browser's spellcheck is enabled for the input field or not.
* @param {boolean=} [caseInsensitiveTags=false] Flag indicating if tags are case insensitive or not
* @param {expression} onTagAdded Expression to evaluate upon adding a new tag. The new tag is available as $tag.
* @param {expression} onInvalidTag Expression to evaluate when a tag is invalid. The invalid tag is available as $tag.
* @param {expression} onTagRemoved Expression to evaluate upon removing an existing tag. The removed tag is available as $tag.
Expand All @@ -58,7 +59,7 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig)
tagText.length >= options.minLength &&
tagText.length <= options.maxLength &&
options.allowedTagsPattern.test(tagText) &&
!findInObjectArray(self.items, tag, options.displayProperty);
!findInObjectArray(self.items, tag, options.displayProperty, options.caseInsensitiveTags);
};

self.items = [];
Expand Down Expand Up @@ -152,7 +153,8 @@ tagsInput.directive('tagsInput', function($timeout, $document, tagsInputConfig)
displayProperty: [String, 'text'],
allowLeftoverText: [Boolean, false],
addFromAutocompleteOnly: [Boolean, false],
spellcheck: [Boolean, true]
spellcheck: [Boolean, true],
caseInsensitiveTags: [Boolean, false]
});

$scope.tagList = new TagList($scope.options, $scope.events);
Expand Down
9 changes: 5 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ function makeObjectArray(array, key) {
return array;
}

function findInObjectArray(array, obj, key) {
function findInObjectArray(array, obj, key, caseInsesitive) {
var item = null;
for (var i = 0; i < array.length; i++) {
// I'm aware of the internationalization issues regarding toLowerCase()
// but I couldn't come up with a better solution right now
if (safeToString(array[i][key]).toLowerCase() === safeToString(obj[key]).toLowerCase()) {
if(caseInsesitive && safeToString(array[i][key]) === safeToString(obj[key])) {
item = array[i];
break;
} else if(!caseInsesitive && safeToString(array[i][key]).toLocaleLowerCase() === safeToString(obj[key]).toLocaleLowerCase()) {
item = array[i];
break;
}
Expand Down

0 comments on commit a6a17ea

Please sign in to comment.