-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
177 lines (162 loc) · 6.31 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Number Spinner</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="lib/prism/prism.css">
<script src="lib/prism/prism.js"></script>
<script data-main="src/main" src="bower_components/requirejs/require.js"></script>
</head>
<body>
<div class="container">
<h1>Bootstrap Number Spinner</h1>
<p>
Mobile-friendly number spinner for Twitter Bootstrap.
</p>
<h2>Options</h2>
<p>
All options can be set using <code>data-</code> attributes or passed as a JavaScript object.
</p>
<dl>
<dt>min</dt>
<dd>Minimum value</dd>
</dl>
<dl>
<dt>max</dt>
<dd>Maximum value</dd>
</dl>
<dl>
<dt>format</dt>
<dd>Formatting string used for displaying the value.
Bootstrap Number Spinner uses <a href="https://github.com/rse/sprintfjs">sprintf.js</a> for formatting.</dd>
</dl>
<h2>Events</h2>
<dl>
<dt>change.bs.spinner</dt>
<dd>
Fired when the value of the spinner changes.
The plain numeric value is passed as second parameter to the event handler, see <a href="#example-change-event">example</a>.
</dd>
</dl>
<h2>Setting / getting the value</h2>
<p>
The value can be get/set using the <code>val</code> function on the jQuery object:
</p>
<p>
<code class="language-javascript">var spinner = $('#spinner').bsSpinner({ format: '%d mm' });
spinner.val(3);
var value = spinner.val(); // 3
</code>
</p>
<h2>Examples</h2>
<h3>Integer</h3>
<div class="row">
<div class="col-sm-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<input type="text" name="font-size" class="form-control spinner" value="12" data-format="%d pt" data-min="6" data-max="20">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-1">–</button>
<button class="btn btn-default" type="button" data-incr="1">+</button>
</span>
</div>
</div>
</form>
</div>
<div class="col-sm-6">
<code class="language-markup"><div class="input-group">
<input type="text" name="font-size" class="form-control spinner"
value="12" data-format="%d pt" data-min="6" data-max="20">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-1">–</button>
<button class="btn btn-default" type="button" data-incr="1">+</button>
</span>
</div></code>
</div>
</div>
<h3>Decimal</h3>
<div class="row">
<div class="col-sm-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<input type="text" name="font-size" class="form-control spinner" value="1.09" data-format="$ %.2f" data-min="0" data-max="2">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-0.01">–</button>
<button class="btn btn-default" type="button" data-incr="0.01">+</button>
</span>
</div>
</div>
</form>
</div>
<div class="col-sm-6">
<code class="language-markup"><div class="input-group">
<input type="text" name="font-size" class="form-control spinner"
value="1.09" data-format="$ %.2f" data-min="0" data-max="2">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-0.01">–</button>
<button class="btn btn-default" type="button" data-incr="0.01">+</button>
</span>
</div></code>
</div>
</div>
<h3>Initialization via JavaScript</h3>
<div class="row">
<div class="col-sm-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<input type="text" name="font-size" class="form-control" id="options-demo-spinner">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-1">–</button>
<button class="btn btn-default" type="button" data-incr="1">+</button>
</span>
</div>
</div>
</form>
</div>
<div class="col-sm-6">
<code class="language-javascript">$('#options-demo-spinner')
.bsSpinner({ min: 2, max: 5, format: '%d mm' })
.val(3);</code>
</div>
</div>
<section id="example-change-event">
<h3>Events</h3>
<div class="row">
<div class="col-sm-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<input type="text" name="font-size" class="form-control" id="event-demo-spinner"
value="5" data-format="%d mm">
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-incr="-1">–</button>
<button class="btn btn-default" type="button" data-incr="1">+</button>
</span>
</div>
</div>
<div>
Current value: <span class="output" id="event-demo-indicator">5</span> mm
</div>
</form>
</div>
<div class="col-sm-6">
<code class="language-javascript">$('#event-demo-spinner').bsSpinner()
.on('change.bs.spinner', function(evt, value) {
$('#event-demo-indicator').html(value);
});</code>
</div>
</div>
</section>
<section id="license">
<h2>License</h2>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2.0</a></p>
</section>
</div>
</body>
</html>