5 <script type="text/javascript" src="/planetlab/prototype/prototype.js"></script>
6 <script type="text/javascript" src="/planetlab/minitabs/minitabs.js"></script>
7 <link href="/planetlab/minitabs/minitabs.css" rel="stylesheet" type="text/css" />
11 // the expected argument is an (ordered) associative array
12 // ( label => todo , ...)
13 // label is expected to be the string to display in the menu
15 // (*) a string : it is then taken to be a URL to move to
16 // (*) or an associative array with the following keys
17 // (*) 'label' : if set, this overrides the string key just above
18 // this is used for functions that return a tab, more convenient to write&use
19 // (*) 'method': 'POST' or 'GET' -- default is 'GET'
20 // (*) 'url': where to go
21 // (*) 'values': an associative array of (key,value) pairs to send to the URL; values are strings
22 // (*) 'confirm': a question to display before actually triggering
23 // (*) 'bubble': a longer message displayed when the mouse stays quite for a while on the label
24 // (*) 'image' : the url of an image used instead of the label
25 // (*) 'height' : used for the image
26 // (*) 'id' : assign given id to the <li> element
29 // (*) values can also be set in the URL, e.g. ?var=value&foo=bar, even for POST'ing
30 // (*) several instances can appear on the same page but you need to give them different id's
33 // function my_tab () { return array('label'=>'Go to google','url'=>'http://google.com'); }
35 // $tabs[] = my_tab();
36 // $tabs['Simple Tab']="http://planet-lab.org";
37 // $tabs['Complex Tab']=array('url'=>'http://planet-lab.org/',
38 // 'bubble'=>'This text gets displayed when the mouse remains over for a while');
41 ////////// Notes: limited support for images
42 // (*) for some reason, confirmation does not work with image tabs
43 // (the form gets submitted whatever the confirmation....)
44 // (*) you need to tune the image size, which is wrong, as the image should rather be bottom-aligned
46 function plc_tabs ($array, $id=NULL) {
47 if (! $id) $id="minitabs";
48 print "<div id='$id' class='minitabs'>";
50 foreach ($array as $label=>$todo) {
51 // in case we have a simple string, rewrite it as an array
52 if (is_string ($todo)) $todo=array('method'=>'GET','url'=>$todo);
53 // the 'label' key, if set in the hash, supersedes key
54 if ($todo['label']) $label=$todo['label'];
55 $tracer="class=minitabs";
57 $tracer .= " id=".$todo['id'];
60 if ( ! $todo['method'] ) $todo['method']='GET';
61 // extract var=value settings from url if any
62 $full_url=$todo['url'];
63 $split=split_url($full_url);
65 $url_values=$split['values'];
68 $method=$todo['method'];
69 print "<form name='$label' action='$url' method='$method'>";
71 $values=$todo['values'];
72 if ( ! $values) $values = array();
73 if ($url_values) $values = array_merge($values,$url_values);
74 if ( $values ) foreach ($values as $key=>$value) {
75 print "<input class='minitabs-hidden' type=hidden name='$key' value='$value' />";
77 $tracer="class=minitabs-submit";
78 // image and its companions 'height'
80 $type='type=image src="' . $todo['image'] . '"';
81 if ($todo['height']) $type.= ' height=' . $todo['height'];
83 $type='type=button value="' . $label . '"';
85 $bubble=$todo['bubble'];
86 print "<span title='$bubble'>";
88 if ($todo['confirm']) $message=$todo['confirm'] . " ?";
89 print "<input $tracer $type onclick='minitabs_namespace.submit(\"$id\",\"$message\")' />";
91 print "</form></li>\n";
95 print "<p class='plc-minittabs'></p>\n";