[Bio] / FigWebServices / WebApplicationComponents / List.pm Repository:
ViewVC logotype

Annotation of /FigWebServices/WebApplicationComponents/List.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : olson 1.1 package List;
2 :    
3 :     use strict;
4 :     use warnings;
5 :    
6 :     1;
7 :    
8 :     sub new {
9 :     my ($class, $params) = @_;
10 :    
11 :     # retrieve params from params hash
12 :     my @items = @{$params->{items}};
13 :     my @links = [];
14 :     if (defined($params->{links})) {
15 :     @links = @{$params->{links}};
16 :     }
17 :     my $highlight_selected = $params->{highlight_selected} || 0;
18 :     my $show_image = $params->{show_image} || 0;
19 :     my $img_path = $params->{img_path} || "../images/";
20 :     my $headline = $params->{headline} || "";
21 :     my $current = $params->{current} || -1;
22 :     my $id = $params->{id} || "list";
23 :    
24 :     # determine indirect values
25 :     my $num_items = scalar(@items);
26 :    
27 :     # initialize list string
28 :     my $list = "<table class='list_table'>";
29 :    
30 :     # check for headline
31 :     if ($headline) {
32 :     $list .= "<tr><td></td><td class='list_headline'>" . $headline . "</td></tr>";
33 :     }
34 :    
35 :     my $curr = 0;
36 :     foreach my $item (@items) {
37 :    
38 :     my $class_name = "list_item";
39 :     my $image = "";
40 :     my $link = "";
41 :    
42 :     # check if links are present
43 :     if (defined($links[$curr])) {
44 :     $link = " onclick='list_select(\"list_" . $id . "\", \"" . $links[$curr] . "\")'";
45 :     }
46 :    
47 :     # check for selected row
48 :     if ($curr == $current) {
49 :     if ($show_image) {
50 :     $image = "<img class='list_image' src='" . $img_path . "arrow.gif'>";
51 :     }
52 :     if ($highlight_selected) {
53 :     $class_name = "list_selected";
54 :     }
55 :     }
56 :    
57 :     $list .= "<tr><td class='list_img'>" . $image . "</td><td" . $link . " class='" . $class_name . "'>" . $item . "</td></tr>";
58 :     $curr++;
59 :     }
60 :    
61 :     # close surrounding table
62 :     $list .= "</table>";
63 :    
64 :     # return list string
65 :     return $list;
66 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3