2 * Toolbar with menus providing quick access to class members.
4 Ext.define('Docs.view.cls.Toolbar', {
5 extend: 'Ext.toolbar.Toolbar',
7 'Docs.view.HoverMenuButton',
16 * @cfg {Object} docClass
17 * Documentation for a class.
21 initComponent: function() {
23 this.memberButtons = {};
27 property: "Properties",
31 for (var type in memberTitles) {
32 var members = this.docClass.members[type];
34 var btn = this.createMemberButton({
35 text: memberTitles[type],
39 this.memberButtons[type] = btn;
44 if (this.docClass.subclasses.length) {
45 this.items.push(this.createClassListButton("Sub Classes", this.docClass.subclasses));
47 if (this.docClass.mixedInto.length) {
48 this.items.push(this.createClassListButton("Mixed Into", this.docClass.mixedInto));
51 this.items = this.items.concat([
54 boxLabel: 'Hide inherited',
55 boxLabelAlign: 'before',
59 checked: Docs.Settings.get("hideInherited"),
60 handler: function(el) {
61 this.hideInherited(el.checked);
67 iconCls: 'expandAllMembers',
68 tooltip: "Expand all",
70 Ext.Array.forEach(Ext.query('.side.expandable'), function(el) {
71 Ext.get(el).parent().addCls('open');
77 iconCls: 'collapseAllMembers',
78 tooltip: "Collapse all",
80 Ext.Array.forEach(Ext.query('.side.expandable'), function(el) {
81 Ext.get(el).parent().removeCls('open');
87 this.callParent(arguments);
90 createMemberButton: function(cfg) {
91 var data = Ext.Array.map(cfg.members, function(m) {
92 return this.createLinkRecord(this.docClass.name, m);
95 return Ext.create('Docs.view.HoverMenuButton', {
97 cls: 'icon-'+cfg.type,
98 store: this.createStore(data),
102 this.up('classoverview').scrollToEl("#m-" + cfg.type);
109 createClassListButton: function(text, classes) {
110 var data = Ext.Array.map(classes, function(cls) {
111 return this.createLinkRecord(cls);
114 return Ext.create('Docs.view.HoverMenuButton', {
116 cls: 'icon-subclass',
118 store: this.createStore(data)
122 // creates store tha holds link records
123 createStore: function(records) {
124 var store = Ext.create('Ext.data.Store', {
125 fields: ['id', 'cls', 'url', 'label', 'inherited']
131 // Creates link object referencing a class (and optionally a class member)
132 createLinkRecord: function(cls, member) {
135 url: member ? cls+"-"+member.tagname+"-"+member.name : cls,
136 label: member ? member.name : cls,
137 inherited: member ? member.owner !== cls : false
142 * Hides or unhides inherited members.
143 * @param {Boolean} hide
145 hideInherited: function(hide) {
146 Docs.Settings.set("hideInherited", hide);
148 // show/hide all inherited members
149 Ext.Array.forEach(Ext.query('.member.inherited'), function(m) {
150 Ext.get(m).setStyle({display: hide ? 'none' : 'block'});
153 // Remove all first-child classes
154 Ext.Array.forEach(Ext.query('.member.first-child'), function(m) {
155 Ext.get(m).removeCls('first-child');
158 Ext.Array.forEach(['cfg', 'property', 'method', 'event'], function(type) {
159 var sectionId = '#m-' + type;
161 // Hide the section completely if all items in it are inherited
162 if (Ext.query(sectionId+' .member.not-inherited').length === 0) {
163 var section = Ext.query(sectionId)[0];
164 section && Ext.get(section).setStyle({display: hide ? 'none' : 'block'});
167 // add first-child class to first member in section
168 var sectionMembers = Ext.query(sectionId+' .member' + (hide ? ".not-inherited" : ""));
169 if (sectionMembers.length > 0) {
170 Ext.get(sectionMembers[0]).addCls('first-child');
173 if (this.memberButtons[type]) {
174 var store = this.memberButtons[type].getStore();
176 store.filterBy(function(m) { return !m.get("inherited"); });