From 7c0ea176236eb4232303fbc60aabb2e0448a169f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 16 Aug 2009 03:29:46 +0000 Subject: libs/cbi: implement tabbing to split large sections and group options in tabs --- libs/cbi/htdocs/luci-static/resources/cbi.js | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'libs/cbi/htdocs/luci-static/resources') diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js index 77c59e511e..24f929c9bc 100644 --- a/libs/cbi/htdocs/luci-static/resources/cbi.js +++ b/libs/cbi/htdocs/luci-static/resources/cbi.js @@ -2,7 +2,7 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich + Copyright 2008-2009 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ */ var cbi_d = []; +var cbi_t = []; function cbi_d_add(field, dep, next) { var obj = document.getElementById(field); @@ -219,3 +220,32 @@ function cbi_hijack_forms(layer, win, fail, load) { }); } } + + +function cbi_t_add(section, tab) { + var t = document.getElementById('tab.' + section + '.' + tab); + var c = document.getElementById('container.' + section + '.' + tab); + + if( t && c ) { + cbi_t[section] = (cbi_t[section] || [ ]); + cbi_t[section][tab] = { 'tab': t, 'container': c }; + } +} + +function cbi_t_switch(section, tab) { + if( cbi_t[section] && cbi_t[section][tab] ) { + var o = cbi_t[section][tab]; + for( var tid in cbi_t[section] ) { + var o2 = cbi_t[section][tid]; + if( o.tab.id != o2.tab.id ) { + o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab( |$)/, " cbi-tab-disabled "); + o2.container.style.display = 'none'; + } + else { + o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab-disabled( |$)/, " cbi-tab "); + o2.container.style.display = 'block'; + } + } + } + return false +} -- cgit v1.2.3