Changed the tabbed dialog API to include an epilogue that
[citadel.git] / webcit / tabs.c
index 2118d8bb1c7baa42bbef3fd923dd70068c6ce1ad..569a7f7633e8ea79d912115b0239e90267bfb535 100644 (file)
@@ -1,17 +1,12 @@
 /*
  * $Id$
+ *
  */
-/**
- * \defgroup TabUtils Utility functions for creating tabbed dialogs
- * \ingroup WebcitDisplayItems
- */
-/*@{*/
+
 #include "webcit.h"
 
-/**
- * \brief print tabbed dialog
- * \param num_tabs how many tabs do we have?
- * \param tabnames the headers of the tables
+/*
+ * print tabbed dialog
  */
 void tabbed_dialog(int num_tabs, char *tabnames[]) {
        int i;
@@ -24,6 +19,8 @@ void tabbed_dialog(int num_tabs, char *tabnames[]) {
                "       }                                                                       "
                "       $('tabdiv'+previously_selected_tab).style.display = 'none';             "
                "       $('tabdiv'+which_tab).style.display = 'block';                          "
+               "       $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         "
+               "       $('tabtd'+which_tab).className = 'tab_cell_label';                      "
                "       previously_selected_tab = which_tab;                                    "
                "}                                                                              "
                "</script>                                                                      \n"
@@ -39,9 +36,8 @@ void tabbed_dialog(int num_tabs, char *tabnames[]) {
                        ">",
                        i,
                        ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
-                       i,
                        i
-               );
+                       );
                wprintf("%s", tabnames[i]);
                wprintf("</td>");
 
@@ -49,41 +45,55 @@ void tabbed_dialog(int num_tabs, char *tabnames[]) {
        }
 
        wprintf("</tr></table>\n");
-       wprintf("<div class=\"tabcontent\">");
 }
 
-/**
- * \brief print the tab-header
- * \param tabnum number of the tab to print
- * \param num_tabs total number oftabs to be printed
+/*
+ * print the tab-header
+ *
+ * tabnum:      number of the tab to print
+ * num_tabs:    total number oftabs to be printed
+ *
  */
 void begin_tab(int tabnum, int num_tabs) {
-       wprintf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
-       wprintf("<div id=\"tabdiv%d\" style=\"display:%s\">",
-               tabnum,
-               ( (tabnum == 0) ? "block" : "none" )
-       );
+
+       if (tabnum == num_tabs) {
+               wprintf("<!-- begin tab-common epilogue -->\n");
+               wprintf("<div class=\"tabcontent_submit\">");
+       }
+
+       else {
+               wprintf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
+               wprintf("<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
+                       tabnum,
+                       ( (tabnum == 0) ? "block" : "none" )
+               );
+       }
 }
 
-/**
- * \brief print the tab-footer
- * \param tabnum number of the tab to print
- * \param num_tabs total number of tabs to be printed
+/*
+ * print the tab-footer
+ * tabnum:      number of the tab to print
+ * num_tabs:    total number of tabs to be printed
+ *
  */
 void end_tab(int tabnum, int num_tabs) {
-       wprintf("</div>\n");
-       wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
 
-       if (tabnum == num_tabs-1) {
+       if (tabnum == num_tabs) {
                wprintf("</div>\n");
-               wprintf("<script type=\"text/javascript\">"
-                       " Nifty(\"table#TheTabs td\", \"small transparent top\");"
-                       " Nifty(\"div.tabcontent\", \"big transparent bottom\");"
-                       " Nifty(\"div.tabcontent_submit\", \"big transparent bottom\");"
-                       "</script>"
-               );
+               wprintf("<!-- end tab-common epilogue -->\n");
+       }
+
+       else {
+               wprintf("</div>\n");
+               wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
+       
+               if (tabnum == num_tabs-1) {
+                       wprintf("<script type=\"text/javascript\">"
+                               " Nifty(\"table#TheTabs td\", \"small transparent top\");"
+                               "</script>"
+                       );
+               }
        }
 }
 
 
-/*@}*/