Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 7f00936

Browse files
committed
0.19.6
1 parent 651da0a commit 7f00936

File tree

6 files changed

+57
-46
lines changed

6 files changed

+57
-46
lines changed

dist/select.css

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.19.5 - 2016-10-24T23:13:59.551Z
4+
* Version: 0.19.6 - 2017-03-08T04:21:53.894Z
55
* License: MIT
66
*/
77

@@ -325,17 +325,10 @@ body > .ui-select-bootstrap.open {
325325
}
326326

327327
/* Spinner */
328-
.ui-select-refreshing {
328+
.ui-select-refreshing.glyphicon {
329329
position: absolute;
330330
right: 0;
331331
padding: 8px 27px;
332-
top: 1px;
333-
display: inline-block;
334-
font-family: 'Glyphicons Halflings';
335-
font-style: normal;
336-
font-weight: normal;
337-
line-height: 1;
338-
-webkit-font-smoothing:antialiased;
339332
}
340333

341334
@-webkit-keyframes ui-select-spin {

dist/select.js

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.19.5 - 2016-10-24T23:13:59.434Z
4+
* Version: 0.19.6 - 2017-03-08T04:21:53.759Z
55
* License: MIT
66
*/
77

@@ -118,7 +118,8 @@ var uis = angular.module('ui.select', [])
118118
},
119119
appendToBody: false,
120120
spinnerEnabled: false,
121-
spinnerClass: 'glyphicon-refresh ui-select-spin'
121+
spinnerClass: 'glyphicon glyphicon-refresh ui-select-spin',
122+
backspaceReset: true
122123
})
123124

