Vulcan/client/templates/post_page.js

42 lines
1 KiB
JavaScript
Raw Normal View History

(function() {
2012-09-13 10:55:05 +09:00
var editor;
Template.post_page.events = {
'click input[type=submit]': function(e){
e.preventDefault();
2012-09-13 10:55:05 +09:00
var content = editor.exportFile();
2012-09-08 12:11:26 +09:00
var post_id = Session.get('selected_post_id');
var $comment = $('#comment');
2012-09-13 10:55:05 +09:00
var new_comment_id=Meteor.call('comment', post_id, null, content, function(error, result){
$("#"+result).removeClass("queued"); // does not work because new element is not yet in the DOM (probably)
});
$comment.val('');
2012-09-04 11:14:12 +09:00
}
};
Template.post_page.show_comment_form = function(){
return Meteor.user() !== null;
2012-08-31 19:41:54 -04:00
};
Template.post_page.post = function(){
2012-09-05 11:55:06 +09:00
var post = Posts.findOne(Session.get('selected_post_id'));
return post;
2012-08-22 23:40:09 -04:00
};
2012-08-30 21:35:48 -04:00
Template.post_page.body_formatted = function(){
2012-09-08 11:54:08 +09:00
var converter = new Markdown.Converter();
var html_body=converter.makeHtml(this.body);
return html_body.autoLink();
}
Template.post_page.rendered = function(){
t("post_page");
if(Meteor.user()){
editor= new EpicEditor(EpicEditorOptions).load();
}
}
window.newCommentTimestamp=new Date();
})();