work on comments

This commit is contained in:
albert
2010-10-20 19:24:53 -04:00
parent d7eafdaaf5
commit f8b1bd3142
15 changed files with 184 additions and 44 deletions

View File

@@ -0,0 +1,42 @@
(function() {
Danbooru.Comment = {};
Danbooru.Comment.initialize_all = function() {
this.initialize_response_link();
this.initialize_preview_button();
}
Danbooru.Comment.initialize_response_link = function() {
$("a.expand-comment-response").click(function(e) {
e.stopPropagation();
$(e.target).closest("div.new-comment").find("form").show();
$(e.target).hide();
return false;
});
$("div.new-comment form").hide();
}
Danbooru.Comment.initialize_preview_button = function() {
$("div.new-comment input[type=submit][value=Preview]").click(function(e) {
e.stopPropagation();
$.ajax({
context: e.target,
url: "/dtext/preview",
data: {
body: $(e.target).closest("form").find("textarea").val()
},
success: function(data, text_status, xhr) {
console.log($(this).closest("div.new-comment").find("div.comment-preview"));
$(this).closest("div.new-comment").find("div.comment-preview").show().html(data);
},
type: "post"
});
return false;
});
}
})();
$(document).ready(function() {
Danbooru.Comment.initialize_all();
});

View File

@@ -174,10 +174,12 @@
Danbooru.Post.initialize_tag_list = function() {
$("#tag-box a.search-inc-tag").click(function(e) {
$("#tags").val($("#tags").val() + " " + $(e.target).parent("li").attr("data-tag-name"));
return false;
});
$("#tag-box a.search-exl-tag").click(function(e) {
$("#tags").val($("#tags").val() + " -" + $(e.target).parent("li").attr("data-tag-name"));
return false;
});
}
@@ -189,6 +191,7 @@
var name = e.target.hash;
$(name).show();
e.stopPropagation();
return false;
});
$("#tag-and-wiki-box menu li:first-child").addClass("active");
@@ -205,6 +208,7 @@
var name = e.target.hash;
$(name).show();
e.stopPropagation();
return false;
});
$("#post-sections li:first-child").addClass("active");