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