forked from bevacqua/rome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
179 lines (175 loc) · 4.85 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
178
179
<link href='dist/rome.css' rel='stylesheet' type='text/css' />
<link href='example/example.css' rel='stylesheet' type='text/css' />
<title>Rome</title>
<h1>Rome</h1>
<h3>Dependency free, opt-in UI, customizable date <em>(and time)</em> picker!</h3>
<a href='https://github.com/bevacqua/rome'>
<img class='gh-fork' src='https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67' alt='Fork me on GitHub' data-canonical-src='https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png' />
</a>
<div class='examples'>
<div class='parent'>
<label for='dt'>Pick a date and a time: </label>
<input id='dt' class='input' />
<pre>
<code>
rome(input);
</code>
</pre>
</div>
<div class='parent'>
<label for='sm'>Weeks starting on monday: </label>
<input id='sm' class='input' />
<pre>
<code>
rome(input, { weekStart: 1 });
</code>
</pre>
</div>
<div class='parent'>
<label for='d'>Pick a date: </label>
<input id='d' class='input' />
<pre>
<code>
rome(input, { time: false });
</code>
</pre>
</div>
<div class='parent'>
<label for='t'>Pick a time: </label>
<input id='t' class='input' />
<pre>
<code>
rome(input, { date: false });
</code>
</pre>
</div>
<div class='parent'>
<label for='ind'>Remove and restore <code>rome</code> at will: </label>
<input id='ind' class='input' />
<button id='toggle'>Destroy <code>rome</code> instance!</button>
<pre>
<code>
var picker = rome(input); // rome.find(input) also returns picker
toggle.addEventListener('click', function () {
if (picker.restore) {
picker.restore();
} else {
picker.destroy();
}
});
</code>
</pre>
</div>
<div class='parent'>
<label for='mm'>Pick a date between <em>2013-12-30</em> and <em>2014-10-01</em>: </label>
<input id='mm' class='input' />
<pre>
<code>
rome(input, { min: '2013-12-30', max: '2014-10-01' });
</code>
</pre>
</div>
<div class='parent'>
<label for='mmt'>It works great with specific date and time too! </label>
<input id='mmt' class='input' />
<pre>
<code>
rome(input, { min: '2014-04-30 19:45', max: '2014-09-01 08:30' });
</code>
</pre>
</div>
<div class='parent'>
<label for='iwe'>Tired of people thinking saturdays are <code>'valid'</code> dates? </label>
<input id='iwe' class='input' />
<pre>
<code>
rome(input, {
dateValidator: function (d) {
return moment(d).day() !== 6;
}
});
</code>
</pre>
</div>
<div class='parent'>
<label for='win'>Winter doesn't meet your fancy? </label>
<input id='win' class='input' />
<pre>
<code>
rome(input, {
dateValidator: function (d) {
var m = moment(d);
var y = m.year();
var f = 'MM-DD';
var start = moment('12-21', f).year(y).startOf('day');
var end = moment('03-19', f).year(y).endOf('day');
return m.isBefore(start) && m.isAfter(end);
}
});
</code>
</pre>
</div>
<div class='parent'>
<label for='tim'>Sure enough, it also allows you to define specific time ranges </label>
<input id='tim' class='input' />
<pre>
<code>
rome(input, {
timeValidator: function (d) {
var m = moment(d);
var start = m.clone().hour(12).minute(59).second(59);
var end = m.clone().hour(18).minute(0).second(1);
return m.isAfter(start) && m.isBefore(end);
}
});
</code>
</pre>
</div>
<div class='parent'>
<label class='block' for='inl'>Did I mention you can use Rome inline as well? Just give it a non-input element!</label>
<div class='inline' id='inl'></div>
<div class='inline' id='inlvc'>Value: <span id='inlv' class='inline'>(choose)</span></div>
<pre>
<code>
<div id='parent'></div>
<div id='result'>(choose)</div>
rome(parent).on('data', function (value) {
result.innerText = value;
});
</code>
</pre>
</div>
<div class='parent'>
<p>Range between two inputs? Sure!</p>
<input id='left' class='input' />
<input id='right' class='input' />
<pre>
<code>
rome(left, {
dateValidator: rome.val.beforeEq(right)
});
rome(right, {
dateValidator: rome.val.afterEq(left)
});
</code>
</pre>
</div>
<div class='parent'>
<p>Inline? No problem!</p>
<div class='inline' id='leftInline'></div>
<div class='inline' id='rightInline'></div>
<pre>
<code>
rome(left, {
dateValidator: rome.val.beforeEq(right)
});
rome(right, {
dateValidator: rome.val.afterEq(left)
});
</code>
</pre>
</div>
</div>
<h3>Get it on GitHub! <a href='https://github.com/bevacqua/rome'>bevacqua/rome</a></h3>
<script src='dist/rome.js'></script>
<script src='example/example.js'></script>