summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/VNPage.pm
diff options
context:
space:
mode:
authorzx14 <zx14@vndb.org>2018-10-28 11:33:29 +0700
committerYorhel <git@yorhel.nl>2018-10-28 18:51:01 +0100
commit0687115f993831353674397857f697e5be0c01f6 (patch)
tree5e6da589645737c3b3cb00c2b337cddb2a11d339 /lib/VNDB/Handler/VNPage.pm
parentc26cf6eded734cc79c6dfdfd8ed2a81aabe9fe0b (diff)
Add JS-less NSFW screenshot toggle
(cherry picked from commit 6446d7d185543440b97be009fdf2a1f0c379b26f)
Diffstat (limited to 'lib/VNDB/Handler/VNPage.pm')
-rw-r--r--lib/VNDB/Handler/VNPage.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 3502cb13..be60558e 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -901,15 +901,20 @@ sub _release_icons {
sub _screenshots {
my($self, $v, $r) = @_;
- div class => 'mainbox', id => 'screenshots';
if(grep $_->{nsfw}, @{$v->{screenshots}}) {
+ input id => 'nsfwhide_chk', type => 'checkbox', class => 'visuallyhidden', $self->authPref('show_nsfw') ? (checked => 'checked') : ();
+ div class => 'mainbox', id => 'screenshots';
+
p class => 'nsfwtoggle';
txt 'Showing ';
- i id => 'nsfwshown', $self->authPref('show_nsfw') ? scalar @{$v->{screenshots}} : scalar grep(!$_->{nsfw}, @{$v->{screenshots}});
+ i id => 'nsfwshown', scalar grep(!$_->{nsfw}, @{$v->{screenshots}});
+ span class => 'nsfw', scalar @{$v->{screenshots}};
txt sprintf ' out of %d screenshot%s. ', scalar @{$v->{screenshots}}, @{$v->{screenshots}} == 1 ? '' : 's';
- a href => '#', id => "nsfwhide", 'show/hide NSFW';
+ label for => 'nsfwhide_chk', class => 'fake_link', 'show/hide NSFW';
end;
+ } else {
+ div class => 'mainbox', id => 'screenshots';
}
h1 'Screenshots';
@@ -926,7 +931,7 @@ sub _screenshots {
for (@scr) {
my($w, $h) = imgsize($_->{width}, $_->{height}, @{$self->{scr_size}});
a href => imgurl(sf => $_->{id}),
- class => sprintf('scrlnk%s%s', $_->{nsfw} ? ' nsfw':'', $_->{nsfw}&&!$self->authPref('show_nsfw')?' hidden':''),
+ class => sprintf('scrlnk%s', $_->{nsfw} ? ' nsfw':''),
'data-iv' => "$_->{width}x$_->{height}:scr";
img src => imgurl(st => $_->{id}),
width => $w, height => $h, alt => "Screenshot #$_->{id}";