1
1
/*!
2
2
* ui-select
3
3
* http://github.com/angular-ui/ui-select
4
- * Version: 0.13.2 - 2015-10-09T15:34:24.040Z
4
+ * Version: 0.13.2 - 2015-11-06T02:57:40.960Z
5
5
* License: MIT
6
6
*/
7
7
@@ -143,7 +143,7 @@ var uis = angular.module('ui.select', [])
143
143
}
144
144
145
145
return function ( matchItem , query ) {
146
- return query && matchItem ? matchItem . replace ( new RegExp ( escapeRegexp ( query ) , 'gi' ) , '<span class="ui-select-highlight">$&</span>' ) : matchItem ;
146
+ return query && matchItem ? ( '' + matchItem ) . replace ( new RegExp ( escapeRegexp ( query ) , 'gi' ) , '<span class="ui-select-highlight">$&</span>' ) : matchItem ;
147
147
} ;
148
148
} )
149
149
@@ -244,8 +244,8 @@ uis.directive('uiSelectChoices',
244
244
* put as much logic in the controller (instead of the link functions) as possible so it can be easily tested.
245
245
*/
246
246
uis . controller ( 'uiSelectCtrl' ,
247
- [ '$scope' , '$element' , '$timeout' , '$filter' , 'uisRepeatParser' , 'uiSelectMinErr' , 'uiSelectConfig' , '$parse' ,
248
- function ( $scope , $element , $timeout , $filter , RepeatParser , uiSelectMinErr , uiSelectConfig , $parse ) {
247
+ [ '$scope' , '$element' , '$timeout' , '$filter' , 'uisRepeatParser' , 'uiSelectMinErr' , 'uiSelectConfig' , '$parse' , '$injector' ,
248
+ function ( $scope , $element , $timeout , $filter , RepeatParser , uiSelectMinErr , uiSelectConfig , $parse , $injector ) {
249
249
250
250
var ctrl = this ;
251
251
@@ -280,11 +280,21 @@ uis.controller('uiSelectCtrl',
280
280
ctrl . clickTriggeredSelect = false ;
281
281
ctrl . $filter = $filter ;
282
282
283
+ // Use $injector to check for $animate and store a reference to it
284
+ ctrl . $animate = ( function ( ) {
285
+ try {
286
+ return $injector . get ( '$animate' ) ;
287
+ } catch ( err ) {
288
+ // $animate does not exist
289
+ return null ;
290
+ }
291
+ } ) ( ) ;
292
+
283
293
ctrl . searchInput = $element . querySelectorAll ( 'input.ui-select-search' ) ;
284
294
if ( ctrl . searchInput . length !== 1 ) {
285
295
throw uiSelectMinErr ( 'searchInput' , "Expected 1 input.ui-select-search but got '{0}'." , ctrl . searchInput . length ) ;
286
296
}
287
-
297
+
288
298
ctrl . isEmpty = function ( ) {
289
299
return angular . isUndefined ( ctrl . selected ) || ctrl . selected === null || ctrl . selected === '' ;
290
300
} ;
@@ -329,14 +339,29 @@ uis.controller('uiSelectCtrl',
329
339
ctrl . activeIndex = 0 ;
330
340
}
331
341
332
- // Give it time to appear before focus
333
- $timeout ( function ( ) {
334
- ctrl . search = initSearchValue || ctrl . search ;
335
- ctrl . searchInput [ 0 ] . focus ( ) ;
336
- if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 ) {
337
- _ensureHighlightVisible ( ) ;
338
- }
339
- } ) ;
342
+ var container = $element . querySelectorAll ( '.ui-select-choices-content' ) ;
343
+ if ( ctrl . $animate && ctrl . $animate . enabled ( container [ 0 ] ) ) {
344
+ ctrl . $animate . on ( 'enter' , container [ 0 ] , function ( elem , phase ) {
345
+ if ( phase === 'close' ) {
346
+ // Only focus input after the animation has finished
347
+ $timeout ( function ( ) {
348
+ ctrl . focusSearchInput ( initSearchValue ) ;
349
+ } ) ;
350
+ }
351
+ } ) ;
352
+ } else {
353
+ $timeout ( function ( ) {
354
+ ctrl . focusSearchInput ( initSearchValue ) ;
355
+ } ) ;
356
+ }
357
+ }
358
+ } ;
359
+
360
+ ctrl . focusSearchInput = function ( initSearchValue ) {
361
+ ctrl . search = initSearchValue || ctrl . search ;
362
+ ctrl . searchInput [ 0 ] . focus ( ) ;
363
+ if ( ! ctrl . tagging . isActivated && ctrl . items . length > 1 ) {
364
+ _ensureHighlightVisible ( ) ;
340
365
}
341
366
} ;
342
367
@@ -388,7 +413,7 @@ uis.controller('uiSelectCtrl',
388
413
//If collection is an Object, convert it to Array
389
414
390
415
var originalSource = ctrl . parserResult . source ;
391
-
416
+
392
417
//When an object is used as source, we better create an array and use it as 'source'
393
418
var createArrayFromObject = function ( ) {
394
419
var origSrc = originalSource ( $scope ) ;
@@ -434,7 +459,7 @@ uis.controller('uiSelectCtrl',
434
459
ctrl . items = [ ] ;
435
460
} else {
436
461
if ( ! angular . isArray ( items ) ) {
437
- throw uiSelectMinErr ( 'items' , "Expected an array but got '{0}'." , items ) ;
462
+ throw uiSelectMinErr ( 'items' , "Expected an array but got '{0}'." , items ) ;
438
463
} else {
439
464
//Remove already selected items (ex: while searching)
440
465
//TODO Should add a test
@@ -1911,16 +1936,16 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
1911
1936
} ] ) ;
1912
1937
1913
1938
} ( ) ) ;
1914
- angular . module ( "ui.select" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "bootstrap/choices.tpl.html" , "<ul class=\"ui-select-choices ui-select-choices-content ui-select-dropdown dropdown-menu\" role=\"listbox\" ng-show=\"$select.items.length > 0\"><li class=\"ui-select-choices-group\" id=\"ui-select-choices-{{ $select.generatedId }}\"><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=\"$group.name\"></div><div id=\"ui-select-choices-row-{{ $select.generatedId }}-{{$index}}\" class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\" role=\"option\"><a href =\"javascript:void(0 )\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>" ) ;
1939
+ angular . module ( "ui.select" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "bootstrap/choices.tpl.html" , "<ul class=\"ui-select-choices ui-select-choices-content ui-select-dropdown dropdown-menu\" role=\"listbox\" ng-show=\"$select.items.length > 0\"><li class=\"ui-select-choices-group\" id=\"ui-select-choices-{{ $select.generatedId }}\"><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=\"$group.name\"></div><div id=\"ui-select-choices-row-{{ $select.generatedId }}-{{$index}}\" class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\" role=\"option\"><a ng-click =\"$event.preventDefault( )\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>" ) ;
1915
1940
$templateCache . put ( "bootstrap/match-multiple.tpl.html" , "<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><span class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$selectMultiple.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$selectMultiple.activeMatchIndex === $index, \'select-locked\':$select.isLocked(this, $index)}\" ui-select-sort=\"$select.selected\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$selectMultiple.removeChoice($index)\"> ×</span> <span uis-transclude-append=\"\"></span></span></span></span>" ) ;
1916
1941
$templateCache . put ( "bootstrap/match.tpl.html" , "<div class=\"ui-select-match\" ng-hide=\"$select.open\" ng-disabled=\"$select.disabled\" ng-class=\"{\'btn-default-focus\':$select.focus}\"><span tabindex=\"-1\" class=\"btn btn-default form-control ui-select-toggle\" aria-label=\"{{ $select.baseTitle }} activate\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activate()\" style=\"outline: 0;\"><span ng-show=\"$select.isEmpty()\" class=\"ui-select-placeholder text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"ui-select-match-text pull-left\" ng-class=\"{\'ui-select-allow-clear\': $select.allowClear && !$select.isEmpty()}\" ng-transclude=\"\"></span> <i class=\"caret pull-right\" ng-click=\"$select.toggle($event)\"></i> <a ng-show=\"$select.allowClear && !$select.isEmpty()\" aria-label=\"{{ $select.baseTitle }} clear\" style=\"margin-right: 10px\" ng-click=\"$select.clear($event)\" class=\"btn btn-xs btn-link pull-right\"><i class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></i></a></span></div>" ) ;
1917
1942
$templateCache . put ( "bootstrap/select-multiple.tpl.html" , "<div class=\"ui-select-container 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=\"false\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$selectMultiple.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\" role=\"combobox\" aria-label=\"{{ $select.baseTitle }}\" ondrop=\"return false;\"></div><div class=\"ui-select-choices\"></div></div>" ) ;
1918
1943
$templateCache . put ( "bootstrap/select.tpl.html" , "<div class=\"ui-select-container ui-select-bootstrap dropdown\" ng-class=\"{open: $select.open}\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"false\" tabindex=\"-1\" aria-expanded=\"true\" aria-label=\"{{ $select.baseTitle }}\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" 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>" ) ;
1919
- $templateCache . put ( "selectize/choices.tpl.html" , "<div ng-show=\"$select.open\" class=\"ui-select-choices ui-select-dropdown selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\" role=\"listbox\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\" ng-bind=\"$group.name\"></div><div role=\"option\" 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>" ) ;
1920
- $templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>" ) ;
1921
- $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"ui-select-container selectize-control single\" ng-class=\"{\'open\': $select.open}\"><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=\"false\" 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\" aria-label=\"{{ $select.baseTitle }}\"></div><div class=\"ui-select-choices\"></div></div>" ) ;
1922
1944
$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=\"$group.name\"></div><ul role=\"listbox\" id=\"ui-select-choices-{{ $select.generatedId }}\" ng-class=\"{\'select2-result-sub\': $select.choiceGrouped($group), \'select2-result-single\': !$select.choiceGrouped($group) }\"><li role=\"option\" id=\"ui-select-choices-row-{{ $select.generatedId }}-{{$index}}\" 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>" ) ;
1923
1945
$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\':$selectMultiple.activeMatchIndex === $index, \'select2-locked\':$select.isLocked(this, $index)}\" ui-select-sort=\"$select.selected\"><span uis-transclude-append=\"\"></span> <a href=\"javascript:;\" class=\"ui-select-match-close select2-search-choice-close\" ng-click=\"$selectMultiple.removeChoice($index)\" tabindex=\"-1\"></a></li></span>" ) ;
1924
1946
$templateCache . put ( "select2/match.tpl.html" , "<a class=\"select2-choice ui-select-match\" ng-class=\"{\'select2-default\': $select.isEmpty()}\" ng-click=\"$select.toggle($event)\" aria-label=\"{{ $select.baseTitle }} select\"><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.clear($event)\"></abbr> <span class=\"select2-arrow ui-select-toggle\"><b></b></span></a>" ) ;
1925
1947
$templateCache . put ( "select2/select-multiple.tpl.html" , "<div class=\"ui-select-container ui-select-multiple select2 select2-container select2-container-multi\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open, \'select2-container-disabled\': $select.disabled}\"><ul class=\"select2-choices\"><span class=\"ui-select-match\"></span><li class=\"select2-search-field\"><input type=\"text\" autocomplete=\"false\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"select2-input ui-select-search\" placeholder=\"{{$selectMultiple.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-model=\"$select.search\" ng-click=\"$select.activate()\" style=\"width: 34px;\" ondrop=\"return false;\"></li></ul><div class=\"ui-select-dropdown select2-drop select2-with-searchbox select2-drop-active\" ng-class=\"{\'select2-display-none\': !$select.open}\"><div class=\"ui-select-choices\"></div></div></div>" ) ;
1926
- $templateCache . put ( "select2/select.tpl.html" , "<div class=\"ui-select-container select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open, \'select2-container-disabled\': $select.disabled, \'select2-container-active\': $select.focus, \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}\"><div class=\"ui-select-match\"></div><div class=\"ui-select-dropdown 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=\"false\" autocorrect=\"false\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>" ) ; } ] ) ;
1948
+ $templateCache . put ( "select2/select.tpl.html" , "<div class=\"ui-select-container select2 select2-container\" ng-class=\"{\'select2-container-active select2-dropdown-open open\': $select.open, \'select2-container-disabled\': $select.disabled, \'select2-container-active\': $select.focus, \'select2-allowclear\': $select.allowClear && !$select.isEmpty()}\"><div class=\"ui-select-match\"></div><div class=\"ui-select-dropdown 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=\"false\" autocorrect=\"false\" autocapitalize=\"off\" spellcheck=\"false\" role=\"combobox\" aria-expanded=\"true\" aria-owns=\"ui-select-choices-{{ $select.generatedId }}\" aria-label=\"{{ $select.baseTitle }}\" aria-activedescendant=\"ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}\" class=\"ui-select-search select2-input\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div></div>" ) ;
1949
+ $templateCache . put ( "selectize/choices.tpl.html" , "<div ng-show=\"$select.open\" class=\"ui-select-choices ui-select-dropdown selectize-dropdown single\"><div class=\"ui-select-choices-content selectize-dropdown-content\"><div class=\"ui-select-choices-group optgroup\" role=\"listbox\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label optgroup-header\" ng-bind=\"$group.name\"></div><div role=\"option\" 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>" ) ;
1950
+ $templateCache . put ( "selectize/match.tpl.html" , "<div ng-hide=\"($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>" ) ;
1951
+ $templateCache . put ( "selectize/select.tpl.html" , "<div class=\"ui-select-container selectize-control single\" ng-class=\"{\'open\': $select.open}\"><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=\"false\" 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\" aria-label=\"{{ $select.baseTitle }}\"></div><div class=\"ui-select-choices\"></div></div>" ) ; } ] ) ;
0 commit comments