Loading template/app/Application.js +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ Ext.define('Docs.Application', { 'Videos', 'Tabs', 'Comments', 'CommentCounts', 'Tests' ], launch: this.launch Loading template/app/CommentCounts.js +14 −7 Original line number Diff line number Diff line Loading @@ -16,15 +16,22 @@ Ext.define('Docs.CommentCounts', { }, /** * Returns comments count for a specific item. * @param {String} type * @param {String} cls * @param {String} member * Returns comments count for a specific target. * @param {String[]} target * @return {Number} */ get: function(type, cls, member) { var key = [type||"", cls||"", member||""].join("__"); return this.counts[key]; get: function(target) { return this.counts[target.join("__")] || 0; }, /** * Changes comment count of a target by the given amount. * @param {String[]} target The target which count to change. * @param {Number} amount Usually +1 or -1. * @return {Number} The resulting total amount of comments. */ change: function(target, amount) { return this.counts[target.join("__")] = this.get(target) + amount; }, /** Loading template/app/Comments.js +18 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ * Provides a way to perform queries to the comments backend. */ Ext.define('Docs.Comments', { extend: 'Ext.util.Observable', singleton: true, requires: [ "Docs.Auth", Loading Loading @@ -96,8 +97,22 @@ Ext.define('Docs.Comments', { /** * @inheritdoc Docs.CommentCounts#get */ getCount: function(type, cls, member) { return this.counts.get(type, cls, member); getCount: function(target) { return this.counts.get(target); }, /** * @inheritdoc Docs.CommentCounts#change */ changeCount: function(target, amount) { var count = this.counts.change(target, amount); /** * @event countChange * Fired when comment count of a target changes. * @param {String[]} target * @param {Number} count */ this.fireEvent("countChange", target, count); }, /** Loading Loading @@ -153,6 +168,7 @@ Ext.define('Docs.Comments', { callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); if (success && data.success) { this.changeCount(target, +1); callback && callback.call(scope, data.comment); } }, Loading template/app/controller/CommentCounts.js 0 → 100644 +26 −0 Original line number Diff line number Diff line /** * Retrieving and posting Comments */ Ext.define('Docs.controller.CommentCounts', { extend: 'Ext.app.Controller', requires: [ "Docs.Comments" ], refs: [ { ref: "classOverview", selector: "classoverview" } ], init: function() { Docs.Comments.on("countChange", this.updateCounts, this); }, updateCounts: function(target, count) { this.getClassOverview().updateCommentCounts(); } }); template/app/model/Comment.js +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ Ext.define('Docs.model.Comment', { success: function() { this.set("deleted", deleted); this.commit(); Docs.Comments.changeCount(this.get("target"), deleted ? -1 : +1); }, scope: this }); Loading Loading
template/app/Application.js +1 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ Ext.define('Docs.Application', { 'Videos', 'Tabs', 'Comments', 'CommentCounts', 'Tests' ], launch: this.launch Loading
template/app/CommentCounts.js +14 −7 Original line number Diff line number Diff line Loading @@ -16,15 +16,22 @@ Ext.define('Docs.CommentCounts', { }, /** * Returns comments count for a specific item. * @param {String} type * @param {String} cls * @param {String} member * Returns comments count for a specific target. * @param {String[]} target * @return {Number} */ get: function(type, cls, member) { var key = [type||"", cls||"", member||""].join("__"); return this.counts[key]; get: function(target) { return this.counts[target.join("__")] || 0; }, /** * Changes comment count of a target by the given amount. * @param {String[]} target The target which count to change. * @param {Number} amount Usually +1 or -1. * @return {Number} The resulting total amount of comments. */ change: function(target, amount) { return this.counts[target.join("__")] = this.get(target) + amount; }, /** Loading
template/app/Comments.js +18 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ * Provides a way to perform queries to the comments backend. */ Ext.define('Docs.Comments', { extend: 'Ext.util.Observable', singleton: true, requires: [ "Docs.Auth", Loading Loading @@ -96,8 +97,22 @@ Ext.define('Docs.Comments', { /** * @inheritdoc Docs.CommentCounts#get */ getCount: function(type, cls, member) { return this.counts.get(type, cls, member); getCount: function(target) { return this.counts.get(target); }, /** * @inheritdoc Docs.CommentCounts#change */ changeCount: function(target, amount) { var count = this.counts.change(target, amount); /** * @event countChange * Fired when comment count of a target changes. * @param {String[]} target * @param {Number} count */ this.fireEvent("countChange", target, count); }, /** Loading Loading @@ -153,6 +168,7 @@ Ext.define('Docs.Comments', { callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); if (success && data.success) { this.changeCount(target, +1); callback && callback.call(scope, data.comment); } }, Loading
template/app/controller/CommentCounts.js 0 → 100644 +26 −0 Original line number Diff line number Diff line /** * Retrieving and posting Comments */ Ext.define('Docs.controller.CommentCounts', { extend: 'Ext.app.Controller', requires: [ "Docs.Comments" ], refs: [ { ref: "classOverview", selector: "classoverview" } ], init: function() { Docs.Comments.on("countChange", this.updateCounts, this); }, updateCounts: function(target, count) { this.getClassOverview().updateCommentCounts(); } });
template/app/model/Comment.js +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ Ext.define('Docs.model.Comment', { success: function() { this.set("deleted", deleted); this.commit(); Docs.Comments.changeCount(this.get("target"), deleted ? -1 : +1); }, scope: this }); Loading