File: jsfunc.menu.js

package info (click to toggle)
typo3-src 4.0.2%2Bdebian-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 29,856 kB
  • ctags: 33,382
  • sloc: php: 134,523; xml: 6,976; sql: 1,084; sh: 168; makefile: 45
file content (133 lines) | stat: -rw-r--r-- 4,229 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************
*
*  JavaScript menu
*
* $Id: jsfunc.menu.js 1421 2006-04-10 09:27:15Z mundaun $
*
*
*
*  Copyright notice
*
*  (c) 1998-2003 Kasper Skaarhoj
*  All rights reserved
*
*  This script is part of the TYPO3 t3lib/ library provided by
*  Kasper Skaarhoj <kasper@typo3.com> together with TYPO3
*
*  Released under GNU/GPL (see license file in tslib/)
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*  This copyright notice MUST APPEAR in all copies of this script
***************************************************************/


function JSmenuItem (owner, id, nextItem, parent, openID, title, url, target) {
	this.owner = owner;
	this.id = id;
	this.nextItem = nextItem;
	this.child = 0;
	this.openID = openID;
	this.parent = parent;
	this.title = title;
	this.url = url;
	this.target = target;
}
function JSmenu (levels,formname) {
	this.name = name,
	this.levels = levels;
	this.formname = formname;

	this.openID = 0;

	this.entry = new JSmenuItem (this);
	this.count = 0;
	this.defTopTitle = new Array();
	this.add = JSmenuAddItem;			// Tilfjer Item
	this.writeOut = JSmenuWrite;
	this.act = JSactivate;
}
function JSmenuAddItem (parent,prevItem,openID,title,url,target) {
	this.count++;
	var entryID = this.count;
	this.entry[entryID] = new JSmenuItem (this, entryID, 0, parent, openID, title, url, target);
	if (prevItem) {
		this.entry[prevItem].nextItem = entryID;
	} else if(parent) {
		this.entry[parent].child = entryID;
	}
	return entryID;
}
function JSmenuWrite(theEntryID,openID,theLevel) {
	var level=theLevel;
	if (level<=this.levels)	{
		var entryID = theEntryID;
		var firstEntryID = theEntryID;
		var selectorBox = document[this.formname]["selector"+level];
		var index=0;
		selectorBox.length=0;
		selectorBox.length++;
		selectorBox.options[index].text = this.defTopTitle[theLevel] ? this.defTopTitle[theLevel] : "                   ";
		selectorBox.options[index].value = 0;
		index++;
		var indexSet=0;
		if (entryID && this.entry[entryID])	{
			var ids = "";
			while(entryID)	{
			ids+="-"+entryID;
				selectorBox.length++;
				selectorBox.options[index].text = this.entry[entryID].title;
				selectorBox.options[index].value = entryID;
				if (openID==entryID)	{
					var indexSet = 1;
					selectorBox.selectedIndex = index;
					if (level<this.levels)	{
						this.writeOut(this.entry[entryID].child, this.entry[entryID].openID,level+1);
					}
				}
				index++;
				entryID=this.entry[entryID].nextItem;
			}
			if (!indexSet) {
				selectorBox.selectedIndex=0;
				this.writeOut(this.entry[firstEntryID].child, this.entry[firstEntryID].openID,level+1);
			}
		} else if (level<this.levels)	{
			this.writeOut(0, 0,level+1);
		}
	}
}
function JSactivate(level) {
	var selectorBox = document[this.formname]["selector"+level];
	var entryID = selectorBox.options[selectorBox.selectedIndex].value;
	if (this.entry[entryID])	{
		this.writeOut(this.entry[entryID].child,this.entry[entryID].openID,level+1);
		if (this.entry[this.entry[entryID].parent])	{
			this.entry[this.entry[entryID].parent].openID = entryID;
		}
		if (this.entry[entryID].url)	{
			if (document.getElementsByTagName("base").size && document.getElementsByTagName("base")[0].href != "") {
				if (this.entry[entryID].url.substr(0,7) != "http://")	{
					this.entry[entryID].url = document.getElementsByTagName("base")[0].href + this.entry[entryID].url;
				}
			}
			if (!this.entry[entryID].target || this.entry[entryID].target=="_self")	{
				window.location.href = this.entry[entryID].url;
			} else if (this.entry[entryID].target=="_top") {
				top.location.href = this.entry[entryID].url;
			} else {
				var test = eval ("parent."+this.entry[entryID].target);
				if (!test) {
					test = eval ("top."+this.entry[entryID].target);
				}
				if (test && test.document) {
					test.location.href = this.entry[entryID].url;
				} else {
					window.open(this.entry[entryID].url,this.entry[entryID].target,"status=yes,menubar=yes,resizable=yes,location=yes,directories=yes,scrollbars=yes,toolbar=yes");
				}
			}
		}
	}
}