annotate media/js/tiny_mce/utils/mctabs.js @ 242:7e8d2dda99e3

For #93: fix url scheme for weblinks.
author Brian Neal <bgneal@gmail.com>
date Wed, 15 Sep 2010 03:24:01 +0000
parents 149c3567fec1
children
rev   line source
bgneal@45 1 /**
bgneal@183 2 * mctabs.js
bgneal@45 3 *
bgneal@183 4 * Copyright 2009, Moxiecode Systems AB
bgneal@183 5 * Released under LGPL License.
bgneal@45 6 *
bgneal@183 7 * License: http://tinymce.moxiecode.com/license
bgneal@183 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@45 9 */
bgneal@45 10
bgneal@45 11 function MCTabs() {
bgneal@45 12 this.settings = [];
bgneal@45 13 };
bgneal@45 14
bgneal@45 15 MCTabs.prototype.init = function(settings) {
bgneal@45 16 this.settings = settings;
bgneal@45 17 };
bgneal@45 18
bgneal@45 19 MCTabs.prototype.getParam = function(name, default_value) {
bgneal@45 20 var value = null;
bgneal@45 21
bgneal@45 22 value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
bgneal@45 23
bgneal@45 24 // Fix bool values
bgneal@45 25 if (value == "true" || value == "false")
bgneal@45 26 return (value == "true");
bgneal@45 27
bgneal@45 28 return value;
bgneal@45 29 };
bgneal@45 30
bgneal@45 31 MCTabs.prototype.displayTab = function(tab_id, panel_id) {
bgneal@45 32 var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;
bgneal@45 33
bgneal@45 34 panelElm= document.getElementById(panel_id);
bgneal@45 35 panelContainerElm = panelElm ? panelElm.parentNode : null;
bgneal@45 36 tabElm = document.getElementById(tab_id);
bgneal@45 37 tabContainerElm = tabElm ? tabElm.parentNode : null;
bgneal@45 38 selectionClass = this.getParam('selection_class', 'current');
bgneal@45 39
bgneal@45 40 if (tabElm && tabContainerElm) {
bgneal@45 41 nodes = tabContainerElm.childNodes;
bgneal@45 42
bgneal@45 43 // Hide all other tabs
bgneal@45 44 for (i = 0; i < nodes.length; i++) {
bgneal@45 45 if (nodes[i].nodeName == "LI")
bgneal@45 46 nodes[i].className = '';
bgneal@45 47 }
bgneal@45 48
bgneal@45 49 // Show selected tab
bgneal@45 50 tabElm.className = 'current';
bgneal@45 51 }
bgneal@45 52
bgneal@45 53 if (panelElm && panelContainerElm) {
bgneal@45 54 nodes = panelContainerElm.childNodes;
bgneal@45 55
bgneal@45 56 // Hide all other panels
bgneal@45 57 for (i = 0; i < nodes.length; i++) {
bgneal@45 58 if (nodes[i].nodeName == "DIV")
bgneal@45 59 nodes[i].className = 'panel';
bgneal@45 60 }
bgneal@45 61
bgneal@45 62 // Show selected panel
bgneal@45 63 panelElm.className = 'current';
bgneal@45 64 }
bgneal@45 65 };
bgneal@45 66
bgneal@45 67 MCTabs.prototype.getAnchor = function() {
bgneal@45 68 var pos, url = document.location.href;
bgneal@45 69
bgneal@45 70 if ((pos = url.lastIndexOf('#')) != -1)
bgneal@45 71 return url.substring(pos + 1);
bgneal@45 72
bgneal@45 73 return "";
bgneal@45 74 };
bgneal@45 75
bgneal@45 76 // Global instance
bgneal@45 77 var mcTabs = new MCTabs();