diff options
author | Yorhel <git@yorhel.nl> | 2009-10-03 11:57:27 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-10-03 11:57:27 +0200 |
commit | 5a3e3f05d2355229b7620aa7aab874bdbf8d8027 (patch) | |
tree | 9c2221943334c8487f1237f657ea427b38985347 | |
parent | c4ad807678926c4915c8c26b9b108250535053f7 (diff) |
JS: Updated and generalized list expand/collapse functions
-rw-r--r-- | data/style.css | 6 | ||||
-rw-r--r-- | lib/VNDB/Handler/Users.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 4 | ||||
-rw-r--r-- | static/f/script.js | 46 |
4 files changed, 28 insertions, 32 deletions
diff --git a/data/style.css b/data/style.css index 02dca828..a511d01d 100644 --- a/data/style.css +++ b/data/style.css @@ -479,13 +479,13 @@ div.mainbox.history td.tc1_2 { } div.mainbox.history td.tc2 { width: 65px; } div.mainbox.history td.tc3 { width: 90px } -tr.editsum td { +tr.collapse td { color: $grayedout$; padding-top: 0; text-align: right; } -a#history_comments { float: right } -a#history_comments:hover { border-bottom: none } +a#expandlist { float: right } +a#expandlist:hover { border-bottom: none } diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index d6193ddc..32bf96cd 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -386,7 +386,7 @@ sub posts { [ '' ], [ '' ], [ mt '_uposts_col_date' ], - sub { td; a href => '#', id => 'history_comments', 'expand'; txt mt '_uposts_col_title'; end; } + sub { td; a href => '#', id => 'expandlist', 'expand'; txt mt '_uposts_col_title'; end; } ], row => sub { my($s, $n, $l) = @_; @@ -396,7 +396,7 @@ sub posts { td class => 'tc3', $self->{l10n}->date($l->{date}); td class => 'tc4'; a href => "/t$l->{tid}.$l->{num}", $l->{title}; end; end; - Tr class => $n % 2 ? 'editsum odd hidden' : 'editsum hidden'; + Tr class => $n % 2 ? 'collapse odd hidden' : 'collapse hidden'; td colspan => 4; lit bb2html $l->{msg}, 150; end; diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index b1eb6432..1298af00 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -501,7 +501,7 @@ sub htmlHistory { sub { td colspan => 2, class => 'tc1', mt '_hist_col_rev' }, [ mt '_hist_col_date' ], [ mt '_hist_col_user' ], - sub { td; a href => '#', id => 'history_comments', 'expand'; txt mt '_hist_col_page'; end; } + sub { td; a href => '#', id => 'expandlist', 'expand'; txt mt '_hist_col_page'; end; } ], row => sub { my($s, $n, $i) = @_; @@ -524,7 +524,7 @@ sub htmlHistory { end; end; if($i->{comments}) { - Tr class => $n % 2 ? 'editsum odd hidden' : 'editsum hidden'; + Tr class => $n % 2 ? 'collapse odd hidden' : 'collapse hidden'; td colspan => 5; lit bb2html $i->{comments}, 150; end; diff --git a/static/f/script.js b/static/f/script.js index 148c76df..4ab704f0 100644 --- a/static/f/script.js +++ b/static/f/script.js @@ -660,6 +660,27 @@ if(byId('batchedit')) { }; } +// expand/collapse listings (/*/hist, /u+/posts) +if(byId('expandlist')) { + var lnk = byId('expandlist'); + setexpand = function() { + var exp = getCookie('histexpand') == 1; + setText(lnk, exp ? 'collapse' : 'expand'); + var tbl = lnk; + while(tbl.nodeName.toLowerCase() != 'table') + tbl = tbl.parentNode; + var l = byClass(tbl, 'tr', 'collapse'); + for(var i=0; i<l.length; i++) + setClass(l[i], 'hidden', !exp); + }; + setexpand(); + lnk.onclick = function () { + setCookie('histexpand', getCookie('histexpand') == 1 ? 0 : 1); + setexpand(); + return false; + }; +} + // spam protection on all forms setTimeout(function() { for(i=1; i<document.forms.length; i++) @@ -724,29 +745,4 @@ setTimeout(function() { ); } - // expand/collapse edit summaries on */hist - if(x('history_comments')) { - setcomment = function() { - var e = getCookie('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', getCookie('histexpand') == 1 ? 0 : 1); - setcomment(); - return false; - }; - } |