1
1
/*!
2
2
* ui-select
3
3
* 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
5
5
* License: MIT
6
6
*/
7
7
@@ -118,8 +118,7 @@ var uis = angular.module('ui.select', [])
118
118
} ,
119
119
appendToBody : false ,
120
120
spinnerEnabled : false ,
121
- spinnerClass : 'glyphicon-refresh ui-select-spin' ,
122
- backspaceReset : true
121
+ spinnerClass : 'glyphicon-refresh ui-select-spin'
123
122
} )
124
123
125
124
// 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', [])
180
179
} ;
181
180
} ] ) ;
182
181
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
-
208
182
uis . directive ( 'uiSelectChoices' ,
209
183
[ 'uiSelectConfig' , 'uisRepeatParser' , 'uiSelectMinErr' , '$compile' , '$window' ,
210
184
function ( uiSelectConfig , RepeatParser , uiSelectMinErr , $compile , $window ) {
@@ -262,8 +236,10 @@ uis.directive('uiSelectChoices',
262
236
263
237
264
238
$select . parseRepeatAttr ( attrs . repeat , groupByExp , groupFilterExp ) ; //Result ready at $select.parserResult
239
+
265
240
$select . disableChoiceExpression = attrs . uiDisableChoice ;
266
241
$select . onHighlightCallback = attrs . onHighlight ;
242
+
267
243
$select . dropdownPosition = attrs . position ? attrs . position . toLowerCase ( ) : uiSelectConfig . dropdownPosition ;
268
244
269
245
scope . $on ( '$destroy' , function ( ) {
@@ -273,7 +249,7 @@ uis.directive('uiSelectChoices',
273
249
scope . $watch ( '$select.search' , function ( newValue ) {
274
250
if ( newValue && ! $select . open && $select . multiple ) $select . activate ( false , true ) ;
275
251
$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 ) {
277
253
$select . refresh ( attrs . refresh ) ;
278
254
} else {
279
255
$select . items = [ ] ;
@@ -285,11 +261,10 @@ uis.directive('uiSelectChoices',
285
261
var refreshDelay = scope . $eval ( attrs . refreshDelay ) ;
286
262
$select . refreshDelay = refreshDelay !== undefined ? refreshDelay : uiSelectConfig . refreshDelay ;
287
263
} ) ;
288
-
264
+
289
265
scope . $watch ( '$select.open' , function ( open ) {
290
266
if ( open ) {
291
267
tElement . attr ( 'role' , 'listbox' ) ;
292
- $select . refresh ( attrs . refresh ) ;
293
268
} else {
294
269
tElement . removeAttr ( 'role' ) ;
295
270
}
@@ -416,8 +391,11 @@ uis.controller('uiSelectCtrl',
416
391
if ( ! avoidReset ) _resetSearchInput ( ) ;
417
392
418
393
$scope . $broadcast ( 'uis:activate' ) ;
394
+
419
395
ctrl . open = true ;
396
+
420
397
ctrl . activeIndex = ctrl . activeIndex >= ctrl . items . length ? 0 : ctrl . activeIndex ;
398
+
421
399
// ensure that the index is set to zero for tagging variants
422
400
// that where first option is auto-selected
423
401
if ( ctrl . activeIndex === - 1 && ctrl . taggingLabel !== false ) {
@@ -555,6 +533,7 @@ uis.controller('uiSelectCtrl',
555
533
if ( ctrl . dropdownPosition === 'auto' || ctrl . dropdownPosition === 'up' ) {
556
534
$scope . calculateDropdownPos ( ) ;
557
535
}
536
+
558
537
$scope . $broadcast ( 'uis:refresh' ) ;
559
538
} ;
560
539
@@ -602,7 +581,7 @@ uis.controller('uiSelectCtrl',
602
581
var refreshPromise = $scope . $eval ( refreshAttr ) ;
603
582
if ( refreshPromise && angular . isFunction ( refreshPromise . then ) && ! ctrl . refreshing ) {
604
583
ctrl . refreshing = true ;
605
- refreshPromise . finally ( function ( ) {
584
+ refreshPromise . then ( function ( ) {
606
585
ctrl . refreshing = false ;
607
586
} ) ;
608
587
} } , ctrl . refreshDelay ) ;
@@ -727,7 +706,7 @@ uis.controller('uiSelectCtrl',
727
706
ctrl . close ( skipFocusser ) ;
728
707
return ;
729
708
}
730
- }
709
+ }
731
710
_resetSearchInput ( ) ;
732
711
$scope . $broadcast ( 'uis:select' , item ) ;
733
712
@@ -803,7 +782,7 @@ uis.controller('uiSelectCtrl',
803
782
}
804
783
805
784
if ( ! isLocked && lockedItemIndex > - 1 ) {
806
- lockedItems . splice ( lockedItemIndex , 1 ) ;
785
+ lockedItems . splice ( lockedItemIndex , 0 ) ;
807
786
}
808
787
}
809
788
@@ -1138,12 +1117,6 @@ uis.directive('uiSelect',
1138
1117
$select . sortable = sortable !== undefined ? sortable : uiSelectConfig . sortable ;
1139
1118
} ) ;
1140
1119
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
-
1147
1120
attrs . $observe ( 'limit' , function ( ) {
1148
1121
//Limit the number of selections allowed
1149
1122
$select . limit = ( angular . isDefined ( attrs . limit ) ) ? parseInt ( attrs . limit , 10 ) : undefined ;
@@ -2083,7 +2056,7 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
2083
2056
} ) ;
2084
2057
focusser . bind ( "keydown" , function ( e ) {
2085
2058
2086
- if ( e . which === KEY . BACKSPACE && $select . backspaceReset !== false ) {
2059
+ if ( e . which === KEY . BACKSPACE ) {
2087
2060
e . preventDefault ( ) ;
2088
2061
e . stopPropagation ( ) ;
2089
2062
$select . select ( undefined ) ;
@@ -2270,6 +2243,31 @@ uis.directive('uiSelectSort', ['$timeout', 'uiSelectConfig', 'uiSelectMinErr', f
2270
2243
} ;
2271
2244
} ] ) ;
2272
2245
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
+
2273
2271
uis . directive ( 'uisOpenClose' , [ '$parse' , '$timeout' , function ( $parse , $timeout ) {
2274
2272
return {
2275
2273
restrict : 'A' ,
0 commit comments