adapt original note resizing js code

This commit is contained in:
albert
2013-03-22 20:06:15 -04:00
parent 217e878a0f
commit 61b3a18ec7
3 changed files with 38 additions and 24 deletions

View File

@@ -179,28 +179,42 @@ Danbooru.Note = {
var w = $note_body.width();
var h = $note_body.height();
var golden_ratio = 1.6180339887;
var last = 0;
var x = 0;
if ((w / h) < golden_ratio) {
var lo = 140;
var hi = 400;
do {
last = w;
x = (lo + hi) / 2;
$note_body.css("min-width", x);
w = $note_body.width();
h = $note_body.height();
while (w / h < golden_ratio) {
w = w * 1.025;
h = h / 1.025;
}
while (w / h > golden_ratio) {
w = w / 1.025;
h = h * 1.025;
}
if ($note_body.html().length < 20) {
while (h > 20) {
h = h / 1.025;
w = w * 1.025;
if ((w / h) < golden_ratio) {
lo = x;
} else {
hi = x;
}
} while ((lo < hi) && (w > last));
} else if ($note_body[0].scrollWidth <= $note_body.width()) {
var lo = 20;
var hi = w;
do {
x = (lo + hi) / 2;
$note_body.css("min-width", x);
if ($note_body.height() > h) {
lo = x
} else {
hi = x;
}
} while ((hi - lo) > 4)
if ($note_body.height() > h) {
$note_body.css("minWidth", hi);
}
}
$note_body.css({
width: w,
height: "auto"
});
},
set_text: function($note_body, text) {

View File

@@ -6,7 +6,7 @@ div#note-container {
position: absolute;
border: 1px solid black;
background: #FFE;
min-width: 10px;
min-width: 140px;
min-height: 1em;
line-height: normal;
cursor: pointer;

View File

@@ -4,13 +4,13 @@ require 'mail'
class UploadErrorChecker
def check!
count = Upload.where("status like 'error%' and created_at >= ?", 1.hour.ago).count
if count > 5
uploads = Upload.where("status like 'error%' and created_at >= ?", 1.hour.ago).all
if uploads.size > 5
mail = Mail.new do
from "webmaster@danbooru.donmai.us"
to "r888888888@gmail.com"
subject "[danbooru] Upload error count at #{count}"
body "nt"
subject "[danbooru] Upload error count at #{uploads.size}"
body uploads.map {|x| x.status}.join("\n")
end
mail.delivery_method :sendmail
mail.deliver