mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04:00

Currently, ``throwError`` is used for all manner of messages, including errors, "success" messages, and "info" messages. This makes appropriate styling of the error message difficult. In addition, the name ``throwError`` seems to create confusion, implying that an error will actually be thrown (e.g. stopping execution when a user isn't logged in [0][1]), when in fact it just displays a message. Replace ``throwError`` with ``flashMessage``, and reliably include a message "type" (e.g. "error", "success", "info") every time. rename ``lib/errors.js`` to ``lib/messages.js`` to more accurately reflect its function. This commit doesn't rename the message collection (``Errors``), nor the template responsible for rendering the messages (``error_item.html``) -- that should probably still be done, but has higher likelihood of trouble for existing alternate themes and installations. [0]6ccf7d7d47/client/views/users/user_edit.js (L43)
[1]083a4c4dc4/client/views/users/user_email.js (L13)
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
Template[getTemplate('comment_form')].helpers({
|
|
canComment: function(){
|
|
return canComment(Meteor.user());
|
|
}
|
|
});
|
|
|
|
Template[getTemplate('comment_form')].rendered = function(){
|
|
if(Meteor.user() && !this.editor){
|
|
this.editor = new EpicEditor(EpicEditorOptions).load();
|
|
$(this.editor.editor).bind('keydown', 'meta+return', function(){
|
|
$(window.editor).closest('form').find('input[type="submit"]').click();
|
|
});
|
|
}
|
|
};
|
|
|
|
Template[getTemplate('comment_form')].events({
|
|
'submit form': function(e, instance){
|
|
e.preventDefault();
|
|
$(e.target).addClass('disabled');
|
|
clearSeenMessages();
|
|
var content = instance.editor.exportFile();
|
|
if(getCurrentTemplate() == 'comment_reply'){
|
|
// child comment
|
|
var parentComment = this.comment;
|
|
Meteor.call('comment', parentComment.postId, parentComment._id, content, function(error, newComment){
|
|
if(error){
|
|
console.log(error);
|
|
flashMessage(error.reason, "error");
|
|
}else{
|
|
trackEvent("newComment", newComment);
|
|
Router.go('/posts/'+parentComment.postId+'/comment/'+newComment._id);
|
|
}
|
|
});
|
|
}else{
|
|
// root comment
|
|
var post = postObject;
|
|
|
|
Meteor.call('comment', post._id, null, content, function(error, newComment){
|
|
if(error){
|
|
console.log(error);
|
|
flashMessage(error.reason, "error");
|
|
}else{
|
|
trackEvent("newComment", newComment);
|
|
Session.set('scrollToCommentId', newComment._id);
|
|
instance.editor.importFile('editor', '');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|