diff options
-rw-r--r-- | data/js/misc.js | 28 | ||||
-rw-r--r-- | data/style.css | 7 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 4 |
3 files changed, 36 insertions, 3 deletions
diff --git a/data/js/misc.js b/data/js/misc.js index f41e8140..688d063b 100644 --- a/data/js/misc.js +++ b/data/js/misc.js @@ -108,7 +108,6 @@ if(byId('nsfwhide')) // vndb.org domain check -// (let's just keep this untranslatable, nobody cares anyway ^^) if(location.hostname != 'vndb.org') { addBody(tag('div', {id:'debug'}, tag('h2', 'This is not VNDB!'), @@ -119,6 +118,33 @@ if(location.hostname != 'vndb.org') { } +// 'more' / 'less' summarization of some boxes on VN pages +(function(){ + function set(o, h) { + var a = tag('a', {href:'#', summarizeOn:false}, ''); + var toggle = function() { + a.summarizeOn = !a.summarizeOn; + o.style.maxHeight = a.summarizeOn ? h+'px' : null; + o.style.overflowY = a.summarizeOn ? 'hidden' : null; + setText(a, a.summarizeOn ? '⇓ more ⇓' : '⇑ less ⇑'); + return false; + }; + a.onclick = toggle; + var t = tag('div', {'class':'summarize_more'}, a); + l[i].parentNode.insertBefore(t, l[i].nextSibling); + toggle(); + } + + var l = byClass(document, 'summarize'); + + for(var i=0; i<l.length; i++) { + var h = Math.floor(l[i].getAttribute('data-summarize-height') || 150); + if(l[i].offsetHeight > h+30) + set(l[i], h); + } +})(); + + // make some fields readonly when patch flag is set (/r+/edit) (function(){ function sync() { diff --git a/data/style.css b/data/style.css index 79b63ae3..9053bbdd 100644 --- a/data/style.css +++ b/data/style.css @@ -385,6 +385,13 @@ div#vntags { margin: 15px 30px 0 30px; border-top: 1px solid #screenshots #nsfwshown { font-style: normal } #screenshots p.nsfwtoggle { float: right; margin: 0; } +.summarize_more { + margin-top: 9px; margin-bottom: -10px; padding: 0; height: 15px; + border: 1px solid $border$; border-top: none; + background: url($_boxbg$) repeat; + text-align: center +} + /***** Vote stats ****/ diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 7a554c35..74969a8b 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -917,7 +917,7 @@ sub _charsum { } } - div class => 'mainbox charsum'; + div class => 'mainbox charsum summarize'; $self->charOps(0) if $has_spoilers; h1 mt '_vnpage_charsum'; div class => 'charsum_list'; @@ -949,7 +949,7 @@ sub _staff { my ($self, $v) = @_; return if !@{$v->{credits}}; - div class => 'mainbox staff', id => 'staff'; + div class => 'mainbox staff summarize', 'data-summarize-height' => 100, id => 'staff'; h1 mt '_vnpage_staff'; for my $r (@{$self->{staff_roles}}) { my @s = grep $_->{role} eq $r, @{$v->{credits}}; |