forked from indyone/TipTip
-
Notifications
You must be signed in to change notification settings - Fork 3
/
jquery.tipTip.minified.js
17 lines (17 loc) · 4.88 KB
/
jquery.tipTip.minified.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
* TipTip
* Copyright 2010 Drew Wilson
* www.drewwilson.com
* code.drewwilson.com/entry/tiptip-jquery-plugin
*
* Modified by: indyone (https://github.com/indyone/TipTip)
* Modified by: Jonathan Lim-Breitbart (https://github.com/breity/TipTip) - Updated: Oct. 10, 2012
* Modified by: Alan Hussey/EnergySavvy (https://github.com/EnergySavvy/TipTip) - Updated: Mar. 18, 2013
*
* Version 1.3 - Updated: Mar. 23, 2010
*
* This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function(a){function e(a){return d.test(a)}a.fn.tipTip=function(b){var c={activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:0,defaultPosition:"bottom",delay:400,delayHover:500,delayHide:0,hideOnClick:!1,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},afterEnter:function(){},exit:function(){},afterExit:function(){},cssClass:"",detectTextDir:!0};if(0>=a("#tiptip_holder").length){var d=a("<div>",{id:"tiptip_arrow_inner"}),f=a("<div>",{id:"tiptip_arrow"}).append(d),g=a("<div>",{id:"tiptip_content"}),h=a("<div>",{id:"tiptip_holder"}).append(f).append(g);a("body").append(h)}else var h=a("#tiptip_holder"),g=a("#tiptip_content"),f=a("#tiptip_arrow");var i=!1;return this.each(function(){function o(){a("html").off("click.tipTip").on("click.tipTip",function(b){"block"!=h.css("display")||a(b.target).closest("#tiptip_holder").length||(a("html").off("click.tipTip"),q(0))})}function p(){if(k.enter.call(d,l)!==!1){var b;k.content?b=a.isFunction(k.content)?k.content.call(d,l):k.content:(b=k.content=d.attr(k.attribute),d.removeAttr(k.attribute)),b&&(g.html(b),h.hide().removeAttr("class").css({"max-width":k.maxWidth}),k.cssClass&&h.addClass(k.cssClass),r(),m&&clearTimeout(m),i&&clearTimeout(i),m=setTimeout(function(){h.stop(!0,!0).fadeIn(k.fadeIn)},k.delay),a(window).bind("resize.tipTip scroll.tipTip",r),d.addClass("tiptip_visible"),k.afterEnter.call(d,l))}}function q(b){function c(){h.fadeOut(k.fadeOut,function(){a(this).css({left:"",top:"",height:"",width:""})})}if(k.exit.call(d,l)!==!1){m&&clearTimeout(m);var b=void 0!==b?b:k.delayHide;0==b?(c(),k.delayHide>0&&clearTimeout(i)):(h.one("mouseenter.tipTip",function(){clearTimeout(i),h.on("mouseleave.tipTip",function(){q()})}),i=setTimeout(function(){c()},b)),setTimeout(function(){a(window).unbind("resize.tipTip scroll.tipTip"),d.removeClass("tiptip_visible"),k.afterExit.call(d,l)},b)}}function r(){function C(){q=r.top,m=c-p-k.edgeOffset-v/2,n=i+(j-o)/2}function D(){q=r.bottom,m=c+l+k.edgeOffset,n=i+(j-o)/2}function E(){q=r.left,m=c+(l-p)/2,n=i-o-k.edgeOffset-u/2}function F(){q=r.right,m=c+(l-p)/2,n=i+j+k.edgeOffset}var m,n,q,s,t,b=d.offset(),c=b.top,i=b.left,j=d.outerWidth(),l=d.outerHeight(),o=h.outerWidth(),p=h.outerHeight(),r={top:"tip_top",bottom:"tip_bottom",left:"tip_left",right:"tip_right"},u=12,v=12,w=a(window),x=w.scrollTop(),y=w.scrollLeft(),z=w.width(),A=w.height(),B=k.detectTextDir&&e(g.text());"bottom"==k.defaultPosition?D():"top"==k.defaultPosition?C():"left"!=k.defaultPosition||B?"left"==k.defaultPosition&&B?F():"right"!=k.defaultPosition||B?"right"==k.defaultPosition&&B?E():D():F():E(),q==r.left&&!B&&y>n?F():q==r.left&&B&&y>n-o?F():q==r.right&&!B&&n>y+z?E():q==r.right&&B&&n+o>y+z?E():q==r.top&&x>m?D():q==r.bottom&&m>x+A&&C(),(q==r.left||q==r.right)&&(m+p>A+x?m=c+l>A+x?c+l-p:A+x-p-4:x>m&&(m=x>c?c:x+4)),(q==r.top||q==r.bottom)&&(n+o>z+y?n=i+j>z+y?i+j-o:z+y-o-4:y>n&&(n=y>i?i:y+4)),h.css({left:Math.round(n),top:Math.round(m)}).removeClass(r.top).removeClass(r.bottom).removeClass(r.left).removeClass(r.right).addClass(q),q==r.top?(s=p,t=i-n+(j-u)/2):q==r.bottom?(s=0,t=i-n+(j-u)/2):q==r.left?(s=c-m+(l-v)/2,t=o):q==r.right&&(s=c-m+(l-v)/2,t=0),f.css({left:Math.round(t),top:Math.round(s)})}var d=a(this),j=d.data("tipTip"),k=j&&j.options||a.extend({},c,b),l={holder:h,content:g,arrow:f,options:k};if(k.content||a.isFunction(k.content)||(k.content=d.attr(k.attribute),d.removeAttr(k.attribute)),j)switch(b){case"show":p();break;case"hide":q();break;case"destroy":d.unbind(".tipTip").removeData("tipTip");break;case"position":r()}else{var m=!1,n=!1;d.data("tipTip",{options:k}),"hover"==k.activation?d.bind("mouseenter.tipTip",function(){k.delayHover?n=setTimeout(function(){p()},k.delayHover):p()}).bind("mouseleave.tipTip",function(){n&&clearTimeout(n),k.keepAlive?h.one("mouseleave.tipTip",function(){q()}):q(),k.hideOnClick&&o()}):"focus"==k.activation?d.bind("focus.tipTip",function(){p()}).bind("blur.tipTip",function(){q()}):"click"==k.activation?d.bind("click.tipTip",function(a){return a.preventDefault(),p(),!1}).bind("mouseleave.tipTip",function(){k.keepAlive?h.one("mouseleave.tipTip",function(){q()}):q(),o()}):"manual"==k.activation}})};var b="A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff",c="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",d=RegExp("^[^"+b+"]*["+c+"]")})(jQuery);