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();
});