2012-09-09 13:38:56 +09:00
|
|
|
(function() {
|
2012-09-13 10:55:05 +09:00
|
|
|
|
|
|
|
var editor;
|
|
|
|
|
2012-09-06 10:14:03 +09:00
|
|
|
Template.post_page.events = {
|
2012-09-04 18:57:07 +09:00
|
|
|
'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');
|
2012-09-04 18:57:07 +09:00
|
|
|
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){
|
2012-09-10 18:12:04 +09:00
|
|
|
$("#"+result).removeClass("queued"); // does not work because new element is not yet in the DOM (probably)
|
|
|
|
});
|
2012-09-04 18:57:07 +09:00
|
|
|
$comment.val('');
|
2012-09-04 11:14:12 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-09-06 10:14:03 +09:00
|
|
|
Template.post_page.show_comment_form = function(){
|
2012-09-04 18:57:07 +09:00
|
|
|
return Meteor.user() !== null;
|
2012-08-31 19:41:54 -04:00
|
|
|
};
|
|
|
|
|
2012-09-06 10:14:03 +09:00
|
|
|
Template.post_page.post = function(){
|
2012-09-05 11:55:06 +09:00
|
|
|
var post = Posts.findOne(Session.get('selected_post_id'));
|
2012-09-04 18:57:07 +09:00
|
|
|
return post;
|
2012-08-22 23:40:09 -04:00
|
|
|
};
|
2012-08-30 21:35:48 -04:00
|
|
|
|
2012-09-08 10:23:58 +09: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();
|
2012-09-09 13:38:56 +09:00
|
|
|
}
|
|
|
|
|
2012-09-11 11:09:16 +09:00
|
|
|
Template.post_page.rendered = function(){
|
|
|
|
t("post_page");
|
2012-09-18 08:09:47 +09:00
|
|
|
if(Meteor.user()){
|
|
|
|
editor= new EpicEditor(EpicEditorOptions).load();
|
|
|
|
}
|
2012-09-11 11:09:16 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
window.newCommentTimestamp=new Date();
|
|
|
|
|
2012-09-09 13:38:56 +09:00
|
|
|
})();
|