var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); $k.fn.tooltip = function (config) { var obj = function (selector, config) { this.selector = selector; this.config = $.extendEx({}, this.defConfig, config); } obj.prototype.defConfig = { }; obj.prototype.tooltip = function () { var _obj = this; var title = _obj.selector.attr('title'); if (!title) { return; } var tipPanel; _obj.selector.mouseenter(function (ev) { $(this).removeAttr('title'); tipPanel = $('
' + title + '
').appendTo($('body')); //var left = $(this).offset().left; //var top = $(this).offset().top; var left = ev.pageX; var top = ev.pageY; tipPanel.css('left', left+1);//加1的原因:假如光标在悬停在输入框中间,显示提示层时由于提示层在光标的下方会导致mouseleave发生,因此提示层会移除,提示层移除又导致mouseenter发生,所以最终出现提示层一直一闪一闪的。 tipPanel.css('top', top); }).mouseleave(function () { if (tipPanel) { tipPanel.remove(); } tipPanel = undefined; $(this).attr('title', title); }); } var _obj = new obj($(this.jo), config || {}); _obj.tooltip(); return _obj; } //自动调用 $(function () { $.each($('.kui-tooltip'), function (i, o) { $k(o).tooltip(); }); }); }