added more conditional checks for javascripts to reduce computation load

This commit is contained in:
albert
2011-11-02 12:27:40 -04:00
parent 10141af07d
commit 02eac64bd9
20 changed files with 193 additions and 176 deletions

View File

@@ -9,16 +9,12 @@ group :test do
end end
group :assets do group :assets do
gem "uglifier"
gem "uglifier-rails"
gem "therubyracer"
gem "sass" gem "sass"
end end
gem "rails", "3.1.0" gem "rails", "3.1.1"
gem "pg" gem "pg"
gem "memcache-client", :require => "memcache" gem "memcache-client", :require => "memcache"
# gem "imagesize", :require => "image_size"
gem "delayed_job" gem "delayed_job"
gem "super_exception_notifier" gem "super_exception_notifier"
gem "simple_form" gem "simple_form"
@@ -28,7 +24,7 @@ gem "meta_search", :git => "git://github.com/ernie/meta_search.git"
gem "silent-postgres" gem "silent-postgres"
gem "whenever", :require => false gem "whenever", :require => false
gem "sanitize", :git => "git://github.com/rgrove/sanitize.git" gem "sanitize", :git => "git://github.com/rgrove/sanitize.git"
gem 'rmagick', :require => "RMagick" gem 'mini_magick'
group :development do group :development do
gem 'pry' gem 'pry'

View File

