Skip to content

Commit 149a226

Browse files
committed
chore(build): v0.8.0
1 parent f28934b commit 149a226

File tree

6 files changed

+84
-35
lines changed

6 files changed

+84
-35
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ui-select",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"homepage": "https://github.com/angular-ui/ui-select",
55
"authors": [
66
"AngularUI"

dist/select.css

Lines changed: 8 additions & 1 deletion
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.7.0 - 2014-09-09T01:02:43.612Z
4+
* Version: 0.8.0 - 2014-10-06T23:55:23.050Z
55
* License: MIT
66
*/
77

@@ -144,6 +144,13 @@
144144
background-color: #428bca;
145145
}
146146

147+
.ui-select-bootstrap .ui-select-choices-row.disabled>a,
148+
.ui-select-bootstrap .ui-select-choices-row.active.disabled>a {
149+
color: #777;
150+
cursor: not-allowed;
151+
background-color: #fff;
152+
}
153+
147154
/* fix hide/show angular animation */
148155
.ui-select-match.ng-hide-add,
149156
.ui-select-search.ng-hide-add {

dist/select.js

Lines changed: 70 additions & 28 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.7.0 - 2014-09-09T01:02:43.608Z
4+
* Version: 0.8.0 - 2014-10-06T23:55:23.047Z
55
* License: MIT
66
*/
77

@@ -164,6 +164,7 @@
164164
ctrl.resetSearchInput = undefined; // Initialized inside uiSelect directive link function
165165
ctrl.refreshDelay = undefined; // Initialized inside uiSelectChoices directive link function
166166
ctrl.multiple = false; // Initialized inside uiSelect directive link function
167+
ctrl.disableChoiceExpression = undefined; // Initialized inside uiSelect directive link function
167168

168169
ctrl.isEmpty = function() {
169170
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
@@ -268,10 +269,11 @@
268269
if (ctrl.multiple){
269270
//Remove already selected items
270271
$scope.$watchCollection('$select.selected', function(selectedItems){
271-
if (!selectedItems) return;
272+
if (!selectedItems.length) return;
272273
var data = ctrl.parserResult.source($scope);
273274
var filteredItems = data.filter(function(i) {return selectedItems.indexOf(i) < 0;});
274275
setItemsFn(filteredItems);
276+
ctrl.sizeSearchInput();
275277
});
276278
}
277279

@@ -307,24 +309,40 @@
307309
return ctrl.items.indexOf(itemScope[ctrl.itemProperty]) === ctrl.activeIndex;
308310
};
309311

312+
ctrl.isDisabled = function(itemScope) {
313+
var itemIndex = ctrl.items.indexOf(itemScope[ctrl.itemProperty]);
314+
var isDisabled = false;
315+
var item;
316+
317+
if (itemIndex >= 0 && !angular.isUndefined(ctrl.disableChoiceExpression)) {
318+
item = ctrl.items[itemIndex];
319+
isDisabled = !!(itemScope.$eval(ctrl.disableChoiceExpression)); // force the boolean value
320+
item._uiSelectChoiceDisabled = isDisabled; // store this for later reference
321+
}
322+
323+
return isDisabled;
324+
};
325+
310326
// When the user clicks on an item inside the dropdown
311327
ctrl.select = function(item) {
312328

313-
var locals = {};
314-
locals[ctrl.parserResult.itemName] = item;
329+
if (!item._uiSelectChoiceDisabled) {
330+
var locals = {};
331+
locals[ctrl.parserResult.itemName] = item;
315332

316-
ctrl.onSelectCallback($scope, {
317-
$item: item,
318-
$model: ctrl.parserResult.modelMapper($scope, locals)
319-
});
333+
ctrl.onSelectCallback($scope, {
334+
$item: item,
335+
$model: ctrl.parserResult.modelMapper($scope, locals)
336+
});
320337

321-
if(ctrl.multiple){
322-
ctrl.selected.push(item);
323-
ctrl.sizeSearchInput();
324-
} else {
325-
ctrl.selected = item;
338+
if(ctrl.multiple){
339+
ctrl.selected.push(item);
340+
ctrl.sizeSearchInput();
341+
} else {
342+
ctrl.selected = item;
343+
}
344+
ctrl.close();
326345
}
327-
ctrl.close();
328346
};
329347

330348
// Closes the dropdown
@@ -338,6 +356,13 @@
338356
}
339357
};
340358

