diff options
author | Yorhel <git@yorhel.nl> | 2016-01-10 16:03:37 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2016-01-10 16:03:37 +0100 |
commit | ba1b3906aa7e19643fc745b4e19b29f68dbdbf37 (patch) | |
tree | 3a036c699e622319ffbd548fbd9f7456135cd2a4 /data | |
parent | 279ac5d9bf1162824849ba0bb71c3fdad33b20d1 (diff) |
Add 'more'/'less' buttons to staff/character boxes on VN pages
Diffstat (limited to 'data')
-rw-r--r-- | data/js/misc.js | 28 | ||||
-rw-r--r-- | data/style.css | 7 |
2 files changed, 34 insertions, 1 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 ****/ |