@@ -10,52 +10,50 @@ GIT
GIT GIT
remote: git://github.com/rgrove/sanitize.git remote: git://github.com/rgrove/sanitize.git
revision: afdfa8f7f4129820c573f94f79b99aed715a385d revision: 052abea134e409c7f676f0cf56e6a2315b2a150b
specs: specs:
sanitize (2.0.3) sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6) nokogiri (>= 1.4.4, < 1.6)
GIT GIT
remote: http://github.com/EmmanuelOga/ffaker.git remote: http://github.com/EmmanuelOga/ffaker.git
revision: f94bcf502fcdd4ba5f29155a3df1811af2663950 revision: 80dc4cf8531b12bf6f5425d2a35b27be91acc447
specs: specs:
ffaker (1.8.1) ffaker (1.8.1)
GEM GEM
remote: http://gemcutter.org/ remote: http://gemcutter.org/
specs: specs:
actionmailer (3.1.0) actionmailer (3.1.1)
actionpack (= 3.1.0) actionpack (= 3.1.1)
mail (~> 2.3.0) mail (~> 2.3.0)
actionpack (3.1.0) actionpack (3.1.1)
activemodel (= 3.1.0) activemodel (= 3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
builder (~> 3.0.0) builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
i18n (~> 0.6) i18n (~> 0.6)
rack (~> 1.3.2) rack (~> 1.3.2)
rack-cache (~> 1.0.3) rack-cache (~> 1.1)
rack-mount (~> 0.8.2) rack-mount (~> 0.8.2)
rack-test (~> 0.6.1) rack-test (~> 0.6.1)
sprockets (~> 2.0.0) sprockets (~> 2.0.2)
activemodel (3.1.0) activemodel (3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
bcrypt-ruby (~> 3.0.0)
builder (~> 3.0.0) builder (~> 3.0.0)
i18n (~> 0.6) i18n (~> 0.6)
activerecord (3.1.0) activerecord (3.1.1)
activemodel (= 3.1.0) activemodel (= 3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
arel (~> 2.2.1) arel (~> 2.2.1)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activeresource (3.1.0) activeresource (3.1.1)
activemodel (= 3.1.0) activemodel (= 3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
activesupport (3.1.0) activesupport (3.1.1)
multi_json (~> 1.0) multi_json (~> 1.0)
arel (2.2.1) arel (2.2.1)
awesome_print (0.4.0) awesome_print (0.4.0)
bcrypt-ruby (3.0.1)
builder (3.0.0) builder (3.0.0)
chronic (0.6.4) chronic (0.6.4)
coderay (0.9.8) coderay (0.9.8)
@@ -64,13 +62,11 @@ GEM
activesupport (~> 3.0) activesupport (~> 3.0)
daemons daemons
erubis (2.7.0) erubis (2.7.0)
execjs (1.2.9) factory_girl (2.2.0)
multi_json (~> 1.0)
factory_girl (2.1.2)
activesupport activesupport
hike (1.2.1) hike (1.2.1)
i18n (0.6.0) i18n (0.6.0)
libv8 (3.3.10.2) json (1.6.1)
mail (2.3.0) mail (2.3.0)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
@@ -82,9 +78,11 @@ GEM
webrobots (~> 0.0, >= 0.0.9) webrobots (~> 0.0, >= 0.0.9)
memcache-client (1.8.5) memcache-client (1.8.5)
metaclass (0.0.1) metaclass (0.0.1)
method_source (0.6.5) method_source (0.6.7)
ruby_parser (>= 2.0.5) ruby_parser (>= 2.3.1)
mime-types (1.16) mime-types (1.17.2)
mini_magick (3.3)
subexec (~> 0.1.0)
mocha (0.10.0) mocha (0.10.0)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.0.3) multi_json (1.0.3)
@@ -94,14 +92,14 @@ GEM
pg (0.11.0) pg (0.11.0)
polyamorous (0.5.0) polyamorous (0.5.0)
activerecord (~> 3.0) activerecord (~> 3.0)
polyglot (0.3.2) polyglot (0.3.3)
pry (0.9.6.2) pry (0.9.7.3)
coderay (~> 0.9.8) coderay (~> 0.9.8)
method_source (~> 0.6.5) method_source (~> 0.6.7)
ruby_parser (~> 2.0.5) ruby_parser (>= 2.3.1)
slop (~> 2.1.0) slop (~> 2.1.0)
rack (1.3.3) rack (1.3.5)
rack-cache (1.0.3) rack-cache (1.1)
rack (>= 0.4) rack (>= 0.4)
rack-mount (0.8.3) rack-mount (0.8.3)
rack (>= 1.0.0) rack (>= 1.0.0)
@@ -109,59 +107,52 @@ GEM
rack rack
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rails (3.1.0) rails (3.1.1)
actionmailer (= 3.1.0) actionmailer (= 3.1.1)
actionpack (= 3.1.0) actionpack (= 3.1.1)
activerecord (= 3.1.0) activerecord (= 3.1.1)
activeresource (= 3.1.0) activeresource (= 3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.1.0) railties (= 3.1.1)
railties (3.1.0) railties (3.1.1)
actionpack (= 3.1.0) actionpack (= 3.1.1)
activesupport (= 3.1.0) activesupport (= 3.1.1)
rack-ssl (~> 1.3.2) rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.6) thor (~> 0.14.6)
rake (0.9.2) rake (0.9.2.2)
rdoc (3.9.4) rdoc (3.11)
rmagick (2.13.1) json (~> 1.4)
ruby_parser (2.0.6) ruby_parser (2.3.1)
sexp_processor (~> 3.0) sexp_processor (~> 3.0)
sass (3.1.7) sass (3.1.10)
sexp_processor (3.0.7) sexp_processor (3.0.7)
shoulda (2.11.3) shoulda (2.11.3)
silent-postgres (0.1.1) silent-postgres (0.1.1)
simple_form (1.5.2) simple_form (1.5.2)
actionpack (~> 3.0) actionpack (~> 3.0)
activemodel (~> 3.0) activemodel (~> 3.0)
simplecov (0.5.3) simplecov (0.5.4)
multi_json (~> 1.0.3) multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3) simplecov-html (~> 0.5.3)
simplecov-html (0.5.3) simplecov-html (0.5.3)
slop (2.1.0) slop (2.1.0)
sprockets (2.0.0) sprockets (2.0.3)
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
subexec (0.1.0)
super_exception_notifier (3.0.13) super_exception_notifier (3.0.13)
actionmailer actionmailer
rake rake
therubyracer (0.9.4)
libv8 (~> 3.3.10)
thor (0.14.6) thor (0.14.6)
tilt (1.3.3) tilt (1.3.3)
treetop (1.4.10) treetop (1.4.10)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.29) tzinfo (0.3.30)
uglifier (1.0.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
uglifier-rails (3.1.0.rc.2)
railties (~> 3.1.0.rc1)
uglifier (>= 1.0.0)
webrobots (0.0.12) webrobots (0.0.12)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
whenever (0.7.0) whenever (0.7.0)
@@ -179,12 +170,12 @@ DEPENDENCIES
mechanize mechanize
memcache-client memcache-client
meta_search! meta_search!
mini_magick
mocha mocha
nokogiri nokogiri
pg pg
pry pry
rails (= 3.1.0) rails (= 3.1.1)
rmagick
sanitize! sanitize!
sass sass
shoulda shoulda
@@ -192,7 +183,4 @@ DEPENDENCIES
simple_form simple_form
simplecov simplecov
super_exception_notifier super_exception_notifier
therubyracer
uglifier
uglifier-rails
whenever whenever

View File

@@ -103,16 +103,19 @@
$post.addClass("blacklisted").addClass("blacklisted-active"); $post.addClass("blacklisted").addClass("blacklisted-active");
} }
Danbooru.Blacklist.initialize = function() { Danbooru.Blacklist.initialize_all = function() {
Danbooru.Blacklist.parse_entries(); if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) {
if (Danbooru.Blacklist.apply() > 0) { Danbooru.Blacklist.parse_entries();
Danbooru.Blacklist.update_sidebar();
} else { if (Danbooru.Blacklist.apply() > 0) {
$("#blacklist-box").hide(); Danbooru.Blacklist.update_sidebar();
} else {
$("#blacklist-box").hide();
}
} }
} }
})(); })();
$(document).ready(function() { $(document).ready(function() {
Danbooru.Blacklist.initialize(); Danbooru.Blacklist.initialize_all();
}); });

