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.3 - 2014-12-08T17:27:37.929Z
5
5
* License: MIT
6
6
*/
7
7
29
29
DELETE : 46 ,
30
30
COMMAND : 91 ,
31
31
32
- 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 : "'"
32
+ 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 : "'"
33
33
} ,
34
34
35
35
isControl : function ( e ) {
406
406
var locals = { } ;
407
407
locals [ ctrl . parserResult . itemName ] = item ;
408
408
409
- ctrl . onSelectCallback ( $scope , {
410
- $item : item ,
411
- $model : ctrl . parserResult . modelMapper ( $scope , locals )
412
- } ) ;
413
-
414
409
if ( ctrl . multiple ) {
415
410
ctrl . selected . push ( item ) ;
416
411
ctrl . sizeSearchInput ( ) ;
417
412
} else {
418
413
ctrl . selected = item ;
419
414
}
415
+
416
+ ctrl . onSelectCallback ( $scope , {
417
+ $item : item ,
418
+ $model : ctrl . parserResult . modelMapper ( $scope , locals )
419
+ } ) ;
420
+
420
421
if ( ! ctrl . multiple || ctrl . closeOnSelect ) {
421
422
ctrl . close ( skipFocusser ) ;
422
423
}
611
612
612
613
$scope . $apply ( function ( ) {
613
614
var processed = false ;
615
+ var tagged = false ;
614
616
615
617
if ( ctrl . multiple && KEY . isHorizontalMovement ( key ) ) {
616
618
processed = _handleMatchSelection ( key ) ;
623
625
if ( ctrl . taggingTokens . tokens [ i ] === KEY . MAP [ e . keyCode ] ) {
624
626
// make sure there is a new value to push via tagging
625
627
if ( ctrl . search . length > 0 ) {
626
- ctrl . select ( null , true ) ;
627
- _searchInput . triggerHandler ( 'tagged' ) ;
628
+ tagged = true ;
628
629
}
629
630
}
630
631
}
632
+ if ( tagged ) {
633
+ $timeout ( function ( ) {
634
+ _searchInput . triggerHandler ( 'tagged' , ctrl . items ) ;
635
+ var newItem = ctrl . search . replace ( KEY . MAP [ e . keyCode ] , '' ) . trim ( ) ;
636
+ if ( ctrl . tagging . fct ) {
637
+ newItem = ctrl . tagging . fct ( newItem ) ;
638
+ }
639
+ ctrl . select ( newItem , true ) ;
640
+ } ) ;
641
+ }
631
642
}
632
643
}
633
644
711
722
return ;
712
723
}
713
724
// verify the the tag doesn't match the value of an existing item from
714
- // the searched data set
715
- if ( stashArr . filter ( function ( origItem ) { return origItem . toUpperCase ( ) === ctrl . search . toUpperCase ( ) ; } ) . length > 0 ) {
725
+ // the searched data set or the items already selected
726
+ if ( _findCaseInsensitiveDupe ( stashArr . concat ( ctrl . selected ) ) ) {
716
727
// if there is a tag from prev iteration, strip it / queue the change
717
728
// and return early
718
729
if ( hasTag ) {
724
735
}
725
736
return ;
726
737
}
727
- if ( ctrl . selected . filter ( function ( selection ) { return selection . toUpperCase ( ) === ctrl . search . toUpperCase ( ) ; } ) . length > 0 ) {
738
+ if ( _findCaseInsensitiveDupe ( stashArr ) ) {
728
739
// if there is a tag from prev iteration, strip it
729
740
if ( hasTag ) {
730
741
ctrl . items = stashArr . slice ( 1 , stashArr . length ) ;
760
771
} ) ;
761
772
} ) ;
762
773
774
+ function _findCaseInsensitiveDupe ( arr ) {
775
+ if ( arr === undefined || ctrl . search === undefined ) {
776
+ return false ;
777
+ }
778
+ var hasDupe = arr . filter ( function ( origItem ) {
779
+ if ( ctrl . search . toUpperCase ( ) === undefined ) {
780
+ return false ;
781
+ }
782
+ return origItem . toUpperCase ( ) === ctrl . search . toUpperCase ( ) ;
783
+ } ) . length > 0 ;
784
+
785
+ return hasDupe ;
786
+ }
787
+
763
788
function _findApproxDupe ( haystack , needle ) {
764
789
var tempArr = angular . copy ( haystack ) ;
765
790
var dupeIndex = - 1 ;
845
870
attrs . multiple . toLowerCase ( ) === 'true'
846
871
) ;
847
872
848
- $select . closeOnSelect = ( angular . isDefined ( attrs . closeOnSelect ) && attrs . closeOnSelect . toLowerCase ( ) === 'false' ) ? false : uiSelectConfig . closeOnSelect ;
873
+ $select . closeOnSelect = function ( ) {
874
+ if ( angular . isDefined ( attrs . closeOnSelect ) ) {
875
+ return $parse ( attrs . closeOnSelect ) ( ) ;
876
+ } else {
877
+ return uiSelectConfig . closeOnSelect ;
878
+ }
879
+ } ( ) ;
880
+
849
881
$select . onSelectCallback = $parse ( attrs . onSelect ) ;
850
882
$select . onRemoveCallback = $parse ( attrs . onRemove ) ;
851
883
1023
1055
} ) ;
1024
1056
1025
1057
attrs . $observe ( 'taggingLabel' , function ( ) {
1026
- if ( attrs . tagging !== undefined && attrs . taggingLabel !== undefined )
1058
+ if ( attrs . tagging !== undefined )
1027
1059
{
1028
1060
// check eval for FALSE, in this case, we disable the labels
1029
1061
// associated with tagging
1221
1253
attrs . $observe ( 'placeholder' , function ( placeholder ) {
1222
1254
$select . placeholder = placeholder !== undefined ? placeholder : uiSelectConfig . placeholder ;
1223
1255
} ) ;
1224
-
1256
+
1225
1257
$select . allowClear = ( angular . isDefined ( attrs . allowClear ) ) ? ( attrs . allowClear === '' ) ? true : ( attrs . allowClear . toLowerCase ( ) === 'true' ) : false ;
1226
1258
1227
1259
if ( $select . multiple ) {
1249
1281
} ) ;
1250
1282
} ( ) ) ;
1251
1283
1284
+
1252
1285
angular . module ( "ui.select" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "bootstrap/choices.tpl.html" , "<ul class=\"ui-select-choices ui-select-choices-content dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\" ng-show=\"$select.items.length > 0\"><li class=\"ui-select-choices-group\"><div class=\"divider\" ng-show=\"$select.isGrouped && $index > 0\"></div><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label dropdown-header\" ng-bind-html=\"$group.name\"></div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><a href=\"javascript:void(0)\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>" ) ;
1253
1286
$templateCache . put ( "bootstrap/match-multiple.tpl.html" , "<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><span style=\"margin-right: 3px;\" class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$select.activeMatchIndex === $index}\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$select.removeChoice($index)\"> ×</span> <span uis-transclude-append=\"\"></span></span></span></span>" ) ;
1254
1287
$templateCache . put ( "bootstrap/match.tpl.html" , "<button type=\"button\" class=\"btn btn-default form-control ui-select-match\" tabindex=\"-1\" ng-hide=\"$select.open\" ng-disabled=\"$select.disabled\" ng-class=\"{\'btn-default-focus\':$select.focus}\" ;=\"\" ng-click=\"$select.activate()\"><span ng-show=\"$select.isEmpty()\" class=\"text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" ng-transclude=\"\"></span> <span class=\"caret ui-select-toggle\" ng-click=\"$select.toggle($event)\"></span></button>" ) ;
1255
1288
$templateCache . put ( "bootstrap/select-multiple.tpl.html" , "<div class=\"ui-select-multiple ui-select-bootstrap dropdown form-control\" ng-class=\"{open: $select.open}\"><div><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div>" ) ;
1256
1289
$templateCache . put ( "bootstrap/select.tpl.html" , "<div class=\"ui-select-bootstrap dropdown\" ng-class=\"{open: $select.open}\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"form-control ui-select-search\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-show=\"$select.searchEnabled && $select.open\"><div class=\"ui-select-choices\"></div></div>" ) ;
1290
+ $templateCache . put ( "selectize/choices.tpl.html" , "<div ng-show=\"$select.open\" class=\"ui-select-choices selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\" ng-bind-html=\"$group.name\"></div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><div class=\"option ui-select-choices-row-inner\" data-selectable=\"\"></div></div></div></div></div>" ) ;
1291
+ $templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>" ) ;
1292
+ $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"selectize-control single\"><div class=\"selectize-input\" ng-class=\"{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}\" ng-click=\"$select.activate()\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"ui-select-search ui-select-toggle\" ng-click=\"$select.toggle($event)\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-hide=\"!$select.searchEnabled || ($select.selected && !$select.open)\" ng-disabled=\"$select.disabled\"></div><div class=\"ui-select-choices\"></div></div>" ) ;
1257
1293
$templateCache . put ( "select2/choices.tpl.html" , "<ul class=\"ui-select-choices ui-select-choices-content select2-results\"><li class=\"ui-select-choices-group\" ng-class=\"{\'select2-result-with-children\': $select.choiceGrouped($group) }\"><div ng-show=\"$select.choiceGrouped($group)\" class=\"ui-select-choices-group-label select2-result-label\" ng-bind-html=\"$group.name\"></div><ul ng-class=\"{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }\"><li class=\"ui-select-choices-row\" ng-class=\"{\'select2-highlighted\': $select.isActive(this), \'select2-disabled\': $select.isDisabled(this)}\"><div class=\"select2-result-label ui-select-choices-row-inner\"></div></li></ul></li></ul>" ) ;
1258
1294
$templateCache . put ( "select2/match-multiple.tpl.html" , "<span class=\"ui-select-match\"><li class=\"ui-select-match-item select2-search-choice\" ng-repeat=\"$item in $select.selected\" ng-class=\"{\'select2-search-choice-focus\':$select.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}\"><span uis-transclude-append=\"\"></span> <a href=\"javascript:;\" class=\"ui-select-match-close select2-search-choice-close\" ng-click=\"$select.removeChoice($index)\" tabindex=\"-1\"></a></li></span>" ) ;
1259
1295
$templateCache . put ( "select2/match.tpl.html" , "<a class=\"select2-choice ui-select-match\" ng-class=\"{\'select2-default\': $select.isEmpty()}\" ng-click=\"$select.activate()\"><span ng-show=\"$select.isEmpty()\" class=\"select2-chosen\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"select2-chosen\" ng-transclude=\"\"></span> <abbr ng-if=\"$select.allowClear && !$select.isEmpty()\" class=\"select2-search-choice-close\" ng-click=\"$select.select(undefined)\"></abbr> <span class=\"select2-arrow ui-select-toggle\" ng-click=\"$select.toggle($event)\"><b></b></span></a>" ) ;
1260
1296
$templateCache . put ( "select2/select-multiple.tpl.html" , "<div class=\"ui-select-multiple select2 select2-container select2-container-multi\" ng-class=\"{\'select2-container-active select2-dropdown-open\': $select.open,\n \'select2-container-disabled\': $select.disabled}\"><ul class=\"select2-choices\"><span class=\"ui-select-match\"></span><li class=\"select2-search-field\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"select2-input ui-select-search\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-model=\"$select.search\" ng-click=\"$select.activate()\" style=\"width: 34px;\"></li></ul><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"ui-select-choices\"></div></div></div>" ) ;
1261
- $templateCache . put ( "select2/select.tpl.html" , "<div class=\"select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open\': $select.open,\n \'select2-container-disabled\': $select.disabled,\n \'select2-container-active\': $select.focus, \n \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}\"><div class=\"ui-select-match\"></div><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"select2-search\" ng-show=\"$select.searchEnabled\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>" ) ;
1262
- $templateCache . put ( "selectize/choices.tpl.html" , "<div ng-show=\"$select.open\" class=\"ui-select-choices selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\" ng-bind-html=\"$group.name\"></div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><div class=\"option ui-select-choices-row-inner\" data-selectable=\"\"></div></div></div></div></div>" ) ;
1263
- $templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>" ) ;
1264
- $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"selectize-control single\"><div class=\"selectize-input\" ng-class=\"{\'focus\': $select.open, \'disabled\': $select.disabled, \'selectize-focus\' : $select.focus}\" ng-click=\"$select.activate()\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"ui-select-search ui-select-toggle\" ng-click=\"$select.toggle($event)\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-hide=\"!$select.searchEnabled || ($select.selected && !$select.open)\" ng-disabled=\"$select.disabled\"></div><div class=\"ui-select-choices\"></div></div>" ) ; } ] ) ;
1297
+ $templateCache . put ( "select2/select.tpl.html" , "<div class=\"select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open\': $select.open,\n \'select2-container-disabled\': $select.disabled,\n \'select2-container-active\': $select.focus, \n \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}\"><div class=\"ui-select-match\"></div><div class=\"select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"select2-search\" ng-show=\"$select.searchEnabled\"><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>" ) ; } ] ) ;
0 commit comments