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

Commit 3bd3d4b

Browse files
author
Austin McDaniel
committed
Updating lock to be an expression
1 parent d53fdb6 commit 3bd3d4b

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

dist/select.css

Lines changed: 5 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.8.3 - 2014-10-14T18:22:05.435Z
4+
* Version: 0.8.3 - 2014-10-17T13:11:28.038Z
55
* License: MIT
66
*/
77

@@ -36,6 +36,10 @@
3636
padding-left: 0;
3737
}
3838

39+
.select2-locked > .select2-search-choice-close{
40+
display:none;
41+
}
42+
3943
/* Selectize theme */
4044

4145
/* Helper class to show styles when focus */

dist/select.js

Lines changed: 15 additions & 2 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.8.3 - 2014-10-14T18:22:05.432Z
4+
* Version: 0.8.3 - 2014-10-17T13:11:28.034Z
55
* License: MIT
66
*/
77

@@ -167,6 +167,7 @@
167167
ctrl.refreshDelay = undefined; // Initialized inside uiSelectChoices directive link function
168168
ctrl.multiple = false; // Initialized inside uiSelect directive link function
169169
ctrl.disableChoiceExpression = undefined; // Initialized inside uiSelect directive link function
170+
ctrl.lockChoiceExpression = undefined; // Initialized inside uiSelect directive link function
170171

171172
ctrl.isEmpty = function() {
172173
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
@@ -374,6 +375,17 @@
374375
e.stopPropagation();
375376
};
376377

378+
ctrl.isLocked = function(itemScope, itemIndex) {
379+
var isLocked, item = ctrl.selected[itemIndex];
380+
381+
if (item && !angular.isUndefined(ctrl.lockChoiceExpression)) {
382+
isLocked = !!(itemScope.$eval(ctrl.lockChoiceExpression)); // force the boolean value
383+
item._uiSelectChoiceLocked = isLocked; // store this for later reference
384+
}
385+
386+
return isLocked;
387+
};
388+
377389
// Remove item from multiple select
378390
ctrl.removeChoice = function(index){
379391
var removedChoice = ctrl.selected[index];
@@ -940,6 +952,7 @@
940952
return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
941953
},
942954
link: function(scope, element, attrs, $select) {
955+
$select.lockChoiceExpression = attrs.uiLockChoice;
943956
attrs.$observe('placeholder', function(placeholder) {
944957
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
945958
});
@@ -975,7 +988,7 @@ $templateCache.put("bootstrap/match.tpl.html","<button type=\"button\" class=\"b
975988
$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>");
976989
$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>");
977990
$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>");
978-
$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>");
991+
$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, \'select2-locked\':$select.isLocked(this, $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>");
979992
$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>");
980993
$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>");
981994
$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>");

dist/select.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/select.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
padding-left: 0;
2929
}
3030

31+
.select2-locked > .select2-search-choice-close{
32+
display:none;
33+
}
34+
3135
/* Selectize theme */
3236

3337
/* Helper class to show styles when focus */

src/select.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
ctrl.refreshDelay = undefined; // Initialized inside uiSelectChoices directive link function
160160
ctrl.multiple = false; // Initialized inside uiSelect directive link function
161161
ctrl.disableChoiceExpression = undefined; // Initialized inside uiSelect directive link function
162+
ctrl.lockChoiceExpression = undefined; // Initialized inside uiSelect directive link function
162163

163164
ctrl.isEmpty = function() {
164165
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
@@ -366,8 +367,15 @@
366367
e.stopPropagation();
367368
};
368369

369-
ctrl.isLocked = function(index){
370-
return ctrl.selected[index] && ctrl.selected[index].locked;
370+
ctrl.isLocked = function(itemScope, itemIndex) {
371+
var isLocked, item = ctrl.selected[itemIndex];
372+
373+
if (item && !angular.isUndefined(ctrl.lockChoiceExpression)) {
374+
isLocked = !!(itemScope.$eval(ctrl.lockChoiceExpression)); // force the boolean value
375+
item._uiSelectChoiceLocked = isLocked; // store this for later reference
376+
}
377+
378+
return isLocked;
371379
};
372380

373381
// Remove item from multiple select
@@ -936,6 +944,7 @@
936944
return theme + (multi ? '/match-multiple.tpl.html' : '/match.tpl.html');
937945
},
938946
link: function(scope, element, attrs, $select) {
947+
$select.lockChoiceExpression = attrs.uiLockChoice;
939948
attrs.$observe('placeholder', function(placeholder) {
940949
$select.placeholder = placeholder !== undefined ? placeholder : uiSelectConfig.placeholder;
941950
});

src/select2/match-multiple.tpl.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
-->
66
<span class="ui-select-match">
77
<li class="ui-select-match-item select2-search-choice" ng-repeat="$item in $select.selected"
8-
ng-class="{'select2-search-choice-focus':$select.activeMatchIndex === $index, 'select2-locked':$select.isLocked($index)}">
8+
ng-class="{'select2-search-choice-focus':$select.activeMatchIndex === $index, 'select2-locked':$select.isLocked(this, $index)}">
99
<span uis-transclude-append></span>
10-
<a href="javascript:;" ng-if="!$select.isLocked($index)" class="ui-select-match-close select2-search-choice-close" ng-click="$select.removeChoice($index)" tabindex="-1"></a>
10+
<a href="javascript:;" class="ui-select-match-close select2-search-choice-close" ng-click="$select.removeChoice($index)" tabindex="-1"></a>
1111
</li>
1212
</span>

0 commit comments

Comments
 (0)