forked from jonstipe/number-polyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
255 lines (241 loc) · 8.69 KB
/
demo.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTML5 Number polyfill</title>
<meta name="author" content="Jonathan Stipe" />
<meta name="copyright" content="© 2012 Jonathan Stipe" />
<link rel="stylesheet" type="text/css" href="number-polyfill.css" />
<style type="text/css">
.hiddenClass {
visibility: hidden;
}
.opacityZero {
opacity: 0;
}
.opacityHalf {
opacity: 0.5;
}
.opacityOne {
opacity: 1;
}
.transVisibleClass {
opacity: 1;
-moz-transition: opacity 3s;
-webkit-transition: opacity 3s;
-o-transition: opacity 3s;
transition: opacity 3s;
}
.transHiddenClass {
opacity: 0;
-moz-transition: opacity 3s;
-webkit-transition: opacity 3s;
-o-transition: opacity 3s;
transition: opacity 3s;
}
</style>
<script type="text/javascript" src="vendor/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="number-polyfill.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function(){
var trElem = document.createElement("tr"),
tdElem1 = document.createElement("td"),
tdElem2 = document.createElement("td"),
inputElem = document.createElement("input");
inputElem.setAttribute("name", "numberGenerated");
inputElem.setAttribute("type", "number");
tdElem1.appendChild(document.createTextNode("Dynamically generated element:"));
tdElem2.appendChild(inputElem);
trElem.appendChild(tdElem1);
trElem.appendChild(tdElem2);
$("table").append(trElem);
$(inputElem).inputNumber();
$("#disableNumberInput").click(function(event) {
var $elem = $('input[name="numberDisablable"]').first();
if ($elem.is(":disabled")) {
$elem.removeAttr("disabled");
$(this).attr("value", "Disable");
} else {
$elem.attr("disabled", "disabled");
$(this).attr("value", "Enable");
}
});
$("#hideNumberInputByClass").click(function(event) {
var $elem = $('input[name="numberClassHidable"]').first();
if ($elem.is(".hiddenClass")) {
$elem.removeClass("hiddenClass");
$(this).attr("value", "Hide");
} else {
$elem.addClass("hiddenClass");
$(this).attr("value", "Show");
}
});
$("#hideNumberInputByDisplay").click(function(event) {
var $elem = $('input[name="numberDisplayHidable"]').first();
if ($elem.css("display") == "none") {
$elem.css("display", "");
$(this).attr("value", "Hide");
} else {
$elem.css("display", "none");
$(this).attr("value", "Show");
}
});
$("#hideNumberInputByVisibility").click(function(event) {
var $elem = $('input[name="numberVisibilityHidable"]').first();
if ($elem.css("visibility") == "hidden") {
$elem.css("visibility", "visible");
$(this).attr("value", "Hide");
} else {
$elem.css("visibility", "hidden");
$(this).attr("value", "Show");
}
});
$("#hideNumberInputByOpacity").click(function(event) {
var $elem = $('input[name="numberOpacityHidable"]').first();
if ($elem.css("opacity") == "0") {
$elem.css("opacity", "1");
$(this).attr("value", "Hide");
} else {
$elem.css("opacity", "0");
$(this).attr("value", "Show");
}
});
$("#hideNumberInputByTransition").click(function(event) {
var $elem = $('input[name="numberTransitionHidable"]').first();
if ($elem.is(".transHiddenClass")) {
$elem.removeClass("transHiddenClass").addClass("transVisibleClass");
$(this).attr("value", "Hide");
} else {
$elem.removeClass("transVisibleClass").addClass("transHiddenClass");
$(this).attr("value", "Show");
}
});
});
//]]>
</script>
</head>
<body>
<div id="demos">
<form id="form-demo">
<table>
<tr>
<td>What the polyfill should look like:</td>
<td><input name="numberPlain" type="text" /><div class="number-spin-btn-container"><div class="number-spin-btn number-spin-btn-up" style="height: 0.7em;"></div><div class="number-spin-btn number-spin-btn-down" style="height: 0.7em;"></div></div></td>
</tr>
<tr>
<td>Number which can be hidden by the class attribute:</td>
<td><input name="numberClassHidable" type="number" min="0" max="100" /><input name="hideNumberInputByClass" id="hideNumberInputByClass" type="button" value="Hide"/></td>
</tr>
<tr>
<td>Number which can be hidden by the inline display property:</td>
<td><input name="numberDisplayHidable" type="number" min="0" max="100" /><input name="hideNumberInputByDisplay" id="hideNumberInputByDisplay" type="button" value="Hide"/></td>
</tr>
<tr>
<td>Number which can be hidden by the inline visibility property:</td>
<td><input name="numberVisibilityHidable" type="number" min="0" max="100" /><input name="hideNumberInputByVisibility" id="hideNumberInputByVisibility" type="button" value="Hide"/></td>
</tr>
<tr>
<td>Number which can be hidden by the inline opacity property:</td>
<td><input name="numberOpacityHidable" type="number" min="0" max="100" /><input name="hideNumberInputByOpacity" id="hideNumberInputByOpacity" type="button" value="Hide"/></td>
</tr>
<tr>
<td>Number which transitions to a hidden state:</td>
<td><input name="numberTransitionHidable" type="number" min="0" max="100" /><input name="hideNumberInputByTransition" id="hideNumberInputByTransition" type="button" value="Hide"/></td>
</tr>
<tr>
<td>Number, hidden:</td>
<td><input name="numberHidden" type="number" style="display: none;"/></td>
</tr>
<tr>
<td>Number which can be disabled:</td>
<td><input name="numberDisablable" type="number" min="0" max="100" /><input name="disableNumberInput" id="disableNumberInput" type="button" value="Disable"/></td>
</tr>
<tr>
<td>Number, plain disabled:</td>
<td><input name="numberDisabled" type="number" disabled="disabled" /></td>
</tr>
<tr>
<td>Number, plain readonly:</td>
<td><input name="numberReadonly" type="number" readonly="readonly" value="123.45" /></td>
</tr>
<tr>
<td>Number, plain:</td>
<td><input name="number" type="number" /></td>
</tr>
<tr>
<td>Number with min:</td>
<td><input name="numberMin" type="number" min="5" /></td>
</tr>
<tr>
<td>Number with max:</td>
<td><input name="numberMax" type="number" max="100" /></td>
</tr>
<tr>
<td>Number with min and max:</td>
<td><input name="numberMinMax" type="number" min="5" max="100" /></td>
</tr>
<tr>
<td>Number with step=any:</td>
<td><input name="numberAnyStepped" type="number" step="any" /></td>
</tr>
<tr>
<td>Number with min and step=any:</td>
<td><input name="numberMinAnyStepped" type="number" min="5" step="any" /></td>
</tr>
<tr>
<td>Number with max and step=any:</td>
<td><input name="numberMaxAnyStepped" type="number" max="100" step="any" /></td>
</tr>
<tr>
<td>Number with min, max, and step=any:</td>
<td><input name="numberMinMaxAnyStepped" type="number" min="5" max="100" step="any" /></td>
</tr>
<tr>
<td>Number with step=5:</td>
<td><input name="numberStepped" type="number" step="5" /></td>
</tr>
<tr>
<td>Number with min and step=5:</td>
<td><input name="numberMinStepped" type="number" min="5" step="5" /></td>
</tr>
<tr>
<td>Number with max and step=5:</td>
<td><input name="numberMaxStepped" type="number" max="100" step="5" /></td>
</tr>
<tr>
<td>Number with misstepped max and step=5:</td>
<td><input name="numberMaxStepped" type="number" max="102" step="5" /></td>
</tr>
<tr>
<td>Number with min, max, and step=5:</td>
<td><input name="numberMinMaxStepped" type="number" min="5" max="100" step="5" /></td>
</tr>
<tr>
<td>Number with fractional step:</td>
<td><input name="numberStepped" type="number" step="0.01" /></td>
</tr>
<tr>
<td>Number with min and fractional step:</td>
<td><input name="numberMinStepped" type="number" min="5" step="0.01" /></td>
</tr>
<tr>
<td>Number with max and fractional step:</td>
<td><input name="numberMaxStepped" type="number" max="100" step="0.01" /></td>
</tr>
<tr>
<td>Number with min, max, and fractional step:</td>
<td><input name="numberMinMaxStepped" type="number" min="5" max="100" step="0.01" /></td>
</tr>
<tr>
<td>Number with negative min, max, and fractional step:</td>
<td><input name="numberNegaMinMaxStepped" type="number" min="-100" max="100" step="0.01" /></td>
</tr>
</table>
<input type="submit" />
<input type="reset" />
</form>
<a href="https://github.com/jonstipe/number-polyfill">Back to GitHub repo</a>
</div>
</body>
</html>