Loading template/app/controller/Comments.js +12 −6 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ */ Ext.define('Docs.controller.Comments', { extend: 'Docs.controller.Content', baseUrl: '#!/comments', baseUrl: '#!/comment', title: 'Comments', mixins: { Loading Loading @@ -56,9 +56,11 @@ Ext.define('Docs.controller.Comments', { }, loggedIn: function() { Docs.view.Comments.renderNewCommentForms(); this.isMod() && this.getController("Tabs").showCommentsTab(); }, loggedOut: function() { Docs.view.Comments.renderNewCommentForms(); this.getController("Tabs").hideCommentsTab(); }, scope: this }); Loading Loading @@ -119,7 +121,7 @@ Ext.define('Docs.controller.Comments', { 'classoverview toolbar': { afterrender: function(cmp) { cmp.el.addListener('click', function() { var commentsDiv = Ext.get(Ext.query('#m-comment .comments')[0]); var commentsDiv = Ext.get(Ext.query('#m-comment .comments-div')[0]); this.getOverview().scrollToEl('#m-comment', -20); this.openComments(commentsDiv); }, this, { Loading @@ -130,6 +132,10 @@ Ext.define('Docs.controller.Comments', { }); }, isMod: function() { return this.getController('Auth').currentUser.mod; }, enableComments: function() { if (!this.commentsEnabled) { this.commentsEnabled = true; Loading Loading @@ -174,7 +180,7 @@ Ext.define('Docs.controller.Comments', { } var postButton = Ext.get(el), comments = postButton.up('.comments'), comments = postButton.up('.comments-div'), id = comments.getAttribute('id'), target = Ext.JSON.encode(this.commentId(id)), textarea = comments.down('textarea').dom, Loading Loading @@ -311,7 +317,7 @@ Ext.define('Docs.controller.Comments', { */ deleteComment: function(cmp, el) { var id = Ext.get(el).up('.comment').getAttribute('id'), commentsEl = Ext.get(el).up('.comments'), commentsEl = Ext.get(el).up('.comments-div'), cls = commentsEl && commentsEl.getAttribute('id'); Ext.Ajax.request({ Loading Loading @@ -459,7 +465,7 @@ Ext.define('Docs.controller.Comments', { }, toggleComments: function(cmp, el) { var commentsDiv = Ext.get(el).up('.comments'); var commentsDiv = Ext.get(el).up('.comments-div'); if (commentsDiv.hasCls('open')) { this.closeComments(commentsDiv); Loading Loading @@ -500,7 +506,7 @@ Ext.define('Docs.controller.Comments', { showMemberComments: function(cml, el) { var member = Ext.get(el).up('.member'), commentsDiv = member.down('.comments'); commentsDiv = member.down('.comments-div'); member.addCls('open'); this.openComments(commentsDiv); Loading template/app/controller/Tabs.js +24 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,10 @@ Ext.define('Docs.controller.Tabs', { ref: 'exampleIndex', selector: '#exampleindex' }, { ref: 'commentIndex', selector: '#commentindex' }, { ref: 'classTree', selector: '#classtree' Loading Loading @@ -118,6 +122,10 @@ Ext.define('Docs.controller.Tabs', { this.getExampleIndex().getTab() ], function(x){return x;})); // just initialize the comments tab. // show/hide of it is performed separately. this.commentsTab = this.getCommentIndex().getTab(); var tabs = Docs.Settings.get('tabs'); if (tabs) { Ext.Array.forEach(tabs, function(url) { Loading @@ -127,6 +135,22 @@ Ext.define('Docs.controller.Tabs', { Docs.History.notifyTabsLoaded(); }, /** * Makes comments tab visible. */ showCommentsTab: function() { var tabs = this.getDoctabs().getStaticTabs(); this.getDoctabs().setStaticTabs(tabs.concat(this.commentsTab)); }, /** * Hides comments tab. */ hideCommentsTab: function() { var tabs = this.getDoctabs().getStaticTabs(); this.getDoctabs().setStaticTabs(Ext.Array.remove(tabs, this.commentsTab)); }, /** * Adds a tab based on information from the class tree * @param {String} url The url of the record in the tree Loading template/app/view/Comments.js +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ Ext.define('Docs.view.Comments', { ); var commentsMeta = [ '<div class="comments first-child" id="comments-{id}">', '<div class="comments-div first-child" id="comments-{id}">', '<a href="#" class="side toggleComments"><span></span></a>', '<a href="#" class="name toggleComments">', numComments.join(''), '</a>', '</div>' Loading Loading @@ -358,7 +358,7 @@ Ext.define('Docs.view.Comments', { var memberEl = Ext.get(memberDom), memberId = memberEl.getAttribute('id'), memberCls = memberEl.down('.meta .defined-in').getAttribute('rel'), commentsWrap = memberEl.down('.comments a.name'), commentsWrap = memberEl.down('.comments-div a.name'), memberTitle = memberEl.down('.title'), numComments = Docs.commentMeta['class'][memberCls] && Docs.commentMeta['class'][memberCls][memberId], memberTitleComments = memberTitle.down('.toggleMemberComments'); Loading template/app/view/Tabs.js +11 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,14 @@ Ext.define('Docs.view.Tabs', { this.refresh(); }, /** * Returns array of static tab configs. * @return {Object[]} See {@link #setStaticTabs} for details. */ getStaticTabs: function(tab) { return this.staticTabs; }, /** * Adds a new tab * Loading Loading @@ -484,6 +492,9 @@ Ext.define('Docs.view.Tabs', { else if (/#!?\/example/.test(url)) { return 'Examples'; } else if (/#!?\/comment/.test(url)) { return 'Comments'; } else { return 'Index'; } Loading template/app/view/comments/Index.js +9 −1 Original line number Diff line number Diff line Loading @@ -12,5 +12,13 @@ Ext.define('Docs.view.comments.Index', { items: [ { xtype: 'container', html: '<h1>Recent Comments</h1>' }, { xtype: 'container', id: 'recentcomments' } ] ], /** * Returns tab config for comments page. * @return {Object} */ getTab: function() { return Docs.enableComments ? {cls: 'comments', href: '#!/comment', tooltip: 'Comments'} : false; } }); Loading
template/app/controller/Comments.js +12 −6 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ */ Ext.define('Docs.controller.Comments', { extend: 'Docs.controller.Content', baseUrl: '#!/comments', baseUrl: '#!/comment', title: 'Comments', mixins: { Loading Loading @@ -56,9 +56,11 @@ Ext.define('Docs.controller.Comments', { }, loggedIn: function() { Docs.view.Comments.renderNewCommentForms(); this.isMod() && this.getController("Tabs").showCommentsTab(); }, loggedOut: function() { Docs.view.Comments.renderNewCommentForms(); this.getController("Tabs").hideCommentsTab(); }, scope: this }); Loading Loading @@ -119,7 +121,7 @@ Ext.define('Docs.controller.Comments', { 'classoverview toolbar': { afterrender: function(cmp) { cmp.el.addListener('click', function() { var commentsDiv = Ext.get(Ext.query('#m-comment .comments')[0]); var commentsDiv = Ext.get(Ext.query('#m-comment .comments-div')[0]); this.getOverview().scrollToEl('#m-comment', -20); this.openComments(commentsDiv); }, this, { Loading @@ -130,6 +132,10 @@ Ext.define('Docs.controller.Comments', { }); }, isMod: function() { return this.getController('Auth').currentUser.mod; }, enableComments: function() { if (!this.commentsEnabled) { this.commentsEnabled = true; Loading Loading @@ -174,7 +180,7 @@ Ext.define('Docs.controller.Comments', { } var postButton = Ext.get(el), comments = postButton.up('.comments'), comments = postButton.up('.comments-div'), id = comments.getAttribute('id'), target = Ext.JSON.encode(this.commentId(id)), textarea = comments.down('textarea').dom, Loading Loading @@ -311,7 +317,7 @@ Ext.define('Docs.controller.Comments', { */ deleteComment: function(cmp, el) { var id = Ext.get(el).up('.comment').getAttribute('id'), commentsEl = Ext.get(el).up('.comments'), commentsEl = Ext.get(el).up('.comments-div'), cls = commentsEl && commentsEl.getAttribute('id'); Ext.Ajax.request({ Loading Loading @@ -459,7 +465,7 @@ Ext.define('Docs.controller.Comments', { }, toggleComments: function(cmp, el) { var commentsDiv = Ext.get(el).up('.comments'); var commentsDiv = Ext.get(el).up('.comments-div'); if (commentsDiv.hasCls('open')) { this.closeComments(commentsDiv); Loading Loading @@ -500,7 +506,7 @@ Ext.define('Docs.controller.Comments', { showMemberComments: function(cml, el) { var member = Ext.get(el).up('.member'), commentsDiv = member.down('.comments'); commentsDiv = member.down('.comments-div'); member.addCls('open'); this.openComments(commentsDiv); Loading
template/app/controller/Tabs.js +24 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,10 @@ Ext.define('Docs.controller.Tabs', { ref: 'exampleIndex', selector: '#exampleindex' }, { ref: 'commentIndex', selector: '#commentindex' }, { ref: 'classTree', selector: '#classtree' Loading Loading @@ -118,6 +122,10 @@ Ext.define('Docs.controller.Tabs', { this.getExampleIndex().getTab() ], function(x){return x;})); // just initialize the comments tab. // show/hide of it is performed separately. this.commentsTab = this.getCommentIndex().getTab(); var tabs = Docs.Settings.get('tabs'); if (tabs) { Ext.Array.forEach(tabs, function(url) { Loading @@ -127,6 +135,22 @@ Ext.define('Docs.controller.Tabs', { Docs.History.notifyTabsLoaded(); }, /** * Makes comments tab visible. */ showCommentsTab: function() { var tabs = this.getDoctabs().getStaticTabs(); this.getDoctabs().setStaticTabs(tabs.concat(this.commentsTab)); }, /** * Hides comments tab. */ hideCommentsTab: function() { var tabs = this.getDoctabs().getStaticTabs(); this.getDoctabs().setStaticTabs(Ext.Array.remove(tabs, this.commentsTab)); }, /** * Adds a tab based on information from the class tree * @param {String} url The url of the record in the tree Loading
template/app/view/Comments.js +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ Ext.define('Docs.view.Comments', { ); var commentsMeta = [ '<div class="comments first-child" id="comments-{id}">', '<div class="comments-div first-child" id="comments-{id}">', '<a href="#" class="side toggleComments"><span></span></a>', '<a href="#" class="name toggleComments">', numComments.join(''), '</a>', '</div>' Loading Loading @@ -358,7 +358,7 @@ Ext.define('Docs.view.Comments', { var memberEl = Ext.get(memberDom), memberId = memberEl.getAttribute('id'), memberCls = memberEl.down('.meta .defined-in').getAttribute('rel'), commentsWrap = memberEl.down('.comments a.name'), commentsWrap = memberEl.down('.comments-div a.name'), memberTitle = memberEl.down('.title'), numComments = Docs.commentMeta['class'][memberCls] && Docs.commentMeta['class'][memberCls][memberId], memberTitleComments = memberTitle.down('.toggleMemberComments'); Loading
template/app/view/Tabs.js +11 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,14 @@ Ext.define('Docs.view.Tabs', { this.refresh(); }, /** * Returns array of static tab configs. * @return {Object[]} See {@link #setStaticTabs} for details. */ getStaticTabs: function(tab) { return this.staticTabs; }, /** * Adds a new tab * Loading Loading @@ -484,6 +492,9 @@ Ext.define('Docs.view.Tabs', { else if (/#!?\/example/.test(url)) { return 'Examples'; } else if (/#!?\/comment/.test(url)) { return 'Comments'; } else { return 'Index'; } Loading
template/app/view/comments/Index.js +9 −1 Original line number Diff line number Diff line Loading @@ -12,5 +12,13 @@ Ext.define('Docs.view.comments.Index', { items: [ { xtype: 'container', html: '<h1>Recent Comments</h1>' }, { xtype: 'container', id: 'recentcomments' } ] ], /** * Returns tab config for comments page. * @return {Object} */ getTab: function() { return Docs.enableComments ? {cls: 'comments', href: '#!/comment', tooltip: 'Comments'} : false; } });