Loading template/app/CommentSubscriptions.js 0 → 100644 +33 −0 Original line number Diff line number Diff line /** * Manages comment subscriptions. */ Ext.define('Docs.CommentSubscriptions', { /** * Initializes CommentSubscriptions with the list of subscriptions from * comments_meta request result. * * @param {String[][]} subscriptions 2D array like: * * [ * ['class', 'Ext', 'method-foo'], * ['class', 'Ext', 'method-bar'] * ] */ constructor: function(subscriptions) { this.subscriptions = {}; Ext.Array.each(subscriptions, function(r) { this.subscriptions[r.join("__")] = true; }, this); }, /** * True if current user has subscribed to a particular target. * @param {String[]} target * @return {Boolean} */ has: function(target) { return this.subscriptions[target.join("__")]; } }); template/app/Comments.js +9 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Ext.define('Docs.Comments', { requires: [ "Docs.Auth", "Docs.CommentCounts", "Docs.CommentSubscriptions", "Ext.data.JsonP", "Ext.Ajax" ], Loading @@ -30,6 +31,7 @@ Ext.define('Docs.Comments', { this.enabled = true; this.fetchCountsAndSubscriptions(function(counts, subscriptions) { this.counts = new Docs.CommentCounts(counts); this.subscriptions = new Docs.CommentSubscriptions(subscriptions); callback.call(scope); }, this); } Loading Loading @@ -66,6 +68,13 @@ Ext.define('Docs.Comments', { return this.counts.get(type, cls, member); }, /** * @inheritdoc Docs.CommentSubscriptions#has */ hasSubscription: function(target) { return this.subscriptions.has(target); }, /** * @inheritdoc Docs.CommentCounts#getClassTotal */ Loading template/app/view/comments/ListWithForm.js +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ Ext.define('Docs.view.comments.ListWithForm', { this.commentingForm = new Docs.view.comments.Form({ title: this.newCommentTitle, user: Docs.Auth.getUser(), userSubscribed: Docs.Comments.hasSubscription(this.target), listeners: { submit: this.postComment, scope: this Loading Loading
template/app/CommentSubscriptions.js 0 → 100644 +33 −0 Original line number Diff line number Diff line /** * Manages comment subscriptions. */ Ext.define('Docs.CommentSubscriptions', { /** * Initializes CommentSubscriptions with the list of subscriptions from * comments_meta request result. * * @param {String[][]} subscriptions 2D array like: * * [ * ['class', 'Ext', 'method-foo'], * ['class', 'Ext', 'method-bar'] * ] */ constructor: function(subscriptions) { this.subscriptions = {}; Ext.Array.each(subscriptions, function(r) { this.subscriptions[r.join("__")] = true; }, this); }, /** * True if current user has subscribed to a particular target. * @param {String[]} target * @return {Boolean} */ has: function(target) { return this.subscriptions[target.join("__")]; } });
template/app/Comments.js +9 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ Ext.define('Docs.Comments', { requires: [ "Docs.Auth", "Docs.CommentCounts", "Docs.CommentSubscriptions", "Ext.data.JsonP", "Ext.Ajax" ], Loading @@ -30,6 +31,7 @@ Ext.define('Docs.Comments', { this.enabled = true; this.fetchCountsAndSubscriptions(function(counts, subscriptions) { this.counts = new Docs.CommentCounts(counts); this.subscriptions = new Docs.CommentSubscriptions(subscriptions); callback.call(scope); }, this); } Loading Loading @@ -66,6 +68,13 @@ Ext.define('Docs.Comments', { return this.counts.get(type, cls, member); }, /** * @inheritdoc Docs.CommentSubscriptions#has */ hasSubscription: function(target) { return this.subscriptions.has(target); }, /** * @inheritdoc Docs.CommentCounts#getClassTotal */ Loading
template/app/view/comments/ListWithForm.js +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ Ext.define('Docs.view.comments.ListWithForm', { this.commentingForm = new Docs.view.comments.Form({ title: this.newCommentTitle, user: Docs.Auth.getUser(), userSubscribed: Docs.Comments.hasSubscription(this.target), listeners: { submit: this.postComment, scope: this Loading