Monday, December 1, 2008

[jQuery] Re: button is null

This is the code:

toolTip: function ($this){
if(!$this.is("input:text, input:file, select, textarea"))
return false;
$this.bind("mouseenter",
function(e){
e = e || window.event;
if($("#"+$.fn.validator.init.toolTipId).length>0)//
Removes tooltips if there is any
$("#"+$.fn.validator.init.toolTipId).remove();
classes = $this.attr("class");
isReq = $.fn.validator.init.regExpReq.test
(classes);
validationClass = classes.match
($.fn.validator.init.regExpClass);
fieldValid = new RegExp("\\b"+
$.fn.validator.init.validClass+"\\b");
if(!isReq && validationClass == null ||
fieldValid.test(classes)) return false; //abort tooltip if there is no
class associated.
msg = isReq ? "<b style=\"color:#F10\">"+
$.fn.validator.init.reqMsg+"</b><br />" : "";
if(validationClass!=null){
a = $.fn.validator.init.classValidation
[validationClass][1].split(",");
msg1 = "<ul>";
for(x = 0; x<a.length;x++)
msg1 +="<li>"+a[x]+"</li>";
msg1 += "</ul>";
msg +="<b>Examples of accepted:</b><br /
>"+msg1;
}
tool = "<div id=\""+$.fn.validator.init.toolTipId
+"\" class=\"validatorToolTip\">"+msg+"</div>";
$(tool).css({
width:"170px",height:"auto",
/*padding:".3em",*/
backgroundColor:"#fffcd1",
opacity:"0.8",color : "#444",
position: "absolute",zIndex : "100",
display:"none",border:"1px solid #444"
}).appendTo("body");
inX = e.pageX || e.clientX -
document.body.scrollLeft;
inY = e.pageY || e.clientY -
document.body.scrollTop;
toolY = inY > $(window).height() ? parseInt(inY-10
- $("#"+$.fn.validator.init.toolTipId).height()) : inY - 10;
toolX = parseInt($("#"+
$.fn.validator.init.toolTipId).width()+ inX + 10) > $(window).width
() ? parseInt(inX-$("#"+$.fn.validator.init.toolTipId).width()-10) :
parseInt(inX+10);
$("#"+$.fn.validator.init.toolTipId).css({top :
toolY,left: toolX}).fadeIn(150).addClass
($.fn.validator.init.options.customClass);
return true;
}).bind("mousemove",
function(e){
e = e || window.event;
inX = e.pageX || e.clientX -
document.body.scrollLeft;
inY = e.pageY || e.clientY -
document.body.scrollTop;
toolY = inY > $(window).height() ? parseInt(inY -
10 -$("#"+$.fn.validator.init.toolTipId).height()) : inY - 10;
toolX = parseInt($("#"+
$.fn.validator.init.toolTipId).width()+ inX + 10) > $(window).width
() ? parseInt(inX-$("#"+$.fn.validator.init.toolTipId).width()-10) :
parseInt(inX+10);
$("#"+$.fn.validator.init.toolTipId).css({top :
toolY,left: toolX});
}
).bind("mouseleave",
function(){
$("#"+$.fn.validator.init.toolTipId).fadeOut
(100,function(){$(this).remove();});
}
);
return true;
},

And in the jQuery-1.2.6 (line 2405) script:

var withinElement = function(event, elem) {
// Check if mouse(over|out) are still within the same parent
element
var parent = event.relatedTarget;
// Traverse up the tree
while ( parent && parent != elem ) try { parent =
parent.parentNode; } catch(error) { parent = elem; }
// Return true if we actually just moused on to a sub-element
return parent == elem;
};

What could it be?

Thanks.

No comments: