Obsah fóra
PravidláRegistrovaťPrihlásenie




Odpovedať na tému [ Príspevok: 1 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
Obrázok užívateľa

Registrovaný: 06.09.07
Prihlásený: 21.03.24
Príspevky: 263
Témy: 62
Príspevok NapísalOffline : 28.01.2009 10:40

Kedze nepatrim medzi tych co len beru a nic nedaju ... prispievam aj ja troskou ... menu je napisane JavaScriptom ... podobne ako ma napr. Agem.sk alebo Sofos.sk, dufam ze sa Vam to zide. Pokial si najde uplatnenie, pouyite ho.

tree.js

Kód:
tree = {
   /* ------------------ user customization starts here ------------------ */
   
   // classes used in HTML document to mark important elements
   classRoot         : "tree",      // ULs with this class will be transformed into trees
   classDefault      : "default",   // LIs with this class will be expanded by default
   classLast         : "last",      // this class will be added to all last branches of the tree
                              // (this is good for easier CSS formatting of the tree)
   
   // paths to images used in tree nodes
   nodeExpand         : "images/tree-plus.gif",      // image of expandable node
   nodeExpandAlt      : "[ + ] ",
   nodeCollapse      : "images/tree-minus.gif",      // image of collapsable node
   nodeCollapseAlt      : "[ - ] ",
   nodeNone         : "images/tree-none.gif",      // image for node without children
   nodeNoneAlt         : "[ · ] ",
   
   /* ------------------ user customization ends here ------------------ */   


   // initialisation of the tree
   init : function() {
      // find all unordered lists marked as trees
      var uls = tree.getElementsByClassName(document, tree.classRoot, "ul");
      for (var i = 0; i < uls.length; i++) {
         // find all last branches of the tree and mark them
         tree.markLast(uls[i]);
         var uls2 = uls[i].getElementsByTagName("ul");
         for (var j = 0; j < uls2.length; j++) {
            tree.markLast(uls2[j]);
         }
         
         // ad node pictures to all branches
         var lis = uls[i].getElementsByTagName("li");
         for (var j = 0; j < lis.length; j++) {
            tree.addNode(lis[j]);
         }
         
         // collapse all branches at the start
         tree.collapseAll(uls[i]);
         
         // find default branches and expand them      
         var def = tree.getElementsByClassName(uls[i], tree.classDefault, "li");
         for (var j = 0; j < def.length; j++) {
            var path = new Array();
            var step = def[j];
            while (step != uls[i]) {
               if (step.tagName == "LI") {
                  tree.expand(step);
               }
               step = step.parentNode;
            }
         }
      }
   },

   // adds node picture at the beginning of all branches
   addNode : function(elm) {
      var uls = elm.getElementsByTagName("ul");
      var image = document.createElement("img");
      if (uls.length > 0) {
         image.src = tree.nodeExpand;
         image.alt = tree.nodeExpandAlt;
         evt.add(image, "click", tree.changeState);
      } else {
         image.src = tree.nodeNone;
         image.alt = tree.nodeNoneAlt;
      }
      elm.insertBefore(image, elm.firstChild);
   },
   
   // gets the actual state of branch and changes it
   changeState : function(e) {
      e = evt.fix(e);
      var obj = (e.currentTarget) ? e.currentTarget : e.target;
      while (obj.tagName != "LI") {
         obj = obj.parentNode;
      }
      if (obj.state == "collapsed") {
         tree.expand(obj);
      } else {
         tree.collapse(obj);
      }
   },
   
   // expands given branch
   expand : function(elm) {
      var uls = elm.getElementsByTagName("ul");
      for (var i = 0; i < uls.length; i++) {
         if (uls[i].parentNode == elm) {
            uls[i].style.display = "block";
            uls[i].parentNode.state = "expanded";
            elm.firstChild.src = tree.nodeCollapse;
            elm.firstChild.alt = tree.nodeCollapseAlt;
         }
      }
   },
   
   // collapses given branch
   collapse : function(elm) {
      var uls = elm.getElementsByTagName("ul");
      for (var i = 0; i < uls.length; i++) {
         if (uls[i].parentNode == elm) {
            uls[i].style.display = "none";
            uls[i].parentNode.state = "collapsed";
            elm.firstChild.src = tree.nodeExpand;
            elm.firstChild.alt = tree.nodeExpandAlt;
         }
      }
   },
   
   // collapses all branches in the given tree
   collapseAll : function(elm) {
      if (elm.tagName == "LI") {tree.expand(elm);}
      var lis = elm.getElementsByTagName("li");
      for (var i = 0; i < lis.length; i++) {
         tree.collapse(lis[i]);
      }
   },
   
   // expands all branches in the given tree
   expandAll : function(elm) {
      if (elm.tagName == "LI") {tree.expand(elm);}
      var lis = elm.getElementsByTagName("li");
      for (var i = 0; i < lis.length; i++) {
         tree.expand(lis[i]);
      }
   },
   
   // marks the last branch in the given branch as last
   markLast : function(elm) {
      var lis = elm.getElementsByTagName("li");
      var i = lis.length - 1;
      while (lis[i].parentNode != elm) {i--;}
      cls.add(lis[i], tree.classLast);
   },
   
   // returns all elements with given class, that are children of given source element
   // attribute tagName is not required, but it speeds up the function a bit
   getElementsByClassName : function(srcElm, clName, tName) {
      foundElements = [];
      tName = (tName) ? tName.toUpperCase() : "*";
      allElements = srcElm.getElementsByTagName(tName);
      for (var i = 0; i < allElements.length; i++) {
         if (cls.has(allElements[i], clName)) {
            foundElements[foundElements.length] = allElements[i];
         }
      }
      return foundElements;
   }

};

// initialisation of the script on load
evt.add(window, "load", tree.init);


tree.css

Kód:
ul.tree, ul.tree ul {
   margin: 0px;
   padding: 0px;
   list-style: none;
}
ul.tree li {
   margin: 0;
   padding: 0px 0px 0px 19px;
   text-indent: -19px;
   background: url(images/tree-line-vertical.gif) top left repeat-y;
}
ul.tree li.last {
   background-image: url(images/tree-line-last.gif);
   background-repeat: no-repeat;
   background-position: top left;
}

.tree img {
   border: 0px;
   vertical-align: middle;
}

Tak zatim


Odpovedať na tému [ Príspevok: 1 ] 


Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy. Rolovacie menu

v HTML, XHTML, XML, CSS

3

1779

22.05.2007 16:55

p360t Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. rolovacie menu v php

v PHP, ASP

21

1697

05.05.2008 15:11

pitbull Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Rolovacie menu vo wordpresse.

v Redakčné systémy

0

678

05.02.2010 12:56

zeto750 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. naj jednoduchšie rolovacie menu

v HTML, XHTML, XML, CSS

1

913

05.06.2007 14:26

Tominator Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Vertikalne menu

[ Choď na stránku:Choď na stránku: 1, 2 ]

v HTML, XHTML, XML, CSS

34

829

21.03.2014 13:14

petko117 Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. vertikalne rozbalovacie menu

v JavaScript, VBScript, Ajax

7

4381

24.01.2007 22:07

m@-nX Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. vertikalne menu IE

v HTML, XHTML, XML, CSS

1

708

01.03.2012 16:14

Ďuri Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Vertikalne 3-urovnove menu

v HTML, XHTML, XML, CSS

7

568

13.03.2014 20:31

Mego Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. vertikalne jquery accordion menu

v JavaScript, VBScript, Ajax

7

438

30.01.2013 22:48

shaggy Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. "Rolovacie" menu

v HTML, XHTML, XML, CSS

3

3235

17.11.2007 17:54

viktorcech Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. rolovacie koliesko myšky

v Externé zariadenia

1

335

18.01.2013 16:06

walther Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. vertikalne zarovnanie textu

v HTML, XHTML, XML, CSS

20

2174

03.01.2008 15:12

vkmt Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. vertikalne uchytenie grafickej karty

v Ostatné

4

596

30.06.2018 21:14

Juryoku Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. WP vertikalne zarovnane 3 obrazky

v Redakčné systémy

6

469

12.04.2015 18:45

eMp Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Dva monitory nad sebou - vertikálne presúvanie

v Operačné systémy Microsoft

3

589

24.12.2017 16:27

Doldy Zobrazenie posledných príspevkov

V tomto fóre nie sú ďalšie neprečítané témy. Vertikalne aj horizontalne zarovnanie na stred

v HTML, XHTML, XML, CSS

2

556

07.10.2016 9:52

17mark Zobrazenie posledných príspevkov


Nemôžete zakladať nové témy v tomto fóre
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre

Skočiť na:  

Powered by phpBB Jarvis © 2005 - 2024 PCforum, webhosting by WebSupport, secured by GeoTrust, edited by JanoF
Ako väčšina webových stránok aj my používame cookies. Zotrvaním na webovej stránke súhlasíte, že ich môžeme používať.
Všeobecné podmienky, spracovanie osobných údajov a pravidlá fóra