diff options
author | Yorhel <git@yorhel.nl> | 2009-03-21 13:21:25 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-03-21 13:21:25 +0100 |
commit | cbfb086feab8d06e8184f7b8d809780404d091bf (patch) | |
tree | ec3d668f004fda2de76df3aaccf0a038ead9856c | |
parent | 53ebdbc751f742e74ef33fb2a20dcd089c73cfd0 (diff) |
Show/hide spoiler tags on VN pages
-rw-r--r-- | data/style.css | 24 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 16 | ||||
-rw-r--r-- | static/f/script.js | 26 |
3 files changed, 49 insertions, 17 deletions
diff --git a/data/style.css b/data/style.css index 023e46a4..e5a78d92 100644 --- a/data/style.css +++ b/data/style.css @@ -596,23 +596,23 @@ div.vndetails td.anime b { font-weight: normal; padding-right: 4px; } -div.vntags { - clear: left; +div#vntags { margin: 15px 30px 0 30px; border-top: 1px solid $border$; - padding: 5px 0 0 0; + padding: 1px 5% 0 5%; text-align: center; } -/* -div.vndescription h2 { - margin: 0 30px!important; - border-top: 1px solid $border$; - padding: 3px 70px; - font-weight: bold!important; +#vntags span { white-space: nowrap; margin-left: 15px; } +#vntags span.hidden { display: none } +#vntags b { color: $grayedout$; font-weight: normal; font-size: 8px } +#tagops { + float: right; + text-align: right; + width: auto; + margin: 0 30px; } -div.vndescription p { - margin: 0 100px!important; -}*/ +#tagops a { margin: 0 0 0 10px; border: 0; outline: none } +#maincontent #tagops a.tsel { color: $maintext$; } .releases table, #screenshots table { width: 100%; diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 69142a94..da8fe570 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -138,14 +138,20 @@ sub page { end; clearfloat; - # description + # tags my $t = $self->dbTagStats(vid => $v->{id}, order => 'avg(tv.vote) DESC', minrating => 0); if(@$t) { - div class => 'vntags'; + div id => 'tagops'; + a href => '#', 'hide spoilers'; + a href => '#', class => 'tsel', 'show minor spoilers'; + a href => '#', 'all tags'; + end; + div id => 'vntags'; for (@$t) { - a href => "/g$_->{id}", style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name}; - b class => 'grayedout', style => 'font-size: 8px', sprintf ' %.1f', $_->{rating}; - lit ' '; + span class => sprintf 'tagspl%.0f %s', $_->{spoiler}, $_->{spoiler} > 1 ? 'hidden' : ''; + a href => "/g$_->{id}", style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name}; + b class => 'grayedout', sprintf ' %.1f', $_->{rating}; + end; } end; } diff --git a/static/f/script.js b/static/f/script.js index 7c28f060..fa92382d 100644 --- a/static/f/script.js +++ b/static/f/script.js @@ -477,6 +477,32 @@ DOMLoad(function() { break; } + // VN tag spoiler options + if(x('tagops')) { + l = x('tagops').getElementsByTagName('a'); + for(i=0;i<l.length;i++) + l[i].onclick = function() { + l = x('tagops').getElementsByTagName('a'); + var lvl; + for(var i=0;i<l.length;i++) { + if(l[i] == this) + lvl = i; + if(l[i] == this && l[i].className.indexOf('tsel') < 0) + l[i].className += ' tsel'; + else if(l[i] != this && l[i].className.indexOf('tsel') >= 0) + l[i].className = l[i].className.replace(/tsel/, ''); + } + l = x('vntags').getElementsByTagName('span'); + for(i=0;i<l.length;i++) { + if(lvl < l[i].className.substr(6, 1) && l[i].className.indexOf('hidden') < 0) + l[i].className += ' hidden'; + else if(lvl >= l[i].className.substr(6, 1) && l[i].className.indexOf('hidden') >= 0) + l[i].className = l[i].className.replace(/hidden/, ''); + } + return false; + }; + } + // Javascript tabs if(x('jt_select')) jtInit(); |