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

Commit 2ce5568

Browse files
committed
Improve documentation and demo
1 parent ec67b8f commit 2ce5568

File tree

3 files changed

+55
-11
lines changed

3 files changed

+55
-11
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
AngularJS-native version of [Select2](http://ivaynberg.github.io/select2/) and [Selectize](http://brianreavis.github.io/selectize.js/).
44

55
- [Basic demo](http://plnkr.co/edit/GtOOWE?p=preview)
6-
- [Select2 Bootstrap 3 demo](http://plnkr.co/edit/L8BdYv?p=preview)
6+
- [Bootstrap theme](http://plnkr.co/edit/7Fpbtg?p=preview)
77

88
## Features
99

1010
- Search and select
11-
- Support themes from Select2 (default theme) and Selectize (default, Bootstrap 2 & 3 themes)
11+
- Available themes: Bootstrap, Select2 and Selectize
1212
- Keyboard support
1313
- jQuery not required (except for old browsers)
1414
- Small code base: 250 lines of JavaScript vs 20 KB for select2.min.js
@@ -37,6 +37,13 @@ Bower:
3737
[cdnjs](http://cdnjs.com/):
3838
- `<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">`
3939

40+
Configuration:
41+
```JavaScript
42+
app.config(function(uiSelectConfig) {
43+
uiSelectConfig.theme = 'select2';
44+
});
45+
```
46+
4047
### Selectize theme
4148

4249
Bower:
@@ -47,6 +54,32 @@ Bower:
4754
[cdnjs](http://cdnjs.com/):
4855
- `<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">`
4956

57+
Configuration:
58+
```JavaScript
59+
app.config(function(uiSelectConfig) {
60+
uiSelectConfig.theme = 'selectize';
61+
});
62+
```
63+
64+
### Bootstrap theme
65+
66+
If you already use Bootstrap, this theme will save you a lot of CSS code compared to the Select2 and Selectize themes.
67+
68+
Bower:
69+
- `bower install bootstrap`
70+
- `<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">`
71+
- Or the [LESS](http://lesscss.org/) version: `@import "bower_components/bootstrap/less/bootstrap.less";`
72+
73+
[Bootstrap CDN](http://www.bootstrapcdn.com/):
74+
- `<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">`
75+
76+
Configuration:
77+
```JavaScript
78+
app.config(function(uiSelectConfig) {
79+
uiSelectConfig.theme = 'bootstrap';
80+
});
81+
```
82+
5083
## Run the tests
5184

5285
Install [Node.js](http://nodejs.org/), then inside a console:

examples/demo.html

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<![endif]-->
2020

2121
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script>
22+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
2223

2324
<!-- ui-select files -->
2425
<script src="../dist/select.js"></script>
@@ -39,9 +40,12 @@
3940

4041
<style>
4142
body {
42-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
43-
font-size: 14px;
44-
color: #333;
43+
padding: 15px;
44+
}
45+
46+
.select2 > .select2-choice.ui-select-match {
47+
/* Because of the inclusion of Bootstrap */
48+
height: 29px;
4549
}
4650

4751
.selectize-control > .selectize-dropdown {
@@ -55,14 +59,15 @@
5559

5660
<p>Selected: {{person.selected.name}}</p>
5761

58-
<p>Select2 theme (default):</p>
59-
<ui-select ng-model="person.selected" style="width: 300px;">
62+
<p>Select2 theme:</p>
63+
<ui-select ng-model="person.selected" theme="select2" style="width: 300px;">
6064
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
6165
<choices repeat="item in people | filter: $select.search">
6266
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
6367
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
6468
</choices>
6569
</ui-select>
70+
<br><br>
6671

6772
<p>Selectize theme:</p>
6873
<ui-select ng-model="person.selected" theme="selectize" style="width: 300px;">
@@ -72,5 +77,15 @@
7277
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
7378
</choices>
7479
</ui-select>
80+
<br>
81+
82+
<p>Bootstrap theme:</p>
83+
<ui-select ng-model="person.selected" theme="bootstrap" style="width: 300px;">
84+
<match placeholder="Select or search a person in the list...">{{$select.selected.name}}</match>
85+
<choices repeat="item in people | filter: $select.search">
86+
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
87+
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
88+
</choices>
89+
</ui-select>
7590
</body>
7691
</html>

examples/demo.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
'use strict';
22

33
angular.module('demo', ['ui.select'])
4-
.config(function(uiSelectConfig) {
5-
// uiSelectConfig.defaultTheme = 'select2';
6-
// uiSelectConfig.defaultTheme = 'selectize';
7-
})
84
.controller('MainCtrl', ['$scope', function ($scope) {
95
$scope.person = {};
106
$scope.people = [

0 commit comments

Comments
 (0)