diff options
author | Yorhel <git@yorhel.nl> | 2010-12-20 12:57:23 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2010-12-20 12:57:23 +0100 |
commit | 725b626dddd1acd033f61a94712336142c733937 (patch) | |
tree | 2c028f282b481570683e9d380565c2d7ca5c8dd3 | |
parent | 34e150d039b0a2421a0d0f489147cdcfbaed6bf0 (diff) |
Added advanced page-browsing tabs to threads
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | data/lang.txt | 14 | ||||
-rw-r--r-- | data/style.css | 63 | ||||
-rw-r--r-- | lib/VNDB/Handler/Discussions.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 43 |
5 files changed, 70 insertions, 55 deletions
@@ -7,6 +7,7 @@ - ULists::votelist: Don't give a 404 on /u+/votes when no votes found - Added tab and link for /u+/votes to user tabs & main menu - ULists::votelist: Added first character selection + - Added advanced page-browsing tabs to threads 2.15 - 2010-12-15 - Removed expand/collapse from history browser and /u+/posts and switched to diff --git a/data/lang.txt b/data/lang.txt index c1507c4b..2a3653bc 100644 --- a/data/lang.txt +++ b/data/lang.txt @@ -1921,6 +1921,13 @@ nl : relaties # Navigation buttons on the browse pages +:_browse_first +en : first +ru*: +cs*: +hu*: +nl : eerste + :_browse_previous en : previous ru : назад @@ -1935,6 +1942,13 @@ cs : další hu : következő nl : volgende +:_browse_last +en : last +ru*: +cs*: +hu*: +nl : laatste + # Revision pages diff --git a/data/style.css b/data/style.css index 88cca7e9..60051cdc 100644 --- a/data/style.css +++ b/data/style.css @@ -322,53 +322,36 @@ b.future, b.standout, a.standout { /***** main tabs *****/ -#maincontent ul.maintabs { - display: inline; - margin: 0; -} -#maincontent ul.maintabs.notfirst { - display: block; - height: 20px; -} -#maincontent ul.maintabs li { - display: inline; - list-style-type: none; -} -#maincontent ul.maintabs li a { +ul.maintabs { display: inline; margin: 0; } +ul.maintabs.notfirst { display: block; height: 20px } +ul.maintabs li { display: inline; list-style-type: none } +ul.maintabs li a, ul.maintabs li b { float: right; display: block; height: 14px; - border: 1px solid $border$; - border-bottom: none; padding: 1px 7px 5px 7px; margin: 0 0 0 10px; - background-color: $tabbg$; -} -#maincontent ul.maintabs.notfirst li a { - margin-top: 20px; -} -#maincontent ul.maintabs.bottom li a { - margin-top: 10px; - border-bottom: 1px solid $border$; - border-top: none; - padding: 4px 7px 2px 7px; -} -#maincontent ul.maintabs li.left a { - float: left; - margin-left: 0; - margin-right: 10px; } -#maincontent ul.maintabs li.tabselected a, -#maincontent ul.maintabs li a:hover { - background-color: $_blendbg$; - padding-bottom: 6px; -} -#maincontent ul.maintabs.bottom li.tabselected a, -#maincontent ul.maintabs.bottom li a:hover { - padding-bottom: 2px; - padding-top: 5px; - margin-top: 9px; +ul.maintabs li a { + border: 1px solid $border$; + border-bottom: none; + background-color: $tabbg$; } +ul.maintabs.notfirst li a, +ul.maintabs.notfirst li b { margin-top: 20px } +ul.maintabs.bottom li a, +ul.maintabs.bottom li b { margin-top: 10px; padding: 4px 7px 2px 7px } +ul.maintabs.bottom li a { border-bottom: 1px solid $border$; border-top: none } +ul.maintabs li.left a, +ul.maintabs li.left b { float: left; margin-left: 0; margin-right: 10px } +ul.maintabs li b { margin-left: -2px; margin-right: -7px } +ul.maintabs li.left b { margin-left: -7px; margin-right: -2px } +ul.maintabs li.tabselected a, +ul.maintabs li a:hover { background-color: $_blendbg$; padding-bottom: 6px } +ul.maintabs.bottom li.tabselected a, +ul.maintabs.bottom li a:hover { padding-bottom: 2px; padding-top: 5px; margin-top: 9px } +ul.maintabs.browsetabs li a { margin-left: 5px } +ul.maintabs.browsetabs li.left a { margin-left: 0; margin-right: 5px } diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm index d9974b00..7c0160de 100644 --- a/lib/VNDB/Handler/Discussions.pm +++ b/lib/VNDB/Handler/Discussions.pm @@ -48,7 +48,7 @@ sub thread { end; end; - $self->htmlBrowseNavigate("/t$tid/", $page, $t->{count} > $page*25, 't', 1); + $self->htmlBrowseNavigate("/t$tid/", $page, [ $t->{count}, 25 ], 't', 1); div class => 'mainbox thread'; table; for my $i (0..$#$p) { @@ -83,7 +83,7 @@ sub thread { } end; end; - $self->htmlBrowseNavigate("/t$tid/", $page, $t->{count} > $page*25, 'b', 1); + $self->htmlBrowseNavigate("/t$tid/", $page, [ $t->{count}, 25 ], 'b', 1); if($t->{locked}) { div class => 'mainbox'; diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index 139ff1b0..62e01fd1 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -6,6 +6,7 @@ use warnings; use YAWF ':html', 'xml_escape'; use Exporter 'import'; use VNDB::Func; +use POSIX 'ceil'; our @EXPORT = qw| htmlBrowse htmlBrowseNavigate htmlBrowseHist htmlBrowseVN |; @@ -83,23 +84,39 @@ sub htmlBrowse { # creates next/previous buttons (tabs), if needed -# Arguments: page url, current page (1..n), nextpage (0/1), alignment (t/b), noappend (0/1) +# Arguments: page url, current page (1..n), nextpage (0/1 or [$total, $perpage]), alignment (t/b), noappend (0/1) sub htmlBrowseNavigate { my($self, $url, $p, $np, $al, $na) = @_; - return if $p == 1 && !$np; + my($cnt, $pp) = ref($np) ? @$np : ($p+$np, 1); + return if $p == 1 && $cnt <= $pp; $url .= $url =~ /\?/ ? ';p=' : '?p=' unless $na; - ul class => 'maintabs ' . ($al eq 't' ? 'notfirst' : 'bottom'); - if($p > 1) { - li class => 'left'; - a href => $url.($p-1), '<- '.mt '_browse_previous'; - end; - } - if($np) { - li; - a href => $url.($p+1), mt('_browse_next').' ->'; - end; - } + + my $tab = sub { + my($left, $page, $label) = @_; + li $left ? (class => 'left') : (); + a href => $url.$page; lit $label; end; + end; + }; + my $ell = sub { + use utf8; + li class => 'ellipsis'.(shift() ? ' left' : ''); + b '⋯'; + end; + }; + my $nc = 5; # max. number of buttons on each side + + ul class => 'maintabs browsetabs ' . ($al eq 't' ? 'notfirst' : 'bottom'); + $p > 2 and ref $np and $tab->(1, 1, '« '.mt '_browse_first'); + $p > $nc+1 and ref $np and $ell->(1); + $p > $_ and ref $np and $tab->(1, $p-$_, $p-$_) for (reverse 2..($nc>$p-2?$p-2:$nc-1)); + $p > 1 and $tab->(1, $p-1, '‹ '.mt '_browse_previous'); + + my $l = ceil($cnt/$pp)-$p+1; + $l > 2 and $tab->(0, $l+$p-1, mt('_browse_last').' »'); + $l > $nc+1 and $ell->(0); + $l > $_ and $tab->(0, $p+$_, $p+$_) for (reverse 2..($nc>$l-2?$l-2:$nc-1)); + $l > 1 and $tab->(0, $p+1, mt('_browse_next').' ›'); end; } |