forked from jtsage/jtsage-datebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.html
106 lines (89 loc) · 6.19 KB
/
events.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQueryMobile - DateBox Demos</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
<link type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.css" rel="stylesheet" />
<link type="text/css" href="http://dev.jtsage.com/jQM-DateBox/css/demos.css" rel="stylesheet" />
<!-- NOTE: Script load order is significant! -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/gpretty/prettify.js"></script>
<link type="text/css" href="http://dev.jtsage.com/gpretty/prettify.css" rel="stylesheet" />
<script type="text/javascript">
$('div').live('pagecreate', function() {
prettyPrint()
});
</script>
</head>
<body>
<div data-role="page" data-theme="a" id="apiEvent">
<div data-role="header">
<h1>jQueryMobile - DateBox</h1>
<a href="../../" data-icon="home" data-iconpos="notext">Home</a>
</div>
<div data-role="content" data-theme="c">
<h2>Public Functions</h2>
<p>Datebox has a number of public functions. They are:</p>
<ul data-role="listview" data-inset="true">
<li><h3>$('element').datebox('open');</h3><p>Open the DateBox control</p></li>
<li><h3>$('element').datebox('close');</h3><p>Close the DateBox control</p></li>
<li><h3>$('element').datebox('disable');</h3><p>Disable the DateBox control</p></li>
<li><h3>$('element').datebox('enable');</h3><p>Enable the DateBox control</p></li>
<li><h3>$('element').datebox('refresh');</h3><p>Refresh the DateBox control</p></li>
<li><h3>$('element').datebox('hardreset');</h3><p>Hard Reset the DateBox control, rebuild the interface window.</p></li>
</ul>
<h2>Events</h2>
<p>Datebox has a few standard init events. They are:</p>
<ul data-role="listview" data-inset="true">
<li data-role="list-divider">Standard Callbacks</li>
<li><h3>Triggered before init of datebox</h3><p><strong>dateboxbeforecreate</strong> Note: this is called on *every* page if datebox is loaded, regardless if there are any datebox elements.</p></li>
<li><h3>Triggered at init of datebox</h3><p><strong>dateboxcreate</strong> Note: this happens dureing the init, before anything is set, and only on when datebox elements are found</p></li>
<li><h3>Triggered post-init of datebox</h3><p><strong>dateboxaftercreate</strong></p></li>
</ul>
<p>Datebox also has a number of custom callback event types. They all fire the same master event, with an object payload. To catch:</p>
<pre class="prettyprint">$('element').bind('datebox', function (e, passed) { ... });</pre>
<p>To override one of the action causeing methods, something like: (must happen before loading JQM and datebox to work)</p>
<pre class="prettyprint">$('document').bind('pagecreate', function() {
$('element').bind('datebox', function(e, p) {
if ( p.method === 'set' ) {
e.stopImmediatePropagation()
//DO SOMETHING//
}
});
});</pre>
<ul data-role="listview" data-inset="true">
<li data-role="list-divider">Event Payloads - Trigger causes action</li>
<li><h3>Trigger to open datebox</h3><p><strong>{'method'}</strong> === open</p></li>
<li><h3>Trigger to close datebox</h3><p><strong>{'method'}</strong> === close</p></li>
<li><h3>Trigger to set specified date</h3><p><strong>{'method'}</strong> === set<br /><strong>{'value'}</strong> === value to place in input</p></li>
<li><h3>Trigger to refresh input date</h3><p><strong>{'method'}</strong> === doset</p></li>
<li><h3>Trigger to refresh</h3><p><strong>Note:</strong> Not used interaly.<br /><strong>{'method'}</strong> === dorefresh</p></li>
<li><h3>Trigger to hard reset the controls</h3><p><strong>Note:</strong> Not used interaly.<br /><strong>{'method'}</strong> === doreset</p></li>
<li><h3>Trigger to change date</h3><p><strong>Note:</strong> Not used interaly.<br /><strong>{'method'}</strong> === dooffset<br /><strong>{'amount'}</strong> === Amount of change (usually +/- 1)<br /><strong>{'type'}</strong> === Type of change ( 'y' = Year, 'm' = Month, 'd' = Date, 'h' = Hour, 'i' = Minute, 's' = Second, 'a' = Meridian ) </p></li>
<li data-role="list-divider">Event Payloads - Action causes trigger</li>
<li><h3>Triggered on datebox enable</h3><p><strong>{'method'}</strong> === enable</p></li>
<li><h3>Triggered on datebox disable</h3><p><strong>{'method'}</strong> === disable</p></li>
<li><h3>Triggered on every data refresh</h3><p><strong>{'method'}</strong> === refresh</p></li>
<li><h3>Triggered on date change</h3><p><strong>{'method'}</strong> === offset<br /><strong>{'amount'}</strong> === Amount of change (usually +/- 1)<br /><strong>{'type'}</strong> === Type of change ( 'y' = Year, 'm' = Month, 'd' = Date, 'h' = Hour, 'i' = Minute, 's' = Second, 'a' = Meridian ) </p></li>
</ul>
<p>Example code to disable datebox on close:</p>
<pre class="prettyprint">$('element').bind('datebox', function (e, passed) {
if ( passed.method === 'close' ) {
$('element').datebox('disable');
}
});</pre>
<p>Example to modify and set date without open (increment month by 2):</p>
<pre class="prettyprint">$('element').trigger('datebox', {'method':'dooffset', 'type':'m', 'amount':2}).trigger('datebox', {'method':'doset'});</pre>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
<a data-role="button" href="https://github.com/jtsage/jquery-mobile-datebox">GitHub Source</a><a data-role="button" rel='external' href="http://dev.jtsage.com/blog/">Blog</a><a data-role="button" href="mailto:jtsage+datebox@gmail.com">Contact</a><a data-role="button" href="http://jquerymobile.com/">jQueryMobile Homepage</a>
</div>
</div>
</div>
</html>