moved stylesheets and javascripts to assets

This commit is contained in:
albert
2011-05-24 18:24:45 -04:00
parent 1c964b5189
commit ca68b2def1
45 changed files with 921 additions and 568 deletions

View File

@@ -0,0 +1,7 @@
//= require jquery-1.6.2.min.js
//= require jquery-ui-1.8.12.custom.min.js
//= require jquery.hotkeys.js
//= require jquery.timeout.js
//= require rails.js
//= require common.js
//= require_tree .

View File

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

View File

@@ -0,0 +1,46 @@
$(document).ready(function() {
// $("#hide-upgrade-account-link").click(function() {
// $("#upgrade-account").hide();
// Cookie.put('hide-upgrade-account', '1', 7);
// });
// Table striping
$("table.striped tbody tr:even").addClass("even");
$("table.striped tbody tr:odd").addClass("odd");
// Comment listing
$(".comment-section form").hide();
$(".comment-section input.expand-comment-response").click(function() {
var post_id = $(this).closest(".comment-section").data("post-id");
$(".comment-section[data-post-id=" + post_id + "] form").show();
$(this).hide();
});
// Ajax links
$("a[data-remote=true]").click(function(e) {
Danbooru.ajax_start(e.target);
})
$("a[data-remote=true]").ajaxComplete(function(e) {
Danbooru.ajax_stop(e.target);
})
// Image resize sidebar
$("#resize-links").hide();
$("#resize-links a").click(function(e) {
var image = $("#image");
var target = $(e.target);
image.attr("src", target.data("src"));
image.attr("width", target.data("width"));
image.attr("height", target.data("height"));
e.preventDefault();
});
$("#resize-link a").click(function(e) {
$("#resize-links").toggle();
e.preventDefault();
});
});
var Danbooru = {};

View File

@@ -0,0 +1,65 @@
(function() {
Danbooru.Cookie = {};
Danbooru.Cookie.put = function(name, value, days) {
if (days == null) {
days = 365;
}
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
}
Danbooru.Cookie.raw_get = function(name) {
var nameEq = name + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; ++i) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEq) == 0) {
return c.substring(nameEq.length, c.length);
}
}
return "";
}
Danbooru.Cookie.get = function(name) {
return this.unescape(this.raw_get(name));
}
Danbooru.Cookie.remove = function(name) {
this.put(name, "", -1);
}
Danbooru.Cookie.unescape = function(val) {
return decodeURIComponent(val.replace(/\+/g, " "));
}
Danbooru.Cookie.initialize = function() {
if (location.href.match(/^\/(comment|pool|note|post)/) && this.get("tos") != "1") {
// Setting location.pathname in Safari doesn't work, so manually extract the domain.
var domain = location.href.match(/^(http:\/\/[^\/]+)/)[0];
location.href = domain + "/static/terms_of_service?url=" + location.href;
return;
}
if (this.get("hide-upgrade-account") != "1") {
if ($("upgrade-account")) {
$("upgrade-account").show();
}
}
}
})();
$(document).ready(function() {
Danbooru.Cookie.initialize();
});

View File

@@ -0,0 +1,27 @@
(function() {
Danbooru.Favorite = {};
Danbooru.Favorite.initialize_all = function() {
this.hide_or_show_add_to_favorites_link();
}
Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() {
var favorites = Danbooru.meta("favorites");
var current_user_id = Danbooru.meta("current-user-id");
if (current_user_id == "") {
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").hide();
return;
}
var regexp = new RegExp("\\bfav:" + current_user_id + "\\b");
if ((favorites != undefined) && (favorites.match(regexp))) {
$("a#add-to-favorites").hide();
} else {
$("a#remove-from-favorites").hide();
}
}
})();
$(document).ready(function() {
Danbooru.Favorite.initialize_all();
});

View File

@@ -0,0 +1,36 @@
(function() {
Danbooru.ForumPost = {};
Danbooru.ForumPost.initialize_all = function() {
$("#c-forum-topics #preview").hide();
this.initialize_preview_link();
}
Danbooru.ForumPost.initialize_preview_link = function() {
$("#c-forum-topics #preview a[name=toggle-preview]").click(function() {
$("#preview").toggle();
$("#dtext-help").toggle();
});
$("#c-forum-topics input[value=Preview]").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/dtext/preview",
data: {
body: $("#forum_post_body").val()
},
success: function(data) {
$("#dtext-help").hide();
$("#preview").show();
$("#preview .content").html(data);
}
});
});
}
})();
$(document).ready(function() {
Danbooru.ForumPost.initialize_all();
});

View File

