diff --git a/client/views/comments/comment_form.js b/client/views/comments/comment_form.js index 2c19cf30e..3375807d6 100644 --- a/client/views/comments/comment_form.js +++ b/client/views/comments/comment_form.js @@ -17,7 +17,11 @@ Template[getTemplate('comment_form')].events({ var $submitButton = instance.$('.btn-submit'); var body = $commentForm.val(); - $submitButton.addClass('loading'); + // now that the form is latency compensated, we don't actually need to show this + // $commentForm.prop('disabled', true); + // $submitButton.addClass('loading'); + + $commentForm.val(''); if(getCurrentTemplate() == 'comment_reply'){ @@ -33,22 +37,14 @@ Template[getTemplate('comment_form')].events({ Meteor.call('submitComment', comment, function(error, newComment){ + $commentForm.prop('disabled', false); $submitButton.removeClass('loading'); if (error) { - console.log(error); flashMessage(error.reason, "error"); - } else { - trackEvent("newComment", newComment); - - Router.go('post_page_comment', { - _id: parentComment.postId, - commentId: newComment._id - }); - } }); @@ -65,20 +61,14 @@ Template[getTemplate('comment_form')].events({ Meteor.call('submitComment', comment, function(error, newComment){ - $commentForm.val(''); - + $commentForm.prop('disabled', false); $submitButton.removeClass('loading'); if(error){ - console.log(error); flashMessage(error.reason, "error"); - }else{ - trackEvent("newComment", newComment); - Session.set('scrollToCommentId', newComment._id); - } }); diff --git a/collections/comments.js b/collections/comments.js index 839927b8b..b2ce359e9 100644 --- a/collections/comments.js +++ b/collections/comments.js @@ -92,8 +92,8 @@ Comments.allow({ // ------------------------------------------------------------------------------------------- // Comments.before.insert(function (userId, doc) { - if(Meteor.isServer) - doc.htmlBody = sanitize(marked(doc.body)); + // note: only actually sanitizes on the server + doc.htmlBody = sanitize(marked(doc.body)); }); Comments.before.update(function (userId, doc, fieldNames, modifier, options) { @@ -131,6 +131,10 @@ commentAfterSubmitMethodCallbacks.push(function (comment) { // ------------------------------------------------------------------------------------------- // submitComment = function (comment) { + console.log(comment) + if (Meteor.isServer) { + Meteor._sleepForMs(4000) + } var userId = comment.userId; // at this stage, a userId is expected diff --git a/packages/telescope-theme-base/lib/client/scss/global/_forms.scss b/packages/telescope-theme-base/lib/client/scss/global/_forms.scss index e0758149a..7f8d2b34d 100644 --- a/packages/telescope-theme-base/lib/client/scss/global/_forms.scss +++ b/packages/telescope-theme-base/lib/client/scss/global/_forms.scss @@ -88,6 +88,10 @@ form, .accounts-dialog{ &[type="number"]{ width: 30%; } + &:disabled{ + background: #eee; + color: $light-text; + } } input[type="text"], input[type="password"], input[type="number"], .login-form input{ height:30px; @@ -120,19 +124,20 @@ input[type="submit"], button, .button, .btn{ font-size:15px; cursor:pointer; margin:0; + color: white; // line-height:26px; // height:26px; font-weight:normal; &.disabled, &.loading{ background:$lighter-grey !important; pointer-events:none; + color: $medium-text; } &.inline{ display: inline-block; } &.btn-primary{ background:$red; - color:white; &:link, &:hover, &:active, &:visited{ color:white; }