summaryrefslogtreecommitdiff
path: root/skins/default/functions.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-10-06 06:48:19 +0000
committeralecpl <alec@alec.pl>2010-10-06 06:48:19 +0000
commit6769ba767005b8adc93a077c04eb745502b01238 (patch)
treefaab9d68069ae9ee4abb416b89ac3f4ae607a6bf /skins/default/functions.js
parent76ee6cafcd7847c802857431ec4224a577fa7ee3 (diff)
- Improve tabs to fixed width and add tabs in identities info (#1486974)
Diffstat (limited to 'skins/default/functions.js')
-rw-r--r--skins/default/functions.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/skins/default/functions.js b/skins/default/functions.js
index 64a6d9921..82f7c1562 100644
--- a/skins/default/functions.js
+++ b/skins/default/functions.js
@@ -21,6 +21,56 @@ function rcube_show_advanced(visible)
$('tr.advanced').css('display', (visible ? (bw.ie ? 'block' : 'table-row') : 'none'));
}
+// Fieldsets-to-tabs converter
+// Warning: don't place "caller" <script> inside page element (id)
+function rcube_init_tabs(id, current)
+{
+ var content = document.getElementById(id),
+ fs = $('fieldset', content);
+
+ current = current ? current : 0;
+
+ // first hide not selected tabs
+ fs.each(function(idx) { if (idx != current) $(this).hide(); });
+
+ // create tabs container
+ var tabs = $('<div>').addClass('tabsbar').appendTo($(content));
+
+ // convert fildsets into tabs
+ fs.each(function(idx) {
+ var tab, a, elm = $(this), legend = $('legend', elm);
+
+ // create a tab
+ a = $('<a>').text(legend.text()).attr('href', '#');
+ tab = $('<span>').attr({'id': 'tab'+idx, 'class': 'tablink'})
+ .click(function() { return rcube_show_tab(id, idx); })
+
+ // remove legend
+ legend.remove();
+ // style fieldset
+ elm.addClass('tabbed');
+ // style selected tab
+ if (idx == current)
+ tab.addClass('tablink-selected');
+
+ // add the tab to container
+ tab.append(a).appendTo(tabs);
+ });
+}
+
+function rcube_show_tab(id, index)
+{
+ var content = document.getElementById(id),
+ fs = $('fieldset', content);
+
+ fs.each(function(idx) {
+ // Show/hide fieldset (tab content)
+ $(this)[index==idx ? 'show' : 'hide']();
+ // Select/unselect tab
+ $('#tab'+idx).toggleClass('tablink-selected', idx==index);
+ });
+}
+
/**
* Mail UI
*/