summaryrefslogtreecommitdiffstats
path: root/src/docs/examples.html
blob: 9f4881c4e7b30ac4d048368e27f5a42debcda73a (plain)
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
<!-- ---------------------------------------------- -->
<!-- ---------------------------------------------- -->
<div id="Examples" class="section">
	<h2>Examples</h2>
					



	<h3 id="Examples-Basics">Basics</h3>
					


<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>A timepicker in the simplest fashion.</p>
	
	<input type="text" id="ex_basic_1" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_basic_1').intimidatetime();
</pre>
</div>

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>Add a few options, change the format.  Intimidate time detects which time units are needed by the format.</p>
	
	<input type="text" id="ex_basic_2" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_basic_2').intimidatetime({
	format: 'MMM d, yyyy'
});
</pre>
</div>

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>Use the preview format, this is useful when you need to generate a Unix timestamp.</p>
	
	<input type="text" id="ex_basic_3" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_basic_3').intimidatetime({
	format: 'u',
	previewFormat: 'yyyy-MM-dd HH:mm:ss'
});
</pre>
</div>

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>You can add on extra functionality by using buttons.  Pass an array of as many as you like.</p>
	
	<input type="text" id="ex_basic_4" value="" class="inputFull"/>
	

<pre class="code">
var $basicEx4 = $('#ex_basic_4').intimidatetime({
	buttons: [
			{ 
				text: 'Done', 
				action: function(e){ $basicEx4.intimidatetime('close'); return false; } 
			},
			{ 
				text: 'Now', 
				action: function(e){ $basicEx4.intimidatetime('value', new Date() ); return false; }
			}
		]
});
</pre>
</div>


<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>You can change input types using the units.{unit type}.type option.</p>
	
	<input type="text" id="ex_basic_5" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_basic_5').intimidatetime({
	format: 'MMM yyyy',
	units: {
		year: { type: 'list', options: [2013,2014,2015] },
		month: { type: 'list', format: 'MMMM' }
	}
});
</pre>
</div>






	<h3 id="Examples-Timezones">Timezones</h3>

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>You can enable timezones with the "z" format token.</p>
	
	<input type="text" id="ex_timezone_1" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_timezone_1').intimidatetime({
	format: 'yyyy-MM-dd HH:mm z'
});
</pre>
</div>
					


<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>Suppose you want the user to have more readable timezone descriptions, but behind the scenes Intimidate time needs the numeric timezone.  We can pass a few timezone options.</p>
	<p>The option values must be minute offsets from utc.  Just like Date.getTimezoneOffset() the offset for -0400 is 240.  Intimidatetime tries to follow the path laid by javascript.  Then You can assign names to each value.</p>
	
	<input type="text" id="ex_timezone_2" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_timezone_2').intimidatetime({
	format: 'yyyy-MM-dd HH:mm zzz',
	units: {
		timezone: {
			format: 'zzz',
			options: [240,300,360,420],
			names: {
				"240": "EDT", 
				"300": "CDT", 
				"360": "MDT",
				"420": "PDT"
			}
		}
	}
});
</pre>
</div>





	<h3 id="Examples-Ranges">Ranges</h3>
					

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>Ranges are very simple, just use the range option.</p>
	
	<input type="text" id="ex_ranges_1" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_ranges_1').intimidatetime({
	ranges: 1
});
</pre>
</div>				

<!-- ---------------------------------------------- -->
<div class="example-container">
	<p>Sometimes maybe you don't want a range necessarily, but a list of dates.  Use the rangeDelimiter and range options together.  Here we request 3 dates.</p>
	
	<input type="text" id="ex_ranges_2" value="" class="inputFull"/>
	

<pre class="code">
$('#ex_ranges_2').intimidatetime({
	format: 'yyyy-MM-dd',
	ranges: 2,
	rangeDelimiter: ', '
});
</pre>
</div>

					
</div><!-- end #Examples -->