View File

@@ -2,9 +2,11 @@
Danbooru.Comment = {}; Danbooru.Comment = {};
Danbooru.Comment.initialize_all = function() { Danbooru.Comment.initialize_all = function() {
this.initialize_response_link(); if ($("#c-posts").length || $("#c-comments").length) {
this.initialize_reply_links(); this.initialize_response_link();
this.initialize_expand_links(); this.initialize_reply_links();
this.initialize_expand_links();
}
} }
Danbooru.Comment.quote_message = function(data) { Danbooru.Comment.quote_message = function(data) {

View File

@@ -3,7 +3,6 @@
Danbooru.Dtext.initialize_links = function() { Danbooru.Dtext.initialize_links = function() {
$(".simple_form .dtext-preview").hide(); $(".simple_form .dtext-preview").hide();
$(".simple_form input[value=Preview]").click(Danbooru.Dtext.click_button); $(".simple_form input[value=Preview]").click(Danbooru.Dtext.click_button);
} }

View File

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

View File

@@ -2,22 +2,24 @@
Danbooru.JanitorTrials = {}; Danbooru.JanitorTrials = {};
Danbooru.JanitorTrials.initialize_all = function() { Danbooru.JanitorTrials.initialize_all = function() {
$("#c-janitor-trials input[value=Test]").click(function(e) { if ($("#c-janitor-trials").length) {
$.ajax({ $("input[value=Test]").click(function(e) {
type: "get", $.ajax({
url: "/janitor_trials/test.json", type: "get",
data: { url: "/janitor_trials/test.json",
janitor_trial: { data: {
user_name: $("#janitor_trial_user_name").val() janitor_trial: {
user_name: $("#janitor_trial_user_name").val()
}
},
success: function(data) {
$("#test-results").html(data);
} }
}, });
success: function(data) {
$("#test-results").html(data); e.preventDefault();
} });
}); }
e.preventDefault();
});
} }
})(); })();

View File

@@ -1,8 +1,10 @@
$(function() { $(function() {
$("#c-landings div.data").each(function(i, div) { if ($("#c-landings").length) {
var $div = $(div); $(".data").each(function(i, div) {
var $image = $div.prev(); var $div = $(div);
var $image = $div.prev();
$div.width($image.width() - 10).height($image.height() - 10).offset({top: $image.position().top, left: $image.position().left});
}); $div.width($image.width() - 10).height($image.height() - 10).offset({top: $image.position().top, left: $image.position().left});
});
}
}); });

View File

@@ -2,7 +2,7 @@
Danbooru.ModQueue = {}; Danbooru.ModQueue = {};
Danbooru.ModQueue.initialize_approve_all_button = function() { Danbooru.ModQueue.initialize_approve_all_button = function() {
$("#c-moderator-post-queues #approve-all-button").click(function(e) { $("#approve-all-button").click(function(e) {
if (!confirm("Are you sure you want to approve every post on this page?")) { if (!confirm("Are you sure you want to approve every post on this page?")) {
return; return;
} }
@@ -13,7 +13,7 @@
} }
Danbooru.ModQueue.initialize_hide_all_button = function() { Danbooru.ModQueue.initialize_hide_all_button = function() {
$("#c-moderator-post-queues #hide-all-button").click(function(e) { $("#hide-all-button").click(function(e) {
if (!confirm("Are you sure you want to hide every post on this page?")) { if (!confirm("Are you sure you want to hide every post on this page?")) {
return; return;
} }
@@ -25,6 +25,8 @@
})(); })();
$(function() { $(function() {
Danbooru.ModQueue.initialize_approve_all_button(); if ($("#c-moderator-post-queues").length) {
Danbooru.ModQueue.initialize_hide_all_button(); Danbooru.ModQueue.initialize_approve_all_button();
Danbooru.ModQueue.initialize_hide_all_button();
}
}); });

View File

@@ -18,8 +18,8 @@
}); });
} }
} }
$(function() {
Danbooru.NewsUpdate.initialize();
});
})(); })();
$(function() {
Danbooru.NewsUpdate.initialize();
});

