work
This commit is contained in:
@@ -3,7 +3,7 @@ Danbooru.Note = {
|
||||
create: function(id) {
|
||||
var $inner_border = $('<div/>');
|
||||
$inner_border.addClass("note-box-inner-border");
|
||||
$inner_border.css({opacity: 0.7});
|
||||
$inner_border.css({opacity: 0.5});
|
||||
|
||||
var $note_box = $('<div/>');
|
||||
$note_box.addClass("note-box");
|
||||
@@ -63,6 +63,10 @@ Danbooru.Note = {
|
||||
);
|
||||
},
|
||||
|
||||
find: function(id) {
|
||||
return $("#note-container div.note-box[data-id=" + id + "]");
|
||||
},
|
||||
|
||||
resize_inner_border: function($note_box) {
|
||||
var $inner_border = $note_box.find("div.note-box-inner-border");
|
||||
$inner_border.css({
|
||||
@@ -124,7 +128,7 @@ Danbooru.Note = {
|
||||
},
|
||||
|
||||
initialize: function($note_body) {
|
||||
var $note_box = $("#note-container div.note-box[data-id=" + $note_body.data("id") + "]");
|
||||
var $note_box = Danbooru.Note.Box.find($note_body.data("id"));
|
||||
$note_body.css({
|
||||
top: $note_box.position().top + $note_box.height() + 5,
|
||||
left: $note_box.position().left
|
||||
@@ -149,18 +153,22 @@ Danbooru.Note = {
|
||||
|
||||
Danbooru.Note.Body.hide_all();
|
||||
Danbooru.Note.clear_timeouts();
|
||||
var $note_body = $("#note-container div.note-body[data-id=" + id + "]");
|
||||
var $note_body = Danbooru.Note.Body.find(id);
|
||||
$note_body.show();
|
||||
Danbooru.Note.Body.initialize($note_body);
|
||||
},
|
||||
|
||||
find: function(id) {
|
||||
return $("#note-container div.note-body[data-id=" + id + "]");
|
||||
},
|
||||
|
||||
hide: function(id) {
|
||||
var $note_body = $("#note-container div.note-body[data-id=" + id + "]");
|
||||
var $note_body = Danbooru.Note.Body.find(id);
|
||||
Danbooru.Note.timeouts.push($.timeout(250).done(function() {$note_body.hide();}));
|
||||
},
|
||||
|
||||
hide_all: function() {
|
||||
$(".note-body").hide();
|
||||
$("#note-container div.note-body").hide();
|
||||
},
|
||||
|
||||
resize: function($note_body) {
|
||||
@@ -250,17 +258,64 @@ Danbooru.Note = {
|
||||
Danbooru.Note.editing = true;
|
||||
},
|
||||
|
||||
parameterize_note: function($note_box, $note_body) {
|
||||
var hash = {
|
||||
note: {
|
||||
x: $note_box.position().left,
|
||||
y: $note_box.position().top,
|
||||
width: $note_box.width(),
|
||||
height: $note_box.height(),
|
||||
body: $note_body.html(),
|
||||
post_id: Danbooru.meta("post-id")
|
||||
}
|
||||
}
|
||||
|
||||
if ($note_box.data("id").match(/x/)) {
|
||||
hash.note.html_id = $note_box.data("id");
|
||||
}
|
||||
|
||||
return hash;
|
||||
},
|
||||
|
||||
error_handler: function(xhr, status, exception) {
|
||||
Danbooru.j_error("There was an error saving the note");
|
||||
},
|
||||
|
||||
success_handler: function(data, status, xhr) {
|
||||
if (data.html_id) {
|
||||
var $note_body = Danbooru.Note.Body.find(data.html_id);
|
||||
var $note_box = Danbooru.Note.Box.find(data.html_id);
|
||||
$note_body.data("id", data.id).attr("data-id", data.id);
|
||||
$note_box.data("id", data.id).attr("data-id", data.id);
|
||||
$note_box.find(".note-box-inner-border").removeClass("unsaved");
|
||||
}
|
||||
},
|
||||
|
||||
save: function() {
|
||||
var $this = $(this);
|
||||
var $textarea = $this.find("textarea");
|
||||
var id = $this.data("id");
|
||||
var $note_body = $("#note-container .note-body[data-id=" + id + "]");
|
||||
var $note_box = $("#note-container .note-box[data-id=" + id + "]");
|
||||
var $note_body = Danbooru.Note.Body.find(id);
|
||||
var $note_box = Danbooru.Note.Box.find(id);
|
||||
var text = $textarea.val();
|
||||
Danbooru.Note.Body.set_text($note_body, text);
|
||||
$this.dialog("close");
|
||||
$note_box.find(".note-box-inner-border").removeClass("unsaved");
|
||||
console.log("save %d", id);
|
||||
|
||||
if (id.match(/\d/)) {
|
||||
$.ajax("/notes/" + id + ".json", {
|
||||
type: "PUT",
|
||||
data: Danbooru.Note.Edit.parameterize_note($note_box, $note_body),
|
||||
error: Danbooru.Note.Edit.error_handler,
|
||||
success: Danbooru.Note.Edit.success_handler
|
||||
});
|
||||
} else {
|
||||
$.ajax("/notes.json", {
|
||||
type: "POST",
|
||||
data: Danbooru.Note.Edit.parameterize_note($note_box, $note_body),
|
||||
error: Danbooru.Note.Edit.error_handler,
|
||||
success: Danbooru.Note.Edit.success_handler
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
@@ -270,29 +325,37 @@ Danbooru.Note = {
|
||||
delete: function() {
|
||||
var $this = $(this);
|
||||
var id = $this.data("id");
|
||||
console.log("delete %d", id);
|
||||
$("#note-container .note-box[data-id=" + id + "]").remove();
|
||||
$("#note-container .note-body[data-id=" + id + "]").remove();
|
||||
Danbooru.Note.Box.find(id).remove();
|
||||
Danbooru.Note.Body.find(id).remove();
|
||||
$(this).dialog("close");
|
||||
|
||||
if (id.match(/\d/)) {
|
||||
$.ajax("/notes/" + id + ".js", {
|
||||
type: "DELETE"
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
history: function() {
|
||||
var $this = $(this);
|
||||
var id = $this.data("id");
|
||||
console.log("history %d", id);
|
||||
$(this).dialog("close");
|
||||
|
||||
if (id.match(/\d/)) {
|
||||
window.href = "/note_versions?search[note_id]=" + id;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
TranslationMode: {
|
||||
start: function() {
|
||||
$("#note-container").click(Danbooru.Note.TranslationMode.create_note);
|
||||
$("#translate-button").one("click", Danbooru.Note.TranslationMode.stop).html("Click on image");
|
||||
$("#translate").one("click", Danbooru.Note.TranslationMode.stop).html("Click on image");
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
$("#note-container").unbind("click");
|
||||
$("#translate-button").one("click", Danbooru.Note.TranslationMode.start).html("Translate");
|
||||
$("#translate").one("click", Danbooru.Note.TranslationMode.start).html("Translate");
|
||||
},
|
||||
|
||||
create_note: function(e) {
|
||||
@@ -330,7 +393,7 @@ Danbooru.Note = {
|
||||
scale: function() {
|
||||
var $image = $("#image");
|
||||
if ($image.attr("ratio")) {
|
||||
|
||||
// TODO: implement
|
||||
}
|
||||
},
|
||||
|
||||
@@ -355,7 +418,7 @@ Danbooru.Note = {
|
||||
new: function(x, y) {
|
||||
var $note_box = Danbooru.Note.Box.create(Danbooru.Note.id);
|
||||
var $note_body = Danbooru.Note.Body.create(Danbooru.Note.id);
|
||||
$note_box.offset({
|
||||
$note_box.css({
|
||||
top: y,
|
||||
left: x
|
||||
});
|
||||
@@ -376,12 +439,12 @@ Danbooru.Note = {
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if ($("#c-posts #a-show").size > 0) {
|
||||
$(function() {
|
||||
if ($("#c-posts #a-show").size() > 0) {
|
||||
Danbooru.Note.Image.resize();
|
||||
$("#translate-button").one("click", Danbooru.Note.TranslationMode.start);
|
||||
$("#translate").one("click", Danbooru.Note.TranslationMode.start);
|
||||
$("#note-container").width($("#image").width()).height($("#image").height());
|
||||
// $(document).bind("keydown", "ctrl+n", Danbooru.Note.TranslationMode.start);
|
||||
$(document).bind("keydown", "ctrl+n", Danbooru.Note.TranslationMode.start);
|
||||
|
||||
$("#toggle-resize").click(function() {
|
||||
var $image = $("#image");
|
||||
|
||||
@@ -171,15 +171,26 @@
|
||||
}
|
||||
|
||||
Danbooru.Post.initialize_wiki_page_excerpt = function() {
|
||||
$("#close-wiki-page-excerpt").click(function() {
|
||||
$("#wiki-page-excerpt").remove();
|
||||
Danbooru.j_alert("Notice", "You can reenable the wiki excerpt by clearing your cookies.");
|
||||
if (Danbooru.Cookie.get("hide-wiki-page-excerpt") === "1") {
|
||||
$("#hide-wiki-page-excerpt").hide();
|
||||
$("#wiki-page-excerpt-content").hide();
|
||||
} else {
|
||||
$("#show-wiki-page-excerpt").hide();
|
||||
}
|
||||
|
||||
$("#hide-wiki-page-excerpt").click(function() {
|
||||
$("#hide-wiki-page-excerpt").hide();
|
||||
$("#wiki-page-excerpt-content").hide();
|
||||
$("#show-wiki-page-excerpt").show();
|
||||
Danbooru.Cookie.put("hide-wiki-page-excerpt", "1");
|
||||
});
|
||||
|
||||
if (Danbooru.Cookie.get("hide-wiki-page-excerpt") === "1") {
|
||||
$("#wiki-page-excerpt").remove();
|
||||
}
|
||||
$("#show-wiki-page-excerpt").click(function() {
|
||||
$("#hide-wiki-page-excerpt").show();
|
||||
$("#wiki-page-excerpt-content").show();
|
||||
$("#show-wiki-page-excerpt").hide();
|
||||
Danbooru.Cookie.put("hide-wiki-page-excerpt", "0");
|
||||
});
|
||||
}
|
||||
|
||||
Danbooru.Post.initialize_post_sections = function() {
|
||||
@@ -191,8 +202,7 @@
|
||||
$(e.target).parent("li").addClass("active");
|
||||
var name = e.target.hash;
|
||||
$(name).show();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#post-sections li:first-child").addClass("active");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
$(document).ready(function() {
|
||||
$("footer.nav-links a").click(function(event) {
|
||||
$("div.users div.new > div").hide();
|
||||
$(function() {
|
||||
$("div#c-users div#a-new footer.nav-links a").click(function(event) {
|
||||
$("div#c-users div#a-new > div").hide();
|
||||
$(event.target.hash).show();
|
||||
});
|
||||
|
||||
|
||||
@@ -107,6 +107,10 @@ dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: Tahoma;
|
||||
font-weight: bold;
|
||||
@@ -366,7 +370,7 @@ form.simple_form {
|
||||
div.input {
|
||||
margin-bottom: 1em;
|
||||
|
||||
input[type=text], input[type=file] {
|
||||
input[type=text], input[type=file], input[type=password], input[type=email] {
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
@@ -396,6 +400,7 @@ form.simple_form {
|
||||
font-weight: normal;
|
||||
width: auto;
|
||||
margin-right: 2em;
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,6 +483,11 @@ div.comments-for-post {
|
||||
div.author {
|
||||
width: 20%;
|
||||
float: left;
|
||||
|
||||
h1 {
|
||||
display: block;
|
||||
font-size: $h2_size;
|
||||
}
|
||||
}
|
||||
|
||||
div.content {
|
||||
@@ -591,14 +601,34 @@ div#c-posts {
|
||||
div#wiki-page-excerpt {
|
||||
position: relative;
|
||||
width: 40em;
|
||||
padding-right: 1em;
|
||||
|
||||
div#hide-or-show-wiki-page-excerpt {
|
||||
font-size: 1em;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
|
||||
span {
|
||||
cursor: pointer;
|
||||
color: #AAA;
|
||||
}
|
||||
|
||||
span:hover {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span#close-wiki-page-excerpt {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
div#a-show {
|
||||
menu#post-sections {
|
||||
font-size: $h3_size;
|
||||
font-weight: bold;
|
||||
line-height: 1.25em;
|
||||
|
||||
li a {
|
||||
color: $link_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,8 +695,8 @@ div#sessions {
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 5px;
|
||||
h1 {
|
||||
font-size: $h2_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,8 +728,8 @@ div#c-artists {
|
||||
|
||||
|
||||
/*** Users ***/
|
||||
div.users {
|
||||
div.new {
|
||||
div#c-users {
|
||||
div#a-new {
|
||||
max-width: 60em;
|
||||
|
||||
p {
|
||||
@@ -708,9 +738,14 @@ div.users {
|
||||
|
||||
li {
|
||||
margin-left: 1em;
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
div#account-comparison {
|
||||
h1 {
|
||||
font-size: $h2_size;
|
||||
}
|
||||
|
||||
li {
|
||||
font-size: 0.9em;
|
||||
line-height: 1.5em;
|
||||
@@ -879,10 +914,12 @@ div#note-container {
|
||||
div.note-box {
|
||||
position: absolute;
|
||||
border: 1px solid white;
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
cursor: move;
|
||||
background: #FFE;
|
||||
background: transparent;
|
||||
|
||||
div.note-box-inner-border {
|
||||
border: 1px solid black;
|
||||
@@ -893,10 +930,10 @@ div#note-container {
|
||||
border: 1px solid red;
|
||||
}
|
||||
}
|
||||
|
||||
div.note-edit-dialog {
|
||||
font-size: 70%;
|
||||
}
|
||||
}
|
||||
|
||||
div.note-edit-dialog {
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user