diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb
index 10f297bfe..25fb9e3a7 100644
--- a/app/controllers/tag_aliases_controller.rb
+++ b/app/controllers/tag_aliases_controller.rb
@@ -3,7 +3,7 @@ class TagAliasesController < ApplicationController
respond_to :html, :xml, :json
def new
- @tag_alias = TagAlias.new
+ @tag_alias = TagAlias.new(params[:tag_alias])
respond_with(@tag_alias)
end
diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb
index 2f589fbe9..be86cd838 100644
--- a/app/controllers/wiki_pages_controller.rb
+++ b/app/controllers/wiki_pages_controller.rb
@@ -2,6 +2,7 @@ class WikiPagesController < ApplicationController
respond_to :html, :xml, :json
before_filter :member_only, :except => [:index, :show]
before_filter :moderator_only, :only => [:destroy]
+ before_filter :normalize_search_params, :only => [:index]
def new
@wiki_page = WikiPage.new
@@ -53,4 +54,12 @@ class WikiPagesController < ApplicationController
@wiki_page.revert_to!(@version)
respond_with(@wiki_page)
end
+
+private
+ def normalize_search_params
+ if params[:title]
+ params[:search] ||= {}
+ params[:search][:title_equals] = params.delete(:title)
+ end
+ end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 716a5532e..26758a192 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -34,7 +34,7 @@ module ApplicationHelper
end
def wait_image(html_id)
- ('
').html_safe
+ ('
').html_safe
end
protected
diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb
index ac4073bfd..4eefe90fb 100644
--- a/app/models/tag_alias.rb
+++ b/app/models/tag_alias.rb
@@ -29,6 +29,14 @@ class TagAlias < ActiveRecord::Base
self.creator_id = CurrentUser.user.id
end
+ def antecedent_tag
+ Tag.find_by_name(antecedent_name)
+ end
+
+ def consequent_tag
+ Tag.find_by_name(consequent_name)
+ end
+
def absence_of_transitive_relation
# We don't want a -> b && b -> c chains
if self.class.exists?(["antecedent_name = ?", consequent_name]) || self.class.exists?(["consequent_name = ?", antecedent_name])
diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb
index 89ebfabee..6b0d2443d 100644
--- a/app/views/artists/show.html.erb
+++ b/app/views/artists/show.html.erb
@@ -61,7 +61,7 @@
- <% form_tag(tag_aliases_path, :method => :get) do %>
- <%= text_field_tag "query", params[:query] %>
- <%= submit_tag "Search Aliases" %>
- <%= submit_tag "Search Implications" %>
- <% end %>
-
+
+
+
+ <% form_tag(tag_aliases_path, :method => :get) do %>
+ <%= text_field_tag "query", params[:query] %>
+ <%= submit_tag "Search Aliases" %>
+ <%= submit_tag "Search Implications" %>
+ <% end %>
+
-
- <% form_tag(:action => "update") do %>
- |
- From |
+ From |
To |
- Reason |
+ Reference |
+ |
-
-
- |
- <% if @current_user.is_admin_or_higher? %>
- <%= button_to_function "Select pending", "$$('.pending').each(function(x) {x.checked = true})" %>
- <%= submit_tag "Approve" %>
- <%= button_to_function "Delete", "$('reason-box').show(); $('reason').focus()" %>
- <%= submit_tag "Fix" %>
- <%= button_to_function "Add", "$('add-box').show().scrollTo(); $('tag_alias_name').focus()" %>
-
-
- Reason:
- <%= text_field_tag "reason", "", :size => 40 %>
- <%= submit_tag "Delete" %>
-
- <% end %>
-
- |
-
-
- <% @aliases.each do |a| %>
-
- | > |
- <%= link_to h(a.name), :controller => "post", :action => "index", :tags => a.name %> (<%= Tag.find_by_name(a.name).post_count rescue 0 %>) |
- <%= link_to h(a.alias_name), :controller => "post", :action => "index", :tags => a.alias_name %> (<%= Tag.find(a.alias_id).post_count rescue 0 %>) |
- <%= format_text(a.reason) %> |
+ <% @tag_aliases.each do |tag_alias| %>
+
+ | <%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>) |
+ <%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>) |
+ <%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %> |
+
+ <% if CurrentUser.is_admin? %>
+ <%= link_to "Delete", :url => tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
+ <% end %>
+ |
<% end %>
- <% end %>
-
-
-<% if @current_user.is_admin_or_higher? %>
-
style="display: none;"<% end %>>
- <% form_tag(:action => "create") do %>
-
Add Alias
-
- <% unless @current_user.is_anonymous? %>
- <%= hidden_field_tag "tag_alias[creator_id]", @current_user.id %>
- <% end %>
-
-
-
- |
- <%= text_field "tag_alias", "name", :size => 40, :value => params[:from_name] %> |
-
-
- |
- <%= text_field "tag_alias", "alias", :size => 40, :value => params[:to_name] %> |
-
-
- |
- <%= text_area "tag_alias", "reason", :size => "40x2", :value => params[:reason] %> |
-
-
- | <%= submit_tag "Submit" %> |
-
-
- <% end %>
-<% end %>
+
<%= will_paginate(@aliases) %>
-<% content_for("subnavbar") do %>
-
<%= link_to "List", :controller => "tag_alias", :action => "index" %>
-
<%= link_to "Add", :controller => "tag_alias", :action => "new" %>
-
<%= link_to "Help", :controller => "help", :action => "tag_aliases" %>
-<% end %>
+<%= render "secondary_links" %>
diff --git a/app/views/tag_aliases/new.html.erb b/app/views/tag_aliases/new.html.erb
index 98d58afe5..b0ebea015 100644
--- a/app/views/tag_aliases/new.html.erb
+++ b/app/views/tag_aliases/new.html.erb
@@ -1,20 +1,13 @@
-<% form_tag(:controller => "forum", :action => "create") do %>
-
You can create a forum thread to suggest the creation of an alias.
-
-
- |
- <%= text_field "tag_alias", "name", :size => 40 %> |
-
-
- |
- <%= text_field "tag_alias", "alias", :size => 40 %> |
-
-
- |
- <%= text_area "tag_alias", "reason", :rows => 10, :cols => 60 %> |
-
-
- | <%= submit_tag "Submit" %> |
-
-
-<% end %>
+
+
+
New Tag Alias
+ <%= simple_form_for(@tag_alias) do |f| %>
+ <%= f.input :antecedent_name, :label => "From" %>
+ <%= f.input :consequent_name, :label => "To" %>
+ <%= f.input :forum_topic_id, :label => "Forum" %>
+ <%= f.button :submit %>
+ <% end %>
+
+
+
+<%= render "secondary_links" %>
\ No newline at end of file
diff --git a/app/views/unapprovals/create.js.erb b/app/views/unapprovals/create.js.erb
index d6397a6bb..b4b9cab48 100644
--- a/app/views/unapprovals/create.js.erb
+++ b/app/views/unapprovals/create.js.erb
@@ -1,8 +1,8 @@
var errors = <%= @unapproval.errors.full_messages.to_json.html_safe %>;
if (errors.length > 0) {
- Danbooru.Utility.j_error(errors.join("; "));
+ Danbooru.j_error(errors.join("; "));
} else {
- Danbooru.Utility.j_alert("Unapproval", "Unapproval successful");
+ Danbooru.j_alert("Unapproval", "Unapproval successful");
$("a#approve").show();
$("a#disapprove").show();
$("a#unapprove").hide();
diff --git a/public/javascripts/compiled/default.js b/public/javascripts/compiled/default.js
index 55802323b..d3d999587 100644
--- a/public/javascripts/compiled/default.js
+++ b/public/javascripts/compiled/default.js
@@ -664,8 +664,47 @@ a,b,d,e){return d-f.easing.easeOutBounce(c,e-a,0,d,e)+b},easeOutBounce:function(
});
});
-Cookie = {
- put: function(name, value, days) {
+$(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();
+ });
+
+ // 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 = {};
+(function() {
+ Danbooru.Cookie = {};
+
+ Danbooru.Cookie.put = function(name, value, days) {
if (days == null) {
days = 365;
}
@@ -674,9 +713,9 @@ Cookie = {
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
- },
-
- raw_get: function(name) {
+ }
+
+ Danbooru.Cookie.raw_get = function(name) {
var nameEq = name + "=";
var ca = document.cookie.split(";");
@@ -693,21 +732,21 @@ Cookie = {
}
return "";
- },
+ }
- get: function(name) {
+ Danbooru.Cookie.get = function(name) {
return this.unescape(this.raw_get(name));
- },
+ }
- remove: function(name) {
- Cookie.put(name, "", -1);
- },
+ Danbooru.Cookie.remove = function(name) {
+ this.put(name, "", -1);
+ }
- unescape: function(val) {
+ Danbooru.Cookie.unescape = function(val) {
return decodeURIComponent(val.replace(/\+/g, " "));
- },
+ }
- setup: function() {
+ 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];
@@ -721,59 +760,33 @@ Cookie = {
}
}
}
-}
+})();
+
$(document).ready(function() {
- Cookie.setup();
-
- // $("#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").attr("data-post-id");
- $(".comment-section[data-post-id=" + post_id + "] form").show();
- $(this).hide();
- });
-
- // Image resize sidebar
- $("#resize-links").hide();
-
- $("#resize-links a").click(function(e) {
- var image = $("#image");
- var target = $(e.target);
- image.attr("src", target.attr("data-src"));
- image.attr("width", target.attr("data-width"));
- image.attr("height", target.attr("data-height"));
- e.preventDefault();
- });
-
- $("#resize-link a").click(function(e) {
- $("#resize-links").toggle();
- e.preventDefault();
- });
+ Danbooru.Cookie.initialize();
});
-
-var Danbooru = {};
(function() {
- Danbooru.Utility = {};
+ Danbooru.meta = function(key) {
+ return $("meta[name=" + key + "]").attr("content");
+ }
- Danbooru.Utility.j_alert = function(title, msg) {
+ Danbooru.j_alert = function(title, msg) {
$('
').html(msg).dialog();
}
- Danbooru.Utility.j_error = function(msg) {
+ Danbooru.j_error = function(msg) {
this.j_alert("Error", msg);
}
+
+ Danbooru.ajax_start = function(element) {
+ $(element).after('
...');
+ }
+
+ Danbooru.ajax_stop = function(element) {
+ $(element).next("span.wait").remove();
+ }
})();
-
// PostModeMenu = {
// init: function() {
// this.original_background_color = $(document.body).css("background-color")
@@ -949,12 +962,12 @@ var Danbooru = {};
Danbooru.Post.initialize_tag_list = function() {
$("#tag-box a.search-inc-tag").click(function(e) {
- $("#tags").val($("#tags").val() + " " + $(e.target).parent("li").attr("data-tag-name"));
+ $("#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").attr("data-tag-name"));
+ $("#tags").val($("#tags").val() + " -" + $(e.target).parent("li").data("tag-name"));
return false;
});
}
@@ -1009,10 +1022,9 @@ $(document).ready(function() {
Danbooru.Comment.initialize_response_link = function() {
$("a.expand-comment-response").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$(e.target).closest("div.new-comment").find("form").show();
$(e.target).hide();
- return false;
});
$("div.new-comment form").hide();
@@ -1020,19 +1032,16 @@ $(document).ready(function() {
Danbooru.Comment.initialize_preview_button = function() {
$("div.new-comment input[type=submit][value=Preview]").click(function(e) {
- e.stopPropagation();
- $.ajax({
- context: e.target,
- url: "/dtext/preview",
+ e.preventDefault();
+ $.ajax("/dtext/preview", {
+ type: "post",
data: {
body: $(e.target).closest("form").find("textarea").val()
},
- success: function(data, text_status, xhr) {
- $(this).closest("div.new-comment").find("div.comment-preview").show().html(data);
- },
- type: "post"
+ success: function(data) {
+ $(e.target).closest("div.new-comment").find("div.comment-preview").show().html(data);
+ }
});
- return false;
});
}
})();
@@ -1041,17 +1050,17 @@ $(document).ready(function() {
Danbooru.Comment.initialize_all();
});
$(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) + "%");
- }
- }
+ 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) + "%");
+ }
+ }
});
$(document).ready(function() {
$("footer.nav-links a").click(function(event) {
@@ -1059,7 +1068,7 @@ $(document).ready(function() {
$(event.target.hash).show();
});
- if ($("meta[name=errors]").attr("content")) {
+ if (Danbooru.meta("errors")) {
$("#p1").hide();
$("#notice").hide();
} else {
@@ -1076,15 +1085,13 @@ $(document).ready(function() {
}
Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() {
- var favorites = $("meta[name=favorites]").attr("content");
- var current_user_id = $("meta[name=current-user-id]").attr("content");
-
+ 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();
@@ -1095,46 +1102,46 @@ $(document).ready(function() {
Danbooru.Favorite.initialize_add_to_favorites = function() {
$("a#add-to-favorites").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$.ajax({
+ type: "post",
url: "/favorites",
data: {
- id: $("meta[name=post-id]").attr("content")
+ id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#add-to-favorites-wait").show();
+ Danbooru.ajax_start(e.target);
},
- success: function(data, text_status, xhr) {
+ success: function() {
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();
- $("img#add-to-favorites-wait").hide();
},
- type: "post"
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
+ }
});
-
- return false;
});
}
Danbooru.Favorite.initialize_remove_from_favorites = function() {
$("a#remove-from-favorites").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$.ajax({
- url: "/favorites/" + $("meta[name=post-id]").attr("content"),
+ type: "delete",
+ url: "/favorites/" + Danbooru.meta("post-id"),
beforeSend: function() {
- $("img#remove-from-favorites-wait").show();
+ Danbooru.ajax_start(e.target);
},
- success: function(data, text_status, xhr) {
+ success: function() {
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();
- $("img#remove-from-favorites-wait").hide();
},
- type: "delete"
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
+ }
});
-
- return false;
});
}
})();
@@ -1151,7 +1158,7 @@ $(document).ready(function() {
}
Danbooru.Unapproval.hide_or_show_unapprove_link = function() {
- if ($("meta[name=post-is-unapprovable]").attr("content") != "true") {
+ if (Danbooru.meta("post-is-unapprovable") != "true") {
$("a#unapprove").hide();
}
}
@@ -1172,9 +1179,9 @@ $(document).ready(function() {
}
});
- $("a#unapprove").click(function() {
+ $("a#unapprove").click(function(e) {
+ e.preventDefault();
$("#unapprove-dialog").dialog("open");
- return false;
});
}
})();
@@ -1195,14 +1202,14 @@ $(document).ready(function() {
}
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
- if ($("meta[name=post-is-approvable]").attr("content") != "true") {
+ if (Danbooru.meta("post-is-approvable") != "true") {
$("a#approve").hide();
$("a#disapprove").hide();
}
}
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
- if ($("meta[name=post-is-deleted]").attr("content") == "true") {
+ if (Danbooru.meta("post-is-deleted") == "true") {
$("a#delete").hide();
} else {
$("a#undelete").hide();
@@ -1210,60 +1217,76 @@ $(document).ready(function() {
}
Danbooru.PostModeration.initialize_delete_link = function() {
- $("a#delete").click(function() {
+ $("a#delete").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/delete.js",
type: "post",
+ url: "/post_moderation/delete.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#delete-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_undelete_link = function() {
- $("a#undelete").click(function() {
+ $("a#undelete").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/undelete.js",
type: "post",
+ url: "/post_moderation/undelete.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#undelete-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_disapprove_link = function() {
- $("a#disapprove").click(function() {
+ $("a#disapprove").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/disapprove.js",
type: "put",
+ url: "/post_moderation/disapprove.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#disapprove-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_approve_link = function() {
- $("a#approve").click(function() {
+ $("a#approve").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/approve.js",
type: "put",
+ url: "/post_moderation/approve.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#approve-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
@@ -1296,12 +1319,13 @@ $(document).ready(function() {
minLength: 4,
});
- $("a#pool").click(function() {
+ $("a#pool").click(function(e) {
+ e.preventDefault();
$("#add-to-pool-dialog").dialog("open");
- return false;
});
- $("ul#recent-pools li").click(function() {
+ $("ul#recent-pools li").click(function(e) {
+ e.preventDefault();
$("#pool_name").val($(this).html());
});
}
@@ -1317,8 +1341,8 @@ $(document).ready(function() {
$("div.pools div.edit form#ordering-form").submit(function(e) {
$.ajax({
- url: e.target.action,
type: "put",
+ url: e.target.action,
data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize()
});
return false;
diff --git a/public/javascripts/src/app/application.js b/public/javascripts/src/app/application.js
index 84dddaa45..2c3ece0c3 100644
--- a/public/javascripts/src/app/application.js
+++ b/public/javascripts/src/app/application.js
@@ -1,6 +1,4 @@
$(document).ready(function() {
- Cookie.setup();
-
// $("#hide-upgrade-account-link").click(function() {
// $("#upgrade-account").hide();
// Cookie.put('hide-upgrade-account', '1', 7);
@@ -13,7 +11,7 @@ $(document).ready(function() {
// Comment listing
$(".comment-section form").hide();
$(".comment-section input.expand-comment-response").click(function() {
- var post_id = $(this).closest(".comment-section").attr("data-post-id");
+ var post_id = $(this).closest(".comment-section").data("post-id");
$(".comment-section[data-post-id=" + post_id + "] form").show();
$(this).hide();
});
@@ -24,9 +22,9 @@ $(document).ready(function() {
$("#resize-links a").click(function(e) {
var image = $("#image");
var target = $(e.target);
- image.attr("src", target.attr("data-src"));
- image.attr("width", target.attr("data-width"));
- image.attr("height", target.attr("data-height"));
+ image.attr("src", target.data("src"));
+ image.attr("width", target.data("width"));
+ image.attr("height", target.data("height"));
e.preventDefault();
});
@@ -36,5 +34,4 @@ $(document).ready(function() {
});
});
-
var Danbooru = {};
diff --git a/public/javascripts/src/app/comments.js b/public/javascripts/src/app/comments.js
index fc2b1e0a4..7050f2dcd 100644
--- a/public/javascripts/src/app/comments.js
+++ b/public/javascripts/src/app/comments.js
@@ -8,10 +8,9 @@
Danbooru.Comment.initialize_response_link = function() {
$("a.expand-comment-response").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$(e.target).closest("div.new-comment").find("form").show();
$(e.target).hide();
- return false;
});
$("div.new-comment form").hide();
@@ -19,19 +18,16 @@
Danbooru.Comment.initialize_preview_button = function() {
$("div.new-comment input[type=submit][value=Preview]").click(function(e) {
- e.stopPropagation();
- $.ajax({
- context: e.target,
- url: "/dtext/preview",
+ e.preventDefault();
+ $.ajax("/dtext/preview", {
+ type: "post",
data: {
body: $(e.target).closest("form").find("textarea").val()
},
- success: function(data, text_status, xhr) {
- $(this).closest("div.new-comment").find("div.comment-preview").show().html(data);
- },
- type: "post"
+ success: function(data) {
+ $(e.target).closest("div.new-comment").find("div.comment-preview").show().html(data);
+ }
});
- return false;
});
}
})();
diff --git a/public/javascripts/src/app/cookie.js b/public/javascripts/src/app/cookie.js
index 4b254f6f8..9c82ccce5 100644
--- a/public/javascripts/src/app/cookie.js
+++ b/public/javascripts/src/app/cookie.js
@@ -1,5 +1,7 @@
-Cookie = {
- put: function(name, value, days) {
+(function() {
+ Danbooru.Cookie = {};
+
+ Danbooru.Cookie.put = function(name, value, days) {
if (days == null) {
days = 365;
}
@@ -8,9 +10,9 @@ Cookie = {
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
- },
-
- raw_get: function(name) {
+ }
+
+ Danbooru.Cookie.raw_get = function(name) {
var nameEq = name + "=";
var ca = document.cookie.split(";");
@@ -27,21 +29,21 @@ Cookie = {
}
return "";
- },
+ }
- get: function(name) {
+ Danbooru.Cookie.get = function(name) {
return this.unescape(this.raw_get(name));
- },
+ }
- remove: function(name) {
- Cookie.put(name, "", -1);
- },
+ Danbooru.Cookie.remove = function(name) {
+ this.put(name, "", -1);
+ }
- unescape: function(val) {
+ Danbooru.Cookie.unescape = function(val) {
return decodeURIComponent(val.replace(/\+/g, " "));
- },
+ }
- setup: function() {
+ 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];
@@ -55,4 +57,9 @@ Cookie = {
}
}
}
-}
+})();
+
+$(document).ready(function() {
+ Danbooru.Cookie.initialize();
+});
+
diff --git a/public/javascripts/src/app/favorites.js b/public/javascripts/src/app/favorites.js
index fbdd87d94..4c058cc70 100644
--- a/public/javascripts/src/app/favorites.js
+++ b/public/javascripts/src/app/favorites.js
@@ -8,15 +8,13 @@
}
Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() {
- var favorites = $("meta[name=favorites]").attr("content");
- var current_user_id = $("meta[name=current-user-id]").attr("content");
-
+ 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();
@@ -27,46 +25,46 @@
Danbooru.Favorite.initialize_add_to_favorites = function() {
$("a#add-to-favorites").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$.ajax({
+ type: "post",
url: "/favorites",
data: {
- id: $("meta[name=post-id]").attr("content")
+ id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#add-to-favorites-wait").show();
+ Danbooru.ajax_start(e.target);
},
- success: function(data, text_status, xhr) {
+ success: function() {
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();
- $("img#add-to-favorites-wait").hide();
},
- type: "post"
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
+ }
});
-
- return false;
});
}
Danbooru.Favorite.initialize_remove_from_favorites = function() {
$("a#remove-from-favorites").click(function(e) {
- e.stopPropagation();
+ e.preventDefault();
$.ajax({
- url: "/favorites/" + $("meta[name=post-id]").attr("content"),
+ type: "delete",
+ url: "/favorites/" + Danbooru.meta("post-id"),
beforeSend: function() {
- $("img#remove-from-favorites-wait").show();
+ Danbooru.ajax_start(e.target);
},
- success: function(data, text_status, xhr) {
+ success: function() {
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();
- $("img#remove-from-favorites-wait").hide();
},
- type: "delete"
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
+ }
});
-
- return false;
});
}
})();
diff --git a/public/javascripts/src/app/pools.js b/public/javascripts/src/app/pools.js
index f7d6e1e97..251b619c9 100644
--- a/public/javascripts/src/app/pools.js
+++ b/public/javascripts/src/app/pools.js
@@ -21,12 +21,13 @@
minLength: 4,
});
- $("a#pool").click(function() {
+ $("a#pool").click(function(e) {
+ e.preventDefault();
$("#add-to-pool-dialog").dialog("open");
- return false;
});
- $("ul#recent-pools li").click(function() {
+ $("ul#recent-pools li").click(function(e) {
+ e.preventDefault();
$("#pool_name").val($(this).html());
});
}
@@ -42,8 +43,8 @@
$("div.pools div.edit form#ordering-form").submit(function(e) {
$.ajax({
- url: e.target.action,
type: "put",
+ url: e.target.action,
data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize()
});
return false;
diff --git a/public/javascripts/src/app/post_moderation.js b/public/javascripts/src/app/post_moderation.js
index b1d20bba6..8b0cb63e7 100644
--- a/public/javascripts/src/app/post_moderation.js
+++ b/public/javascripts/src/app/post_moderation.js
@@ -11,14 +11,14 @@
}
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
- if ($("meta[name=post-is-approvable]").attr("content") != "true") {
+ if (Danbooru.meta("post-is-approvable") != "true") {
$("a#approve").hide();
$("a#disapprove").hide();
}
}
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
- if ($("meta[name=post-is-deleted]").attr("content") == "true") {
+ if (Danbooru.meta("post-is-deleted") == "true") {
$("a#delete").hide();
} else {
$("a#undelete").hide();
@@ -26,60 +26,76 @@
}
Danbooru.PostModeration.initialize_delete_link = function() {
- $("a#delete").click(function() {
+ $("a#delete").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/delete.js",
type: "post",
+ url: "/post_moderation/delete.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#delete-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_undelete_link = function() {
- $("a#undelete").click(function() {
+ $("a#undelete").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/undelete.js",
type: "post",
+ url: "/post_moderation/undelete.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#undelete-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_disapprove_link = function() {
- $("a#disapprove").click(function() {
+ $("a#disapprove").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/disapprove.js",
type: "put",
+ url: "/post_moderation/disapprove.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#disapprove-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
}
Danbooru.PostModeration.initialize_approve_link = function() {
- $("a#approve").click(function() {
+ $("a#approve").click(function(e) {
+ e.preventDefault();
$.ajax({
- url: "/post_moderation/approve.js",
type: "put",
+ url: "/post_moderation/approve.js",
data: {
- post_id: $("meta[name=post-id]").attr("content")
+ post_id: Danbooru.meta("post-id")
},
beforeSend: function() {
- $("img#approve-wait").show();
+ Danbooru.ajax_start(e.target);
+ },
+ complete: function() {
+ Danbooru.ajax_stop(e.target);
}
});
});
diff --git a/public/javascripts/src/app/posts.js b/public/javascripts/src/app/posts.js
index 783afc84f..5d16c70f2 100644
--- a/public/javascripts/src/app/posts.js
+++ b/public/javascripts/src/app/posts.js
@@ -173,12 +173,12 @@
Danbooru.Post.initialize_tag_list = function() {
$("#tag-box a.search-inc-tag").click(function(e) {
- $("#tags").val($("#tags").val() + " " + $(e.target).parent("li").attr("data-tag-name"));
+ $("#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").attr("data-tag-name"));
+ $("#tags").val($("#tags").val() + " -" + $(e.target).parent("li").data("tag-name"));
return false;
});
}
diff --git a/public/javascripts/src/app/unapprovals.js b/public/javascripts/src/app/unapprovals.js
index 1250d6faf..99fa0fe36 100644
--- a/public/javascripts/src/app/unapprovals.js
+++ b/public/javascripts/src/app/unapprovals.js
@@ -7,7 +7,7 @@
}
Danbooru.Unapproval.hide_or_show_unapprove_link = function() {
- if ($("meta[name=post-is-unapprovable]").attr("content") != "true") {
+ if (Danbooru.meta("post-is-unapprovable") != "true") {
$("a#unapprove").hide();
}
}
@@ -28,9 +28,9 @@
}
});
- $("a#unapprove").click(function() {
+ $("a#unapprove").click(function(e) {
+ e.preventDefault();
$("#unapprove-dialog").dialog("open");
- return false;
});
}
})();
diff --git a/public/javascripts/src/app/uploads.js b/public/javascripts/src/app/uploads.js
index fd10373fb..4713e536d 100644
--- a/public/javascripts/src/app/uploads.js
+++ b/public/javascripts/src/app/uploads.js
@@ -1,13 +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) + "%");
- }
- }
+ 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) + "%");
+ }
+ }
});
diff --git a/public/javascripts/src/app/users.js b/public/javascripts/src/app/users.js
index 2d4bd4502..ddef4a736 100644
--- a/public/javascripts/src/app/users.js
+++ b/public/javascripts/src/app/users.js
@@ -4,7 +4,7 @@ $(document).ready(function() {
$(event.target.hash).show();
});
- if ($("meta[name=errors]").attr("content")) {
+ if (Danbooru.meta("errors")) {
$("#p1").hide();
$("#notice").hide();
} else {
diff --git a/public/javascripts/src/app/utility.js b/public/javascripts/src/app/utility.js
index 1472018aa..5040faeca 100644
--- a/public/javascripts/src/app/utility.js
+++ b/public/javascripts/src/app/utility.js
@@ -1,12 +1,21 @@
(function() {
- Danbooru.Utility = {};
+ Danbooru.meta = function(key) {
+ return $("meta[name=" + key + "]").attr("content");
+ }
- Danbooru.Utility.j_alert = function(title, msg) {
+ Danbooru.j_alert = function(title, msg) {
$('
').html(msg).dialog();
}
- Danbooru.Utility.j_error = function(msg) {
+ Danbooru.j_error = function(msg) {
this.j_alert("Error", msg);
}
+
+ Danbooru.ajax_start = function(element) {
+ $(element).after('
...');
+ }
+
+ Danbooru.ajax_stop = function(element) {
+ $(element).next("span.wait").remove();
+ }
})();
-
diff --git a/public/stylesheets/compiled/default.css b/public/stylesheets/compiled/default.css
index b2fbd2504..b210be788 100644
--- a/public/stylesheets/compiled/default.css
+++ b/public/stylesheets/compiled/default.css
@@ -120,6 +120,9 @@ span.link {
color: #006ffa;
cursor: pointer; }
+span.wait {
+ color: #CCC; }
+
table tfoot {
margin-top: 2em; }
@@ -198,7 +201,7 @@ form.simple_form div.input {
margin-right: 10px;
text-align: right; }
form.simple_form div.input span.hint {
- margin-left: 10em;
+ margin-left: 11em;
color: #666;
font-style: italic;
vertical-align: top;
diff --git a/public/stylesheets/src/default.scss b/public/stylesheets/src/default.scss
index 3c3e6ebd9..2df028b94 100644
--- a/public/stylesheets/src/default.scss
+++ b/public/stylesheets/src/default.scss
@@ -2,21 +2,21 @@ $link_color: #006FFA;
$link_hover_color: #9093FF;
.blacklisted {
- display: none !important;
+ display: none !important;
}
body, div, h1, h2, h3, h4, h5, h6, p, ul, li, dd, dt {
font-family: Verdana, Geneva, sans-serif;
- font-size: 100%;
+ font-size: 100%;
margin: 0;
padding: 0;
- border: 0;
- vertical-align: baseline;
+ border: 0;
+ vertical-align: baseline;
}
h1, h2, h3, h4 {
font-family: Tahoma;
- line-height: 1em;
+ line-height: 1em;
}
body {
@@ -94,9 +94,9 @@ h6 {
}
header {
- margin: 0 0 1em 0;
- padding: 0;
- display: block;
+ margin: 0 0 1em 0;
+ padding: 0;
+ display: block;
}
img {
@@ -106,19 +106,19 @@ img {
input[type=text], input[type=password], input[type=url], textarea, button {
/* border: 1px solid #AAA;*/
- font-size: 1em;
+ font-size: 1em;
/* -moz-border-radius: 4px;*/
/* -webkit-border-radius: 4px;*/
}
input[type=submit] {
- padding: 1px 4px;
+ padding: 1px 4px;
/* border: 1px solid #AAA;*/
/* background-color: #EEE;*/
/* -moz-border-radius: 4px;*/
/* -webkit-border-radius: 4px;*/
- font-size: 1em;
- cursor: pointer;
+ font-size: 1em;
+ cursor: pointer;
}
input:focus, textarea:focus {
@@ -130,24 +130,24 @@ input[type=submit]:hover {
}
menu {
- margin: 0;
- padding: 0;
-
- ul {
- margin: 0;
- padding: 0;
- }
-
- li {
- margin: 0 1em 0 0;
- padding: 0;
- list-style-type: none;
- display: inline;
- }
+ margin: 0;
+ padding: 0;
+
+ ul {
+ margin: 0;
+ padding: 0;
+ }
+
+ li {
+ margin: 0 1em 0 0;
+ padding: 0;
+ list-style-type: none;
+ display: inline;
+ }
}
section {
- display: block;
+ display: block;
}
span.link {
@@ -155,6 +155,10 @@ span.link {
cursor: pointer;
}
+span.wait {
+ color: #CCC;
+}
+
table tfoot {
margin-top: 2em;
}
@@ -180,18 +184,18 @@ div#notice {
div#page {
aside#sidebar {
- width: 20%;
- float: left;
+ width: 20%;
+ float: left;
}
aside#sidebar > section {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
section#content {
width: 75%;
- float: left;
- margin-left: 2em;
+ float: left;
+ margin-left: 2em;
}
}
@@ -277,7 +281,7 @@ form.simple_form {
}
span.hint {
- margin-left: 10em;
+ margin-left: 11em;
color: #666;
font-style: italic;
vertical-align: top;
diff --git a/script/custom/compile_javascripts b/script/custom/compile_javascripts
index de07ac31d..acf3c2290 100755
--- a/script/custom/compile_javascripts
+++ b/script/custom/compile_javascripts
@@ -6,8 +6,8 @@ cat public/javascripts/src/lib/jquery-1.5.1.min.js > public/javascripts/compiled
cat public/javascripts/src/lib/jquery-ui-1.8.9.custom.min.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/lib/jrails.min.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/lib/rails.js >> public/javascripts/compiled/default.js
-cat public/javascripts/src/app/cookie.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/app/application.js >> public/javascripts/compiled/default.js
+cat public/javascripts/src/app/cookie.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/app/utility.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/app/posts.js >> public/javascripts/compiled/default.js
cat public/javascripts/src/app/comments.js >> public/javascripts/compiled/default.js