View File

@@ -425,8 +425,8 @@ Danbooru.Note = {
height: h height: h
}); });
$("div#note-container").append($note_box); $("#note-container").append($note_box);
$("div#note-container").append($note_body); $("#note-container").append($note_body);
$note_body.data("original-body", text); $note_body.data("original-body", text);
Danbooru.Note.Box.scale($note_box); Danbooru.Note.Box.scale($note_box);
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
@@ -442,8 +442,8 @@ Danbooru.Note = {
}); });
$note_box.find(".note-box-inner-border").addClass("unsaved"); $note_box.find(".note-box-inner-border").addClass("unsaved");
$note_body.html("<em>Click to edit</em>"); $note_body.html("<em>Click to edit</em>");
$("div#note-container").append($note_box); $("#note-container").append($note_box);
$("div#note-container").append($note_body); $("#note-container").append($note_body);
Danbooru.Note.Box.resize_inner_border($note_box); Danbooru.Note.Box.resize_inner_border($note_box);
Danbooru.Note.id += "x"; Danbooru.Note.id += "x";
}, },
@@ -457,7 +457,7 @@ Danbooru.Note = {
}, },
load_all: function() { load_all: function() {
$.each($("section#notes article"), function(i, article) { $.each($("#notes article"), function(i, article) {
var $article = $(article); var $article = $(article);
Danbooru.Note.add( Danbooru.Note.add(
$article.data("id"), $article.data("id"),
@@ -472,7 +472,7 @@ Danbooru.Note = {
} }
$(function() { $(function() {
if ($("#c-posts #a-show").size() > 0) { if ($("#c-posts").length && $("#a-show").length) {
$("#translate").one("click", Danbooru.Note.TranslationMode.start); $("#translate").one("click", Danbooru.Note.TranslationMode.start);
key("n", Danbooru.Note.TranslationMode.start); key("n", Danbooru.Note.TranslationMode.start);
Danbooru.Note.load_all(); Danbooru.Note.load_all();

View File

@@ -1,15 +1,14 @@
(function() { (function() {
Danbooru.Paginator = {}; Danbooru.Paginator = {};
Danbooru.Paginator.next_page = function() { Danbooru.Paginator.next_page = function() {
if($('.paginator li span').parent().next().length != 0) if ($('.paginator li span').parent().next().length) {
{
window.location = $('.paginator li span').parent().next().find('a').attr('href'); window.location = $('.paginator li span').parent().next().find('a').attr('href');
} }
} }
Danbooru.Paginator.prev_page = function() { Danbooru.Paginator.prev_page = function() {
if($('.paginator li span').parent().prev().length != 0) if ($('.paginator li span').parent().prev().length) {
{
window.location = $('.paginator li span').parent().prev().find('a').attr('href'); window.location = $('.paginator li span').parent().prev().find('a').attr('href');
} }
} }

View File

@@ -2,8 +2,13 @@
Danbooru.Pool = {}; Danbooru.Pool = {};
Danbooru.Pool.initialize_all = function() { Danbooru.Pool.initialize_all = function() {
this.initialize_add_to_pool_link(); if ($("#c-posts").length && $("#a-show").length) {
this.initialize_simple_edit(); this.initialize_add_to_pool_link();
}
if ($("#c-pool-orders").length) {
this.initialize_simple_edit();
}
} }
Danbooru.Pool.initialize_add_to_pool_link = function() { Danbooru.Pool.initialize_add_to_pool_link = function() {
@@ -21,24 +26,24 @@
minLength: 4, minLength: 4,
}); });
$("a#pool").click(function(e) { $("#pool").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#add-to-pool-dialog").dialog("open"); $("#add-to-pool-dialog").dialog("open");
}); });
$("ul#recent-pools li").click(function(e) { $("#recent-pools li").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#pool_name").val($(this).html()); $("#pool_name").val($(this).html());
}); });
} }
Danbooru.Pool.initialize_simple_edit = function() { Danbooru.Pool.initialize_simple_edit = function() {
$("ul#sortable").sortable({ $("#sortable").sortable({
placeholder: "ui-state-placeholder" placeholder: "ui-state-placeholder"
}); });
$("ul#sortable").disableSelection(); $("#sortable").disableSelection();
$("div#c-pool-orders div#a-edit form#ordering-form").submit(function(e) { $("#ordering-form").submit(function(e) {
$.ajax({ $.ajax({
type: "put", type: "put",
url: e.target.action, url: e.target.action,

View File

@@ -2,13 +2,15 @@
Danbooru.PostAppeal = {}; Danbooru.PostAppeal = {};
Danbooru.PostAppeal.initialize_all = function() { Danbooru.PostAppeal.initialize_all = function() {
this.initialize_appeal(); if ($("#c-posts") && $("#a-show")) {
this.hide_or_show_appeal_link(); this.initialize_appeal();
this.hide_or_show_appeal_link();
}
} }
Danbooru.PostAppeal.hide_or_show_appeal_link = function() { Danbooru.PostAppeal.hide_or_show_appeal_link = function() {
if (Danbooru.meta("post-is-flagged") !== "true") { if (Danbooru.meta("post-is-flagged") !== "true") {
$("#c-posts #appeal").hide(); $("#appeal").hide();
} }
} }
@@ -28,7 +30,7 @@
} }
}); });
$("a#appeal").click(function(e) { $("#appeal").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#appeal-dialog").dialog("open"); $("#appeal-dialog").dialog("open");
}); });

View File

@@ -2,13 +2,15 @@
Danbooru.PostFlag = {}; Danbooru.PostFlag = {};
Danbooru.PostFlag.initialize_all = function() { Danbooru.PostFlag.initialize_all = function() {
this.initialize_flag(); if ($("#c-posts") && $("#a-show")) {
this.hide_or_show_flag_link(); this.initialize_flag();
this.hide_or_show_flag_link();
}
} }
Danbooru.PostFlag.hide_or_show_flag_link = function() { Danbooru.PostFlag.hide_or_show_flag_link = function() {
if (Danbooru.meta("post-is-deleted") == "true") { if (Danbooru.meta("post-is-deleted") == "true") {
$("a#flag").hide(); $("#flag").hide();
} }
} }
@@ -28,7 +30,7 @@
} }
}); });
$("a#flag").click(function(e) { $("#flag").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#flag-dialog").dialog("open"); $("#flag-dialog").dialog("open");
}); });

View File

@@ -2,9 +2,11 @@
Danbooru.PostModeMenu = {}; Danbooru.PostModeMenu = {};
Danbooru.PostModeMenu.initialize = function() { Danbooru.PostModeMenu.initialize = function() {
this.initialize_selector(); if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) {
this.initialize_preview_link(); this.initialize_selector();
this.initialize_edit_form(); this.initialize_preview_link();
this.initialize_edit_form();
}
} }
Danbooru.PostModeMenu.initialize_selector = function() { Danbooru.PostModeMenu.initialize_selector = function() {

View File

@@ -2,22 +2,24 @@
Danbooru.PostModeration = {}; Danbooru.PostModeration = {};
Danbooru.PostModeration.initialize_all = function() { Danbooru.PostModeration.initialize_all = function() {
this.hide_or_show_approve_and_disapprove_links(); if ($("#c-posts").length && $("#a-show").length) {
this.hide_or_show_delete_and_undelete_links(); 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() { Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
if (Danbooru.meta("post-is-approvable") != "true") { if (Danbooru.meta("post-is-approvable") != "true") {
$("a#approve").hide(); $("#approve").hide();
$("a#disapprove").hide(); $("#disapprove").hide();
} }
} }
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() { Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
if (Danbooru.meta("post-is-deleted") == "true") { if (Danbooru.meta("post-is-deleted") == "true") {
$("a#delete").hide(); $("#delete").hide();
} else { } else {
$("a#undelete").hide(); $("#undelete").hide();
} }
} }
})(); })();

View File

@@ -4,13 +4,19 @@
Danbooru.Post.pending_update_count = 0; Danbooru.Post.pending_update_count = 0;
Danbooru.Post.initialize_all = function() { Danbooru.Post.initialize_all = function() {
this.initialize_post_sections();
this.initialize_wiki_page_excerpt();
this.initialize_post_image_resize_links();
this.initialize_image_resize();
this.initialize_titles(); this.initialize_titles();
this.initialize_links();
this.initialize_resize_links(); if ($("#c-posts").length && $("#a-index").length) {
this.initialize_wiki_page_excerpt();
}
if ($("#c-posts").length && $("#a-show").length) {
this.initialize_resize_links();
this.initialize_links();
this.initialize_image_resize();
this.initialize_post_sections();
this.initialize_post_image_resize_links();
}
} }
Danbooru.Post.initialize_links = function() { Danbooru.Post.initialize_links = function() {
@@ -32,7 +38,7 @@
image.attr("height", target.data("height")); image.attr("height", target.data("height"));
e.preventDefault(); e.preventDefault();
}); });
$("#resize-link a").click(function(e) { $("#resize-link a").click(function(e) {
$("#resize-links").toggle(); $("#resize-links").toggle();
e.preventDefault(); e.preventDefault();
@@ -40,7 +46,7 @@
} }
Danbooru.Post.initialize_titles = function() { Danbooru.Post.initialize_titles = function() {
$("article.post-preview").each(function(i, v) { $(".post-preview").each(function(i, v) {
Danbooru.Post.initialize_title_for(v); Danbooru.Post.initialize_title_for(v);
}); });
} }
@@ -69,19 +75,17 @@
} }
Danbooru.Post.initialize_image_resize = function() { Danbooru.Post.initialize_image_resize = function() {
if ($("#c-posts #a-show").size() > 0) { var default_image_size = Danbooru.meta("default-image-size");
var default_image_size = Danbooru.meta("default-image-size"); var original_width = parseInt($("#image").data("original-width"));
var original_width = parseInt($("#image").data("original-width")); var medium_width = parseInt(Danbooru.meta("config-medium-width"));
var medium_width = parseInt(Danbooru.meta("config-medium-width")); var large_width = parseInt(Danbooru.meta("config-large-width"));
var large_width = parseInt(Danbooru.meta("config-large-width"));
if ((default_image_size === "medium") && (original_width > medium_width)) { if ((default_image_size === "medium") && (original_width > medium_width)) {
$("#medium-file-link").trigger("click"); $("#medium-file-link").trigger("click");
} else if ((default_image_size === "large") && (original_width > large_width)) { } else if ((default_image_size === "large") && (original_width > large_width)) {
$("#large-file-link").trigger("click"); $("#large-file-link").trigger("click");
} else { } else {
$("#original-file-link").trigger("click"); $("#original-file-link").trigger("click");
}
} }
} }

