diff --git a/template/app/controller/Auth.js b/template/app/controller/Auth.js index 4da45fe9206a6f40c48ec5b8ba45607b9d9cb8a5..38f8365a466b80bc6c917d2d676f3450c0c84ce7 100644 --- a/template/app/controller/Auth.js +++ b/template/app/controller/Auth.js @@ -1,17 +1,19 @@ +/** + * Authentication controller. + */ Ext.define('Docs.controller.Auth', { extend: 'Ext.app.Controller', requires: ['Ext.util.Cookies'], refs: [ - { + { ref: 'auth', selector: 'authentication' } ], init: function() { - this.sid = Ext.util.Cookies.get('sid'); this.addEvents( @@ -65,7 +67,6 @@ Ext.define('Docs.controller.Auth', { * Checks if a user is logged in server side and sets up a local session if they are. */ getSession: function() { - if (!Docs.enableComments) { return; } @@ -98,7 +99,6 @@ Ext.define('Docs.controller.Auth', { * @param {Ext.Element} submitEl */ login: function(username, password, remember, submitEl) { - Ext.Ajax.request({ url: Docs.baseUrl + '/login', method: 'POST', @@ -162,7 +162,7 @@ Ext.define('Docs.controller.Auth', { */ loggedOut: function(user) { this.currentUser = {}; - this.setSid(null) + this.setSid(null); this.getAuth().showLoggedOut(); this.fireEvent('loggedOut'); }, @@ -189,7 +189,7 @@ Ext.define('Docs.controller.Auth', { username = form.down('input[name=username]').getValue(), password = form.down('input[name=password]').getValue(), rememberEl = form.down('input[name=remember]'), - submitEl = form.down('input[type=submit]') + submitEl = form.down('input[type=submit]'); var remember = rememberEl ? Boolean(rememberEl.getAttribute('checked')) : false; diff --git a/template/app/controller/AuthHelpers.js b/template/app/controller/AuthHelpers.js index 49256542c60f5fa1eda61828e8467e646e4e43c3..910dcdba06a23055fd429f2497a33097a9f80c59 100644 --- a/template/app/controller/AuthHelpers.js +++ b/template/app/controller/AuthHelpers.js @@ -1,3 +1,6 @@ +/** + * A mixin for Comments controller to help with authentication. + */ Ext.define('Docs.controller.AuthHelpers', { addSid: function(url) { @@ -8,4 +11,4 @@ Ext.define('Docs.controller.AuthHelpers', { loggedIn: function() { return this.getController('Auth').isLoggedIn(); } -}); \ No newline at end of file +}); diff --git a/template/app/controller/Comments.js b/template/app/controller/Comments.js index 92daf55705b62ae50308da2c513d19659cc6d791..e355063278e5663e55f7dab7e4a7a2128aa7df83 100644 --- a/template/app/controller/Comments.js +++ b/template/app/controller/Comments.js @@ -26,16 +26,17 @@ Ext.define('Docs.controller.Comments', { ], init: function() { - this.addEvents( /** - * @event add Fired after a comment is added + * @event add + * Fired after a comment is added * @param {String} key Key of the comment */ 'add', /** - * @event remove Fired after a comment is removed + * @event remove + * Fired after a comment is removed * @param {String} key Key of the comment */ 'remove' @@ -121,7 +122,6 @@ Ext.define('Docs.controller.Comments', { }, fetchComments: function(id, callback, opts) { - var startkey = Ext.JSON.encode(this.commentId(id)), endkey = Ext.JSON.encode(this.commentId(id).concat([{}])), currentUser = this.getController('Auth').currentUser, @@ -144,7 +144,6 @@ Ext.define('Docs.controller.Comments', { }, postComment: function(cmp, el) { - if (!this.loggedIn()) { return false; } @@ -214,7 +213,6 @@ Ext.define('Docs.controller.Comments', { * Fetches the most recent comments */ fetchRecentComments: function(id) { - var url = Docs.baseUrl + '/' + Docs.commentsDb + '/_design/Comments/_list/with_vote/by_date'; Ext.data.JsonP.request({ @@ -236,7 +234,6 @@ Ext.define('Docs.controller.Comments', { * if the user confirms. */ promptDeleteComment: function(cmp, el) { - if (!this.loggedIn()) { return false; } @@ -259,7 +256,6 @@ Ext.define('Docs.controller.Comments', { * Sends a delete comment request to the server. */ deleteComment: function(cmp, el) { - var id = Ext.get(el).up('.comment').getAttribute('id'), commentsEl = Ext.get(el).up('.comments'), cls = commentsEl && commentsEl.getAttribute('id'); @@ -295,7 +291,6 @@ Ext.define('Docs.controller.Comments', { callback: function(options, success, response) { var data = Ext.JSON.decode(response.responseText); if (data.success) { - contentEl.dom.origContent = contentEl.dom.innerHTML; var commentData = Ext.merge(Ext.clone(currentUser), { @@ -314,7 +309,6 @@ Ext.define('Docs.controller.Comments', { }, updateComment: function(cmp, el) { - if (!this.loggedIn()) { return false; } @@ -370,7 +364,6 @@ Ext.define('Docs.controller.Comments', { * @private */ vote: function(direction, el) { - if (!this.loggedIn()) { this.showError('Please login to vote on this comment', el); return false; @@ -410,7 +403,6 @@ Ext.define('Docs.controller.Comments', { }, toggleComments: function(cmp, el) { - var commentsDiv = Ext.get(el).up('.comments'); if (commentsDiv.hasCls('open')) { @@ -421,7 +413,6 @@ Ext.define('Docs.controller.Comments', { }, openComments: function(commentsDiv) { - if (commentsDiv.hasCls('open')) return; var commentNum = commentsDiv.down('.name'), @@ -439,7 +430,6 @@ Ext.define('Docs.controller.Comments', { }, closeComments: function(commentsDiv) { - if (!commentsDiv.hasCls('open')) return; var commentNum = commentsDiv.down('.name'), @@ -467,7 +457,6 @@ Ext.define('Docs.controller.Comments', { }, renderComments: function(rows, id, opts) { - opts = opts || {}; var comments = Ext.get(id), @@ -487,7 +476,6 @@ Ext.define('Docs.controller.Comments', { if (opts.hideCommentForm) { comments.addCls('hideCommentForm'); } else if (!comments.hasCls('hideCommentForm')) { - var commentWrap = comments.down('.new-comment-wrap'); if (this.loggedIn()) { var wrap = Docs.view.Comments.loggedInCommentTpl.overwrite(commentWrap, this.getController('Auth').currentUser, true); @@ -527,7 +515,7 @@ Ext.define('Docs.controller.Comments', { data = row.value; data.id = opts.id; } - }) + }); } else { data = rows[rows.length - 1].value; data.id = rows[rows.length - 1].id; @@ -556,7 +544,6 @@ Ext.define('Docs.controller.Comments', { }, showError: function(msg, el) { - if (this.errorTip) { this.errorTip.update(msg); this.errorTip.setTarget(el); @@ -570,4 +557,4 @@ Ext.define('Docs.controller.Comments', { this.errorTip.show(); } } -}); \ No newline at end of file +}); diff --git a/template/app/controller/CommentsMeta.js b/template/app/controller/CommentsMeta.js index 4770d2a3e9aba2653e2ef5909f1e683331e4c984..08a2d118d4de175d2936fb95d53bcc7994d16786 100644 --- a/template/app/controller/CommentsMeta.js +++ b/template/app/controller/CommentsMeta.js @@ -21,7 +21,6 @@ Ext.define('Docs.controller.CommentsMeta', { ], init: function() { - Docs.commentMeta = { idMap: {}, 'class': {} @@ -83,7 +82,6 @@ Ext.define('Docs.controller.CommentsMeta', { group_level: 3 }, success: function(response) { - Ext.Array.each(response.rows, function(r) { this.updateMeta(r.key, r.value.num); }, this); @@ -97,7 +95,6 @@ Ext.define('Docs.controller.CommentsMeta', { }, // updateVoteMeta: function() { - // // var id = Docs.App.getController('Classes').currentCls.name, // startkey = Ext.JSON.encode(['class',id]), // endkey = Ext.JSON.encode(['class',id,{}]), @@ -123,7 +120,6 @@ Ext.define('Docs.controller.CommentsMeta', { // }, fetchCommentLeaders: function() { - Ext.data.JsonP.request({ url: Docs.baseUrl + '/' + Docs.commentsDb + '/_design/Comments/_view/by_author', method: 'GET', @@ -134,7 +130,6 @@ Ext.define('Docs.controller.CommentsMeta', { limit: 10 }, success: function(response) { - var tpl = Ext.create('Ext.XTemplate', '