summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/fancytooltips/examples/tex4ht/overlib_crossframe.js
blob: d58e5a8377f474c8b3449fe4aef04dfb5f27034d (plain)
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
//\/////
//\  overLIB Crossframe Support Plugin
//\  This file requires overLIB 4.10 or later.
//\
//\  overLIB 4.05 - You may not remove or change this notice.
//\  Copyright Erik Bosrup 1998-2004. All rights reserved.
//\  Contributors are listed on the homepage.
//\  See http://www.bosrup.com/web/overlib/ for details.
//   $Revision: 1.8 $                $Date: 2004/11/25 21:27:19 $
//\/////
//\mini

////////
// PRE-INIT
// Ignore these lines, configuration is below.
////////
if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Cross Frame Support Plugin.');
else {
registerCommands('frame');


////////
//  PLUGIN FUNCTIONS
///////

// Parses FRAME command
function parseFrameExtras(pf,i,ar) {
	var k = i,v;

	if (k < ar.length) {
		if (ar[k] == FRAME) { v = ar[++k]; if(pf == 'ol_') ol_frame = v; else opt_FRAME(v); return k; }
	}

	return -1;
}

////////
// SUPPORT FUNCTIONS
////////

// Defines which frame we should point to.
function opt_FRAME(frm) {
 	o3_frame = frm; 	
	over = createDivContainer('overDiv');	
	return 0;
}

// Get frame depth of nested frames
function frmDepth(thisFrame,ofrm) {
	var retVal = '';

	for (var i = 0; i<thisFrame.length; i++) {
		if (thisFrame[i].length > 0) { 
			retVal = frmDepth(thisFrame[i],ofrm);
			if (retVal ==  '') continue;
		} else if (thisFrame[i] != ofrm) continue;
		retVal = '[' + i + ']' + retVal;
		break;
	}

	return retVal;
}

// Gets frame reference value relative to top frame
function getFrmRef(srcFrm,tgetFrm) {
	var rtnVal = ''

	if (tgetFrm != srcFrm) {
		var tFrm = frmDepth(top.frames,tgetFrm)
		var sFrm = frmDepth(top.frames,srcFrm)
		if (sFrm.length ==  tFrm.length) {
			l = tFrm.lastIndexOf('[')
			
			if (l) {
				while ( sFrm.substring(0,l) != tFrm.substring(0,l) )
				l = tFrm.lastIndexOf('[',l-1)
				tFrm = tFrm.substr(l)
				sFrm = sFrm.substr(l)
			}
		}
	
		var cnt = 0, p = '',str = tFrm
		while ((k = str.lastIndexOf('[')) != -1) {
			cnt++ 
			str = str.substring(0,k)
		}

		for (var i = 0; i<cnt; i++) p = p + 'parent.'
		rtnVal = p + 'frames' + sFrm + '.'
	}
 
	return rtnVal
}

function chkForFrmRef() {
	if(o3_frame != ol_frame) fnRef = getFrmRef(ol_frame,o3_frame)
	return true;
}

////////
// PLUGIN REGISTRATIONS
////////
registerCmdLineFunction(parseFrameExtras);
registerPostParseFunction(chkForFrmRef);
}