forked from cocoo/easyui-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatebox.html
198 lines (182 loc) · 6.39 KB
/
datebox.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>datebox</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/SyntaxHighlighter.css" />
<script type="text/javascript" src="js/shCore.js"></script>
<script type="text/javascript" src="js/shBrushJScript.js"></script>
<script type="text/javascript" src="js/shBrushXml.js"></script>
</head>
<body style="text-align:left">
<div style="padding:10px">
<h3>DateBox</h3>
<p>Extend from $.fn.combo.defaults. Override defaults with $.fn.datebox.defaults</p>
<p>
The datebox combines a editable text box with drop-down calendar panel that allows the user to select a date.
The entered string in the text box can be transformed to a valid date.
The selected date can also be formatted as expected.
</p>
<img src="images/datebox.png">
<h4>Dependencies</h4>
<ul>
<li>combo</li>
<li>calendar</li>
</ul>
<h4>Usage Example</h4>
<p>Create datebox from markup.</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">id</span><span>=</span><span class="attribute-value">"dd"</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span> </span><span class="attribute">class</span><span>=</span><span class="attribute-value">"easyui-datebox"</span><span> </span><span class="attribute">required</span><span>=</span><span class="attribute-value">"required"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">input</span><span class="tag">></span><span> </span></span></li></ol></div><textarea class="html" name="code-datebox" style="display: none;"> <input id="dd" type="text" class="easyui-datebox" required="required"></input>
</textarea>
<p>Create datebox using javascript.</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">input</span><span> </span><span class="attribute">id</span><span>=</span><span class="attribute-value">"dd"</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">input</span><span class="tag">></span><span> </span></span></li></ol></div><textarea class="html" name="code-datebox" style="display: none;"> <input id="dd" type="text"></input>
</textarea>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>$(</span><span class="string">'#dd'</span><span>).datebox({ </span></span></li><li class=""><span> required:<span class="keyword">true</span><span> </span></span></li><li class="alt"><span>}); </span></li></ol></div><textarea class="js" name="code-datebox" style="display: none;"> $('#dd').datebox({
required:true
});
</textarea>
<br>
<h4>Properties</h4>
<p>The properties extend from combo, below is the added properties for datebox.</p>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Type</strong></th>
<th><strong>Description</strong></th>
<th><strong>Default</strong></th>
</tr>
<tr>
<td>panelWidth</td>
<td>number</td>
<td>The drop down calendar panel width.</td>
<td>180</td>
</tr>
<tr>
<td>panelHeight</td>
<td>number</td>
<td>The drop down calendar panel height.</td>
<td>auto</td>
</tr>
<tr>
<td>currentText</td>
<td>string</td>
<td>The text to display for the current day button.</td>
<td>Today</td>
</tr>
<tr>
<td>closeText</td>
<td>string</td>
<td>The text to display for the close button.</td>
<td>Close</td>
</tr>
<tr>
<td>okText</td>
<td>string</td>
<td>The text to display for the ok button.</td>
<td>Ok</td>
</tr>
<tr>
<td>disabled</td>
<td>boolean</td>
<td>When true to disable the field.</td>
<td>false</td>
</tr>
<tr>
<td>formatter</td>
<td>function</td>
<td>
A function to format the date, the function take a 'date' parameter and return a string value.
The example below shows how to override the default formatter function.
<pre>$.fn.datebox.defaults.formatter = function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return m+'/'+d+'/'+y;
}
</pre>
</td>
<td></td>
</tr>
<tr>
<td>parser</td>
<td>function</td>
<td>
A function to parse a date string, the function take a 'date' string and return a date value.
The example below shows how to override the default parser function.
<pre>$.fn.datebox.defaults.parser = function(s){
var t = Date.parse(s);
if (!isNaN(t)){
return new Date(t);
} else {
return new Date();
}
}
</pre>
</td>
<td></td>
</tr>
</tbody></table>
<h4>Events</h4>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameters</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>onSelect</td>
<td>date</td>
<td>
Fires when user select a date.
<p>Code example:</p>
<pre>$('#dd').datebox({
onSelect: function(date){
alert(date.getFullYear()+":"+(date.getMonth()+1)+":"+date.getDate());
}
});
</pre>
</td>
</tr>
</tbody></table>
<h4>Methods</h4>
<p>The methods extend from combo, below is the overridden methods for datebox.</p>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameter</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>options</td>
<td>none</td>
<td>Return the options object.</td>
</tr>
<tr>
<td>calendar</td>
<td>none</td>
<td>
Get the calendar object.
The example below shows how to get the calendar object and then recreate it.
<pre>// get the calendar object
var c = $('#dd').datebox('calendar');
// set the first day of week to monday
c.calendar({
firstDay: 1
});
</pre>
</td>
</tr>
<tr>
<td>setValue</td>
<td>value</td>
<td>
Set the datebox value.
<p>Code example:</p>
<pre>$('#dd').datebox('setValue', '6/1/2012'); // set datebox value
var v = $('#dd').datebox('getValue'); // get datebox value
</pre>
</td>
</tr>
</tbody></table>
</div>
</body>
</html>