@@ -0,0 +1,347 @@
(function() {
Danbooru.Note = function() {}
Danbooru.Note.initialize_all = function() {
$("#note-container").width($("#image").width());
$("#note-container").height($("#image").height());
$("a#translate").click(function(e) {
e.preventDefault();
Danbooru.Note.create(1);
});
}
Danbooru.Note.prototype.getElement = function(name, unwrap) {
var element = $("#note-" + name + "-" + this.id);
if (unwrap) {
return element[0];
} else {
return element;
}
}
Danbooru.Note.prototype.getBox = function(unwrap) {
return this.getElement("box", unwrap);
}
Danbooru.Note.prototype.getImage = function(unwrap) {
return this.getElement("image", unwrap);
}
Danbooru.Note.prototype.getBody = function(unwrap) {
return this.getElement("body", unwrap);
}
Danbooru.Note.prototype.getCorner = function(unwrap) {
return this.getElement("corner", unwrap);
}
Danbooru.Note.prototype.initialize = function(id, is_new, raw_body) {
if (Note.debug) {
console.debug("Note#initialize (id=%d)", id);
}
this.id = id;
this.is_new = is_new;
// Cache the dimensions
this.fullsize = {
left: this.getBox().offset().left,
top: this.getBox().offset().top,
width: this.getBox().width(),
height: this.getBox().height()
}
// Store the original values (in case the user clicks Cancel)
this.old = {
raw_body: raw_body,
formatted_body: this.getBody().html()
}
for (p in this.fullsize) {
this.old[p] = this.fullsize[p];
}
// Make the note translucent
if (is_new) {
this.getBox().css({opacity: 0.2});
} else {
this.getBox().css({opacity: 0.5});
}
if (is_new && raw_body == '') {
this.bodyfit = true;
this.getBody().css({height: 100});
}
// Attach the event listeners
this.getBox().mousedown(this.dragStart);
this.getBox().mouseout(this.bodyHideTimer);
this.getBox().mouseover(this.bodyShow);
this.getCorner().mousedown(this.resizeStart);
this.getBody().mouseover(this.bodyShow);
this.getBody().mouseout(this.bodyHideTimer);
this.getBody().click(this.showEditBox);
this.adjustScale();
}
// Returns the raw text value of this note
Danbooru.Note.prototype.textValue = function() {
if (Note.debug) {
console.debug("Note#textValue (id=%d)", this.id);
}
return this.old.raw_body.trim();
}
// Removes the edit box
Danbooru.Note.prototype.hideEditBox = function(e) {
if (Note.debug) {
console.debug("Note#hideEditBox (id=%d)", this.id)
}
var id = $("#edit-box").data("id");
if (id != null) {
$("#edit-box").unbind();
$("#note-save-" + id).unbind();
$("#note-cancel-" + id).unbind();
$("#note-remove-" + id).unbind();
$("#note-history-" + id).unbind();
$("#edit-box").remove();
}
}
// Shows the edit box
Danbooru.Note.prototype.showEditBox = function(e) {
if (Note.debug) {
console.debug("Note#showEditBox (id=%d)", this.id);
}
this.hideEditBox(e);
var insertionPosition = this.getInsertionPosition();
var top = insertionPosition[0];
var left = insertionPosition[1];
html += '<div id="edit-box" style="top: '+top+'px; left: '+left+'px; position: absolute; visibility: visible; z-index: 100; background: white; border: 1px solid black; padding: 12px;">';
html += '<form onsubmit="return false;" style="padding: 0; margin: 0;">';
html += '<textarea rows="7" id="edit-box-text" style="width: 350px; margin: 2px 2px 12px 2px;">' + this.textValue() + '</textarea>';
html += '<input type="submit" value="Save" name="save" id="note-save-' + this.id + '">';
html += '<input type="submit" value="Cancel" name="cancel" id="note-cancel-' + this.id + '">';
html += '<input type="submit" value="Delete" name="remove" id="note-remove-' + this.id + '">';
html += '<input type="submit" value="History" name="history" id="note-history-' + this.id + '">';
html += '</form>';
html += '</div>';
$("#note-container").append(html);
$('#edit-box').data("id", this.id);
$("#edit-box").mousedown(this.editDragStart);
$("#note-save-" + this.id).click(this.save);
$("#note-cancel-" + this.id).click(this.cancel);
$("#note-remove-" + this.id).click(this.remove);
$("#note-history-" + this.id).click(this.history)
$("#edit-box-text").focus();
}
// Shows the body text for the note
Danbooru.Note.prototype.bodyShow = function(e) {
if (Note.debug) {
console.debug("Note#bodyShow (id=%d)", this.id);
}
if (this.dragging) {
return;
}
if (this.hideTimer) {
this.hideTimer.clear();
}
if (Note.noteShowingBody == this) {
return;
}
if (Note.noteShowingBody) {
Note.noteShowingBody.bodyHide();
}
Note.noteShowingBody = this;
if (Note.zindex >= 9) {
/* don't use more than 10 layers (+1 for the body, which will always be above all notes) */
Note.zindex = 0;
for (var i=0; i< Note.all.length; ++i) {
Note.all[i].getBox().css({zIndex: 0});
}
}
this.getBox().css({zIndex: ++Note.zindex});
this.getBody().css({zIndex: 10, top: 0, left: 0});
var dw = document.documentElement.scrollWidth;
this.getBody().css({visibility: "hidden", display: "block"});
if (!this.bodyfit) {
this.getBody().css({height: "auto", minWidth: 140});
var w = this.getBody(true).offsetWidth;
var h = this.getBody(true).offsetHeight;
var lo = null;
var hi = null;
var x = null;
var last = null;
if (this.getBody(true).scrollWidth <= this.getBody(true).clientWidth) {
/* for short notes (often a single line), make the box no wider than necessary */
// scroll test necessary for Firefox
lo = 20;
hi = w;
do {
x = (lo+hi)/2
this.getBody().css({minWidth: x});
if (this.getBody(true).offsetHeight > h) {
lo = x;
} else {
hi = x;
}
} while ((hi - lo) > 4);
if (this.getBody(true).offsetHeight > h) {
this.getBody().css({minWidth: hi});
}
}
if ($.browser.msie) {
// IE7 adds scrollbars if the box is too small, obscuring the text
if (this.getBody(true).offsetHeight < 35) {
this.getBody().css({minHeight: 35});
}
if (this.getBody(true).offsetWidth < 47) {
this.getBody().css({minWidth: 47});
}
}
this.bodyfit = true;
}
this.getBody().css({
top: this.getBox(true).offsetTop + this.getBox(true).clientHeight + 5
});
// keep the box within the document's width
var l = 0;
var e = this.getBox(true);
do {
l += e.offsetLeft
} while (e = e.offsetParent);
l += this.getBody(true).offsetWidth + 10 - dw;
if (l > 0) {
this.getBody().css({left: this.getBox(true).offsetLeft - l});
} else {
this.getBody().css({left: this.getBox(true).offsetLeft});
}
this.getBody().css({visibility: "visible"});
}
Danbooru.Note.prototype.bodyHideTimer = function(e) {
if (Note.debug) {
console.debug("Note#bodyHideTimer (id=%d)", this.id);
}
this.hideTimer = $.timeout(250).done(this.bodyHide);
}
// Start dragging the note
Danbooru.Note.prototype.dragStart = function(e) {
if (Note.debug) {
console.debug("Note#dragStart (id=%d)", this.id);
}
$(document).mousemove(this.drag);
$(document).mouseup(this.dragStop);
$(document).select(function(e) {e.preventDefault();});
this.cursorStartX = e.pageX;
this.cursorStartY = e.pageY;
this.boxStartX = this.getBox().offset().left;
this.boxStartY = this.getBox().offset().top;
this.boundsX = new ClipRange(5, this.getImage(true).clientWidth - this.getBox(true).clientWidth - 5);
this.boundsY = new ClipRange(5, this.getImage(true).clientHeight - this.getBox(true).clientHeight - 5);
this.dragging = true;
this.bodyHide();
}
// Stop dragging the note
Danbooru.Note.prototype.dragStop = function(e) {
if (Note.debug) {
console.debug("Note#dragStop (id=%d)", this.id);
}
$(document).unbind();
this.cursorStartX = null;
this.cursorStartY = null;
this.boxStartX = null;
this.boxStartY = null;
this.boundsX = null;
this.boundsY = null;
this.dragging = false;
this.bodyShow();
}
Danbooru.Note.prototype.ratio = function() {
return this.getImage().width() / parseFloat(this.getImage().data("original-width"));
}
// Scale the notes for when the image gets resized
Danbooru.Note.prototype.adjustScale = function() {
if (Note.debug) {
console.debug("Note#adjustScale (id=%d)", this.id);
}
var ratio = this.ratio();
this.getBox().css({
left: this.fullsize.left * ratio,
top: this.fullsize.top * ratio,
width: this.fullsize.width * ratio,
height: this.fullsize.height * ratio
});
}
// Update the note's position as it gets dragged
Danbooru.Note.prototype.drag = function(e) {
var left = this.boxStartX + e.pageX - this.cursorStartX;
var top = this.boxStartY + e.pageY - this.cursorStartY;
left = this.boundsX.clip(left);
top = this.boundsY.clip(top);
this.getBox().css({left: left, top: top});
var ratio = this.ratio();
this.fullsize.left = left / ratio;
this.fullsize.top = top / ratio;
e.preventDefault();
}
// Start dragging the edit box
Danbooru.Note.prototype.editDragStart = function(e) {
if (Note.debug) {
console.debug("Note#editDragStart (id=%d)", this.id);
}
var node = e.element().nodeName;
if (node != 'FORM' && node != 'DIV') {
return
}
document.observe("mousemove", this.editDrag.bindAsEventListener(this))
document.observe("mouseup", this.editDragStop.bindAsEventListener(this))
document.observe("selectstart", function() {return false})
this.elements.editBox = $('edit-box');
this.cursorStartX = e.pointerX()
this.cursorStartY = e.pointerY()
this.editStartX = this.elements.editBox.offsetLeft
this.editStartY = this.elements.editBox.offsetTop
this.dragging = true
}
})();
$(document).ready(function() {
Danbooru.Note.initialize_all();
});

