1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*
* $Id: tabs.c 5615 2007-10-24 17:47:07Z thierry $
*/
/**
* \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
*/
void tabbed_dialog(int num_tabs, char *tabnames[]) {
int i;
wprintf("<script type=\"text/javascript\"> "
"var previously_selected_tab = '0'; "
"function tabsel(which_tab) { "
" if (which_tab == previously_selected_tab) { "
" return; "
" } "
" $('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"
);
wprintf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
"<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
);
for (i=0; i<num_tabs; ++i) {
wprintf("<td id=\"tabtd%d\" class=\"%s\" "
"onClick='tabsel(\"%d\");'"
">",
i,
( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
i,
i
);
wprintf("%s", tabnames[i]);
wprintf("</td>");
wprintf("<td> </td>\n");
}
wprintf("</tr></table>\n");
}
/**
* \brief print the tab-header
* \param tabnum number of the tab to print
* \param 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\" 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
*/
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) {
wprintf("<script type=\"text/javascript\">"
" Nifty(\"table#TheTabs td\", \"small transparent top\");"
"</script>"
);
}
}
/*@}*/
|