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

Annotation of /FigWebServices/WebApplicationComponents/Menu.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1 package Menu;
2 :    
3 :     1;
4 :    
5 :     sub new {
6 :     my ($class, $params) = @_;
7 :    
8 :     # retrieve params from param hash
9 :     my @items = @{$params->{items}};
10 :     my @links = @{$params->{links}};
11 : paczian 1.3 my $targets = $params->{targets} || {};
12 : olson 1.1 my $selected = $params->{selected} || -1;
13 :     my $id = $params->{id} || "menu";
14 :     my $title = $params->{title} || "title";
15 : paczian 1.2 my $class = $params->{class} || "";
16 : olson 1.1
17 :     # initialize menu string
18 : paczian 1.2 my $menu = "<div id='" . $id ."' class='" . $class . "'><table class='div_box'>";
19 : olson 1.1
20 :     # create menu title
21 : paczian 1.3 $menu .= qq~<tr><td id="~ . $id . qq~_add" class="hideme" onclick="add_element('~ . $id . qq~')">+</td><td id="~ . $id . qq~_clear" class="div_clear" onclick="change_element('~ . $id . qq~');"><li></td><td id="~ . $id . qq~_title" class="div_title_blue">~ . $title . qq~</td><td id="~ . $id . qq~_remove" class="hideme" onclick="remove_element('~ . $id . qq~')">x</td></tr><tr><td colspan=3 id="~ . $id . qq~_content" class="showme"><table style="width: 100%; background-color: white;">~;
22 : olson 1.1
23 :     # fill in menu points
24 :     my $curr = 0;
25 :     foreach my $item (@items) {
26 :     my $class_name = "menu_item";
27 :     if ($curr == $selected) {
28 :     $class_name = "menu_selected";
29 :     }
30 : paczian 1.2
31 : paczian 1.3 my $target = "";
32 :     if (exists($targets->{$items[$curr]})) {
33 :     $target = " target=_blank";
34 : paczian 1.2 }
35 : paczian 1.3
36 :     $menu .= "<tr><td><a href='" . $links[$curr] . "' class='" . $class_name . "' style='width: 190px;'" . $target . ">" . $items[$curr] . "</a></td></tr>";
37 : olson 1.1 $curr++;
38 :     }
39 :    
40 :     # close surrounding table and div
41 : paczian 1.3 $menu .= "</table></td></tr></table></div>";
42 : olson 1.1
43 :     return $menu;
44 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3