Yui: различия между версиями

1089 байт добавлено ,  14 лет назад
нет описания правки
Нет описания правки
Нет описания правки
<h3><span>TreeView (Иерархические деревья)</span></h3>
<source lang="javascript">
'''Простое иерархическое дерево:'''
'''Движение обьекта по траектории:'''
<source lang="javascript">
<!-- 1 -->
<stylelink rel="stylesheet" type="text/css" href="yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="yui/build/treeview/assets/skins/sam/treeview.css" />
#demo {
<script type="text/javascript" src="yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
background:#ccc;
<script type="text/javascript" src="yui/build/animationevent/animationevent.js"></script>
margin-bottom:1em;
<script type="text/javascript" src="yui/build/treeview/treeview.js"></script>
height:30px;
 
width:30px;
<style>
}
#treeDiv1 {background: #fff; padding:1em;}
</style>
<script type="text/javascript" src="yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="yui/build/animation/animation.js"></script>
<!-- 1 -->
 
<!-- 2 -->
<div id="demotreeDiv1"></div>
<button id="demo-run">run</button>
 
<script type="text/javascript">
 
var tree;
 
(function() {
var attributes = {
points: { to: [600, 10], control: [ [300, 100], [800, 800] ] }
};
var anim = new YAHOO.util.Motion('demo', attributes);
 
 
YAHOO.util.Event.on('demo-run', 'click', function() {
function anim.animatetreeInit(); {
buildRandomTextNodeTree();
});
};
 
function buildRandomTextNodeTree() {
tree = new YAHOO.widget.TreeView("treeDiv1");
 
for (var i = 0; i < Math.floor((Math.random()*4) + 3); i++) {
var tmpNode = new YAHOO.widget.TextNode("label-" + i, tree.getRoot(), false);
 
buildLargeBranch(tmpNode);
}
 
tree.subscribe("expand", function(node) {
YAHOO.log(node.index + " was expanded", "info", "example");
 
});
 
tree.subscribe("collapse", function(node) {
YAHOO.log(node.index + " was collapsed", "info", "example");
});
 
 
tree.subscribe("labelClick", function(node) {
YAHOO.log(node.index + " label was clicked", "info", "example");
});
 
 
tree.draw();
});
 
 
function buildLargeBranch(node) {
if (node.depth < 10) {
YAHOO.log("buildRandomTextBranch: " + node.index, "info", "example");
for ( var i = 0; i < 5; i++ ) {
new YAHOO.widget.TextNode(node.label + "-" + i, node, false);
}
}
}
 
YAHOO.util.Event.onDOMReady(treeInit);
 
})();
 
</script>
<!-- 2 -->
258

правок