work on comments
This commit is contained in:
@@ -991,10 +991,12 @@ var Danbooru = {};
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1006,6 +1008,7 @@ var Danbooru = {};
|
||||
var name = e.target.hash;
|
||||
$(name).show();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#tag-and-wiki-box menu li:first-child").addClass("active");
|
||||
@@ -1022,6 +1025,7 @@ var Danbooru = {};
|
||||
var name = e.target.hash;
|
||||
$(name).show();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#post-sections li:first-child").addClass("active");
|
||||
@@ -1036,6 +1040,48 @@ $(document).ready(function() {
|
||||
|
||||
Danbooru.Post.initialize_all();
|
||||
});
|
||||
(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();
|
||||
});
|
||||
$(document).ready(function() {
|
||||
var img = $("#image-preview img");
|
||||
if (img) {
|
||||
|
||||
42
public/javascripts/src/app/comments.js
Normal file
42
public/javascripts/src/app/comments.js
Normal 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();
|
||||
});
|
||||
@@ -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");
|
||||
|
||||
@@ -205,6 +205,24 @@ form.simple_form div.input {
|
||||
width: auto;
|
||||
margin-right: 2em; }
|
||||
|
||||
/*** DText Preview ***/
|
||||
div.dtext p {
|
||||
margin-bottom: 1em; }
|
||||
|
||||
/*** Comments ***/
|
||||
div.comments-for-post div.list-of-comments article {
|
||||
margin-bottom: 2em; }
|
||||
div.comments-for-post div.list-of-comments article div.author {
|
||||
width: 20%;
|
||||
float: left; }
|
||||
div.comments-for-post div.list-of-comments article div.content {
|
||||
margin-left: 2em;
|
||||
width: 40em;
|
||||
float: left; }
|
||||
div.comments-for-post div.comment-preview {
|
||||
width: 40em;
|
||||
margin-bottom: 2em; }
|
||||
|
||||
/*** Posts ***/
|
||||
div.posts h1 {
|
||||
font-size: 1.2em; }
|
||||
|
||||
@@ -285,6 +285,42 @@ form.simple_form {
|
||||
}
|
||||
|
||||
|
||||
/*** DText Preview ***/
|
||||
|
||||
div.dtext {
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Comments ***/
|
||||
|
||||
div.comments-for-post {
|
||||
div.list-of-comments {
|
||||
article {
|
||||
margin-bottom: 2em;
|
||||
|
||||
div.author {
|
||||
width: 20%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.content {
|
||||
margin-left: 2em;
|
||||
width: 40em;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.comment-preview {
|
||||
width: 40em;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Posts ***/
|
||||
|
||||
div.posts {
|
||||
@@ -363,7 +399,6 @@ div.posts {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** Comments ***/
|
||||
div.comment-response {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user