includes/clientside/tinymce/utils/mctabs.js
author Dan Fuhry <dan@enanocms.org>
Tue, 06 Jul 2010 00:59:06 -0400
changeset 1263 eb717f5c283f
parent 543 dffcbfbc4e59
permissions -rw-r--r--
Clean up that GLOBALS silliness.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     1
/**
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
     2
 * $Id: mctabs.js 758 2008-03-30 13:53:29Z spocke $
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     3
 *
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     4
 * Moxiecode DHTML Tabs script.
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     5
 *
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     6
 * @author Moxiecode
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     7
 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     8
 */
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
     9
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    10
function MCTabs() {
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    11
	this.settings = [];
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    12
};
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    13
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    14
MCTabs.prototype.init = function(settings) {
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    15
	this.settings = settings;
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    16
};
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    17
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    18
MCTabs.prototype.getParam = function(name, default_value) {
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    19
	var value = null;
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    20
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    21
	value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    22
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    23
	// Fix bool values
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    24
	if (value == "true" || value == "false")
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    25
		return (value == "true");
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    26
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    27
	return value;
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    28
};
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    29
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    30
MCTabs.prototype.displayTab = function(tab_id, panel_id) {
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    31
	var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    32
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    33
	panelElm= document.getElementById(panel_id);
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    34
	panelContainerElm = panelElm ? panelElm.parentNode : null;
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    35
	tabElm = document.getElementById(tab_id);
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    36
	tabContainerElm = tabElm ? tabElm.parentNode : null;
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    37
	selectionClass = this.getParam('selection_class', 'current');
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    38
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    39
	if (tabElm && tabContainerElm) {
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    40
		nodes = tabContainerElm.childNodes;
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    41
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    42
		// Hide all other tabs
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    43
		for (i = 0; i < nodes.length; i++) {
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    44
			if (nodes[i].nodeName == "LI")
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    45
				nodes[i].className = '';
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    46
		}
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    47
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    48
		// Show selected tab
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    49
		tabElm.className = 'current';
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    50
	}
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    51
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    52
	if (panelElm && panelContainerElm) {
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    53
		nodes = panelContainerElm.childNodes;
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    54
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    55
		// Hide all other panels
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 395
diff changeset
    56
		for (i = 0; i < nodes.length; i++) {
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    57
			if (nodes[i].nodeName == "DIV")
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    58
				nodes[i].className = 'panel';
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    59
		}
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    60
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    61
		// Show selected panel
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    62
		panelElm.className = 'current';
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    63
	}
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    64
};
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    65
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    66
MCTabs.prototype.getAnchor = function() {
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    67
	var pos, url = document.location.href;
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    68
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    69
	if ((pos = url.lastIndexOf('#')) != -1)
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    70
		return url.substring(pos + 1);
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    71
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    72
	return "";
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    73
};
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    74
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    75
// Global instance
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
diff changeset
    76
var mcTabs = new MCTabs();