comparison jquery-ui/development-bundle/demos/accordion/hoverintent.html @ 0:b2e4605f20b2

beta version
author dwinter
date Thu, 30 Jun 2011 09:07:49 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b2e4605f20b2
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery UI Accordion - Open on hoverintent</title>
6 <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7 <script src="../../jquery-1.5.1.js"></script>
8 <script src="../../ui/jquery.ui.core.js"></script>
9 <script src="../../ui/jquery.ui.widget.js"></script>
10 <script src="../../ui/jquery.ui.accordion.js"></script>
11 <link rel="stylesheet" href="../demos.css">
12 <script>
13 $(function() {
14 $("#accordion").accordion({
15 event: "click hoverintent"
16 });
17 });
18
19 var cfg = ($.hoverintent = {
20 sensitivity: 7,
21 interval: 100
22 });
23
24 $.event.special.hoverintent = {
25 setup: function() {
26 $( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler );
27 },
28 teardown: function() {
29 $( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler );
30 },
31 handler: function( event ) {
32 event.type = "hoverintent";
33 var self = this,
34 args = arguments,
35 target = $( event.target ),
36 cX, cY, pX, pY;
37
38 function track( event ) {
39 cX = event.pageX;
40 cY = event.pageY;
41 };
42 pX = event.pageX;
43 pY = event.pageY;
44 function clear() {
45 target
46 .unbind( "mousemove", track )
47 .unbind( "mouseout", arguments.callee );
48 clearTimeout( timeout );
49 }
50 function handler() {
51 if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) {
52 clear();
53 jQuery.event.handle.apply( self, args );
54 } else {
55 pX = cX;
56 pY = cY;
57 timeout = setTimeout( handler, cfg.interval );
58 }
59 }
60 var timeout = setTimeout( handler, cfg.interval );
61 target.mousemove( track ).mouseout( clear );
62 return true;
63 }
64 };
65 </script>
66 </head>
67 <body>
68
69 <div class="demo">
70
71 <div id="accordion">
72 <h3><a href="#">Section 1</a></h3>
73 <div>
74 <p>
75 Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
76 ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
77 amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
78 odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
79 </p>
80 </div>
81 <h3><a href="#">Section 2</a></h3>
82 <div>
83 <p>
84 Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
85 purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
86 velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
87 suscipit faucibus urna.
88 </p>
89 </div>
90 <h3><a href="#">Section 3</a></h3>
91 <div>
92 <p>
93 Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
94 Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
95 ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
96 lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
97 </p>
98 <ul>
99 <li>List item one</li>
100 <li>List item two</li>
101 <li>List item three</li>
102 </ul>
103 </div>
104 <h3><a href="#">Section 4</a></h3>
105 <div>
106 <p>
107 Cras dictum. Pellentesque habitant morbi tristique senectus et netus
108 et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
109 faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
110 mauris vel est.
111 </p>
112 <p>
113 Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
114 Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
115 inceptos himenaeos.
116 </p>
117 </div>
118 </div>
119
120 </div><!-- End demo -->
121
122 <div class="demo-description">
123 <p>
124 Click headers to expand/collapse content that is broken into logical sections, much like tabs.
125 Optionally, toggle sections open/closed on mouseover.
126 </p>
127 <p>
128 The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is
129 usable without JavaScript.
130 </p>
131 </div><!-- End demo-description -->
132
133 </body>
134 </html>