|
From: FlorinCB <ory...@us...> - 2008-09-18 00:44:00
|
Update of /cvsroot/mxbb/mx_music/phpbb2/mx_mod/mx_shared/mygosumenu/1.2 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19367/mx_mod/mx_shared/mygosumenu/1.2 Added Files: TreeMenu.css TreeMenu.js TreeMenu.txt example1.html example1.php Log Message: upgrade --- NEW FILE: example1.html --- <html> <head> <link rel="stylesheet" type="text/css" href="TreeMenu.css"> <script type="text/javascript" src="TreeMenu.js"></script> </head> <body> <script type="text/javascript"> window.onload = function() { new TreeMenu("menu1"); } </script> <ul id="menu1" class="tree-menu"> <li><a href="javascript:void(0)">Products</a> <ul> <li><a href="#">Product One</a></li> <li><a href="javascript:void(0)">Product Two</a> <ul> <li><a href="#">Overview</a></li> <li><a href="#">Features</a></li> <li><a href="#">Requirements</a></li> <li><a href="#">Flash Demos</a></li> </ul> </li> <li><a href="javascript:void(0)">Product Three</a> <ul> <li><a href="#">Overview</a></li> <li><a href="#">Features</a></li> <li><a href="#">Requirements</a></li> <li><a href="#">Screenshots</a></li> <li><a href="#">Flash Demos</a></li> <li><a href="javascript:void(0)">Live Demo</a> <ul> <li><a href="#">Create Account</a></li> <li><a href="javascript:void(0)">Test Drive</a> <ul> <li><a href="#">Test One</a></li> <li><a href="#">Test Two</a></li> <li><a href="#">Test Three</a></li> </ul> </li> </ul> </li> </ul> </li> <li><a href="javascript:void(0)">Product Four</a> <ul> <li><a href="#">Overview</a></li> <li><a href="#">Features</a></li> <li><a href="#">Requirements</a></li> </ul> </li> <li><a href="#">Product Five</a></li> </ul> </li> <li><a href="javascript:void(0)">Downloads</a> <ul> <li><a href="#">30-day Demo Key</a></li> <li><a href="javascript:void(0)">Product One Download</a> <ul> <li><a href="#">Windows Download</a></li> <li><a href="#">Solaris Download</a></li> <li><a href="#">Linux Download</a></li> </ul> </li> <li><a href="javascript:void(0)">Product Two Download</a> <ul> <li><a href="#">Linux Download</a></li> </ul> </li> </ul> </li> <li><a href="javascript:void(0)">Support</a> <ul> <li><a href="#">E-mail Support</a></li> </ul> </li> <li><a href="javascript:void(0)">Partners</a> <ul> <li><a href="#">Partner Benefits</a></li> <li><a href="javascript:void(0)">Partner Application</a> <ul> <li><a href="#">Application One</a></li> <li><a href="#">Application Two</a></li> <li><a href="#">Application Three</a></li> <li><a href="#">Application Four</a></li> <li><a href="#">Application Five</a></li> <li><a href="#">Application Six</a></li> <li><a href="#">Application Seven</a></li> <li><a href="#">Application Eight</a></li> </ul> </li> <li><a href="#">Partner Listing</a></li> </ul> </li> <li><a href="javascript:void(0)">Customers</a> <ul> <li><a href="#">Customer One</a></li> <li><a href="#">Customer Two</a></li> <li><a href="#">Customer Three</a></li> </ul> </li> <li><a href="javascript:void(0)">About Us</a> <ul> <li><a href="#">Executive Team</a></li> <li><a href="#">Investors</a></li> <li><a href="#">Career Opportunities</a></li> <li><a href="javascript:void(0)">Press Center</a> <ul> <li><a href="#">Products Information</a></li> </ul> </li> <li><a href="#">Success Stories</a></li> <li><a href="#">Contact Us</a></li> </ul> </li> </ul> </body> </html> --- NEW FILE: TreeMenu.js --- /* * DO NOT REMOVE THIS NOTICE * * PROJECT: mygosuMenu * VERSION: 1.2.0 * COPYRIGHT: (c) 2003,2004 Cezary Tomczak * LINK: http://gosu.pl/dhtml/mygosumenu.html * LICENSE: BSD (revised) */ function TreeMenu(id) { this.init = function() { if (!document.getElementById(this.id)) { alert("Element '"+this.id+"' does not exist in this document. TreeMenu cannot be initialized"); return; } this.parse(document.getElementById(this.id).childNodes, this.tree, this.id); } this.parse = function(nodes, tree, id) { for (var i = 0; i < nodes.length; i++) { if (nodes[i].nodeType != 1) { continue; } if (nodes[i].tagName.toLowerCase() == "li") { nodes[i].id = id + "-" + tree.length; tree[tree.length] = new Array(); if (nodes[i].childNodes && this.hasUl(nodes[i].childNodes)) { nodes[i].className = "section"; var a; if (a = this.getA(nodes[i].childNodes)) { a.id = nodes[i].id + "-a"; eval("document.getElementById('"+a.id+"').onclick = function() {"+ "self.click('"+nodes[i].id+"');"+ "}"); } } else { nodes[i].className = "box"; } } if (nodes[i].tagName.toLowerCase() == "ul") { nodes[i].style.display = "none"; id = id + "-" + (tree.length - 1); nodes[i].id = id + "-section"; tree = tree[tree.length - 1]; } if (nodes[i].childNodes) { this.parse(nodes[i].childNodes, tree, id); } } } this.hasUl = function(nodes) { for (var i = 0; i < nodes.length; i++) { if (nodes[i].nodeType != 1) { continue; } if (nodes[i].tagName.toLowerCase() == "ul") { return true; } if (nodes[i].childNodes) { if (this.hasUl(nodes[i].childNodes)) { return true; } } } return false; } this.getA = function(nodes) { for (var i = 0; i < nodes.length; i++) { if (nodes[i].nodeType == 1) { if (nodes[i].tagName.toLowerCase() == "a") { return nodes[i]; } return false; } } } this.click = function(id) { e1 = document.getElementById(id + "-section"); e2 = document.getElementById(id); if (e1.style.display == "none") { e1.style.display = ""; e2.className = "section-open"; } else { e1.style.display = "none"; e2.className = "section"; } } var self = this; this.id = id; this.tree = new Array(); this.init(); } --- NEW FILE: example1.php --- <?php /* * PROJECT: mygosuMenu * VERSION: 1.2.0 * COPYRIGHT: (c) 2003,2004 Cezary Tomczak * LINK: http://gosu.pl/software/mygosumenu.html * LICENSE: BSD (revised) */ /** * Note: this function is called recursively * @param array &$a * @param string $id (optional) * @return string */ function generateTreeMenu(&$a, $id = null) { $s = '<ul'; if ($id) $s .= ' id="'.$id.'" class="tree-menu"'; $s .= '>'; foreach ($a as $k => $v) { if (is_array($v)) { $s .= '<li><a href="javascript:void(0)">'.$k.'</a>'; $s .= generateTreeMenu($a[$k]); $s .= '</li>'; } else { $s .= '<li><a href="'.$v.'">'.$k.'</a></li>'; } } $s .= '</ul>'; return $s; } $menu = array( 'Products' => array( 'Product One' => '#', 'Product Two' => array( 'Overview' => '#', 'Features' => '#', 'Requirements' => '#', 'Flash Demos' => '#' ), 'Product Three' => array( 'Overview' => '#', 'Features' => '#', 'Requirements' => '#', 'Screenshots' => '#', 'Flash Demos' => '#', 'Live Demo' => array( 'Create Account' => '#', 'Test Drive' => array( 'Test One' => '#', 'Test Two' => '#', 'Test Three' => '#' ) ) ), 'Product Four' => array( 'Overview' => '#', 'Features' => '#', 'Requirements' => '#' ), 'Product Five' => '#' ), 'Downloads' => array( '30-day Demo Key' => '#', 'Product One Download' => array( 'Windows Download' => '#', 'Solaris Download' => '#', 'Linux Download' => '#' ), 'Product Two Download' => array( 'Linux Download' => '#' ) ), 'Support' => array( 'E-mail Support' => '#' ), 'Partners' => array( 'Partner Benefits' => '#', 'Partner Application' => array( 'Application One' => '#', 'Application Two' => '#', 'Application Three' => '#', 'Application Four' => '#', 'Application Five' => '#', 'Application Six' => '#', 'Application Seven' => '#', 'Application Eight' => '#' ), 'Partner Listing' => '#' ), 'Customers' => array( 'Customer One' => '#', 'Customer Two' => '#', 'Customer Three' => '#' ), 'About Us' => array( 'Executive Team' => '#', 'Investors' => '#', 'Career Opportunities' => '#', 'Press Center' => array( 'Product Information' => '#' ), 'Success Stories' => '#', 'Contact Us' => '#' ) ); ?> <html> <head> <link rel="stylesheet" type="text/css" href="TreeMenu.css"> <script type="text/javascript" src="TreeMenu.js"></script> </head> <body> <script type="text/javascript"> window.onload = function() { new TreeMenu("menu1"); } </script> <?php echo generateTreeMenu($menu, 'menu1'); ?> </body> </html> --- NEW FILE: TreeMenu.css --- ul.tree-menu { font-size: 12px; line-height: 16px; font-family: tahoma; margin: 0; padding: 0; } ul.tree-menu ul { margin: 0 0 0 20px; padding: 2px 0 0 0; } ul.tree-menu li { list-style-type: none; margin: 0; padding: 0; } ul.tree-menu li.section { background-image: url("images/folder.gif"); background-repeat: no-repeat; background-position: top left; padding-top: 1px; padding-bottom: 1px; } ul.tree-menu li.section-open { background-image: url("images/folder-open.gif"); background-repeat: no-repeat; background-position: top left; padding-top: 1px; padding-bottom: 1px; } ul.tree-menu li.box { background-image: url("images/doc.gif"); background-repeat: no-repeat; background-position: top left; padding-top: 1px; padding-bottom: 1px; } ul.tree-menu a { margin-left: 20px; color: #0000ff; text-decoration: none; white-space: nowrap; } ul.tree-menu a:hover { margin-left: 20px; color: #0000ff; text-decoration: underline; white-space: nowrap; } --- NEW FILE: TreeMenu.txt --- /* * PROJECT: mygosuMenu * VERSION: 1.2.0 * COPYRIGHT: (c) 2003,2004 Cezary Tomczak * LINK: http://gosu.pl/dhtml/mygosumenu.html * LICENSE: BSD (revised) */ ---------------- ! ABOUT ---------------- A simple TREE menu. example1.php - auto generating menu from php array ---------------- ! COMPATIBILITY ---------------- Tested on IE 6, Mozilla 1.6, Netscape 7.11, Opera 7.23, Firebird 0.7 |