diff options
author | Yorhel <git@yorhel.nl> | 2009-05-31 10:44:36 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-05-31 10:44:36 +0200 |
commit | 82aea85bad2913a1e9f25751cbe998dc671bd520 (patch) | |
tree | c535850205aa8124730e2150b6dcb70c774d1078 | |
parent | d6eb18f061870fde4c7bdce212f976e48049cd50 (diff) |
Option to expand/collapse edit summaries on history browser
Makes use of cookies to store the users' preference. Might be a good
idea to store this in the DB for logged in users, together with the
tagspoil cookie.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | data/style.css | 10 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 6 | ||||
-rw-r--r-- | static/f/script.js | 26 |
4 files changed, 36 insertions, 7 deletions
@@ -9,6 +9,7 @@ - Show comparable CERO ratings on /r+/edit input field - Allow search queries with only one character - Removed category filter from /v/all + - Added expand/collapse feature to the history browser 2.3 - 2009-04-01 - No page reload needed when changing rlist status from vn page diff --git a/data/style.css b/data/style.css index 66956bd6..aa99acdf 100644 --- a/data/style.css +++ b/data/style.css @@ -101,6 +101,9 @@ b.todo { font-weight: normal; color: $statnok$ } clear: both; height: 0; } +.hidden { + display: none +} b.spoiler, b.spoiler a { color: #000; @@ -453,11 +456,13 @@ div.mainbox.history td.tc1_2 { } div.mainbox.history td.tc2 { width: 65px; } div.mainbox.history td.tc3 { width: 90px } -div.mainbox.history td.editsum { +div.mainbox.history tr.editsum td { color: $grayedout$; padding-top: 0; text-align: right; } +a#history_comments { float: right } +a#history_comments:hover { border-bottom: none } @@ -605,7 +610,6 @@ div#vntags { text-align: center; } #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; @@ -667,7 +671,6 @@ a.addnew { #screenshots td.scr div.nsfw img { border: 3px solid $statnok$; } #screenshots td.scr a:hover img { border: 3px solid $border$; } #screenshots td.scr a { border: none; } -#screenshots div.hidden { display: none } #screenshots #nsfwshown { font-style: normal } #screenshots p.nsfwtoggle { float: right; @@ -808,7 +811,6 @@ a.help { margin: 0 auto; border-top: 1px solid $border$; } -#advoptions.hidden { display: none } #advoptions h2 { clear: left; padding-top: 10px; diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index b9405941..1d6ae43b 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -484,7 +484,7 @@ sub htmlHistory { sub { td colspan => 2, class => 'tc1', 'Rev.' }, [ 'Date' ], [ 'User' ], - [ 'Page' ], + sub { td; a href => '#', id => 'history_comments', 'expand'; txt 'Page'; end; } ], row => sub { my($s, $n, $i) = @_; @@ -507,8 +507,8 @@ sub htmlHistory { end; end; if($i->{comments}) { - Tr $n % 2 ? ( class => 'odd' ) : (); - td colspan => 5, class => 'editsum'; + Tr class => $n % 2 ? 'editsum odd hidden' : 'editsum hidden'; + td colspan => 5; lit bb2html $i->{comments}, 150; end; end; diff --git a/static/f/script.js b/static/f/script.js index 48002287..8cc35118 100644 --- a/static/f/script.js +++ b/static/f/script.js @@ -606,6 +606,32 @@ DOMLoad(function() { l[i].onmouseout = function() { this.className = 'spoiler' }; } + // expand/collapse edit summaries on */hist + if(x('history_comments')) { + setcomment = function() { + var e = readCookie('histexpand') == 1; + var l = x('history_comments'); + l.innerHTML = e ? 'collapse' : 'expand'; + while(l.nodeName.toLowerCase() != 'table') + l = l.parentNode; + l = l.getElementsByTagName('tr'); + for(var i=0;i<l.length;i++) + //alert(l[i].className); + if(l[i].className.indexOf('editsum') >= 0) { + if(!e && l[i].className.indexOf('hidden') < 0) + l[i].className += ' hidden'; + if(e && l[i].className.indexOf('hidden') >= 0) + l[i].className = l[i].className.replace(/hidden/, ''); + } + }; + setcomment(); + x('history_comments').onclick = function () { + setCookie('histexpand', readCookie('histexpand') == 1 ? 0 : 1); + setcomment(); + return false; + }; + } + // Are we really vndb? if(location.hostname != 'vndb.org') { var d = document.createElement('div'); |