* fix another off by one while retrieving the iterator counter params
[citadel.git] / webcit / tabs.c
bloba0cb7a6eb4fef63d9a6f691c259821fc36d7314b
1 /*
2 * $Id$
4 */
5 #include <stdarg.h>
6 #define SHOW_ME_VAPPEND_PRINTF
7 #include "webcit.h"
9 /*
10 * print tabbed dialog
12 void tabbed_dialog(int num_tabs, char *tabnames[]) {
13 int i;
15 StrBufAppendPrintf(WC->trailing_javascript,
16 "var previously_selected_tab = '0'; \n"
17 "function tabsel(which_tab) { \n"
18 " if (which_tab == previously_selected_tab) { \n"
19 " return; \n"
20 " } \n"
21 " $('tabdiv'+previously_selected_tab).style.display = 'none'; \n"
22 " $('tabdiv'+which_tab).style.display = 'block'; \n"
23 " $('tabtd'+previously_selected_tab).className = 'tab_cell_edit'; \n"
24 " $('tabtd'+which_tab).className = 'tab_cell_label'; \n"
25 " previously_selected_tab = which_tab; \n"
26 "} \n"
29 wprintf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
30 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
33 for (i=0; i<num_tabs; ++i) {
34 wprintf("<td id=\"tabtd%d\" class=\"%s\" "
35 "onClick='tabsel(\"%d\");'"
36 ">",
38 ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
41 wprintf("%s", tabnames[i]);
42 wprintf("</td>");
44 wprintf("<td>&nbsp;</td>\n");
47 wprintf("</tr></table>\n");
51 * print the tab-header
53 * tabnum: number of the tab to print
54 * num_tabs: total number oftabs to be printed
57 void begin_tab(int tabnum, int num_tabs) {
59 if (tabnum == num_tabs) {
60 wprintf("<!-- begin tab-common epilogue -->\n");
61 wprintf("<div class=\"tabcontent_submit\">");
64 else {
65 wprintf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
66 wprintf("<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
67 tabnum,
68 ( (tabnum == 0) ? "block" : "none" )
74 * print the tab-footer
75 * tabnum: number of the tab to print
76 * num_tabs: total number of tabs to be printed
79 void end_tab(int tabnum, int num_tabs) {
81 if (tabnum == num_tabs) {
82 wprintf("</div> <!-- end of 'tabcontent_submit' div -->\n");
83 wprintf("<!-- end tab-common epilogue -->\n");
86 else {
87 wprintf("</div>\n");
88 wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
90 if (tabnum == num_tabs-1) {
91 wprintf("<script type=\"text/javascript\">"
92 " Nifty(\"table#TheTabs td\", \"small transparent top\");"
93 "</script>"
101 * print tabbed dialog
103 void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]) {
104 int i;
106 StrBufAppendBufPlain(
107 Target,
108 HKEY(
109 "<script type=\"text/javascript\"> "
110 "var previously_selected_tab = '0'; "
111 "function tabsel(which_tab) { "
112 " if (which_tab == previously_selected_tab) { "
113 " return; "
114 " } "
115 " $('tabdiv'+previously_selected_tab).style.display = 'none'; "
116 " $('tabdiv'+which_tab).style.display = 'block'; "
117 " $('tabtd'+previously_selected_tab).className = 'tab_cell_edit'; "
118 " $('tabtd'+which_tab).className = 'tab_cell_label'; "
119 " previously_selected_tab = which_tab; "
120 "} "
121 "</script> \n"
122 ), 0);
124 StrBufAppendBufPlain(
125 Target,
126 HKEY(
127 "<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
128 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
129 ), 0);
131 for (i=0; i<num_tabs; ++i) {
132 StrBufAppendPrintf(
133 Target,
134 "<td id=\"tabtd%d\" class=\"%s\" "
135 "onClick='tabsel(\"%d\");'"
136 ">",
138 ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
141 StrBufAppendBuf(Target, tabnames[i], 0);
142 StrBufAppendBufPlain(
143 Target,
144 HKEY(
145 "</td>"
146 "<td>&nbsp;</td>\n"), 0);
149 StrBufAppendBufPlain(
150 Target,
151 HKEY("</tr></table>\n"), 0);
155 * print the tab-header
157 * tabnum: number of the tab to print
158 * num_tabs: total number oftabs to be printed
161 void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs) {
163 if (tabnum == num_tabs) {
164 StrBufAppendBufPlain(
165 Target,
166 HKEY(
167 "<!-- begin tab-common epilogue -->\n"
168 "<div class=\"tabcontent_submit\">"), 0);
171 else {
172 StrBufAppendPrintf(
173 Target,
174 "<!-- begin tab %d of %d -->\n"
175 "<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
176 tabnum, num_tabs,
177 tabnum,
178 ( (tabnum == 0) ? "block" : "none" )
184 * print the tab-footer
185 * tabnum: number of the tab to print
186 * num_tabs: total number of tabs to be printed
189 void StrEndTab(StrBuf *Target, int tabnum, int num_tabs) {
191 if (tabnum == num_tabs) {
192 StrBufAppendBufPlain(
193 Target,
194 HKEY(
195 "</div>\n"
196 "<!-- end tab-common epilogue -->\n"), 0);
199 else {
200 StrBufAppendPrintf(
201 Target,
202 "</div>\n",
203 "<!-- end tab %d of %d -->\n", tabnum, num_tabs);
205 if (tabnum == num_tabs-1) {
206 StrBufAppendBufPlain(
207 Target,
208 HKEY(
209 "<script type=\"text/javascript\">"
210 " Nifty(\"table#TheTabs td\", \"small transparent top\");"
211 "</script>"), 0);