124125
// See Rename minErr and make it accessible from outside https://github.com/angular/angular.js/issues/6913
@@ -236,16 +237,10 @@ uis.directive('uiSelectChoices',
236237

237238

238239
$select.parseRepeatAttr(attrs.repeat, groupByExp, groupFilterExp); //Result ready at $select.parserResult
239-
240240
$select.disableChoiceExpression = attrs.uiDisableChoice;
241241
$select.onHighlightCallback = attrs.onHighlight;
242-
243242
$select.dropdownPosition = attrs.position ? attrs.position.toLowerCase() : uiSelectConfig.dropdownPosition;
244243

245-
scope.$on('$destroy', function() {
246-
choices.remove();
247-
});
248-
249244
scope.$watch('$select.search', function(newValue) {
250245
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
251246
$select.activeIndex = $select.tagging.isActivated ? -1 : 0;
@@ -265,8 +260,9 @@ uis.directive('uiSelectChoices',
265260
scope.$watch('$select.open', function(open) {
266261
if (open) {
267262
tElement.attr('role', 'listbox');
263+
$select.refresh(attrs.refresh);
268264
} else {
269-
tElement.removeAttr('role');
265+
element.removeAttr('role');
270266
}
271267
});
272268
};
@@ -297,7 +293,6 @@ uis.controller('uiSelectCtrl',
297293
ctrl.refreshing = false;
298294
ctrl.spinnerEnabled = uiSelectConfig.spinnerEnabled;
299295
ctrl.spinnerClass = uiSelectConfig.spinnerClass;
300-
301296
ctrl.removeSelected = uiSelectConfig.removeSelected; //If selected item(s) should be removed from dropdown list
302297
ctrl.closeOnSelect = true; //Initialized inside uiSelect directive link function
303298
ctrl.skipFocusser = false; //Set to true to avoid returning focus to ctrl when item is selected
@@ -391,11 +386,8 @@ uis.controller('uiSelectCtrl',
391386
if(!avoidReset) _resetSearchInput();
392387

393388
$scope.$broadcast('uis:activate');
394-
395389
ctrl.open = true;
396-
397390
ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
398-
399391
// ensure that the index is set to zero for tagging variants
400392
// that where first option is auto-selected
401393
if ( ctrl.activeIndex === -1 && ctrl.taggingLabel !== false ) {
@@ -533,7 +525,6 @@ uis.controller('uiSelectCtrl',
533525
if (ctrl.dropdownPosition === 'auto' || ctrl.dropdownPosition === 'up'){
534526
$scope.calculateDropdownPos();
535527
}
536-
537528
$scope.$broadcast('uis:refresh');
538529
};
539530

@@ -581,7 +572,7 @@ uis.controller('uiSelectCtrl',
581572
var refreshPromise = $scope.$eval(refreshAttr);
582573
if (refreshPromise && angular.isFunction(refreshPromise.then) && !ctrl.refreshing) {
583574
ctrl.refreshing = true;
584-
refreshPromise.then(function() {
575+
refreshPromise.finally(function() {
585576
ctrl.refreshing = false;
586577
});
587578
}}, ctrl.refreshDelay);
@@ -706,20 +697,12 @@ uis.controller('uiSelectCtrl',
706697
ctrl.close(skipFocusser);
707698
return;
708699
}
709-
}
700+
} else if ( typeof item === 'string') {
701+
item = item.replace(ctrl.taggingLabel,'').trim();
702+
}
710703
_resetSearchInput();
711704
$scope.$broadcast('uis:select', item);
712705

713-
var locals = {};
714-
locals[ctrl.parserResult.itemName] = item;
715-
716-
$timeout(function(){
717-
ctrl.onSelectCallback($scope, {
718-
$item: item,
719-
$model: ctrl.parserResult.modelMapper($scope, locals)
720-
});
721-
});
722-
723706
if (ctrl.closeOnSelect) {
724707
ctrl.close(skipFocusser);
725708
}
@@ -782,7 +765,7 @@ uis.controller('uiSelectCtrl',
782765
}
783766

784767
if (!isLocked && lockedItemIndex > -1) {
785-
lockedItems.splice(lockedItemIndex, 0);
768+
lockedItems.splice(lockedItemIndex, 1);
786769
}
787770
}
788771

@@ -852,11 +835,22 @@ uis.controller('uiSelectCtrl',
852835
switch (key) {
853836
case KEY.DOWN:
854837
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
855-
else if (ctrl.activeIndex < ctrl.items.length - 1) { ctrl.activeIndex++; }
838+
else if (ctrl.activeIndex < ctrl.items.length - 1) {
839+
var idx = ++ctrl.activeIndex;
840+
while(_isItemDisabled(ctrl.items[idx]) && idx < ctrl.items.length) {
841+
ctrl.activeIndex = ++idx;
842+
}
843+
}
856844
break;
857845
case KEY.UP:
846+
var minActiveIndex = (ctrl.search.length === 0 && ctrl.tagging.isActivated) ? -1 : 0;
858847
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
859-
else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) { ctrl.activeIndex--; }
848+
else if (ctrl.activeIndex > minActiveIndex) {
849+
var idxmin = --ctrl.activeIndex;
850+
while(_isItemDisabled(ctrl.items[idxmin]) && idxmin > minActiveIndex) {
851+
ctrl.activeIndex = --idxmin;
852+
}
853+
}
860854
break;
861855
case KEY.TAB:
862856
if (!ctrl.multiple || ctrl.open) ctrl.select(ctrl.items[ctrl.activeIndex], true);
@@ -1117,6 +1111,12 @@ uis.directive('uiSelect',
11171111
$select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
11181112
});
11191113

1114+
attrs.$observe('backspaceReset', function() {
1115+
// $eval() is needed otherwise we get a string instead of a boolean
1116+
var backspaceReset = scope.$eval(attrs.backspaceReset);
1117+
$select.backspaceReset = backspaceReset !== undefined ? backspaceReset : true;
1118+
});
1119+
11201120
attrs.$observe('limit', function() {
11211121
//Limit the number of selections allowed
11221122
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;
@@ -1679,6 +1679,15 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
16791679
return;
16801680
}
16811681
$select.selected.push(item);
1682+
var locals = {};
1683+
locals[$select.parserResult.itemName] = item;
1684+
1685+
$timeout(function(){
1686+
$select.onSelectCallback(scope, {
1687+
$item: item,
1688+
$model: $select.parserResult.modelMapper(scope, locals)
1689+
});
1690+
});
16821691
$selectMultiple.updateModel();
16831692
});
16841693

@@ -2022,6 +2031,15 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
20222031

20232032
scope.$on('uis:select', function (event, item) {
20242033
$select.selected = item;
2034+
var locals = {};
2035+
locals[$select.parserResult.itemName] = item;
2036+
2037+
$timeout(function(){
2038+
$select.onSelectCallback(scope, {
2039+
$item: item,
2040+
$model: $select.parserResult.modelMapper(scope, locals)
2041+
});
2042+
});
20252043
});
20262044

20272045
scope.$on('uis:close', function (event, skipFocusser) {
@@ -2056,7 +2074,7 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
20562074
});
20572075
focusser.bind("keydown", function(e){
20582076

2059-
if (e.which === KEY.BACKSPACE) {
2077+
if (e.which === KEY.BACKSPACE && $select.backspaceReset !== false) {
20602078
e.preventDefault();
20612079
e.stopPropagation();
20622080
$select.select(undefined);

0 commit comments

Comments
 (0)