This repository has been archived by the owner on Jan 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.tooltip.min.js
10 lines (10 loc) · 2.27 KB
/
jquery.tooltip.min.js
1
2
3
4
5
6
7
8
9
10
// Generated by CoffeeScript 1.6.1
/*
*
* jQuery Tooltips by Gary Hepting - https://github.com/ghepting/jquery-tooltips
*
* Open source under the BSD License.
*
* Copyright © 2013 Gary Hepting. All rights reserved.
*
*/(function(){(function(e){return e.fn.tooltip=function(t){var n,r,i,s,o,u,a,f,l;r={topOffset:0,delay:100,speed:100};t=e.extend(r,t);f=e("#tooltip");i="";l="";if(e("#tooltip").length!==1){f=e('<div id="tooltip"></div>');f.appendTo("body").hide()}s=function(t){var n,r,i,s,o,u;i=t.offset();u=e(window);return{top:o=i.top-u.scrollTop(),left:r=i.left-u.scrollLeft(),bottom:n=u.height()-o-t.outerHeight(),right:s=u.width()-r-t.outerWidth()}};u=function(n){var r,i,o,u;i=s(n);f.outerWidth()>e(window).width()-20&&f.css("width",e(window).width()-20);r={};f.css("max-width",Math.min(e(window).width()-parseInt(e("body").css("padding-left"))-parseInt(e("body").css("padding-right")),parseInt(f.css("max-width"))));u=f.outerWidth();o=f.outerHeight();if(i.left<=i.right){f.addClass("left");r.left=i.left}else{f.addClass("right");r.right=i.right}if(i.top-t.topOffset>o+20){f.addClass("top");r.top=n.offset().top-o-20}else{f.addClass("bottom");r.top=n.offset().top+n.outerHeight()-4}return f.css(r)};o=function(){return f.text("").removeClass("left right top bottom").css({left:"auto",right:"auto",top:"auto",bottom:"auto",width:"auto","padding-left":"auto","padding-right":"auto"})};n=function(){f.stop().hide();o();return e("[role=tooltip]").removeClass("on")};a=function(e){clearTimeout(i);return i=setTimeout(function(){f.css({opacity:0,display:"block"}).text(e.attr("data-title"));u(e);e.addClass("on");console.log(f.css("display"));return f.animate({top:"+=10",opacity:1},t.speed)},t.delay)};this.each(function(){var t;t=e(this);t.attr("role","tooltip").attr("data-title",t.attr("title"));return t.removeAttr("title")});e("body").on("focus","[role=tooltip]",function(){return a(e(this))}).on("blur","[role=tooltip]",function(){clearTimeout(i);return n()}).on("mouseenter","[role=tooltip]:not(input,select,textarea)",function(){return a(e(this))}).on("mouseleave","[role=tooltip]:not(input,select,textarea)",function(){clearTimeout(i);return n()});return e(window).on({scroll:function(){l=e("[role=tooltip].on");if(l.length){u(l);return e("#tooltip").css({top:"+=10"})}}})}})(jQuery)}).call(this);