Remove trailing whitespace on files I'm about to edit

This commit is contained in:
小太
2013-02-23 15:33:39 +11:00
parent c0257916b4
commit 800b62b614
2 changed files with 84 additions and 84 deletions

View File

@@ -3,7 +3,7 @@ Danbooru.Note = {
create: function(id) { create: function(id) {
var $inner_border = $('<div/>'); var $inner_border = $('<div/>');
$inner_border.addClass("note-box-inner-border"); $inner_border.addClass("note-box-inner-border");
$inner_border.css({ $inner_border.css({
opacity: 0.5, opacity: 0.5,
"-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)", "-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)",
@@ -17,7 +17,7 @@ Danbooru.Note = {
$note_box.attr("data-id", String(id)); $note_box.attr("data-id", String(id));
$note_box.draggable({containment: $("#image")}); $note_box.draggable({containment: $("#image")});
$note_box.resizable({ $note_box.resizable({
containment: $("#image"), containment: $("#image"),
handles: "se" handles: "se"
}); });
$note_box.css({position: "absolute"}); $note_box.css({position: "absolute"});
@@ -26,7 +26,7 @@ Danbooru.Note = {
return $note_box; return $note_box;
}, },
bind_events: function($note_box) { bind_events: function($note_box) {
$note_box.bind( $note_box.bind(
"dragstart resizestart", "dragstart resizestart",
@@ -38,7 +38,7 @@ Danbooru.Note = {
e.stopPropagation(); e.stopPropagation();
} }
) )
$note_box.bind( $note_box.bind(
"resize", "resize",
function(e) { function(e) {
@@ -74,24 +74,24 @@ Danbooru.Note = {
} }
); );
}, },
find: function(id) { find: function(id) {
return $("#note-container div.note-box[data-id=" + id + "]"); return $("#note-container div.note-box[data-id=" + id + "]");
}, },
resize_inner_border: function($note_box) { resize_inner_border: function($note_box) {
var $inner_border = $note_box.find("div.note-box-inner-border"); var $inner_border = $note_box.find("div.note-box-inner-border");
$inner_border.css({ $inner_border.css({
height: $note_box.height() - 2, height: $note_box.height() - 2,
width: $note_box.width() - 2 width: $note_box.width() - 2
}); });
}, },
scale: function($note_box) { scale: function($note_box) {
var $image = $("#image"); var $image = $("#image");
var original_width = parseFloat($image.data("original-width")); var original_width = parseFloat($image.data("original-width"));
var ratio = $image.width() / original_width; var ratio = $image.width() / original_width;
if (ratio < 1) { if (ratio < 1) {
var scaled_width = Math.round($note_box.width() * ratio); var scaled_width = Math.round($note_box.width() * ratio);
var scaled_height = Math.round($note_box.height() * ratio); var scaled_height = Math.round($note_box.height() * ratio);
@@ -106,18 +106,18 @@ Danbooru.Note = {
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
} }
}, },
scale_all: function() { scale_all: function() {
$(".note-box").each(function(i, v) { $(".note-box").each(function(i, v) {
Danbooru.Note.Box.scale($(v)); Danbooru.Note.Box.scale($(v));
}); });
}, },
descale: function($note_box) { descale: function($note_box) {
var $image = $("#image"); var $image = $("#image");
var original_width = parseFloat($image.data("original-width")); var original_width = parseFloat($image.data("original-width"));
var ratio = original_width / $image.width(); var ratio = original_width / $image.width();
if (ratio > 1) { if (ratio > 1) {
var scaled_width = Math.round($note_box.width() * ratio); var scaled_width = Math.round($note_box.width() * ratio);
var scaled_height = Math.round($note_box.height() * ratio); var scaled_height = Math.round($note_box.height() * ratio);
@@ -132,18 +132,18 @@ Danbooru.Note = {
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
} }
}, },
descale_all: function() { descale_all: function() {
$(".note-box").each(function(i, v) { $(".note-box").each(function(i, v) {
Danbooru.Note.Box.descale($(v)); Danbooru.Note.Box.descale($(v));
}); });
}, },
toggle_all: function() { toggle_all: function() {
$(".note-box").toggle(); $(".note-box").toggle();
} }
}, },
Body: { Body: {
create: function(id) { create: function(id) {
var $note_body = $('<div></div>'); var $note_body = $('<div></div>');
@@ -154,7 +154,7 @@ Danbooru.Note = {
Danbooru.Note.Body.bind_events($note_body); Danbooru.Note.Body.bind_events($note_body);
return $note_body; return $note_body;
}, },
initialize: function($note_body) { initialize: function($note_body) {
var $note_box = Danbooru.Note.Box.find($note_body.data("id")); var $note_box = Danbooru.Note.Box.find($note_body.data("id"));
$note_body.css({ $note_body.css({
@@ -163,11 +163,11 @@ Danbooru.Note = {
}); });
Danbooru.Note.Body.bound_position($note_body); Danbooru.Note.Body.bound_position($note_body);
}, },
bound_position: function($note_body) { bound_position: function($note_body) {
var $image = $("#image"); var $image = $("#image");
var doc_width = $image.offset().left + $image.width(); var doc_width = $image.offset().left + $image.width();
while ($note_body[0].clientHeight < $note_body[0].scrollHeight) { while ($note_body[0].clientHeight < $note_body[0].scrollHeight) {
$note_body.css({height: $note_body.height() + 5}); $note_body.css({height: $note_body.height() + 5});
} }
@@ -175,14 +175,14 @@ Danbooru.Note = {
while ($note_body[0].clientWidth < $note_body[0].scrollWidth) { while ($note_body[0].clientWidth < $note_body[0].scrollWidth) {
$note_body.css({width: $note_body.width() + 5}); $note_body.css({width: $note_body.width() + 5});
} }
if ($note_body.offset().left + $note_body.width() > doc_width) { if ($note_body.offset().left + $note_body.width() > doc_width) {
$note_body.css({ $note_body.css({
left: $note_body.position().left - 10 - ($note_body.offset().left + $note_body.width() - doc_width) left: $note_body.position().left - 10 - ($note_body.offset().left + $note_body.width() - doc_width)
}); });
} }
}, },
show: function(id) { show: function(id) {
if (Danbooru.Note.editing) { if (Danbooru.Note.editing) {
return; return;
@@ -194,20 +194,20 @@ Danbooru.Note = {
$note_body.show(); $note_body.show();
Danbooru.Note.Body.initialize($note_body); Danbooru.Note.Body.initialize($note_body);
}, },
find: function(id) { find: function(id) {
return $("#note-container div.note-body[data-id=" + id + "]"); return $("#note-container div.note-body[data-id=" + id + "]");
}, },
hide: function(id) { hide: function(id) {
var $note_body = Danbooru.Note.Body.find(id); var $note_body = Danbooru.Note.Body.find(id);
Danbooru.Note.timeouts.push($.timeout(250).done(function() {$note_body.hide();})); Danbooru.Note.timeouts.push($.timeout(250).done(function() {$note_body.hide();}));
}, },
hide_all: function() { hide_all: function() {
$("#note-container div.note-body").hide(); $("#note-container div.note-body").hide();
}, },
resize: function($note_body) { resize: function($note_body) {
var w = $note_body.width(); var w = $note_body.width();
var h = $note_body.height(); var h = $note_body.height();
@@ -217,7 +217,7 @@ Danbooru.Note = {
w = w * 1.025; w = w * 1.025;
h = h / 1.025; h = h / 1.025;
} }
while (w / h > golden_ratio) { while (w / h > golden_ratio) {
w = w / 1.025; w = w / 1.025;
h = h * 1.025; h = h * 1.025;
@@ -228,20 +228,20 @@ Danbooru.Note = {
height: "auto" height: "auto"
}); });
}, },
set_text: function($note_body, text) { set_text: function($note_body, text) {
Danbooru.Note.Body.display_text($note_body, text); Danbooru.Note.Body.display_text($note_body, text);
Danbooru.Note.Body.resize($note_body); Danbooru.Note.Body.resize($note_body);
Danbooru.Note.Body.bound_position($note_body); Danbooru.Note.Body.bound_position($note_body);
}, },
display_text: function($note_body, text) { display_text: function($note_body, text) {
text = text.replace(/<tn>/g, '<p class="tn">'); text = text.replace(/<tn>/g, '<p class="tn">');
text = text.replace(/<\/tn>/g, '</p>'); text = text.replace(/<\/tn>/g, '</p>');
text = text.replace(/\n/g, '<br>'); text = text.replace(/\n/g, '<br>');
$note_body.html(text); $note_body.html(text);
}, },
bind_events: function($note_body) { bind_events: function($note_body) {
$note_body.mouseover(function(e) { $note_body.mouseover(function(e) {
var $note_body_inner = $(e.currentTarget); var $note_body_inner = $(e.currentTarget);
@@ -268,7 +268,7 @@ Danbooru.Note = {
} }
} }
}, },
Edit: { Edit: {
show: function($note_body) { show: function($note_body) {
if (Danbooru.Note.editing) { if (Danbooru.Note.editing) {
@@ -283,7 +283,7 @@ Danbooru.Note = {
width: "95%", width: "95%",
height: "10em" height: "10em"
}); });
if ($note_body.html() !== "<em>Click to edit</em>") { if ($note_body.html() !== "<em>Click to edit</em>") {
$textarea.val($note_body.data("original-body")); $textarea.val($note_body.data("original-body"));
} }
@@ -309,12 +309,12 @@ Danbooru.Note = {
}); });
// Danbooru.Note.editing = true; // Danbooru.Note.editing = true;
}, },
parameterize_note: function($note_box, $note_body) { parameterize_note: function($note_box, $note_body) {
var $image = $("#image"); var $image = $("#image");
var original_width = parseInt($image.data("original-width")); var original_width = parseInt($image.data("original-width"));
var ratio = parseInt($image.width()) / original_width; var ratio = parseInt($image.width()) / original_width;
var hash = { var hash = {
note: { note: {
x: $note_box.position().left / ratio, x: $note_box.position().left / ratio,
@@ -325,18 +325,18 @@ Danbooru.Note = {
post_id: Danbooru.meta("post-id") post_id: Danbooru.meta("post-id")
} }
} }
if ($note_box.data("id").match(/x/)) { if ($note_box.data("id").match(/x/)) {
hash.note.html_id = $note_box.data("id"); hash.note.html_id = $note_box.data("id");
} }
return hash; return hash;
}, },
error_handler: function(xhr, status, exception) { error_handler: function(xhr, status, exception) {
Danbooru.error("There was an error saving the note"); Danbooru.error("There was an error saving the note");
}, },
success_handler: function(data, status, xhr) { success_handler: function(data, status, xhr) {
if (data.html_id) { if (data.html_id) {
var $note_body = Danbooru.Note.Body.find(data.html_id); var $note_body = Danbooru.Note.Body.find(data.html_id);
@@ -346,7 +346,7 @@ Danbooru.Note = {
$note_box.find(".note-box-inner-border").removeClass("unsaved"); $note_box.find(".note-box-inner-border").removeClass("unsaved");
} }
}, },
save: function() { save: function() {
var $this = $(this); var $this = $(this);
var $textarea = $this.find("textarea"); var $textarea = $this.find("textarea");
@@ -357,7 +357,7 @@ Danbooru.Note = {
$note_body.data("original-body", text); $note_body.data("original-body", text);
Danbooru.Note.Body.set_text($note_body, text); Danbooru.Note.Body.set_text($note_body, text);
$this.dialog("close"); $this.dialog("close");
if (id.match(/\d/)) { if (id.match(/\d/)) {
$.ajax("/notes/" + id + ".json", { $.ajax("/notes/" + id + ".json", {
type: "PUT", type: "PUT",
@@ -374,29 +374,29 @@ Danbooru.Note = {
}); });
} }
}, },
cancel: function() { cancel: function() {
$(this).dialog("close"); $(this).dialog("close");
}, },
delete: function() { delete: function() {
if (!confirm("Do you really want to delete this note?")) { if (!confirm("Do you really want to delete this note?")) {
return return
} }
var $this = $(this); var $this = $(this);
var id = $this.data("id"); var id = $this.data("id");
Danbooru.Note.Box.find(id).remove(); Danbooru.Note.Box.find(id).remove();
Danbooru.Note.Body.find(id).remove(); Danbooru.Note.Body.find(id).remove();
$(this).dialog("close"); $(this).dialog("close");
if (id.match(/\d/)) { if (id.match(/\d/)) {
$.ajax("/notes/" + id + ".js", { $.ajax("/notes/" + id + ".js", {
type: "DELETE" type: "DELETE"
}); });
} }
}, },
history: function() { history: function() {
var $this = $(this); var $this = $(this);
var id = $this.data("id"); var id = $this.data("id");
@@ -406,18 +406,18 @@ Danbooru.Note = {
$(this).dialog("close"); $(this).dialog("close");
} }
}, },
TranslationMode: { TranslationMode: {
start: function() { start: function() {
$("#original-file-link").click(); $("#original-file-link").click();
$("#image").one("click", Danbooru.Note.TranslationMode.create_note); $("#image").one("click", Danbooru.Note.TranslationMode.create_note);
Danbooru.notice('Click on the image to create a note (shortcut is <span class="key">n</span>)'); Danbooru.notice('Click on the image to create a note (shortcut is <span class="key">n</span>)');
}, },
stop: function() { stop: function() {
// $("#image").unbind("click"); // $("#image").unbind("click");
}, },
create_note: function(e) { create_note: function(e) {
var offset = $("#image").offset(); var offset = $("#image").offset();
Danbooru.Note.new(e.pageX - offset.left, e.pageY - offset.top); Danbooru.Note.new(e.pageX - offset.left, e.pageY - offset.top);
@@ -426,24 +426,24 @@ Danbooru.Note = {
e.stopPropagation(); e.stopPropagation();
} }
}, },
id: "x", id: "x",
dragging: false, dragging: false,
editing: false, editing: false,
timeouts: [], timeouts: [],
pending: {}, pending: {},
add: function(id, x, y, w, h, text) { add: function(id, x, y, w, h, text) {
var $note_box = Danbooru.Note.Box.create(id); var $note_box = Danbooru.Note.Box.create(id);
var $note_body = Danbooru.Note.Body.create(id); var $note_body = Danbooru.Note.Body.create(id);
$note_box.css({ $note_box.css({
left: x, left: x,
top: y, top: y,
width: w, width: w,
height: h height: h
}); });
$("#note-container").append($note_box); $("#note-container").append($note_box);
$("#note-container").append($note_body); $("#note-container").append($note_body);
$note_body.data("original-body", text); $note_body.data("original-body", text);
@@ -451,7 +451,7 @@ Danbooru.Note = {
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
Danbooru.Note.Body.set_text($note_body, text); Danbooru.Note.Body.set_text($note_body, text);
}, },
new: function(x, y) { new: function(x, y) {
var $note_box = Danbooru.Note.Box.create(Danbooru.Note.id); var $note_box = Danbooru.Note.Box.create(Danbooru.Note.id);
var $note_body = Danbooru.Note.Body.create(Danbooru.Note.id); var $note_body = Danbooru.Note.Body.create(Danbooru.Note.id);
@@ -466,15 +466,15 @@ Danbooru.Note = {
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
Danbooru.Note.id += "x"; Danbooru.Note.id += "x";
}, },
clear_timeouts: function() { clear_timeouts: function() {
$.each(Danbooru.Note.timeouts, function(i, v) { $.each(Danbooru.Note.timeouts, function(i, v) {
v.clear(); v.clear();
}); });
Danbooru.Note.timeouts = []; Danbooru.Note.timeouts = [];
}, },
load_all: function() { load_all: function() {
$.each($("#notes article"), function(i, article) { $.each($("#notes article"), function(i, article) {
var $article = $(article); var $article = $(article);

View File

@@ -1,15 +1,15 @@
(function() { (function() {
Danbooru.Post = {}; Danbooru.Post = {};
Danbooru.Post.pending_update_count = 0; Danbooru.Post.pending_update_count = 0;
Danbooru.Post.initialize_all = function() { Danbooru.Post.initialize_all = function() {
this.initialize_titles(); this.initialize_titles();
if ($("#c-posts").length) { if ($("#c-posts").length) {
this.initialize_shortcuts(); this.initialize_shortcuts();
} }
if ($("#c-posts").length && $("#a-index").length) { if ($("#c-posts").length && $("#a-index").length) {
this.initialize_wiki_page_excerpt(); this.initialize_wiki_page_excerpt();
} }
@@ -20,19 +20,19 @@
this.initialize_post_image_resize_links(); this.initialize_post_image_resize_links();
this.initialize_post_image_resize_to_window_link(); this.initialize_post_image_resize_to_window_link();
this.place_jlist_ads(); this.place_jlist_ads();
if (Danbooru.meta("always-resize-images") === "true") { if (Danbooru.meta("always-resize-images") === "true") {
$("#image-resize-to-window-link").click(); $("#image-resize-to-window-link").click();
} }
} }
} }
Danbooru.Post.initialize_shortcuts = function() { Danbooru.Post.initialize_shortcuts = function() {
$(document).bind("keydown./", function(e) { $(document).bind("keydown./", function(e) {
$("#tags").trigger("focus"); $("#tags").trigger("focus");
e.preventDefault(); e.preventDefault();
}); });
if ($("#a-show").length) { if ($("#a-show").length) {
$(document).bind("keydown.e", function(e) { $(document).bind("keydown.e", function(e) {
$("#post-edit-link").trigger("click"); $("#post-edit-link").trigger("click");
@@ -41,7 +41,7 @@
}); });
} }
} }
Danbooru.Post.initialize_links = function() { Danbooru.Post.initialize_links = function() {
$("#side-edit-link").click(function(e) { $("#side-edit-link").click(function(e) {
$("#post-edit-link").trigger("click"); $("#post-edit-link").trigger("click");
@@ -49,28 +49,28 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Post.initialize_titles = function() { Danbooru.Post.initialize_titles = function() {
$(".post-preview").each(function(i, v) { $(".post-preview").each(function(i, v) {
Danbooru.Post.initialize_title_for(v); Danbooru.Post.initialize_title_for(v);
}); });
} }
Danbooru.Post.initialize_title_for = function(post) { Danbooru.Post.initialize_title_for = function(post) {
var $post = $(post); var $post = $(post);
var $img = $post.find("img"); var $img = $post.find("img");
$img.attr("title", $post.data("tags") + " user:" + $post.data("uploader") + " rating:" + $post.data("rating") + " score:" + $post.data("score")); $img.attr("title", $post.data("tags") + " user:" + $post.data("uploader") + " rating:" + $post.data("rating") + " score:" + $post.data("score"));
var status = $post.data("flags"); var status = $post.data("flags");
if (status.match(/pending/)) { if (status.match(/pending/)) {
$post.addClass("post-status-pending"); $post.addClass("post-status-pending");
} }
if (status.match(/flagged/)) { if (status.match(/flagged/)) {
$post.addClass("post-status-flagged"); $post.addClass("post-status-flagged");
} }
if ($post.data("parent-id")) { if ($post.data("parent-id")) {
$post.addClass("post-status-has-parent"); $post.addClass("post-status-has-parent");
} }
@@ -94,7 +94,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Post.initialize_post_image_resize_to_window_link = function() { Danbooru.Post.initialize_post_image_resize_to_window_link = function() {
$("#image-resize-to-window-link").click(function(e) { $("#image-resize-to-window-link").click(function(e) {
var $img = $("#image"); var $img = $("#image");
@@ -124,10 +124,10 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Post.initialize_wiki_page_excerpt = function() { Danbooru.Post.initialize_wiki_page_excerpt = function() {
$("#wiki-page-excerpt").hide(); $("#wiki-page-excerpt").hide();
$("#show-posts-link").click(function(e) { $("#show-posts-link").click(function(e) {
$("#show-posts-link").parent("li").addClass("active"); $("#show-posts-link").parent("li").addClass("active");
$("#show-wiki-excerpt-link").parent("li").removeClass("active"); $("#show-wiki-excerpt-link").parent("li").removeClass("active");
@@ -135,7 +135,7 @@
$("#wiki-page-excerpt").hide(); $("#wiki-page-excerpt").hide();
e.preventDefault(); e.preventDefault();
}); });
$("#show-wiki-excerpt-link").click(function(e) { $("#show-wiki-excerpt-link").click(function(e) {
$("#show-posts-link").parent("li").removeClass("active"); $("#show-posts-link").parent("li").removeClass("active");
$("#show-wiki-excerpt-link").parent("li").addClass("active"); $("#show-wiki-excerpt-link").parent("li").addClass("active");
@@ -144,7 +144,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Post.initialize_post_sections = function() { Danbooru.Post.initialize_post_sections = function() {
$("#post-sections li a").click(function(e) { $("#post-sections li a").click(function(e) {
if (e.target.hash === "#comments") { if (e.target.hash === "#comments") {
@@ -160,25 +160,25 @@
$("#comments").hide(); $("#comments").hide();
$("#share").show(); $("#share").show();
} }
$("#post-sections li").removeClass("active"); $("#post-sections li").removeClass("active");
$(e.target).parent("li").addClass("active"); $(e.target).parent("li").addClass("active");
var name = e.target.hash; var name = e.target.hash;
e.preventDefault(); e.preventDefault();
}); });
$("#post-sections li:first-child").addClass("active"); $("#post-sections li:first-child").addClass("active");
$("#notes").hide(); $("#notes").hide();
$("#edit").hide(); $("#edit").hide();
} }
Danbooru.Post.notice_update = function(x) { Danbooru.Post.notice_update = function(x) {
if (x === "inc") { if (x === "inc") {
Danbooru.Post.pending_update_count += 1; Danbooru.Post.pending_update_count += 1;
Danbooru.notice("Updating posts (" + Danbooru.Post.pending_update_count + " pending)..."); Danbooru.notice("Updating posts (" + Danbooru.Post.pending_update_count + " pending)...");
} else { } else {
Danbooru.Post.pending_update_count -= 1; Danbooru.Post.pending_update_count -= 1;
if (Danbooru.Post.pending_update_count < 1) { if (Danbooru.Post.pending_update_count < 1) {
Danbooru.notice("Posts updated"); Danbooru.notice("Posts updated");
} else { } else {
@@ -186,17 +186,17 @@
} }
} }
} }
Danbooru.Post.update_data = function(data) { Danbooru.Post.update_data = function(data) {
var $post = $("#post_" + data.id); var $post = $("#post_" + data.id);
$post.data("tags", data.tag_string); $post.data("tags", data.tag_string);
$post.data("rating", data.rating); $post.data("rating", data.rating);
Danbooru.Post.initialize_title_for($post); Danbooru.Post.initialize_title_for($post);
} }
Danbooru.Post.vote = function(score, id) { Danbooru.Post.vote = function(score, id) {
Danbooru.Post.notice_update("inc"); Danbooru.Post.notice_update("inc");
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/posts/" + id + "/votes", url: "/posts/" + id + "/votes",
@@ -214,7 +214,7 @@
} }
}); });
} }
Danbooru.Post.update = function(post_id, params) { Danbooru.Post.update = function(post_id, params) {
Danbooru.Post.notice_update("inc"); Danbooru.Post.notice_update("inc");
@@ -227,7 +227,7 @@
}, },
success: function(data, status, xhr) { success: function(data, status, xhr) {
Danbooru.Post.update_data(data); Danbooru.Post.update_data(data);
}, },
error: function(data, status, xhr) { error: function(data, status, xhr) {
Danbooru.notice("Error: " + data.reason); Danbooru.notice("Error: " + data.reason);
@@ -235,7 +235,7 @@
} }
}); });
} }
Danbooru.Post.place_jlist_ads = function() { Danbooru.Post.place_jlist_ads = function() {
var jlist = $("#jlist-rss-ads-for-show"); var jlist = $("#jlist-rss-ads-for-show");
if (jlist.length) { if (jlist.length) {