mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -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)
26 lines
689 B
JavaScript
26 lines
689 B
JavaScript
Template[getTemplate('postUpvote')].helpers({
|
|
upvoted: function(){
|
|
var user = Meteor.user();
|
|
if(!user) return false;
|
|
return _.include(this.upvoters, user._id);
|
|
},
|
|
oneBasedRank: function(){
|
|
if(typeof this.rank !== 'undefined')
|
|
return this.rank + 1;
|
|
}
|
|
});
|
|
|
|
Template[getTemplate('postUpvote')].events({
|
|
'click .upvote-link': function(e, instance){
|
|
var post = this;
|
|
e.preventDefault();
|
|
if(!Meteor.user()){
|
|
Router.go(getSigninUrl());
|
|
flashMessage(i18n.t("Please log in first"), "info");
|
|
return;
|
|
}
|
|
Meteor.call('upvotePost', post, function(error, result){
|
|
trackEvent("post upvoted", {'_id': post._id});
|
|
});
|
|
}
|
|
});
|