4
* Copyright 2009, Moxiecode Systems AB
5
* Released under LGPL License.
7
* License: http://tinymce.moxiecode.com/license
8
* Contributing: http://tinymce.moxiecode.com/contributing
15
MCTabs.prototype.init = function(settings) {
16
this.settings = settings;
19
MCTabs.prototype.getParam = function(name, default_value) {
22
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
25
if (value == "true" || value == "false")
26
return (value == "true");
31
MCTabs.prototype.displayTab = function(tab_id, panel_id) {
32
var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;
34
panelElm= document.getElementById(panel_id);
35
panelContainerElm = panelElm ? panelElm.parentNode : null;
36
tabElm = document.getElementById(tab_id);
37
tabContainerElm = tabElm ? tabElm.parentNode : null;
38
selectionClass = this.getParam('selection_class', 'current');
40
if (tabElm && tabContainerElm) {
41
nodes = tabContainerElm.childNodes;
43
// Hide all other tabs
44
for (i = 0; i < nodes.length; i++) {
45
if (nodes[i].nodeName == "LI")
46
nodes[i].className = '';
50
tabElm.className = 'current';
53
if (panelElm && panelContainerElm) {
54
nodes = panelContainerElm.childNodes;
56
// Hide all other panels
57
for (i = 0; i < nodes.length; i++) {
58
if (nodes[i].nodeName == "DIV")
59
nodes[i].className = 'panel';
62
// Show selected panel
63
panelElm.className = 'current';
67
MCTabs.prototype.getAnchor = function() {
68
var pos, url = document.location.href;
70
if ((pos = url.lastIndexOf('#')) != -1)
71
return url.substring(pos + 1);
77
var mcTabs = new MCTabs();