View File

@@ -2,8 +2,10 @@
Danbooru.RelatedTag = {}; Danbooru.RelatedTag = {};
Danbooru.RelatedTag.initialize_all = function() { Danbooru.RelatedTag.initialize_all = function() {
this.initialize_buttons(); if ($("#c-posts").length || $("#c-uploads").length) {
$("#related-tags-container").hide(); this.initialize_buttons();
$("#related-tags-container").hide();
}
} }
Danbooru.RelatedTag.initialize_buttons = function() { Danbooru.RelatedTag.initialize_buttons = function() {

View File

@@ -3,8 +3,11 @@
Danbooru.Upload.initialize_all = function() { Danbooru.Upload.initialize_all = function() {
this.initialize_image(); this.initialize_image();
this.initialize_info();
this.initialize_similar(); if ($("#c-uploads").length) {
this.initialize_info();
this.initialize_similar();
}
} }
Danbooru.Upload.initialize_similar = function() { Danbooru.Upload.initialize_similar = function() {
@@ -31,8 +34,8 @@
} }
Danbooru.Upload.initialize_info = function() { Danbooru.Upload.initialize_info = function() {
$("#c-uploads #source-info ul").hide(); $("#source-info ul").hide();
$("#c-uploads #fetch-data").click(function(e) { $("#fetch-data").click(function(e) {
Danbooru.ajax_start(e.target); Danbooru.ajax_start(e.target);
$.get(e.target.href).success(function(data) { $.get(e.target.href).success(function(data) {
var tag_html = ""; var tag_html = "";
@@ -61,7 +64,7 @@
} }
Danbooru.Upload.initialize_image = function() { Danbooru.Upload.initialize_image = function() {
var $image = $("#c-uploads #image"); var $image = $("#image");
if ($image.size() > 0) { if ($image.size() > 0) {
var height = $image.height(); var height = $image.height();
var width = $image.width(); var width = $image.width();