View File

@@ -0,0 +1,57 @@
(function() {
Danbooru.Pool = {};
Danbooru.Pool.initialize_all = function() {
this.initialize_add_to_pool_link();
this.initialize_simple_edit();
}
Danbooru.Pool.initialize_add_to_pool_link = function() {
$("#add-to-pool-dialog").dialog({autoOpen: false});
$("#c-pools-posts #a-new input[type=text]").autocomplete({
source: function(req, resp) {
$.getJSON(
"/pools.json?search[name_contains]=" + req.term,
function(data) {
resp(data.map(function(x) {return x.pool.name;}));
}
);
},
minLength: 4,
});
$("a#pool").click(function(e) {
e.preventDefault();
$("#add-to-pool-dialog").dialog("open");
});
$("ul#recent-pools li").click(function(e) {
e.preventDefault();
$("#pool_name").val($(this).html());
});
}
Danbooru.Pool.initialize_simple_edit = function() {
$("ul#sortable").sortable({
placeholder: "ui-state-placeholder"
});
$("ul#sortable").disableSelection();
$("ul#sortable span.delete").click(function(e) {
$(e.target).parent().remove();
});
$("div.pools div.edit form#ordering-form").submit(function(e) {
$.ajax({
type: "put",
url: e.target.action,
data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize()
});
return false;
});
}
})();
$(document).ready(function() {
Danbooru.Pool.initialize_all();
});

