11/*!
22 * ui-select
33 * http://github.com/angular-ui/ui-select
4- * Version: 0.19.6 - 2016-11-08T10:09:40.868Z
4+ * Version: 0.19.5 - 2016-10-24T23:13:59.434Z
55 * License: MIT
66 */
77
@@ -118,8 +118,7 @@ var uis = angular.module('ui.select', [])
118118 } ,
119119 appendToBody : false ,
120120 spinnerEnabled : false ,
121- spinnerClass : 'glyphicon-refresh ui-select-spin' ,
122- backspaceReset : true
121+ spinnerClass : 'glyphicon-refresh ui-select-spin'
123122} )
124123
125124// See Rename minErr and make it accessible from outside https://github.com/angular/angular.js/issues/6913
@@ -180,31 +179,6 @@ var uis = angular.module('ui.select', [])
180179 } ;
181180} ] ) ;
182181
183- /**
184- * Debounces functions
185- *
186- * Taken from UI Bootstrap $$debounce source code
187- * See https://github.com/angular-ui/bootstrap/blob/master/src/debounce/debounce.js
188- *
189- */
190- uis . factory ( '$$uisDebounce' , [ '$timeout' , function ( $timeout ) {
191- return function ( callback , debounceTime ) {
192- var timeoutPromise ;
193-
194- return function ( ) {
195- var self = this ;
196- var args = Array . prototype . slice . call ( arguments ) ;
197- if ( timeoutPromise ) {
198- $timeout . cancel ( timeoutPromise ) ;
199- }
200-
201- timeoutPromise = $timeout ( function ( ) {
202- callback . apply ( self , args ) ;
203- } , debounceTime ) ;
204- } ;
205- } ;
206- } ] ) ;
207-
208182uis . directive ( 'uiSelectChoices' ,
209183 [ 'uiSelectConfig' , 'uisRepeatParser' , 'uiSelectMinErr' , '$compile' , '$window' ,
210184 function ( uiSelectConfig , RepeatParser , uiSelectMinErr , $compile , $window ) {
@@ -262,8 +236,10 @@ uis.directive('uiSelectChoices',
262236
263237
264238 $select . parseRepeatAttr ( attrs . repeat , groupByExp , groupFilterExp ) ; //Result ready at $select.parserResult
239+
265240 $select . disableChoiceExpression = attrs . uiDisableChoice ;
266241 $select . onHighlightCallback = attrs . onHighlight ;
242+
267243 $select . dropdownPosition = attrs . position ? attrs . position . toLowerCase ( ) : uiSelectConfig . dropdownPosition ;
268244
269245 scope . $on ( '$destroy' , function ( ) {
@@ -273,7 +249,7 @@ uis.directive('uiSelectChoices',
273249 scope . $watch ( '$select.search' , function ( newValue ) {
274250 if ( newValue && ! $select . open && $select . multiple ) $select . activate ( false , true ) ;
275251 $select . activeIndex = $select . tagging . isActivated ? - 1 : 0 ;
276- if ( ( ! attrs . minimumInputLength || $select . search . length >= attrs . minimumInputLength ) ) {
252+ if ( ! attrs . minimumInputLength || $select . search . length >= attrs . minimumInputLength ) {
277253 $select . refresh ( attrs . refresh ) ;
278254 } else {
279255 $select . items = [ ] ;
@@ -285,11 +261,10 @@ uis.directive('uiSelectChoices',
285261 var refreshDelay = scope . $eval ( attrs . refreshDelay ) ;
286262 $select . refreshDelay = refreshDelay !== undefined ? refreshDelay : uiSelectConfig . refreshDelay ;
287263 } ) ;
288-
264+
289265 scope . $watch ( '$select.open' , function ( open ) {
290266 if ( open ) {
291267 tElement . attr ( 'role' , 'listbox' ) ;
292- $select . refresh ( attrs . refresh ) ;
293268 } else {
294269 tElement . removeAttr ( 'role' ) ;
295270 }
@@ -416,8 +391,11 @@ uis.controller('uiSelectCtrl',
416391 if ( ! avoidReset ) _resetSearchInput ( ) ;
417392
418393 $scope . $broadcast ( 'uis:activate' ) ;
394+
419395 ctrl . open = true ;
396+
420397 ctrl . activeIndex = ctrl . activeIndex >= ctrl . items . length ? 0 : ctrl . activeIndex ;
398+
421399 // ensure that the index is set to zero for tagging variants
422400 // that where first option is auto-selected
423401 if ( ctrl . activeIndex === - 1 && ctrl . taggingLabel !== false ) {
@@ -555,6 +533,7 @@ uis.controller('uiSelectCtrl',
555533 if ( ctrl . dropdownPosition === 'auto' || ctrl . dropdownPosition === 'up' ) {
556534 $scope . calculateDropdownPos ( ) ;
557535 }
536+
558537 $scope . $broadcast ( 'uis:refresh' ) ;
559538 } ;
560539
@@ -602,7 +581,7 @@ uis.controller('uiSelectCtrl',
602581 var refreshPromise = $scope . $eval ( refreshAttr ) ;
603582 if ( refreshPromise && angular . isFunction ( refreshPromise . then ) && ! ctrl . refreshing ) {
604583 ctrl . refreshing = true ;
605- refreshPromise . finally ( function ( ) {
584+ refreshPromise . then ( function ( ) {
606585 ctrl . refreshing = false ;
607586 } ) ;
608587 } } , ctrl . refreshDelay ) ;
@@ -727,7 +706,7 @@ uis.controller('uiSelectCtrl',
727706 ctrl . close ( skipFocusser ) ;
728707 return ;
729708 }
730- }
709+ }
731710 _resetSearchInput ( ) ;
732711 $scope . $broadcast ( 'uis:select' , item ) ;
733712
@@ -803,7 +782,7 @@ uis.controller('uiSelectCtrl',
803782 }
804783
805784 if ( ! isLocked && lockedItemIndex > - 1 ) {
806- lockedItems . splice ( lockedItemIndex , 1 ) ;
785+ lockedItems . splice ( lockedItemIndex , 0 ) ;
807786 }
808787 }
809788
@@ -1138,12 +1117,6 @@ uis.directive('uiSelect',
11381117 $select . sortable = sortable !== undefined ? sortable : uiSelectConfig . sortable ;
11391118 } ) ;
11401119
1141- attrs . $observe ( 'backspaceReset' , function ( ) {
1142- // $eval() is needed otherwise we get a string instead of a boolean
1143- var backspaceReset = scope . $eval ( attrs . backspaceReset ) ;
1144- $select . backspaceReset = backspaceReset !== undefined ? backspaceReset : true ;
1145- } ) ;
1146-
11471120 attrs . $observe ( 'limit' , function ( ) {
11481121 //Limit the number of selections allowed
11491122 $select . limit = ( angular . isDefined ( attrs . limit ) ) ? parseInt ( attrs . limit , 10 ) : undefined ;
@@ -2083,7 +2056,7 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
20832056 } ) ;
20842057 focusser . bind ( "keydown" , function ( e ) {
20852058
2086- if ( e . which === KEY . BACKSPACE && $select . backspaceReset !== false ) {
2059+ if ( e . which === KEY . BACKSPACE ) {
20872060 e . preventDefault ( ) ;
20882061 e . stopPropagation ( ) ;
20892062 $select . select ( undefined ) ;
@@ -2270,6 +2243,31 @@ uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', f
22702243 } ;
22712244} ] ) ;
22722245
2246+ /**
2247+ * Debounces functions
2248+ *
2249+ * Taken from UI Bootstrap $$debounce source code
2250+ * See https://github.com/angular-ui/bootstrap/blob/master/src/debounce/debounce.js
2251+ *
2252+ */
2253+ uis . factory ( '$$uisDebounce' , [ '$timeout' , function ( $timeout ) {
2254+ return function ( callback , debounceTime ) {
2255+ var timeoutPromise ;
2256+
2257+ return function ( ) {
2258+ var self = this ;
2259+ var args = Array . prototype . slice . call ( arguments ) ;
2260+ if ( timeoutPromise ) {
2261+ $timeout . cancel ( timeoutPromise ) ;
2262+ }
2263+
2264+ timeoutPromise = $timeout ( function ( ) {
2265+ callback . apply ( self , args ) ;
2266+ } , debounceTime ) ;
2267+ } ;
2268+ } ;
2269+ } ] ) ;
2270+
22732271uis . directive ( 'uisOpenClose' , [ '$parse' , '$timeout' , function ( $parse , $timeout ) {
22742272 return {
22752273 restrict : 'A' ,
0 commit comments