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

Commit b8f8306

Browse files
committed
Focus examples
1 parent 7e0dae3 commit b8f8306

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

examples/demo-focus.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html lang="en" ng-app="demo">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>AngularJS ui-select</title>
6+
7+
<!--
8+
IE8 support, see AngularJS Internet Explorer Compatibility http://docs.angularjs.org/guide/ie
9+
For Firefox 3.6, you will also need to include jQuery and ECMAScript 5 shim
10+
-->
11+
<!--[if lt IE 9]>
12+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
13+
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
14+
<script>
15+
document.createElement('ui-select');
16+
document.createElement('ui-select-match');
17+
document.createElement('ui-select-choices');
18+
</script>
19+
<![endif]-->
20+
21+
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js"></script>
22+
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-sanitize.js"></script>
23+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
24+
25+
<!-- ui-select files -->
26+
<script src="../dist/select.js"></script>
27+
<link rel="stylesheet" href="../dist/select.css">
28+
29+
<script src="demo.js"></script>
30+
31+
<!-- Select2 theme -->
32+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">
33+
34+
<!--
35+
Selectize theme
36+
Less versions are available at https://github.com/brianreavis/selectize.js/tree/master/dist/less
37+
-->
38+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">
39+
<!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap2.css"> -->
40+
<!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap3.css"> -->
41+
42+
<style>
43+
body {
44+
padding: 15px;
45+
}
46+
47+
.select2 > .select2-choice.ui-select-match {
48+
/* Because of the inclusion of Bootstrap */
49+
height: 29px;
50+
}
51+
52+
.selectize-control > .selectize-dropdown {
53+
top: 36px;
54+
}
55+
</style>
56+
</head>
57+
58+
<body ng-controller="DemoCtrl">
59+
60+
<h3>Feature: Focus</h3>
61+
<hr>
62+
63+
<p>Regular uiSelect</p>
64+
<ui-select ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person">
65+
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
66+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
67+
<div ng-bind-html="person.name | highlight: $select.search"></div>
68+
<small>
69+
email: {{person.email}}
70+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
71+
</small>
72+
</ui-select-choices>
73+
</ui-select>
74+
75+
<br>
76+
<br>
77+
<br>
78+
79+
<p>Using <b>uisAutofocus</b> to automatically get focus when loaded</p>
80+
<ui-select autofocus ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person">
81+
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
82+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
83+
<div ng-bind-html="person.name | highlight: $select.search"></div>
84+
<small>
85+
email: {{person.email}}
86+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
87+
</small>
88+
</ui-select-choices>
89+
</ui-select>
90+
91+
<br>
92+
<br>
93+
<br>
94+
95+
<p>Using <b>uisFocusOn</b> defining a scope event name to listen</p>
96+
<ui-select focus-on='UiSelectDemo1' ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person">
97+
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
98+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
99+
<div ng-bind-html="person.name | highlight: $select.search"></div>
100+
<small>
101+
email: {{person.email}}
102+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
103+
</small>
104+
</ui-select-choices>
105+
</ui-select>
106+
107+
<br>
108+
<br>
109+
<button class='btn' ng-click="setInputFocus()">Set Focus</button>
110+
111+
</body>
112+
</html>

0 commit comments

Comments
 (0)