View File

@@ -0,0 +1,40 @@
(function() {
Danbooru.PostAppeal = {};
Danbooru.PostAppeal.initialize_all = function() {
this.initialize_appeal();
this.hide_or_show_appeal_link();
}
Danbooru.PostAppeal.hide_or_show_appeal_link = function() {
if (Danbooru.meta("post-is-deleted") != "true") {
$("a#appeal").hide();
}
}
Danbooru.PostAppeal.initialize_appeal = function() {
$("#appeal-dialog").dialog({
autoOpen: false,
width: 700,
modal: true,
buttons: {
"Submit": function() {
$("#appeal-dialog form").submit();
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("a#appeal").click(function(e) {
e.preventDefault();
$("#appeal-dialog").dialog("open");
});
}
})();
$(document).ready(function() {
Danbooru.PostAppeal.initialize_all();
});

View File

@@ -0,0 +1,40 @@
(function() {
Danbooru.PostFlag = {};
Danbooru.PostFlag.initialize_all = function() {
this.initialize_flag();
this.hide_or_show_flag_link();
}
Danbooru.PostFlag.hide_or_show_flag_link = function() {
if (Danbooru.meta("post-is-deleted") == "true") {
$("a#flag").hide();
}
}
Danbooru.PostFlag.initialize_flag = function() {
$("#flag-dialog").dialog({
autoOpen: false,
width: 700,
modal: true,
buttons: {
"Submit": function() {
$("#flag-dialog form").submit();
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("a#flag").click(function(e) {
e.preventDefault();
$("#flag-dialog").dialog("open");
});
}
})();
$(document).ready(function() {
Danbooru.PostFlag.initialize_all();
});

View File

@@ -0,0 +1,27 @@
(function() {
Danbooru.PostModeration = {};
Danbooru.PostModeration.initialize_all = function() {
this.hide_or_show_approve_and_disapprove_links();
this.hide_or_show_delete_and_undelete_links();
}
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
if (Danbooru.meta("post-is-approvable") != "true") {
$("a#approve").hide();
$("a#disapprove").hide();
}
}
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
if (Danbooru.meta("post-is-deleted") == "true") {
$("a#delete").hide();
} else {
$("a#undelete").hide();
}
}
})();
$(document).ready(function() {
Danbooru.PostModeration.initialize_all();
});

View File

@@ -0,0 +1,225 @@
// PostModeMenu = {
// init: function() {
// this.original_background_color = $(document.body).css("background-color")
//
// if (Cookie.get("mode") == "") {
// Cookie.put("mode", "view");
// $("#mode-box select").val("view");
// } else {
// $("#mode-box select").val(Cookie.get("mode"));
// }
//
// // this.change();
// },
//
// change: function() {
// var s = $("#mode-box select").val();
// Cookie.put("mode", s, 7);
//
// if (s == "view") {
// $(document.body).css({"background-color": this.original_background_color});
// } else if (s == "edit") {
// $(document.body).css({"background-color": "#3A3"});
// } else if (s == "add-fav") {
// $(document.body).css({"background-color": "#FFA"});
// } else if (s == "remove-fav") {
// $(document.body).css({"background-color": "#FFA"});
// } else if (s == "rating-q") {
// $(document.body).css({"background-color": "#AAA"});
// } else if (s == "rating-s") {
// $(document.body).css({"background-color": "#6F6"});
// } else if (s == "rating-e") {
// $(document.body).css({"background-color": "#F66"});
// } else if (s == "vote-down") {
// $(document.body).css({"background-color": "#FAA"});
// } else if (s == "vote-up") {
// $(document.body).css({"background-color": "#AFA"});
// } else if (s == "lock-rating") {
// $(document.body).css({"background-color": "#AA3"});
// } else if (s == "lock-note") {
// $(document.body).css({"background-color": "#3AA"});
// } else if (s == "approve") {
// $(document.body).css({"background-color": "#26A"});
// } else if (s == "unapprove") {
// $(document.body).css({"background-color": "#F66"});
// } else if (s == "add-to-pool") {
// $(document.body).css({"background-color": "#26A"});
// } else if (s == "apply-tag-script") {
// $(document.body).css({"background-color": "#A3A"});
// } else if (s == "edit-tag-script") {
// $(document.body).css({"background-color": "#FFF"});
//
// var script = Cookie.get("tag-script");
// script = prompt("Enter a tag script", script);
//
// if (script) {
// Cookie.put("tag-script", script);
// $("#mode-box select").val("apply-tag-script");
// } else {
// $("#mode-box select").val("view");
// }
//
// this.change();
// } else {
// $(document.body).css({"background-color": "#AFA"});
// }
// },
//
// click: function(post_id) {
// var s = $("#mode-box select").val();
//
// if (s.value == "view") {
// return true;
// } else if (s.value == "add-fav") {
// Favorite.create(post_id);
// } else if (s.value == "remove-fav") {
// Favorite.destroy(post_id);
// } else if (s.value == "edit") {
// // TODO
// } else if (s.value == 'vote-down') {
// PostVote.create("down", post_id);
// } else if (s.value == 'vote-up') {
// PostVote.create("up", post_id);
// } else if (s.value == 'rating-q') {
// Post.update(post_id, {"post[rating]": "questionable"});
// } else if (s.value == 'rating-s') {
// Post.update(post_id, {"post[rating]": "safe"});
// } else if (s.value == 'rating-e') {
// Post.update(post_id, {"post[rating]": "explicit"});
// } else if (s.value == 'lock-rating') {
// Post.update(post_id, {"post[is_rating_locked]": "1"});
// } else if (s.value == 'lock-note') {
// Post.update(post_id, {"post[is_note_locked]": "1"});
// } else if (s.value == 'unapprove') {
// Unapproval.create(post_id);
// } else if (s.value == "approve") {
// Post.update(post_id, {"post[is_pending]": "0"});
// } else if (s.value == 'add-to-pool') {
// Pool.add_post(post_id, 0);
// } else if (s.value == "apply-tag-script") {
// var tag_script = Cookie.get("tag-script");
// TagScript.run(post_id, tag_script);
// }
//
// return false;
// }
// }
//
// TagScript = {
// parse: function(script) {
// return script.match(/\[.+?\]|\S+/g);
// },
//
// test: function(tags, predicate) {
// var split_pred = predicate.match(/\S+/g);
// var is_true = true;
//
// split_pred.each(function(x) {
// if (x[0] == "-") {
// if (tags.include(x.substr(1, 100))) {
// is_true = false;
// throw $break;
// }
// } else {
// if (!tags.include(x)) {
// is_true = false;
// throw $break;
// }
// }
// })
//
// return is_true
// },
//
// process: function(tags, command) {
// if (command.match(/^\[if/)) {
// var match = command.match(/\[if\s+(.+?)\s*,\s*(.+?)\]/)
// if (TagScript.test(tags, match[1])) {
// return TagScript.process(tags, match[2]);
// } else {
// return tags;
// }
// } else if (command == "[reset]") {
// return [];
// } else if (command[0] == "-") {
// return tags.reject(function(x) {return x == command.substr(1, 100)})
// } else {
// tags.push(command)
// return tags;
// }
// },
//
// run: function(post_id, tag_script) {
// var commands = TagScript.parse(tag_script);
// var post = Post.posts.get(post_id);
// var old_tags = post.tags.join(" ");
//
// commands.each(function(x) {
// post.tags = TagScript.process(post.tags, x);
// })
//
// Post.update(post_id, {"post[old_tags]": old_tags, "post[tags]": post.tags.join(" ")});
// }
// }
(function() {
Danbooru.Post = {};
Danbooru.Post.initialize_all = function() {
this.initialize_tag_and_wiki_menu();
this.initialize_tag_list();
this.initialize_post_sections();
}
Danbooru.Post.initialize_tag_list = function() {
$("#tag-box a.search-inc-tag").click(function(e) {
$("#tags").val($("#tags").val() + " " + $(e.target).parent("li").data("tag-name"));
return false;
});
$("#tag-box a.search-exl-tag").click(function(e) {
$("#tags").val($("#tags").val() + " -" + $(e.target).parent("li").data("tag-name"));
return false;
});
}
Danbooru.Post.initialize_tag_and_wiki_menu = function() {
$("#tag-and-wiki-box h1 a").click(function(e) {
$("#tag-box").hide();
$("#wiki-box").hide();
$("#tag-and-wiki-box menu li").toggleClass("active");
var name = e.target.hash;
$(name).show();
e.stopPropagation();
return false;
});
$("#tag-and-wiki-box menu li:first-child").addClass("active");
$("#wiki-box").hide();
}
Danbooru.Post.initialize_post_sections = function() {
$("#post-sections li a").click(function(e) {
$("#comments").hide();
$("#notes").hide();
$("#edit").hide();
$("#post-sections li").removeClass("active");
$(e.target).parent("li").addClass("active");
var name = e.target.hash;
$(name).show();
e.stopPropagation();
return false;
});
$("#post-sections li:first-child").addClass("active");
$("#notes").hide();
$("#edit").hide();
}
})();
$(document).ready(function() {
// $("#mode-box select").click(PostModeMenu.change);
// PostModeMenu.init();
Danbooru.Post.initialize_all();
});

View File

@@ -0,0 +1,13 @@
$(document).ready(function() {
var img = $("#image-preview img");
if (img) {
var height = img.attr("height");
var width = img.attr("width");
if (height > 400) {
var ratio = 400.0 / height;
img.attr("height", height * ratio);
img.attr("width", width * ratio);
$("#scale").val("Scaled " + parseInt(100 * ratio) + "%");
}
}
});

View File

@@ -0,0 +1,13 @@
$(document).ready(function() {
$("footer.nav-links a").click(function(event) {
$("div.users div.new > div").hide();
$(event.target.hash).show();
});
if (Danbooru.meta("errors")) {
$("#p1").hide();
$("#notice").hide();
} else {
$("#p2").hide();
}
});

View File

@@ -0,0 +1,21 @@
(function() {
Danbooru.meta = function(key) {
return $("meta[name=" + key + "]").attr("content");
}
Danbooru.j_alert = function(title, msg) {
$('<div title="' + title + '"></div>').html(msg).dialog();
}
Danbooru.j_error = function(msg) {
this.j_alert("Error", msg);
}
Danbooru.ajax_start = function(target) {
$(target).after(' <img src="/images/wait.gif" width="15" height="5" class="wait">');
}
Danbooru.ajax_stop = function(target) {
$(target).next("img.wait").remove();
}
})();

View File

@@ -0,0 +1,36 @@
(function() {
Danbooru.WikiPage = {};
Danbooru.WikiPage.initialize_all = function() {
$("#c-wiki-pages #preview").hide();
this.initialize_preview_link();
}
Danbooru.WikiPage.initialize_preview_link = function() {
$("#c-wiki-pages #preview a[name=toggle-preview]").click(function() {
$("#preview").toggle();
$("#dtext-help").toggle();
});
$("#c-wiki-pages input[value=Preview]").click(function(e) {
e.preventDefault();
$.ajax({
type: "post",
url: "/dtext/preview",
data: {
body: $("#wiki_page_body").val()
},
success: function(data) {
$("#dtext-help").hide();
$("#preview").show();
$("#preview .content").html(data);
}
});
});
}
})();
$(document).ready(function() {
Danbooru.WikiPage.initialize_all();
});

View File

@@ -0,0 +1,925 @@
/*= require "smoothness/jquery-ui-1.8.5.custom.css" */
$link_color: #006FFA;
$link_hover_color: #9093FF;
.blacklisted {
display: none !important;
}
body, div, h1, h2, h3, h4, h5, h6, p, ul, li, dd, dt, header, aside {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.25em;
}
body {
font-size: 87.5%;
}
h1, h2, h3, h4 {
font-family: Tahoma;
line-height: 1em;
}
body {
padding: 1em 2em;
margin: 0;
}
article, section {
display: block;
}
a:link {
color: $link_color;
text-decoration: none;
}
a:visited {
color: $link_color;
text-decoration: none;
}
a:hover {
color: $link_hover_color;
text-decoration: none;
}
a:active {
color: $link_color;
text-decoration: none;
}
abbr[title=required] {
display: none;
}
blockquote {
margin: 0 0 1em 0;
padding: 1em;
border: 1px solid #666;
background: #EEE;
}
code {
font-family: monospace;
font-size: 1.2em;
}
dd {
margin-bottom: 1em;
}
dt {
font-weight: bold;
}
h1 {
font-size: 2.1818em;
}
h2 {
font-size: 1.9091em;
}
h3 {
font-size: 1.6364em;
}
h4 {
font-size: 1.4545em;
}
h5 {
font-size: 1.2727em;
}
h6 {
font-size: 1.090em;
}
header {
margin: 0 0 1em 0;
padding: 0;
display: block;
}
img {
border: none;
vertical-align: middle;
}
input[type=text], input[type=password], input[type=url], textarea, button {
/* border: 1px solid #AAA;*/
font-size: 1em;
/* -moz-border-radius: 4px;*/
/* -webkit-border-radius: 4px;*/
}
input[type=submit] {
padding: 1px 4px;
/* border: 1px solid #AAA;*/
/* background-color: #EEE;*/
/* -moz-border-radius: 4px;*/
/* -webkit-border-radius: 4px;*/
font-size: 1em;
cursor: pointer;
}
input:focus, textarea:focus {
/* background-color: #FFD;*/
}
input[type=submit]:hover {
/* background-color: #F6F6F6;*/
}
menu {
margin: 0;
padding: 0;
ul {
margin: 0;
padding: 0;
}
li {
margin: 0 1em 0 0;
padding: 0;
list-style-type: none;
display: inline;
}
}
p {
margin-bottom: 1em;
}
section {
display: block;
}
span.error {
display: block;
font-weight: bold;
color: red;
}
span.link {
color: $link_color;
cursor: pointer;
}
span.wait {
color: #CCC;
}
span.ui-icon {
float: left;
margin-right: 0.25em;
}
table tfoot {
margin-top: 2em;
}
table.striped {
tbody {
tr:hover {
background-color: #FFE;
}
}
tr.even {
background-color: #EEE;
}
}
div.error-messages {
margin: 1em 0;
padding: 1em;
span.ui-icon {
float: left;
margin-right: 0.5em;
}
h1 {
font-size: 1em;
color: #A00;
}
}
div#search {
margin-bottom: 1em;
}
div#notice {
margin: 1em 0;
padding: 1em;
span.ui-icon {
float: left;
margin-right: 0.5em;
}
}
div#page {
aside#sidebar {
width: 20%;
float: left;
h1 {
font-size: 1.2em;
}
ul {
list-style-type: none;
}
}
aside#sidebar > section {
margin-bottom: 1em;
}
section#content {
width: 75%;
float: left;
margin-left: 2em;
}
}
div.clearfix {
clear: both;
}
/*** Paginator ***/
div.paginator {
display: block;
padding: 2em 0 1em 0;
font-size: 1em;
text-align: center;
font-weight: bold;
clear: both;
a {
margin: 0 3px;
padding: 2px 6px;
font-weight: normal;
border: 1px solid #EAEAEA;
}
a.arrow {
border: none;
}
a.arrow:hover {
background: white;
color: #9093FF;
}
a.current {
border: 1px solid #AAA;
}
a:hover {
background: rgb(60, 60, 220);
color: white;
}
span {
margin: 0 3px;
padding: 2px 6px;
}
}
/*** Header ***/
body > header > h1 {
font-size: 3em;
font-family: Tahoma, Helvetica, sans-serif;
}
/*** Dialog Boxes ***/
div.ui-dialog {
ul {
margin-left: 1em;
margin-bottom: 1em;
}
}
/*** Simple Form ***/
form.simple_form {
margin: 0 0 1em 0;
div.input.boolean {
label {
display: inline;
}
}
div.input {
margin-bottom: 1em;
input[type=text], input[type=file] {
width: 20em;
}
textarea {
width: 30em;
}
label {
display: block;
cursor: pointer;
font-weight: bold;
}
span.hint {
color: #666;
font-style: italic;
display: block;
}
fieldset {
border: none;
display: inline;
margin: 0;
padding: 0;
label {
font-weight: normal;
width: auto;
margin-right: 2em;
}
}
}
}
/*** DText Preview ***/
div.dtext {
width: 30em;
ul {
margin-left: 1em;
}
}
/*** Pools Posts ***/
div#c-pools-posts {
div#a-new {
form {
margin-bottom: 1em;
}
li {
margin-left: 1em;
cursor: pointer;
}
}
}
/*** Pools ***/
div#c-pools {
div#a-edit {
p {
width: 30em;
}
ul.ui-sortable {
list-style-type: none;
span {
margin: 0;
float: right;
cursor: pointer;
}
li {
padding: 0.5em;
}
li.ui-state-default {
margin-bottom: 20px;
width: 180px;
background: none;
}
li.ui-state-placeholder {
margin-bottom: 20px;
width: 180px;
height: 150px;
background: none;
}
}
}
}
/*** 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: 30em;
float: left;
}
}
}
div.comment-preview {
margin-bottom: 2em;
}
}
div.dtext-preview {
border: 2px dashed #AAA;
padding: 1em;
margin: 1em;
width: 30em;
}
div#c-comments {
div#a-index {
div.header {
span.info {
margin-right: 1.5em;
}
strong, time {
margin-right: 0.3em;
}
time {
font-weight: bold;
}
div.list-of-tags {
a {
margin-right: 0.5em;
}
}
div.notices {
margin: 1em 0;
}
}
div.preview {
float: left;
width: 180px;
}
div.post {
margin-bottom: 4em;
div.comments-for-post {
float: left;
width: 55em;
}
}
}
}
/*** Favorites ***/
div#c-favorites {
section#content > h1 {
display: none;
}
}
/*** Posts ***/
article.post-preview {
margin-right: 4em;
margin-bottom: 4em;
float: left;
}
div#c-posts {
div.notice {
font-size: 80%;
padding: 1em;
margin-bottom: 1em;
ul {
margin-left: 1em;
}
}
aside#sidebar > section#pool-sidebar {
span.ui-icon {
color: #666;
}
}
aside#sidebar > section > ul li {
list-style-type: none;
}
aside#sidebar > section > ul ul li {
margin-left: 1em;
}
section#tag-and-wiki-box {
padding: 0;
menu {
li {
display: inline-block;
}
li.active a {
color: #000;
}
}
div#tag-box {
h2 {
display: none;
}
li {
list-style-type: none;
}
}
div#wiki-box {
h2 {
display: none;
}
}
}
section#content > h1 {
display: none;
}
section#content {
section > h2 {
display: none;
}
menu#post-sections {
margin-bottom: 1em;
li {
font-size: 1.1em;
font-weight: bold;
}
li.active a {
color: black;
}
}
section#edit {
fieldset {
label {
display: inline;
}
}
}
}
}
/*** Post Histories ***/
div.post_histories {
div.index {
div.post {
margin-bottom: 2em;
div.preview {
width: 20%;
float: left;
}
div.history {
width: 70%;
float: left;
table {
width: 100%;
}
ins {
color: green;
text-decoration: none;
}
del {
color: red;
text-decoration: line-through;
}
}
}
}
}
/*** Post Unapprovals ***/
div#unapprove-dialog {
p {
margin-bottom: 1em;
}
}
/*** Sessions ***/
div#sessions {
div#new {
section {
width: 30em;
float: left;
}
aside {
width: 20em;
float: left;
li {
display: list-item;
margin-bottom: 0.5em;
list-style-type: square;
margin-left: 1em;
}
}
h2 {
margin-bottom: 5px;
}
}
}
/*** Artists ***/
div#c-artists {
span.new-artist {
font-weight: bold;
color: #A00;
}
div#a-show {
max-width: 60em;
p.legend {
margin-bottom: 2em;
font-size: 0.8em;
font-style: italic;
}
}
div#a-edit, div#a-new {
textarea {
height: 5em;
}
}
}
/*** Users ***/
div.users {
div.new {
max-width: 60em;
p {
margin-bottom: 1em;
}
li {
margin-left: 1em;
}
div#account-comparison {
li {
font-size: 0.9em;
line-height: 1.5em;
}
section {
width: 18em;
float: left;
padding: 1em;
}
}
footer.nav-links {
font-size: 1.4545em;
font-weight: bold;
text-align: center;
display: block;
}
div#p2 ul {
margin-bottom: 2em;
}
}
}
/*** Uploads ***/
div#c-uploads {
div#a-new {
div#upload-guide-notice {
margin-bottom: 2em;
}
fieldset.ratings {
label {
display: inline;
}
}
}
}
/*** Forum ***/
div.list-of-forum-posts {
article {
margin-bottom: 3em;
div.author {
width: 20%;
float: left;
}
div.content {
margin-left: 2em;
width: 30em;
float: left;
menu {
margin-top: 0.5em;
}
}
}
}
div#c-forum-topics {
div.single-forum-post {
width: 60em;
}
div#a-show {
h1#forum-topic-title {
font-size: 2.1818em;
}
}
span.info {
color: #AAA;
}
div#form-content {
float: left;
width: 450px;
padding-right: 1em;
}
div#form-aside {
float: left;
width: 400px;
div#preview > p {
margin-top: 0.5em;
padding-top: 0.5em;
border-top: 1px solid #AAA;
}
}
}
/*** Wiki Pages ***/
div#c-wiki-pages {
span.version {
color: #AAA;
}
div#form-content {
float: left;
width: 30em;
padding-right: 1em;
}
div#form-aside {
float: left;
width: 20em;
div#preview > p {
margin-top: 0.5em;
padding-top: 0.5em;
border-top: 1px solid #AAA;
}
}
div#a-edit, div#a-new {
div#preview {
}
}
}
/*** Post Moderation ***/
div#c-post-moderation {
article {
margin-bottom: 4em;
}
aside {
float: left;
width: 520px;
}
section {
float: left;
width: 300px;
}
}
/*** Note Container ***/
div#note-container {
position: absolute;
div.note-body {
background: #FFE;
border: 1px solid black;
max-width: 300px;
min-width: 140px;
min-height: 10px;
position: absolute;
padding: 5px;
cursor: pointer;
overflow: auto;
p.tn {
font-size: 0.8em;
color: gray;
}
}
div.note-box {
position: absolute;
border: 1px solid black;
width: 150px;
height: 150px;
cursor: move;
background: #FFE;
div.note-corner {
background: black;
width: 7px;
height: 7px;
position: absolute;
bottom: 0;
right: 0;
cursor: se-resize;
}
}
div.unsaved {
background: #FFF;
border: 1px solid red;
div.note-corner {
background: red;
}
}
}
div#jquery-test div.note {
background: #FFE;
border: 1px solid black;
max-width: 300px;
min-width: 140px;
min-height: 10px;
position: absolute;
padding: 5px;
cursor: pointer;
overflow: auto;
}

View File

@@ -40,7 +40,7 @@ class Post < ActiveRecord::Base
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :before_id, lambda {|id| id.present? ? where(["posts.id < ?", id]) : where("TRUE")}
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
search_method :tag_match
search_methods :tag_match
module FileMethods
def delete_files

View File

@@ -3,7 +3,7 @@ class Tag < ActiveRecord::Base
after_save :update_category_cache
has_one :wiki_page, :foreign_key => "name", :primary_key => "title"
scope :name_matches, lambda {|name| where(["name LIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])}
search_method :name_matches
search_methods :name_matches
class CategoryMapping
Danbooru.config.reverse_tag_category_mapping.each do |value, category|

View File

@@ -14,8 +14,8 @@
<meta name="errors" content="true">
<% end %>
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
<%= stylesheet_link_tag "compiled/default", "smoothness/jquery-ui-1.8.5.custom.css", :cache => true %>
<%= javascript_include_tag :defaults, :cache => true %>
<link rel="stylesheet" href="/assets/application.css" media="screen" type="text/css">
<script src="/assets/application.js" type="text/javascript" charset="utf-8" async defer></script>
<%= Danbooru.config.custom_html_header_content %>
<%= yield :html_header %>
</head>