1 /** |
1 /** |
2 * $Id: mctabs.js 520 2008-01-07 16:30:32Z spocke $ |
2 * $Id: mctabs.js 758 2008-03-30 13:53:29Z spocke $ |
3 * |
3 * |
4 * Moxiecode DHTML Tabs script. |
4 * Moxiecode DHTML Tabs script. |
5 * |
5 * |
6 * @author Moxiecode |
6 * @author Moxiecode |
7 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
7 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
8 */ |
8 */ |
9 |
9 |
10 function MCTabs() { |
10 function MCTabs() { |
11 this.settings = new Array(); |
11 this.settings = []; |
12 }; |
12 }; |
13 |
13 |
14 MCTabs.prototype.init = function(settings) { |
14 MCTabs.prototype.init = function(settings) { |
15 this.settings = settings; |
15 this.settings = settings; |
16 }; |
16 }; |
26 |
26 |
27 return value; |
27 return value; |
28 }; |
28 }; |
29 |
29 |
30 MCTabs.prototype.displayTab = function(tab_id, panel_id) { |
30 MCTabs.prototype.displayTab = function(tab_id, panel_id) { |
31 var panelElm = document.getElementById(panel_id); |
31 var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i; |
32 var panelContainerElm = panelElm ? panelElm.parentNode : null; |
32 |
33 var tabElm = document.getElementById(tab_id); |
33 panelElm= document.getElementById(panel_id); |
34 var tabContainerElm = tabElm ? tabElm.parentNode : null; |
34 panelContainerElm = panelElm ? panelElm.parentNode : null; |
35 var selectionClass = this.getParam('selection_class', 'current'); |
35 tabElm = document.getElementById(tab_id); |
|
36 tabContainerElm = tabElm ? tabElm.parentNode : null; |
|
37 selectionClass = this.getParam('selection_class', 'current'); |
36 |
38 |
37 if (tabElm && tabContainerElm) { |
39 if (tabElm && tabContainerElm) { |
38 var nodes = tabContainerElm.childNodes; |
40 nodes = tabContainerElm.childNodes; |
39 |
41 |
40 // Hide all other tabs |
42 // Hide all other tabs |
41 for (var i=0; i<nodes.length; i++) { |
43 for (i = 0; i < nodes.length; i++) { |
42 if (nodes[i].nodeName == "LI") |
44 if (nodes[i].nodeName == "LI") |
43 nodes[i].className = ''; |
45 nodes[i].className = ''; |
44 } |
46 } |
45 |
47 |
46 // Show selected tab |
48 // Show selected tab |
47 tabElm.className = 'current'; |
49 tabElm.className = 'current'; |
48 } |
50 } |
49 |
51 |
50 if (panelElm && panelContainerElm) { |
52 if (panelElm && panelContainerElm) { |
51 var nodes = panelContainerElm.childNodes; |
53 nodes = panelContainerElm.childNodes; |
52 |
54 |
53 // Hide all other panels |
55 // Hide all other panels |
54 for (var i=0; i<nodes.length; i++) { |
56 for (i = 0; i < nodes.length; i++) { |
55 if (nodes[i].nodeName == "DIV") |
57 if (nodes[i].nodeName == "DIV") |
56 nodes[i].className = 'panel'; |
58 nodes[i].className = 'panel'; |
57 } |
59 } |
58 |
60 |
59 // Show selected panel |
61 // Show selected panel |