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

Commit ff8071d

Browse files
gustavohenkeuser378230
authored andcommitted
feat(selectize): add support for multiple selection
Closes #295, closes #1787
1 parent 4915527 commit ff8071d

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

Diff for: docs/examples/demo-selectize-with-bootstrap.html

+17-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
.input-group > .selectize-control > .selectize-input {
1717
border-bottom-right-radius: 0;
1818
border-top-right-radius: 0;
19-
}
20-
</style>
19+
}
20+
</style>
2121
<p>Selected: {{ctrl.person.selected.name}}</p>
2222

2323
<form class="form-horizontal">
@@ -77,6 +77,21 @@
7777
</div>
7878
</div>
7979

80+
<div class="form-group">
81+
<label class="col-sm-3 control-label">Multiple</label>
82+
<div class="col-sm-6">
83+
84+
<ui-select ng-model="ctrl.person.selected" multiple theme="selectize" title="Choose a person">
85+
<ui-select-match placeholder="Select or search a person in the list...">{{$item.name}}</ui-select-match>
86+
<ui-select-choices repeat="item in ctrl.people | filter: $select.search">
87+
<div ng-bind-html="item.name | highlight: $select.search"></div>
88+
<small ng-bind-html="item.email | highlight: $select.search"></small>
89+
</ui-select-choices>
90+
</ui-select>
91+
92+
</div>
93+
</div>
94+
8095
<div class="form-group">
8196
<label class="col-sm-3 control-label">Disabled</label>
8297
<div class="col-sm-6">

Diff for: src/common.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ body > .select2-container.open {
9292
}
9393

9494
/* Fix input width for Selectize theme */
95-
.selectize-control > .selectize-input > input {
95+
.selectize-control.single > .selectize-input > input {
9696
width: 100%;
9797
}
9898

99+
/* Fix line break when there's at least one item selected with the Selectize theme */
100+
.selectize-control.multi > .selectize-input > input {
101+
margin: 0 !important;
102+
}
103+
99104
/* Fix dropdown width for Selectize theme */
100105
.selectize-control > .selectize-dropdown {
101106
width: 100%;

Diff for: src/selectize/choices.tpl.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<div ng-show="$select.open" class="ui-select-choices ui-select-dropdown selectize-dropdown single">
1+
<div ng-show="$select.open" class="ui-select-choices ui-select-dropdown selectize-dropdown"
2+
ng-class="{'single': !$select.multiple, 'multi': $select.multiple}">
23
<div class="ui-select-choices-content selectize-dropdown-content">
34
<div class="ui-select-choices-group optgroup" role="listbox">
45
<div ng-show="$select.isGrouped" class="ui-select-choices-group-label optgroup-header" ng-bind="$group.name"></div>

Diff for: src/selectize/match-multiple.tpl.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="ui-select-match" data-value
2+
ng-repeat="$item in $select.selected track by $index"
3+
ng-click="$selectMultiple.activeMatchIndex = $index;"
4+
ng-class="{'active':$selectMultiple.activeMatchIndex === $index}"
5+
ui-select-sort="$select.selected">
6+
<span class="ui-select-match-item"
7+
ng-class="{'select-locked':$select.isLocked(this, $index)}">
8+
<span uis-transclude-append></span>
9+
<span class="remove ui-select-match-close" ng-hide="$select.disabled" ng-click="$selectMultiple.removeChoice($index)">&times;</span>
10+
</span>
11+
</div>

Diff for: src/selectize/select-multiple.tpl.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="ui-select-container selectize-control multi plugin-remove_button" ng-class="{'open': $select.open}">
2+
<div class="selectize-input"
3+
ng-class="{'focus': $select.open, 'disabled': $select.disabled, 'selectize-focus' : $select.focus}"
4+
ng-click="$select.open && !$select.searchEnabled ? $select.toggle($event) : $select.activate()">
5+
<div class="ui-select-match"></div>
6+
<input type="search" autocomplete="off" tabindex="-1"
7+
class="ui-select-search"
8+
ng-class="{'ui-select-search-hidden':!$select.searchEnabled}"
9+
placeholder="{{$selectMultiple.getPlaceholder()}}"
10+
ng-model="$select.search"
11+
ng-disabled="$select.disabled"
12+
aria-expanded="{{$select.open}}"
13+
aria-label="{{ $select.baseTitle }}"
14+
ondrop="return false;">
15+
</div>
16+
<div class="ui-select-choices"></div>
17+
<div class="ui-select-no-choice"></div>
18+
</div>

0 commit comments

Comments
 (0)