mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00

Using {{pathFor}}, path(), and url() where possible. Passing in path to Meteor.absoluteUrl() where the IronRouter functions didn't make sense. Also deleting some random unused code.
45 lines
No EOL
1.3 KiB
JavaScript
45 lines
No EOL
1.3 KiB
JavaScript
Template[getTemplate('comment_edit')].rendered = function(){
|
|
if(this.data){ // XXX
|
|
var comment = this.data.comment;
|
|
|
|
if(comment && Meteor.user() && !this.editor){
|
|
this.editor = new EpicEditor(EpicEditorOptions).load();
|
|
this.editor.importFile('editor', comment.body);
|
|
$(this.editor.editor).bind('keydown', 'meta+return', function(){
|
|
$(window.editor).closest('form').find('input[type="submit"]').click();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
Template[getTemplate('comment_edit')].events({
|
|
'click input[type=submit]': function(e, instance){
|
|
var comment = this;
|
|
var content = cleanUp(instance.editor.exportFile());
|
|
|
|
e.preventDefault();
|
|
|
|
if(!Meteor.user())
|
|
throw i18n.t('you_must_be_logged_in');
|
|
|
|
Comments.update(comment._id, {
|
|
$set: {
|
|
body: content
|
|
}
|
|
});
|
|
|
|
trackEvent("edit comment", {'postId': comment.postId, 'commentId': comment._id});
|
|
Router.go('post_page_comment', {_id: comment.postId, commentId: comment._id});
|
|
},
|
|
'click .delete-link': function(e){
|
|
var comment = this;
|
|
|
|
e.preventDefault();
|
|
|
|
if(confirm(i18n.t("are_you_sure"))){
|
|
Meteor.call('removeComment', comment._id);
|
|
Router.go('post_page', {_id: comment.postId});
|
|
throwError("Your comment has been deleted.");
|
|
}
|
|
}
|
|
}); |