|
1 | 1 | /*!
|
2 | 2 | * ui-select
|
3 | 3 | * http://github.com/angular-ui/ui-select
|
4 |
| - * Version: 0.9.1 - 2014-12-03T16:41:44.798Z |
| 4 | + * Version: 0.9.2 - 2014-12-08T14:55:46.399Z |
5 | 5 | * License: MIT
|
6 | 6 | */
|
7 | 7 |
|
|
623 | 623 | if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
|
624 | 624 | // make sure there is a new value to push via tagging
|
625 | 625 | if ( ctrl.search.length > 0 ) {
|
626 |
| - ctrl.select(null, true); |
| 626 | + ctrl.select(undefined, true); |
627 | 627 | _searchInput.triggerHandler('tagged');
|
628 | 628 | }
|
629 | 629 | }
|
|
712 | 712 | }
|
713 | 713 | // verify the the tag doesn't match the value of an existing item from
|
714 | 714 | // the searched data set
|
715 |
| - if ( stashArr.filter( function (origItem) { return origItem.toUpperCase() === ctrl.search.toUpperCase(); }).length > 0 ) { |
| 715 | + if ( _findCaseInsensitiveDupe(stashArr) ) { |
716 | 716 | // if there is a tag from prev iteration, strip it / queue the change
|
717 | 717 | // and return early
|
718 | 718 | if ( hasTag ) {
|
|
724 | 724 | }
|
725 | 725 | return;
|
726 | 726 | }
|
727 |
| - if ( ctrl.selected.filter( function (selection) { return selection.toUpperCase() === ctrl.search.toUpperCase(); } ).length > 0 ) { |
| 727 | + if ( _findCaseInsensitiveDupe(stashArr) ) { |
728 | 728 | // if there is a tag from prev iteration, strip it
|
729 | 729 | if ( hasTag ) {
|
730 | 730 | ctrl.items = stashArr.slice(1,stashArr.length);
|
|
760 | 760 | });
|
761 | 761 | });
|
762 | 762 |
|
| 763 | + function _findCaseInsensitiveDupe(arr) { |
| 764 | + if ( arr === undefined || ctrl.search === undefined ) { |
| 765 | + return false; |
| 766 | + } |
| 767 | + var hasDupe = arr.filter( function (origItem) { |
| 768 | + if ( ctrl.search.toUpperCase() === undefined ) { |
| 769 | + return false; |
| 770 | + } |
| 771 | + return origItem.toUpperCase() === ctrl.search.toUpperCase(); |
| 772 | + }).length > 0; |
| 773 | + |
| 774 | + return hasDupe; |
| 775 | + } |
| 776 | + |
763 | 777 | function _findApproxDupe(haystack, needle) {
|
764 | 778 | var tempArr = angular.copy(haystack);
|
765 | 779 | var dupeIndex = -1;
|
|
845 | 859 | attrs.multiple.toLowerCase() === 'true'
|
846 | 860 | );
|
847 | 861 |
|
848 |
| - $select.closeOnSelect = (angular.isDefined(attrs.closeOnSelect) && attrs.closeOnSelect.toLowerCase() === 'false') ? false : uiSelectConfig.closeOnSelect; |
| 862 | + $select.closeOnSelect = function() { |
| 863 | + if (angular.isDefined(attrs.closeOnSelect)) { |
| 864 | + return $parse(attrs.closeOnSelect)(); |
| 865 | + } else { |
| 866 | + return uiSelectConfig.closeOnSelect; |
| 867 | + } |
| 868 | + }(); |
| 869 | + |
849 | 870 | $select.onSelectCallback = $parse(attrs.onSelect);
|
850 | 871 | $select.onRemoveCallback = $parse(attrs.onRemove);
|
851 | 872 |
|
|
1221 | 1242 | attrs.$observe('placeholder', function(placeholder) {
|
1222 | 1243 | $select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
|
1223 | 1244 | });
|
1224 |
| - |
| 1245 | + |
1225 | 1246 | $select.allowClear = (angular.isDefined(attrs.allowClear)) ? (attrs.allowClear === '') ? true : (attrs.allowClear.toLowerCase() === 'true') : false;
|
1226 | 1247 |
|
1227 | 1248 | if($select.multiple){
|
|
0 commit comments