summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2012-01-25 13:59:43 +0100
committerYorhel <git@yorhel.nl>2012-01-25 13:59:43 +0100
commit6f33c4786786978ee785bc3e5020cef5f66254ef (patch)
tree6f6de09886a4baeacbae9e5e8982e4415b881dc7 /lib/VNDB/Util
parent616ddb08bf4f10560229bee326eb89ce1bef7488 (diff)
Do most of the table striping in CSS
Using CSS3 selectors. This is a more elegant approach, and since browser support for CSS3 selectors isn't as crap as it used to be I can finally make use of them.
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r--lib/VNDB/Util/BrowseHTML.pm6
-rw-r--r--lib/VNDB/Util/CommonHTML.pm23
2 files changed, 14 insertions, 15 deletions
diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm
index 993f8746..88396cf5 100644
--- a/lib/VNDB/Util/BrowseHTML.pm
+++ b/lib/VNDB/Util/BrowseHTML.pm
@@ -38,7 +38,7 @@ sub htmlBrowse {
$self->htmlBrowseNavigate($opt{pageurl}, $opt{options}{p}, $opt{nextpage}, 't');
div class => 'mainbox browse'.($opt{class} ? ' '.$opt{class} : '');
- table;
+ table class => 'stripe';
# header
thead;
@@ -139,7 +139,7 @@ sub htmlBrowseHist {
my($s, $n, $i) = @_;
my $revurl = "/$i->{type}$i->{iid}.$i->{rev}";
- Tr $n % 2 ? ( class => 'odd' ) : ();
+ Tr;
td class => 'tc1_1';
a href => $revurl, "$i->{type}$i->{iid}";
end;
@@ -180,7 +180,7 @@ sub htmlBrowseVN {
],
row => sub {
my($s, $n, $l) = @_;
- Tr $n % 2 ? (class => 'odd') : ();
+ Tr;
if($tagscore) {
td class => 'tc_s';
tagscore $l->{tagscore}, 0;
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 8f908b19..3d43a338 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -195,7 +195,7 @@ sub htmlRevision {
# otherwise, compare the two revisions
else {
- table;
+ table class => 'stripe';
thead;
Tr;
td; lit '&nbsp;'; end;
@@ -211,8 +211,7 @@ sub htmlRevision {
end;
end;
end;
- my $i = 1;
- revdiff(\$i, $type, $old, $new, @$_) for (
+ revdiff($type, $old, $new, @$_) for (
[ ihid => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
[ ilock => serialize => sub { mt $_[0] ? '_revision_yes' : '_revision_no' } ],
@fields
@@ -233,7 +232,7 @@ sub revheader { # type, obj
}
sub revdiff {
- my($i, $type, $old, $new, $short, %o) = @_;
+ my($type, $old, $new, $short, %o) = @_;
$o{serialize} ||= $o{htmlize};
$o{diff} = 1 if $o{split};
@@ -268,7 +267,7 @@ sub revdiff {
$ser1 = mt '_revision_empty' if !$ser1 && $ser1 ne '0';
$ser2 = mt '_revision_empty' if !$ser2 && $ser2 ne '0';
- Tr $$i++ % 2 ? (class => 'odd') : ();
+ Tr;
td mt $short eq 'ihid' || $short eq 'ilock' ? "_revfield_$short" : "_revfield_${type}_$short";
td class => 'tcval'; lit $ser1; end;
td class => 'tcval'; lit $ser2; end;
@@ -372,7 +371,7 @@ sub htmlVoteStats {
hide_ign => $type eq 'v',
);
if(@$recent) {
- table class => 'recentvotes';
+ table class => 'recentvotes stripe';
thead; Tr;
td colspan => 3;
txt mt '_votestats_recent';
@@ -383,17 +382,17 @@ sub htmlVoteStats {
end;
end;
end; end;
- for (0..$#$recent) {
- Tr $_ % 2 == 0 ? (class => 'odd') : ();
+ for (@$recent) {
+ Tr;
td;
if($type eq 'u') {
- a href => "/v$recent->[$_]{vid}", title => $recent->[$_]{original}||$recent->[$_]{title}, shorten $recent->[$_]{title}, 40;
+ a href => "/v$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
} else {
- a href => "/u$recent->[$_]{uid}", $recent->[$_]{username};
+ a href => "/u$_->{uid}", $_->{username};
}
end;
- td fmtvote $recent->[$_]{vote};
- td $self->{l10n}->date($recent->[$_]{date});
+ td fmtvote $_->{vote};
+ td $self->{l10n}->date($_->{date});
end;
}
end 'table';