/
jquery.inputHintOverlay.yui.js
1 lines (1 loc) · 1.25 KB
/
jquery.inputHintOverlay.yui.js
1
jQuery.fn.inputHintOverlay=function(a,b,d){a=typeof(a)!="undefined"?a:0;b=typeof(b)!="undefined"?b:0;d=typeof(d)!="undefined"?d:false;var c="jqiho";return this.each(function(){var e=jQuery(this);var g=jQuery(this).find("textarea");var f=jQuery(this).find("input[type=password]");jQuery(this).find("input[type=text]").add(g).add(f).each(function(){var n=jQuery(this).attr("title");var m=jQuery(this).attr("value");var l=jQuery(this);var k;var i;if(n){k=n.replace(/[^a-zA-Z0-9]/g,"");jQuery(this).wrap("<div class='inputHintOverlay' style='position:relative' id='wrap"+k+c+"' />");var j=jQuery(this).parent();var h=jQuery(this).position();newZ=jQuery(this).css("z-index");if(newZ=="auto"){newZ="2000"}else{newZ=newZ+20}var o={position:"absolute","z-index":newZ,left:h.left+b,top:h.top+a,cursor:"text"};i=jQuery(document.createElement("label")).appendTo(j).attr("for",jQuery(this).attr("id")).attr("id",k+c).addClass("inputHintOverlay").html(n).css(o).click(function(){jQuery(this).toggle(false);l.trigger("focus")})}if(i){if(m){i.toggle(false)}jQuery(this).focus(function(){i.toggle(false)});if(d){jQuery(this).change(function(){var p=jQuery(this);i.toggle(jQuery(this).attr("value")=="")})}else{jQuery(this).blur(function(){if(jQuery(this).attr("value")==""){i.toggle(true)}})}}})})};