359+
// Toggle dropdown
360+
ctrl.toggle = function(e) {
361+
if (ctrl.open) ctrl.close(); else ctrl.activate();
362+
e.preventDefault();
363+
e.stopPropagation();
364+
};
365+
341366
// Remove item from multiple select
342367
ctrl.removeChoice = function(index){
343368
ctrl.selected.splice(index, 1);
@@ -550,6 +575,8 @@
550575
var $select = ctrls[0];
551576
var ngModel = ctrls[1];
552577

578+
var searchInput = element.querySelectorAll('input.ui-select-search');
579+
553580
$select.multiple = angular.isDefined(attrs.multiple);
554581

555582
$select.onSelectCallback = $parse(attrs.onSelect);
@@ -560,9 +587,9 @@
560587
result;
561588
if ($select.multiple){
562589
var resultMultiple = [];
563-
for (var j = inputValue.length - 1; j >= 0; j--) {
590+
for (var j = $select.selected.length - 1; j >= 0; j--) {
564591
locals = {};
565-
locals[$select.parserResult.itemName] = inputValue[j];
592+
locals[$select.parserResult.itemName] = $select.selected[j];
566593
result = $select.parserResult.modelMapper(scope, locals);
567594
resultMultiple.unshift(result);
568595
}
@@ -625,6 +652,21 @@
625652

626653
//Idea from: https://github.com/ivaynberg/select2/blob/79b5bf6db918d7560bdd959109b7bcfb47edaf43/select2.js#L1954
627654
var focusser = angular.element("<input ng-disabled='$select.disabled' class='ui-select-focusser ui-select-offscreen' type='text' aria-haspopup='true' role='button' />");
655+
656+
if(attrs.tabindex){
657+
//tabindex might be an expression, wait until it contains the actual value before we set the focusser tabindex
658+
attrs.$observe('tabindex', function(value) {
659+
//If we are using multiple, add tabindex to the search input
660+
if($select.multiple){
661+
searchInput.attr("tabindex", value);
662+
} else {
663+
focusser.attr("tabindex", value);
664+
}
665+
//Remove the tabindex on the parent so that it is not focusable
666+
element.removeAttr("tabindex");
667+
});
668+
}
669+
628670
$compile(focusser)(scope);
629671
$select.focusser = focusser;
630672

@@ -696,10 +738,8 @@
696738
});
697739

698740
if ($select.multiple){
699-
scope.$watchCollection('$select.selected', function(newValue) {
700-
//On v1.2.19 the 2nd and 3rd parameteres are ignored
701-
//On v1.3.0-beta+ 3rd parameter (revalidate) is true, to force $parsers to recreate model
702-
ngModel.$setViewValue(newValue, null, true);
741+
scope.$watchCollection('$select.selected', function() {
742+
ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
703743
});
704744
focusser.prop('disabled', true); //Focusser isn't needed if multiple
705745
}else{
@@ -802,6 +842,8 @@
802842

803843
$select.parseRepeatAttr(attrs.repeat, groupByExp); //Result ready at $select.parserResult
804844

845+
$select.disableChoiceExpression = attrs.uiDisableChoice;
846+
805847
if(groupByExp) {
806848
var groups = element.querySelectorAll('.ui-select-choices-group');
807849
if (groups.length !== 1) throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-group but got '{0}'.", groups.length);
@@ -890,16 +932,16 @@
890932
});
891933
}());
892934

893-
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\">{{$group.name}}</div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this)}\"><a href=\"javascript:void(0)\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>");
894-
$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><button style=\"margin-right: 3px;\" class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" 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)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></button></span></span>");
895-
$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.searchEnabled && $select.isEmpty()\" class=\"text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" ng-transclude=\"\"></span> <span class=\"caret\"></span></button>");
935+
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\">{{$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>");
936+
$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><button 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)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></button></span></span>");
937+
$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.searchEnabled && $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>");
896938
$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>");
897939
$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>");
898-
$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.isGrouped}\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label select2-result-label\">{{$group.name}}</div><ul ng-class=\"{\'select2-result-sub\': $select.isGrouped, \'select2-result-single\': !$select.isGrouped}\"><li class=\"ui-select-choices-row\" ng-class=\"{\'select2-highlighted\': $select.isActive(this)}\"><div class=\"select2-result-label ui-select-choices-row-inner\"></div></li></ul></li></ul>");
899-
$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}\"><span uis-transclude-append=\"\"></span> <a href=\"#\" class=\"ui-select-match-close select2-search-choice-close\" ng-click=\"$select.removeChoice($index)\" tabindex=\"-1\"></a></li></span>");
900-
$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.searchEnabled && $select.isEmpty()\" class=\"select2-chosen\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"select2-chosen\" ng-transclude=\"\"></span> <span class=\"select2-arrow\"><b></b></span></a>");
940+
$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.isGrouped}\"><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label select2-result-label\">{{$group.name}}</div><ul ng-class=\"{\'select2-result-sub\': $select.isGrouped, \'select2-result-single\': !$select.isGrouped}\"><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>");
941+
$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}\"><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>");
942+
$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.searchEnabled && $select.isEmpty()\" class=\"select2-chosen\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" class=\"select2-chosen\" ng-transclude=\"\"></span> <span class=\"select2-arrow ui-select-toggle\" ng-click=\"$select.toggle($event)\"><b></b></span></a>");
901943
$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>");
902944
$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 }\"><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>");
903-
$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\">{{$group.name}}</div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this)}\"><div class=\"option ui-select-choices-row-inner\" data-selectable=\"\"></div></div></div></div></div>");
945+
$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\">{{$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>");
904946
$templateCache.put("selectize/match.tpl.html","<div ng-hide=\"$select.searchEnabled && ($select.open || $select.isEmpty())\" class=\"ui-select-match\" ng-transclude=\"\"></div>");
905-
$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\" 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>");}]);
947+
$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>");}]);

0 commit comments

Comments
 (0)