--- /dev/null
+/**\r
+ * mctabs.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
+function MCTabs() {\r
+ this.settings = [];\r
+};\r
+\r
+MCTabs.prototype.init = function(settings) {\r
+ this.settings = settings;\r
+};\r
+\r
+MCTabs.prototype.getParam = function(name, default_value) {\r
+ var value = null;\r
+\r
+ value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];\r
+\r
+ // Fix bool values\r
+ if (value == "true" || value == "false")\r
+ return (value == "true");\r
+\r
+ return value;\r
+};\r
+\r
+MCTabs.prototype.displayTab = function(tab_id, panel_id) {\r
+ var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;\r
+\r
+ panelElm= document.getElementById(panel_id);\r
+ panelContainerElm = panelElm ? panelElm.parentNode : null;\r
+ tabElm = document.getElementById(tab_id);\r
+ tabContainerElm = tabElm ? tabElm.parentNode : null;\r
+ selectionClass = this.getParam('selection_class', 'current');\r
+\r
+ if (tabElm && tabContainerElm) {\r
+ nodes = tabContainerElm.childNodes;\r
+\r
+ // Hide all other tabs\r
+ for (i = 0; i < nodes.length; i++) {\r
+ if (nodes[i].nodeName == "LI")\r
+ nodes[i].className = '';\r
+ }\r
+\r
+ // Show selected tab\r
+ tabElm.className = 'current';\r
+ }\r
+\r
+ if (panelElm && panelContainerElm) {\r
+ nodes = panelContainerElm.childNodes;\r
+\r
+ // Hide all other panels\r
+ for (i = 0; i < nodes.length; i++) {\r
+ if (nodes[i].nodeName == "DIV")\r
+ nodes[i].className = 'panel';\r
+ }\r
+\r
+ // Show selected panel\r
+ panelElm.className = 'current';\r
+ }\r
+};\r
+\r
+MCTabs.prototype.getAnchor = function() {\r
+ var pos, url = document.location.href;\r
+\r
+ if ((pos = url.lastIndexOf('#')) != -1)\r
+ return url.substring(pos + 1);\r
+\r
+ return "";\r
+};\r
+\r
+// Global instance\r
+var mcTabs = new MCTabs();\r