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

Commit 7320f9d

Browse files
committed
Improve Bootstrap theme
1 parent aee7809 commit 7320f9d

File tree

5 files changed

+69
-9
lines changed

5 files changed

+69
-9
lines changed

examples/bootstrap.html

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script>
2222

23+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
24+
2325
<!-- ui-select files -->
2426
<script src="../dist/select.js"></script>
2527
<link rel="stylesheet" href="../dist/select.css">
2628

27-
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
28-
2929
<style>
3030
body {
3131
padding: 15px;
@@ -73,6 +73,29 @@
7373
</div>
7474
</div>
7575

76+
<div class="form-group">
77+
<label class="col-sm-3 control-label">With a clear button</label>
78+
<div class="col-sm-6">
79+
<div class="input-group">
80+
81+
<ui-select ng-model="person.selected" theme="bootstrap">
82+
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
83+
<choices repeat="item in people | filter: $select.search">
84+
<span ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></span>
85+
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
86+
</choices>
87+
</ui-select>
88+
89+
<span class="input-group-btn">
90+
<button ng-click="person.selected = undefined" class="btn btn-default">
91+
<span class="glyphicon glyphicon-trash"></span>
92+
</button>
93+
</span>
94+
95+
</div>
96+
</div>
97+
</div>
98+
7699
<div class="form-group">
77100
<label class="col-sm-3 control-label">Disabled</label>
78101
<div class="col-sm-6">

src/bootstrap/choices.tpl.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<ul class="ui-select-choices ui-select-choices-content dropdown-menu" role="menu" aria-labelledby="dLabel">
1+
<ul class="ui-select-choices ui-select-choices-content dropdown-menu"
2+
role="menu" aria-labelledby="dLabel">
23
<li class="ui-select-choices-row" ng-class="{active: $select.activeIdx == $index}">
34
<a href="javascript:void(0)" ng-transclude></a>
45
</li>

src/bootstrap/match.tpl.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<a class="btn btn-default ui-select-match"
2-
ng-hide="$select.open"
3-
ng-disabled="$select.disabled"
4-
ng-click="$select.activate()">
1+
<button class="btn btn-default form-control ui-select-match"
2+
ng-hide="$select.open"
3+
ng-disabled="$select.disabled"
4+
ng-click="$select.activate()">
55
<span ng-hide="$select.selected !== undefined" class="text-muted">{{$select.placeholder}}</span>
66
<span ng-show="$select.selected !== undefined" ng-transclude></span>
77
<span class="caret"></span>
8-
</a>
8+
</button>

src/bootstrap/select.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="dropdown" ng-class="{open: $select.open}">
1+
<div class="ui-select-bootstrap dropdown" ng-class="{open: $select.open}">
22
<div class="ui-select-match"></div>
33
<input type="text" autocomplete="off" tabindex=""
44
class="form-control ui-select-search"

src/select.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
font-weight: bold;
44
}
55

6+
7+
/* Select2 theme */
8+
9+
10+
/* Selectize theme */
11+
612
/* Fix input width for Selectize theme */
713
.selectize-control > .selectize-input > input {
814
width: 100%;
@@ -12,3 +18,33 @@
1218
.selectize-control > .selectize-dropdown {
1319
width: 100%;
1420
}
21+
22+
23+
/* Bootstrap theme */
24+
25+
/* Fix Bootstrap dropdown position when inside a input-group */
26+
.input-group > .ui-select-bootstrap.dropdown {
27+
/* Instead of relative */
28+
position: static;
29+
}
30+
31+
.input-group > .ui-select-bootstrap > .ui-select-search.form-control {
32+
border-radius: 4px; /* FIXME hardcoded value :-/ */
33+
border-top-right-radius: 0;
34+
border-bottom-right-radius: 0;
35+
}
36+
37+
.ui-select-bootstrap > .ui-select-match {
38+
/* Instead of center because of .btn */
39+
text-align: left;
40+
}
41+
42+
.ui-select-bootstrap > .ui-select-match > .caret {
43+
top: 45%;
44+
position: absolute;
45+
right: 17px;
46+
}
47+
48+
.ui-select-bootstrap > .ui-select-choices {
49+
width: 100%;
50+
}

0 commit comments

Comments
 (0)