X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..3789b528d8dd8aad4558e38e22d775bcab1cbd36:/docs/js/ClassTree.js diff --git a/docs/js/ClassTree.js b/docs/js/ClassTree.js new file mode 100644 index 00000000..4718ae82 --- /dev/null +++ b/docs/js/ClassTree.js @@ -0,0 +1,71 @@ +/** + * Class tree. + */ +Ext.define('Docs.ClassTree', { + extend: 'Ext.tree.Panel', + + id: 'treePanelCmp', + cls: 'iScroll', + renderTo: 'treePanel', + folderSort: true, + useArrows: true, + rootVisible: false, + + height: Ext.core.Element.getViewportHeight() - 170, + border: false, + bodyBorder: false, + padding: '0 0 0 20', + + listeners: { + itemclick: function(view, node) { + var clsName = node.raw ? node.raw.clsName : node.data.clsName; + + if (clsName) { + Docs.ClassLoader.load(clsName); + } else if (!node.isLeaf()) { + if (node.isExpanded()) { + node.collapse(false); + } else { + node.expand(false); + } + } + } + }, + + initComponent: function() { + // Expand the main tree + this.root.expanded = true; + this.root.children[0].expanded = true; + // Add links for favoriting classes + this.addFavIcons(this.root); + + this.callParent(); + }, + + addFavIcons: function(node) { + if (node.isClass) { + node.text += ''; + } + if (node.children) { + Ext.Array.forEach(node.children, this.addFavIcons, this); + } + }, + + /** + * Selects class node in tree by name. + * + * @param {String} className + */ + selectClass: function(className) { + var classNode = this.getRootNode().findChildBy(function(n) { + return className === n.raw.clsName; + }, null, true); + + if (classNode) { + this.getSelectionModel().select(classNode); + classNode.bubble(function(n) { + n.expand(); + }); + } + } +});