c87cf4a4c269e43bdcd544e226faca256be8c17f
[citadel.git] / webcit / tabs.c
1 /*
2  * $Id$
3  *
4  */
5
6 #include "webcit.h"
7
8 /*
9  * print tabbed dialog
10  */
11 void tabbed_dialog(int num_tabs, char *tabnames[]) {
12         int i;
13
14         wprintf("<script type=\"text/javascript\">                                              "
15                 "var previously_selected_tab = '0';                                             "
16                 "function tabsel(which_tab) {                                                   "
17                 "       if (which_tab == previously_selected_tab) {                             "
18                 "               return;                                                         "
19                 "       }                                                                       "
20                 "       $('tabdiv'+previously_selected_tab).style.display = 'none';             "
21                 "       $('tabdiv'+which_tab).style.display = 'block';                          "
22                 "       $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         "
23                 "       $('tabtd'+which_tab).className = 'tab_cell_label';                      "
24                 "       previously_selected_tab = which_tab;                                    "
25                 "}                                                                              "
26                 "</script>                                                                      \n"
27         );
28
29         wprintf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
30                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
31         );
32
33         for (i=0; i<num_tabs; ++i) {
34                 wprintf("<td id=\"tabtd%d\" class=\"%s\" "
35                         "onClick='tabsel(\"%d\");'"
36                         ">",
37                         i,
38                         ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
39                         i,
40                         i
41                 );
42                 wprintf("%s", tabnames[i]);
43                 wprintf("</td>");
44
45                 wprintf("<td>&nbsp;</td>\n");
46         }
47
48         wprintf("</tr></table>\n");
49 }
50
51 /*
52  * print the tab-header
53  *
54  * tabnum:       number of the tab to print
55  * num_tabs:     total number oftabs to be printed
56  *
57  */
58 void begin_tab(int tabnum, int num_tabs) {
59         wprintf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
60         wprintf("<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
61                 tabnum,
62                 ( (tabnum == 0) ? "block" : "none" )
63         );
64 }
65
66 /*
67  * print the tab-footer
68  * tabnum:       number of the tab to print
69  * num_tabs:     total number of tabs to be printed
70  *
71  */
72 void end_tab(int tabnum, int num_tabs) {
73         wprintf("</div>\n");
74         wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
75
76         if (tabnum == num_tabs-1) {
77
78                 wprintf("<script type=\"text/javascript\">"
79                         " Nifty(\"table#TheTabs td\", \"small transparent top\");"
80                         "</script>"
81                 );
82
83         }
84 }
85
86