Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding mouseenter/mouseleave example for accordion
- Loading branch information
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
examples/gallery-node-accordion/accordion-mouseenter-mouseleave.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>YUI Plugin: gallery-node-accordion </title> | ||
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.2.0/build/cssfonts/fonts-min.css&3.2.0/build/cssreset/reset-min.css&3.2.0/build/cssbase/base-min.css"> | ||
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/gallery-2010.05.21-18-16/build/gallery-node-accordion/assets/skins/sam/gallery-node-accordion.css" /> | ||
<style> | ||
/* module examples */ | ||
div#demo { | ||
position:relative; | ||
width:22em; | ||
padding: 10px; | ||
} | ||
.yui3-accordion .yui3-accordion-item { | ||
text-align: left; | ||
} | ||
.yui3-accordion .yui3-accordion-item .yui3-accordion-item-bd p { | ||
padding: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body class="yui3-skin-sam"> | ||
<div id="doc"> | ||
|
||
<div id="demo"> | ||
<div class="hd"> | ||
<h3 class="title">Accordion using synthetic events (mouseenter/mouseleave) to expand and collapse elements on mouse move.</h3> | ||
<p>More information about gallery-node-accordion here: <br /><a href="http://yuilibrary.com/gallery/show/node-accordion">http://yuilibrary.com/gallery/show/node-accordion</a></p> | ||
</div> | ||
<div class="bd"> | ||
|
||
<div id="myaccordion" class="yui3-accordion"> | ||
|
||
<div class="yui3-module yui3-accordion-item first-of-type"> | ||
|
||
<div class="yui3-hd yui3-accordion-item-hd"> | ||
<a href="#" class="yui3-accordion-item-trigger">item 1</a> | ||
</div> | ||
<div class="yui3-bd yui3-accordion-item-bd"> | ||
<p> | ||
item 1 content here... | ||
</p> | ||
</div> | ||
|
||
</div> | ||
<div class="yui3-module yui3-accordion-item"> | ||
|
||
<div class="yui3-hd yui3-accordion-item-hd"> | ||
<a href="#" class="yui3-accordion-item-trigger">item 2</a> | ||
</div> | ||
<div class="yui3-bd yui3-accordion-item-bd"> | ||
<p> | ||
item 2 content here... | ||
</p> | ||
</div> | ||
|
||
</div> | ||
<div class="yui3-module yui3-accordion-item"> | ||
|
||
<div class="yui3-hd yui3-accordion-item-hd"> | ||
<a href="#" class="yui3-accordion-item-trigger">item 3</a> | ||
</div> | ||
<div class="yui3-bd yui3-accordion-item-bd"> | ||
<p> | ||
item 3 content here... | ||
</p> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
<!-- YUI 3 Seed //--> | ||
<script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script> | ||
<!-- Initialization process //--> | ||
<script type="text/javascript"> | ||
YUI({ | ||
//Last Gallery Build of this module | ||
gallery: 'gallery-2010.05.21-18-16' | ||
}).use('node', 'gallery-node-accordion', 'event-mouseenter', function (Y) { | ||
|
||
var node = Y.one("#myaccordion"); | ||
node.plug(Y.Plugin.NodeAccordion, {}); | ||
|
||
// expanding on mouseenter | ||
node.delegate ('mouseenter', function (e) { | ||
node.accordion.expandItem(e.currentTarget); | ||
}, '.yui3-accordion-item'); | ||
// collapsing on mouseleave | ||
node.delegate ('mouseleave', function (e) { | ||
node.accordion.collapseItem(e.currentTarget); | ||
}, '.yui3-accordion-item'); | ||
|
||
// finally, we might want to have a mouseleave event at the global level to collapse all items | ||
// when the mouse is out of the accordion area to guarantee no problems | ||
// collapsing all items on mouseleave | ||
node.on ('mouseleave', function (e) { | ||
node.accordion.collapseAllItems(); | ||
}); | ||
|
||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters