| | |
| | | |
| | | // insert as child of an existing node |
| | | if (parent_node) { |
| | | node.level = parent_node.level + 1; |
| | | if (!parent_node.children) |
| | | parent_node.children = []; |
| | | |
| | |
| | | } |
| | | // insert at top level |
| | | else { |
| | | node.level = 0; |
| | | data.push(node); |
| | | li = render_node(node, container); |
| | | } |
| | |
| | | |
| | | // render child nodes |
| | | for (var i=0; i < data.length; i++) { |
| | | data[i].level = 0; |
| | | render_node(data[i], container); |
| | | } |
| | | |
| | |
| | | ul.hide(); |
| | | |
| | | for (var i=0; i < node.children.length; i++) { |
| | | node.children[i].level = node.level + 1; |
| | | render_node(node.children[i], ul); |
| | | } |
| | | } |
| | |
| | | id: dom2id(li), |
| | | classes: li.attr('class').split(' '), |
| | | virtual: li.hasClass('virtual'), |
| | | level: level, |
| | | html: li.children().first().get(0).outerHTML, |
| | | children: walk_list(sublist, level+1) |
| | | } |
| | |
| | | } |
| | | |
| | | // declare list item as treeitem |
| | | li.attr('role', 'treeitem'); |
| | | li.attr('role', 'treeitem').attr('aria-level', node.level+1); |
| | | |
| | | // allow virtual nodes to receive focus |
| | | if (node.virtual) { |
| | |
| | | var mod = dir < 0 ? 'prev' : 'next', |
| | | next = li[mod](), limit, parent; |
| | | |
| | | if (dir > 0 && !from_child && li.children('ul[role=tree]:visible').length) { |
| | | if (dir > 0 && !from_child && li.children('ul[role=group]:visible').length) { |
| | | li.children('ul').children('li:first').children('a:first').focus(); |
| | | } |
| | | else if (dir < 0 && !from_child && next.children('ul[role=tree]:visible').length) { |
| | | else if (dir < 0 && !from_child && next.children('ul[role=group]:visible').length) { |
| | | next.children('ul').children('li:last').children('a:last').focus(); |
| | | } |
| | | else if (next.length && next.children('a:first')) { |