Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaks to tooltip code, mostly to simplify and remove artifacts

  • Loading branch information...
commit 87c6c32c313b1f116f2f2f62b41777d4b0bf85a4 1 parent db591d5
@cdsmith authored
Showing with 54 additions and 36 deletions.
  1. +11 −8 web/tooltip.css
  2. +43 −28 web/tooltip.js
View
19 web/tooltip.css
@@ -1,10 +1,13 @@
-* {margin:0; padding:0}
-body {font:11px/1.5 Verdana, Arial, Helvetica, sans-serif; background:#FFF}
-#text {margin:50px auto; width:500px}
-.hotspot {color:#900; padding-bottom:1px; border-bottom:1px dotted #900; cursor:pointer}
+.tt {
+ position : absolute;
+ display : block
+ }
-#tt {position:absolute; display:block}
-#tttop {display:block; height:5px; margin-left:5px; overflow:hidden}
-#ttcont {display:block; padding:2px 12px 3px 7px; margin-left:5px; background:#666; color:#FFF}
-#ttbot {display:block; height:5px; margin-left:5px; overflow:hidden}
+.ttcont {
+ display : block;
+ padding : 2px 12px 3px 7px;
+ margin-left: 5px;
+ background : #666;
+ color : #FFF
+ }
View
71 web/tooltip.js
@@ -1,30 +1,25 @@
/*
* Tooltip function by Michael Leigeber, modified by Chris Smith
*/
-var tooltip=function(){
- var id = 'tt';
+var tooltip = function() {
var top = 3;
- var left = 3;
+ var left = 0;
var speed = 10;
var timer = 20;
- var endalpha = 95;
+ var endalpha = 90;
var alpha = 0;
- var tt,t,c,b,h;
- var ie = document.all ? true : false;
- return{
- show:function(){
- if(tt == null){
+ var tt = null;
+ var c, h;
+
+ return {
+ show: function() {
+ if(tt == null)
+ {
tt = document.createElement('div');
- tt.setAttribute('id',id);
- t = document.createElement('div');
- t.setAttribute('id',id + 'top');
+ tt.className = 'tt';
c = document.createElement('div');
- c.setAttribute('id',id + 'cont');
- b = document.createElement('div');
- b.setAttribute('id',id + 'bot');
- tt.appendChild(t);
+ c.className = 'ttcont';
tt.appendChild(c);
- tt.appendChild(b);
document.body.appendChild(tt);
tt.style.opacity = 0;
tt.style.filter = 'alpha(opacity=0)';
@@ -32,37 +27,57 @@ var tooltip=function(){
}
tt.style.display = 'block';
c.innerHTML = '()';
- tt.style.width = '80px';
+ tt.style.width = '90px';
tt.style.whiteSpace = 'nowrap';
h = parseInt(tt.offsetHeight) + top;
clearInterval(tt.timer);
- tt.timer = setInterval(function(){tooltip.fade(1)},timer);
+ tt.timer = setInterval(function() { tooltip.fade(1) }, timer);
},
- pos:function(e){
- var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
- var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
+
+ pos: function(e) {
+ var u,l;
+
+ if (e.pageX)
+ {
+ var u = e.pageY;
+ var l = e.pageX;
+ }
+ else
+ {
+ var u = event.clientY + document.documentElement.scrollTop;
+ var l = event.clientX + document.documentElement.scrollLeft;
+ }
+
tt.style.top = (u - h) + 'px';
tt.style.left = (l + left) + 'px';
c.innerHTML = "(" + (l - 264) + "," + (252 - u) + ")";
},
- fade:function(d){
+
+ fade: function(d) {
var a = alpha;
- if((a != endalpha && d == 1) || (a != 0 && d == -1)){
+ if((a != endalpha && d == 1) || (a != 0 && d == -1))
+ {
var i = speed;
- if(endalpha - a < speed && d == 1){
+ if(endalpha - a < speed && d == 1)
+ {
i = endalpha - a;
- }else if(alpha < speed && d == -1){
+ }
+ else if(alpha < speed && d == -1)
+ {
i = a;
}
alpha = a + (i * d);
tt.style.opacity = alpha * .01;
tt.style.filter = 'alpha(opacity=' + alpha + ')';
- }else{
+ }
+ else
+ {
clearInterval(tt.timer);
if(d == -1){tt.style.display = 'none'}
}
},
- hide:function(){
+
+ hide: function() {
clearInterval(tt.timer);
tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
}
Please sign in to comment.
Something went wrong with that request. Please try again.