-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
259 lines (249 loc) · 13.1 KB
/
index.html
File metadata and controls
259 lines (249 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AngularJS Step Input Directive</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href="angular-step-input.css" rel="stylesheet">
<style>
body {
margin-top: 1em;
}
p {
line-height: 24px;
}
</style>
</head>
<body class="container" ng-app="stepInputApp">
<div class="row">
<div class="col-lg-10 col-lg-offset-1 col-md-12">
<div class="jumbotron">
<h1>angular-step-input</h1>
<p>Angular directive for a customized numeric user inputs</p>
</div>
<div class="row">
<div class="col-md-12">
<h2>Getting Started</h2>
<ol>
<li>Install with bower: <code>bower install --save angular-step-input</code></li>
<li>Include <code>angular-step-input.js</code>.</li>
<li>Add <code>tien.stepInput</code> to you app modules.</li>
<li>Use the <code>tien-step-input</code> directive.</li>
</ol>
If you don't like package managers, you can also directly download
<a href="./angular-step-input.js">angular-step-input.js</a> or
<a href="./angular-step-input.min.js">angular-step-input.min.js</a>.
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<h2>Demos</h2>
<div class="row">
<div class="col-md-4 text-center" ng-controller="DemoDefaultCtrl">
<h4>1. Out-of-the-box</h4>
<div class="form-group">
<tien-step-input ng-model="demo"></tien-step-input>
<p class="help-block"><code>$scope.demo = {{demo}}</code></p>
</div>
</div>
<div class="col-md-4 text-center" ng-controller="DemoIconCtrl">
<h4>2. Custom icons and style</h4>
<div class="form-group">
<tien-step-input ng-model="demo" step-input-options="options"></tien-step-input>
<p class="help-block"><code>$scope.demo = {{demo}}</code></p>
</div>
</div>
<div class="col-md-4 text-center" ng-controller="DemoStepCtrl">
<h4>3. Specific step settings</h4>
<div class="form-group">
<tien-step-input ng-model="demo" step-input-options="options"></tien-step-input>
<p class="help-block"><code>$scope.demo = {{demo}}</code></p>
</div>
</div>
<div class="col-md-4 text-center" ng-controller="DemoViewFunctionCtrl">
<h4>4. View value as a function</h4>
<div class="form-group">
<tien-step-input ng-model="demo" step-input-options="options"></tien-step-input>
<p class="help-block"><code>$scope.demo = {{demo}}</code></p>
</div>
</div>
<div class="col-md-4 text-center" ng-controller="DemoViewExpressionCtrl">
<h4>5. View value as an expression</h4>
<div class="form-group">
<tien-step-input ng-model="demo" step-input-options="options"></tien-step-input>
<p class="help-block"><code>$scope.demo = {{demo}}</code></p>
</div>
</div>
<div class="col-md-4 text-center" ng-controller="DemoAvailabilityCtrl">
<h4>6. Availability example</h4>
<div class="form-group">
<tien-step-input ng-model="available" step-input-options="options"></tien-step-input>
<p class="help-block"><code>$scope.available = {{available}}</code></p>
</div>
</div>
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script src="angular-step-input.js"></script>
<script>
app = angular.module('stepInputApp', ['tien.stepInput']);
app.controller('DemoDefaultCtrl', function ($scope) {
$scope.demo = 1;
});
app.controller('DemoIconCtrl', function ($scope) {
$scope.demo = 2;
$scope.options = {decrease: 'fa fa-star-o', increase: 'fa fa-star', style: 'warning'};
});
app.controller('DemoStepCtrl', function ($scope) {
$scope.demo = 3;
$scope.options = {overrides: [{value: 3, style: 'success', decrease: 'fa fa-hand-o-left', increase: 'fa fa-hand-o-right'}]};
});
app.controller('DemoViewFunctionCtrl', function ($scope) {
$scope.demo = 4;
icon = function () {
icons = [
'<i class="fa fa-beer"></i>',
'<i class="fa fa-bullhorn"></i>',
'<i class="fa fa-heart"></i>',
'<i class="fa fa-thumbs-up"></i>',
'<i class="fa fa-paw"></i>',
'<i class="fa fa-space-shuttle"></i>',
'<i class="fa fa-paper-plane"></i>'
];
return icons[$scope.demo];
};
$scope.options = {min_value: 0, max_value: 6, view_value: icon};
});
app.controller('DemoViewExpressionCtrl', function ($scope) {
$scope.demo = 5;
$scope.options = {view_value: '{{value * 3}}'};
});
app.controller('DemoAvailabilityCtrl', function ($scope) {
$scope.available = 2;
ten_or_more = function() {
if ($scope.available <= 5) {
return $scope.available;
}
else {
return '5+';
}
}
$scope.options = {
min_value: -1,
max_value: 6,
view_value: ten_or_more,
overrides: [
{value: -1, style: 'danger', view_value: '<i class="fa fa-times"></i>'},
{value: 0, style: 'warning', view_value: '<i class="fa fa-question"></i>'}
]
};
});
</script>
<hr>
<div class="row">
<div class="col-md-12">
<h2>Usage</h2>
<p>
Use the <code>tien-step-input</code> directive as element or attribute. Add the
<code>ng-model</code> directive to bind an integer. Optionally pass through a custom options object
width the <code>step-input-options</code> attribute.
</p>
<pre><code><tien-step-input ng-model="foo" step-input-options="my_options"></tien-input-step>
<script>
$scope.options = {
min_value: -1,
overrides: [
{value: -1, style: 'danger', view_value: '<i class="fa fa-times"></i>'},
{value: 0, style: 'warning', view_value: '<i class="fa fa-question"></i>'}
]
};
</script></code></pre>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<h2>Options</h2>
<h4>decrease</h4>
<p>
Type: <code>String</code><br>
Default: <code>fa fa-minus</code>
</p>
<p>
CSS classes to add to the icon on the decrease button. By default FontAwesome icons are used.
</p>
<h4>increase</h4>
<p>
Type: <code>String</code><br>
Default: <code>fa fa-plus</code>
</p>
<p>
CSS classes to add to the icon on the increase button. By default FontAwesome icons are used.
</p>
<h4>min_value</h4>
<p>
Type: <code>Integer</code><br>
Default: <code>0</code>
</p>
<p>
Minimum value of the field, negative integers allowed.
</p>
<h4>max_value</h4>
<p>
Type: <code>Integer</code><br>
Default: <code>999</code>
</p>
<p>
Maximum value of the field, negative integers allowed.
</p>
<h4>style</h4>
<p>
Type: <code>String</code><br>
Default: <code>primary</code>
</p>
<p>
CSS classes applied to the container element of the directive. The default stylesheet provides all
Bootstrap color classes (<code>primary</code>, <code>success</code>, <code>info</code>,
<code>warning</code>, <code>danger</code>). The [sass-src file]()
includes a mixin to easily add custom colors.
</p>
<h4>view_value</h4>
<p>
Type: <code>Function</code> | <code>Expression</code> | <code>Boolean</code><br>
Default: <code>false</code>
</p>
<p>
By default (<code>false</code>) the input displays the current integer-value in a regular input
element. With the <code>view_value</code> option it is possible to alter this representation with
a function (demo 4) or angular expression (demo 5) that returns an HTML-string.
</p>
<h4>overrides</h4>
<p>
Type: <code>Array</code> <br>
Default: <code>[]</code>
</p>
<p>
This Array overrides options based on specific input values. Each array element has to be an Object
with at least the value-property. All options mentioned above are available. See demo 3 & 6.
</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
<p class="text-center">
angular-step-input 0.1.0 · Created by <a href="http://10kb.nl/">10KB</a><br>
Thanks to <a href="http://fontawesome.io/">FontAwesome</a> for providing awesome icons.
</p>
<p class="text-center">
<a href="https://github.com/10KB/angular-step-input">GitHub Project</a>
</p>
</div>
</div>
</div>
</div>
</body>
</html>