-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
99 lines (86 loc) · 3.34 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
<html>
<head>
<title>Finput</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
</head>
<body>
<div id="root">
<div class="jumbotron">
<div class="container">
<h1>FINPUT</h1>
<p>A test harness for the vanilla-JS financial amount input control</p>
</div>
</div>
<div class="container">
<h2>Controls</h2>
<br>
<form>
<div class="form-group">
<label for="finput-default">Default</label>
<input type="text" id="finput-default" class="form-control">
</div>
<div class="form-group">
<label for="finput-custom-focus">Custom Focus Behaviour</label>
<input type="text" id="finput-custom-focus" class="form-control">
</div>
<div class="form-group">
<label for="finput-invalid-key-callback">Invalid Key Callback</label>
<input type="text" id="finput-invalid-key-callback" class="form-control">
</div>
<div class="form-group">
<label for="finput-reversed-delimiters">Reversed Delimiters</label>
<input type="text" id="finput-reversed-delimiters" class="form-control">
</div>
<div class="form-group">
<label for="finput-switch-options">Switch Options</label>
<input type="text" id="finput-switch-options" class="form-control">
<button type="button" id="finput-switch-options-button">Switch Options</button>
</div>
</form>
<h2>Native Controls</h2>
<br>
<form>
<div class="form-group">
<label for="native-text">Text</label>
<input type="text" id="native-text" class="form-control">
</div>
<div class="form-group">
<label for="native-number">Number</label>
<input type="number" id="native-number" class="form-control">
</div>
</form>
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js"></script>
<script src="dist/finput.js"></script>
<script>
var finputDefault = document.getElementById('finput-default');
var finputCustomFocus = document.getElementById('finput-custom-focus');
var finputInvalidKeyCallback = document.getElementById('finput-invalid-key-callback');
var finputReversedDelimiters = document.getElementById('finput-reversed-delimiters');
var finputSwitchOptions = document.getElementById('finput-switch-options');
var finputSwitchOptionsButton = document.getElementById('finput-switch-options-button');
finput(finputDefault, {});
finput(finputCustomFocus, {
onFocus: function () { return { start: 0, end: 1 }; }
});
finput(finputInvalidKeyCallback, {
onInvalidKey: function (info) { console.log('invalid keypress', info); }
});
finput(finputReversedDelimiters, {
thousands: '.',
decimal: ','
});
var finputSwitchOptionsInstance = finput(finputSwitchOptions, {});
finputSwitchOptionsButton.onclick = function () {
var tempThousands = finputSwitchOptionsInstance.options.thousands;
var tempRawValue = finputSwitchOptionsInstance.rawValue;
finputSwitchOptionsInstance.setOptions({
thousands: finputSwitchOptionsInstance.options.decimal,
decimal: tempThousands
});
finputSwitchOptionsInstance.setRawValue(tempRawValue);
}
</script>
</html>