* Removed the Kevin Roth rich text editor and replaced it with TinyMCE.
[citadel.git] / webcit / tiny_mce / utils / mctabs.js
1 /**
2  * $RCSfile$
3  * $Revision$
4  * $Date$
5  *
6  * Moxiecode DHTML Tabs script.
7  *
8  * @author Moxiecode
9  * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
10  */
11
12 function MCTabs() {
13         this.settings = new Array();
14 };
15
16 MCTabs.prototype.init = function(settings) {
17         this.settings = settings;
18 };
19
20 MCTabs.prototype.getParam = function(name, default_value) {
21         var value = null;
22
23         value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
24
25         // Fix bool values
26         if (value == "true" || value == "false")
27                 return (value == "true");
28
29         return value;
30 };
31
32 MCTabs.prototype.displayTab = function(tab_id, panel_id) {
33         var panelElm = document.getElementById(panel_id);
34         var panelContainerElm = panelElm ? panelElm.parentNode : null;
35         var tabElm = document.getElementById(tab_id);
36         var tabContainerElm = tabElm ? tabElm.parentNode : null;
37         var selectionClass = this.getParam('selection_class', 'current');
38
39         if (tabElm && tabContainerElm) {
40                 var nodes = tabContainerElm.childNodes;
41
42                 // Hide all other tabs
43                 for (var i=0; i<nodes.length; i++) {
44                         if (nodes[i].nodeName == "LI")
45                                 nodes[i].className = '';
46                 }
47
48                 // Show selected tab
49                 tabElm.className = 'current';
50         }
51
52         if (panelElm && panelContainerElm) {
53                 var nodes = panelContainerElm.childNodes;
54
55                 // Hide all other panels
56                 for (var i=0; i<nodes.length; i++) {
57                         if (nodes[i].nodeName == "DIV")
58                                 nodes[i].className = 'panel';
59                 }
60
61                 // Show selected panel
62                 panelElm.className = 'current';
63         }
64 };
65
66 MCTabs.prototype.getAnchor = function() {
67         var pos, url = document.location.href;
68
69         if ((pos = url.lastIndexOf('#')) != -1)
70                 return url.substring(pos + 1);
71
72         return "";
73 };
74
75 // Global instance
76 var mcTabs = new MCTabs();