PageSourceSearch

https://forodinastias.es/styles/4poziomSEO_red/template/portal/src/tooltips.js

js forodinastias.es collected 2026-10-03 02:45:14 UTC 6,083 bytes, 209 lines download raw bytes

1// -----------------------------------------------
2// Tooltip control (c) H.M. Pragt  2006
3// Show the title attribute in a tooltip popup div
4// Internet explorer and mozilla compatible
5// Just insert this script into the page and all 
6// titles on img and a tags will show a tooltip.
7// Adjust the layout of the toolkit with the css file.
8// -----------------------------------------------
9
10
11// ------------------------------------
12// Find the absolute position in the window
13// ------------------------------------
14
15function findPosX(obj) {
16var curleft = 0;
17
18	if (obj.offsetParent)	{
19		while (obj.offsetParent) {
20			curleft += obj.offsetLeft
21			obj = obj.offsetParent;
22		}
23	}
24	else if (obj.x)
25		curleft += obj.x;
26	return curleft;
27}
28
29function findPosY(obj) {
30var curtop = 0;
31
32	if (obj.offsetParent)	{
33		while (obj.offsetParent) {
34			curtop += obj.offsetTop
35			obj = obj.offsetParent;
36		}
37	}
38	else if (obj.y)
39		curtop += obj.y;
40	return curtop;
41}
42
43
44// ------------------------------------
45// Define a eventcache object
46// ------------------------------------
47
48function EventCacheObj() {
49 this.listEvents = [];
50
51  // ------------------------------------
52  // Define an add methode to the eventcache object
53  // ------------------------------------
54  this.add = function(node, sEventName, fHandler){
55	  this.listEvents.push(arguments);
56  }
57
58  // ------------------------------------
59  // Define a flush methode to the eventcache object
60  // ------------------------------------
61
62  this.flush = function () {
63  var i, item;
64
65	  for (i = this.listEvents.length - 1; i >= 0; i--) {
66		  item = this.listEvents[i];
67		  if (item[0].removeEventListener){
68	 	    item[0].removeEventListener(item[1], item[2], item[3]);
69		  }
70		  if (item[1].substring(0, 2) != "on") {
71			  item[1] = "on" + item[1];
72		  }
73		  if (item[0].detachEvent) {
74			  item[0].detachEvent(item[1], item[2]);
75		  }
76  	  item[0][item[1]] = null;
77	  }
78  }
79}
80
81
82	
83
84// ------------------------------------
85// Add any event to any object.
86// ------------------------------------
87
88function addEvent( obj, type, fn ) {
89	if (obj.addEventListener) {		 // Mozilla
90		obj.addEventListener( type, fn, false );
91		EventCache.add(obj, type, fn);
92	}
93	else if (obj.attachEvent) { // IE
94		obj["e"+type+fn] = fn;
95		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
96		obj.attachEvent( "on"+type, obj[type+fn] );
97		EventCache.add(obj, type, fn);
98	}
99	else {
100		obj["on"+type] = obj["e"+type+fn];
101	}
102}
103
104// ------------------------------------
105// The tooltip object.
106// ------------------------------------
107
108function ToolTipObj() { 
109	this.tipElements = ['a','img','acronym'];	// Array of allowable elements for toolTips
110	this.obj = Object;							// Current element that youre hovering over
111	this.tip = Object;							// The actual toolTip DIV itself
112 
113  this.init = function () {
114  	if (!document.getElementById || !document.createElement || !document.getElementsByTagName ) {
115	  	return;
116	  }
117	  var i,j;
118	  this.tip = document.createElement('div');
119	  this.tip.id = 'toolTip';
120	  document.getElementsByTagName('body')[0].appendChild(this.tip);
121	  this.tip.style.top = '0';
122	  this.tip.style.visibility = 'hidden';
123	  var tipLen = this.tipElements.length;
124	  for ( i=0; i<tipLen; i++ ) {
125		  var current = document.getElementsByTagName(this.tipElements[i]);
126		  var curLen = current.length;
127		  for ( j=0; j<curLen; j++ ) {
128		  	addEvent(current[j],'mouseover',this.tipOver);
129			  addEvent(current[j],'mouseout',this.tipOut);
130			  current[j].setAttribute('tip',current[j].title);
131			  if (current[j].getAttribute('alt') != null) {
132				  if (current[j].getAttribute('alt').length != 0 && current[j].title.length == 0) {
133			      current[j].setAttribute('tip',current[j].getAttribute('alt'));
134			      }
135			  current[j].removeAttribute('alt');
136			  }
137			  current[j].removeAttribute('title');
138		  }
139	  }
140  }
141
142  this. tipOut = function () {
143  	ToolTip.tip.style.visibility = 'hidden';
144  }
145
146  this.tipOver = function (e) {
147  	ToolTip.obj = this;
148	  ToolTip.ShowTip();
149  }
150	
151	
152  this.ShowTip = function () {
153	  var Ttop,Tleft,ClientWidth,ClientHeight,ScrollTop;
154    var TipWidth,TipHeight;
155
156	  if (this.obj.getAttribute('tip').length == 0) {
157	    return;
158	  }	
159	  Tleft = findPosX(this.obj);  // offsetLeft;
160	  Ttop = findPosY(this.obj);  //offsetTop;
161    TipWidth = this.tip.offsetWidth;
162    TipHeight = this.tip.offsetHeight;
163	  if (self.innerHeight) { // all except Explorer
164  	  ClientWidth = self.innerWidth;
165	    ClientHeight = self.innerHeight;
166		  ScrollTop = self.scrollTop;
167    }
168    else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
169  	  ClientWidth = document.documentElement.clientWidth;
170	    ClientHeight = document.documentElement.clientHeight;
171		  ScrollTop = document.documentElement.scrollTop;
172    }
173    else if (document.body) { // other Explorers
174  	  ClientWidth = document.body.clientWidth;
175	    ClientHeight = document.body.clientHeight;
176		  ScrollTop = document.body.scrollTop;
177    }
178	  this.tip.innerHTML = '<div>'+this.obj.getAttribute('tip')+'</div>'; 
179    Ttop = Ttop - (TipHeight + 5);	
180    if ((Tleft + TipWidth) > ClientWidth) Tleft = ClientWidth - TipWidth;
181    if (Tleft < 1) Tleft = 1;
182	  if (Ttop < 1) Ttop = 1;
183    if (Ttop < ScrollTop) Ttop = ScrollTop + (TipHeight + 5);
184	  this.tip.style.left = Tleft+'px';
185	  this.tip.style.top = Ttop+'px';
186	  this.tip.style.visibility = 'visible';
187  }
188}
189
190
191// ------------------------------------
192// Create wrapper functions
193// ------------------------------------
194
195function pageLoader() {
196	ToolTip.init();
197}
198function pageFlusher() {
199	EventCache.flush();
200}
201
202// ------------------------------------
203// Create the objects
204// ------------------------------------
205var EventCache = new EventCacheObj();
206var ToolTip = new ToolTipObj();
207
208addEvent(window,'load',pageLoader);
209addEvent(window,'unload',pageFlusher);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.