Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Feister committed Dec 8, 2014
1 parent 7c9dfc1 commit fc93c66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/demo-tagging.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</script>
<![endif]-->

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular-sanitize.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-sanitize.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">

<!-- ui-select files -->
Expand Down Expand Up @@ -106,7 +106,7 @@ <h3>Object Tags with Tokenization (Space, Forward Slash, Comma)</h3>
<ui-select multiple tagging="tagTransform" tagging-tokens="SPACE|,|/" ng-model="multipleDemo.selectedPeople2" theme="bootstrap" ng-disabled="disabled" style="width: 800px;">
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
<div ng-if="person.isTag" ng-bind-html="person.name +' <small>(new)</small>'| highlight: $select.search"></div>
<div ng-if="person.isTag" ng-bind-html="person.name + ' ' + $select.taggingLabel | highlight: $select.search"></div>
<div ng-if="!person.isTag" ng-bind-html="person.name| highlight: $select.search"></div>
<small>
email: {{person.email}}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ app.controller('DemoCtrl', function($scope, $http, $timeout) {
$scope.tagTransform = function (newTag) {
var item = {
name: newTag,
email: newTag+'@email.com',
email: newTag.toLowerCase()+'@email.com',
age: 'unknown',
country: 'unknown'
};
Expand Down
32 changes: 20 additions & 12 deletions src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
DELETE: 46,
COMMAND: 91,

MAP: { 91 : "COMMAND", 8 : "BACKSPACE" , 9 : "TAB" , 13 : "ENTER" , 16 : "SHIFT" , 17 : "CTRL" , 18 : "ALT" , 19 : "PAUSEBREAK" , 20 : "CAPSLOCK" , 27 : "ESC" , 32 : "SPACE" , 33 : "PAGE_UP", 34 : "PAGE_DOWN" , 35 : "END" , 36 : "HOME" , 37 : "LEFT" , 38 : "UP" , 39 : "RIGHT" , 40 : "DOWN" , 43 : "+" , 44 : "PRINTSCREEN" , 45 : "INSERT" , 46 : "DELETE", 48 : "0" , 49 : "1" , 50 : "2" , 51 : "3" , 52 : "4" , 53 : "5" , 54 : "6" , 55 : "7" , 56 : "8" , 57 : "9" , 59 : ";", 61 : "=" , 65 : "A" , 66 : "B" , 67 : "C" , 68 : "D" , 69 : "E" , 70 : "F" , 71 : "G" , 72 : "H" , 73 : "I" , 74 : "J" , 75 : "K" , 76 : "L", 77 : "M" , 78 : "N" , 79 : "O" , 80 : "P" , 81 : "Q" , 82 : "R" , 83 : "S" , 84 : "T" , 85 : "U" , 86 : "V" , 87 : "W" , 88 : "X" , 89 : "Y" , 90 : "Z", 96 : "0" , 97 : "1" , 98 : "2" , 99 : "3" , 100 : "4" , 101 : "5" , 102 : "6" , 103 : "7" , 104 : "8" , 105 : "9", 106 : "*" , 107 : "+" , 109 : "-" , 110 : "." , 111 : "/", 112 : "F1" , 113 : "F2" , 114 : "F3" , 115 : "F4" , 116 : "F5" , 117 : "F6" , 118 : "F7" , 119 : "F8" , 120 : "F9" , 121 : "F10" , 122 : "F11" , 123 : "F12", 144 : "NUMLOCK" , 145 : "SCROLLLOCK" , 186 : ";" , 187 : "=" , 188 : "SPACE" , 189 : "-" , 190 : "." , 191 : "/" , 192 : "`" , 219 : "[" , 220 : "\\" , 221 : "]" , 222 : "'"
MAP: { 91 : "COMMAND", 8 : "BACKSPACE" , 9 : "TAB" , 13 : "ENTER" , 16 : "SHIFT" , 17 : "CTRL" , 18 : "ALT" , 19 : "PAUSEBREAK" , 20 : "CAPSLOCK" , 27 : "ESC" , 32 : "SPACE" , 33 : "PAGE_UP", 34 : "PAGE_DOWN" , 35 : "END" , 36 : "HOME" , 37 : "LEFT" , 38 : "UP" , 39 : "RIGHT" , 40 : "DOWN" , 43 : "+" , 44 : "PRINTSCREEN" , 45 : "INSERT" , 46 : "DELETE", 48 : "0" , 49 : "1" , 50 : "2" , 51 : "3" , 52 : "4" , 53 : "5" , 54 : "6" , 55 : "7" , 56 : "8" , 57 : "9" , 59 : ";", 61 : "=" , 65 : "A" , 66 : "B" , 67 : "C" , 68 : "D" , 69 : "E" , 70 : "F" , 71 : "G" , 72 : "H" , 73 : "I" , 74 : "J" , 75 : "K" , 76 : "L", 77 : "M" , 78 : "N" , 79 : "O" , 80 : "P" , 81 : "Q" , 82 : "R" , 83 : "S" , 84 : "T" , 85 : "U" , 86 : "V" , 87 : "W" , 88 : "X" , 89 : "Y" , 90 : "Z", 96 : "0" , 97 : "1" , 98 : "2" , 99 : "3" , 100 : "4" , 101 : "5" , 102 : "6" , 103 : "7" , 104 : "8" , 105 : "9", 106 : "*" , 107 : "+" , 109 : "-" , 110 : "." , 111 : "/", 112 : "F1" , 113 : "F2" , 114 : "F3" , 115 : "F4" , 116 : "F5" , 117 : "F6" , 118 : "F7" , 119 : "F8" , 120 : "F9" , 121 : "F10" , 122 : "F11" , 123 : "F12", 144 : "NUMLOCK" , 145 : "SCROLLLOCK" , 186 : ";" , 187 : "=" , 188 : "," , 189 : "-" , 190 : "." , 191 : "/" , 192 : "`" , 219 : "[" , 220 : "\\" , 221 : "]" , 222 : "'"
},

isControl: function (e) {
Expand Down Expand Up @@ -398,17 +398,18 @@
var locals = {};
locals[ctrl.parserResult.itemName] = item;

ctrl.onSelectCallback($scope, {
$item: item,
$model: ctrl.parserResult.modelMapper($scope, locals)
});

if(ctrl.multiple) {
ctrl.selected.push(item);
ctrl.sizeSearchInput();
} else {
ctrl.selected = item;
}

ctrl.onSelectCallback($scope, {
$item: item,
$model: ctrl.parserResult.modelMapper($scope, locals)
});

if (!ctrl.multiple || ctrl.closeOnSelect) {
ctrl.close(skipFocusser);
}
Expand Down Expand Up @@ -615,8 +616,14 @@
if ( ctrl.taggingTokens.tokens[i] === KEY.MAP[e.keyCode] ) {
// make sure there is a new value to push via tagging
if ( ctrl.search.length > 0 ) {
ctrl.select(undefined, true);
_searchInput.triggerHandler('tagged');
$timeout(function() {
_searchInput.triggerHandler('tagged', ctrl.items);
var newItem = ctrl.search.replace(KEY.MAP[e.keyCode],'').trim();
if ( ctrl.tagging.fct ) {
newItem = ctrl.tagging.fct( newItem );
}
ctrl.select( newItem, true);
});
}
}
}
Expand Down Expand Up @@ -655,7 +662,7 @@
// taggingLabel === false bypasses all of this
if (ctrl.taggingLabel === false) return;

var items = angular.copy( ctrl.items );
var items = angular.copy( ctrl.items )
var stashArr = angular.copy( ctrl.items );
var newItem;
var item;
Expand Down Expand Up @@ -703,8 +710,8 @@
return;
}
// verify the the tag doesn't match the value of an existing item from
// the searched data set
if ( _findCaseInsensitiveDupe(stashArr) ) {
// the searched data set or the items already selected
if ( _findCaseInsensitiveDupe(stashArr.concat(ctrl.selected)) ) {
// if there is a tag from prev iteration, strip it / queue the change
// and return early
if ( hasTag ) {
Expand Down Expand Up @@ -1036,7 +1043,7 @@
});

attrs.$observe('taggingLabel', function() {
if(attrs.tagging !== undefined && attrs.taggingLabel !== undefined)
if(attrs.tagging !== undefined )
{
// check eval for FALSE, in this case, we disable the labels
// associated with tagging
Expand Down Expand Up @@ -1261,3 +1268,4 @@
};
});
}());

0 comments on commit fc93c66

Please sign in to comment.