1/* 2Sweet Titles (c) Creative Commons 2005 3http://creativecommons.org/licenses/by-sa/2.5/ 4Author: Dustin Diaz | http://www.dustindiaz.com 5*/ 6var sweetTitles = { 7 xCord : 0, // @Number: x pixel value of current cursor position 8 yCord : 0, // @Number: y pixel value of current cursor position 9 tipElements : ['a','abbr','acronym'], // @Array: Allowable elements that can have the toolTip 10 obj : Object, // @Element: That of which you're hovering over 11 tip : Object, // @Element: The actual toolTip itself 12 active : 0, // @Number: 0: Not Active || 1: Active 13 init : function() { 14 if ( !document.getElementById || 15 !document.createElement || 16 !document.getElementsByTagName ) { 17 return; 18 } 19 var i,j; 20 this.tip = document.createElement('div'); 21 this.tip.id = 'toolTip'; 22 document.getElementsByTagName('body')[0].appendChild(this.tip); 23 this.tip.style.top = '0'; 24 this.tip.style.visibility = 'hidden'; 25 var tipLen = this.tipElements.length; 26 for ( i=0; i<tipLen; i++ ) { 27 var current = document.getElementsByTagName(this.tipElements[i]); 28 var curLen = current.length; 29 for ( j=0; j<curLen; j++ ) { 30 addEvent(current[j],'mouseover',this.tipOver); 31 addEvent(current[j],'mouseout',this.tipOut); 32 current[j].setAttribute('tip',current[j].title); 33 current[j].removeAttribute('title'); 34 } 35 } 36 }, 37 updateXY : function(e) { 38 if ( document.captureEvents ) { 39 sweetTitles.xCord = e.pageX; 40 sweetTitles.yCord = e.pageY; 41 } else if ( window.event.clientX ) { 42 sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft; 43 sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop; 44 } 45 }, 46 tipOut: function() { 47 if ( window.tID ) { 48 clearTimeout(tID); 49 } 50 if ( window.opacityID ) { 51 clearTimeout(opacityID); 52 } 53 sweetTitles.tip.style.visibility = 'hidden'; 54 }, 55 checkNode : function() { 56 var trueObj = this.obj; 57 if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) { 58 return trueObj; 59 } else { 60 return trueObj.parentNode; 61 } 62 }, 63 tipOver : function(e) { 64 sweetTitles.obj = this; 65 tID = window.setTimeout("sweetTitles.tipShow()",500); 66 sweetTitles.updateXY(e); 67 }, 68 tipShow : function() { 69 var scrX = Number(this.xCord); 70 var scrY = Number(this.yCord); 71 var tp = parseInt(scrY+15); 72 var lt = parseInt(scrX+10); 73 var anch = this.checkNode(); 74 var addy = ''; 75 var access = ''; 76 if ( anch.nodeName.toLowerCase() == 'a' ) { 77 addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href); 78 var access = ( anch.accessKey ? ' <span>['+anch.accessKey+']</span> ' : '' ); 79 } else { 80 addy = anch.firstChild.nodeValue; 81 } 82 this.tip.innerHTML = "<p>"+anch.getAttribute('tip')+"<em>"+access+addy+"</em></p>"; 83 if ( parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft) < parseInt(this.tip.offsetWidth+lt) ) { 84 this.tip.style.left = parseInt(lt-(this.tip.offsetWidth+10))+'px'; 85 } else { 86 this.tip.style.left = lt+'px'; 87 } 88 if ( parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop) < parseInt(this.tip.offsetHeight+tp) ) { 89 this.tip.style.top = parseInt(tp-(this.tip.offsetHeight+10))+'px'; 90 } else { 91 this.tip.style.top = tp+'px'; 92 } 93 this.tip.style.visibility = 'visible'; 94 this.tip.style.opacity = '.1'; 95 this.tipFade(10); 96 }, 97 tipFade: function(opac) { 98 var passed = parseInt(opac); 99 var newOpac = parseInt(passed+10); 100 if ( newOpac < 80 ) { 101 this.tip.style.opacity = '.'+newOpac; 102 this.tip.style.filter = "alpha(opacity:"+newOpac+")"; 103 opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",20); 104 } 105 else { 106 this.tip.style.opacity = '.80'; 107 this.tip.style.filter = "alpha(opacity:80)"; 108 } 109 } 110}; 111function pageLoader() { 112 sweetTitles.init(); 113} 114addEvent(window,'load',pageLoader);
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.