summaryrefslogtreecommitdiffstats
path: root/jquery/jquery.powertip-1.3.1.min.js
blob: 2e7383a5b9f51108598db3bf37cb674985a8c17c (plain)
1
2
3
4
5
6
7
8
/*!
 PowerTip v1.3.1 (2018-04-15)
 https://stevenbenner.github.io/jquery-powertip/
 Copyright (c) 2018 Steven Benner (http://stevenbenner.com/).
 Released under MIT license.
 https://raw.github.com/stevenbenner/jquery-powertip/master/LICENSE.txt
*/
!function(e,t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(h){var v=h(document),n=h(window),e=h("body"),m="displayController",T="hasActiveHover",g="forcedOpen",i="hasMouseMove",y="mouseOnToPopup",a="originalTitle",b="powertip",H="powertipjq",k="powertiptarget",P=".powertip",O=180/Math.PI,t=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave","contextmenu"],I={elements:null,tooltips:null,isTipOpen:!1,isFixedTipOpen:!1,isClosing:!1,tipOpenImminent:!1,activeHover:null,currentX:0,currentY:0,previousX:0,previousY:0,desyncTimeout:null,closeDelayTimeout:null,mouseTrackingActive:!1,delayInProgress:!1,windowWidth:0,windowHeight:0,scrollTop:0,scrollLeft:0},l={none:0,top:1,bottom:2,left:4,right:8};function x(){var o=this;o.top="auto",o.left="auto",o.right="auto",o.bottom="auto",o.set=function(e,t){h.isNumeric(t)&&(o[e]=Math.round(t))}}function c(o,n,i){var s=null,t=null;function r(e,t){a(),o.data(T)?l():e?(t&&o.data(g,!0),c(),i.showTip(o)):(I.tipOpenImminent=!0,s=setTimeout(function(){var e,t;s=null,e=Math.abs(I.previousX-I.currentX),t=Math.abs(I.previousY-I.currentY),e+t<n.intentSensitivity?(l(),c(),i.showTip(o)):(I.previousX=I.currentX,I.previousY=I.currentY,r())},n.intentPollInterval))}function a(e){s=clearTimeout(s),(I.closeDelayTimeout&&t===I.closeDelayTimeout||e)&&l()}function l(){I.closeDelayTimeout=clearTimeout(I.closeDelayTimeout),I.delayInProgress=!1}function c(){I.delayInProgress&&I.activeHover&&!I.activeHover.is(o)&&I.activeHover.data(m).hide(!0)}this.show=r,this.hide=function(e){t&&(t=I.closeDelayTimeout=clearTimeout(t),I.delayInProgress=!1),a(),I.tipOpenImminent=!1,o.data(T)&&(o.data(g,!1),e?i.hideTip(o):(I.delayInProgress=!0,I.closeDelayTimeout=setTimeout(function(){I.closeDelayTimeout=null,i.hideTip(o),I.delayInProgress=!1,t=null},n.closeDelay),t=I.closeDelayTimeout))},this.cancel=a,this.resetPosition=function(){i.resetPosition(o)}}function o(){this.compute=function(e,t,o,n,i){var s,r,a=t.split("-")[0],l=new x;switch(r=e,s=Boolean(window.SVGElement&&r[0]instanceof SVGElement)?function(e,t){var o,n,i,s,r=e.closest("svg")[0],a=e[0],l=r.createSVGPoint(),c=a.getBBox(),u=a.getScreenCTM(),p=c.width/2,f=c.height/2,w=[],d=["nw","n","ne","e","se","s","sw","w"];function h(){w.push(l.matrixTransform(u))}if(l.x=c.x,l.y=c.y,h(),l.x+=p,h(),l.x+=p,h(),l.y+=f,h(),l.y+=f,h(),l.x-=p,h(),l.x-=p,h(),l.y-=f,h(),w[0].y!==w[1].y||w[0].x!==w[7].x)for(n=Math.atan2(u.b,u.a)*O,(i=Math.ceil((n%360-22.5)/45))<1&&(i+=8);i--;)d.push(d.shift());for(s=0;s<w.length;s++)if(d[s]===t){o=w[s];break}return{top:o.y+I.scrollTop,left:o.x+I.scrollLeft}}(e,a):function(e,t){var o,n,i=e.offset(),s=e.outerWidth(),r=e.outerHeight();switch(t){case"n":o=i.left+s/2,n=i.top;break;case"e":o=i.left+s,n=i.top+r/2;break;case"s":o=i.left+s/2,n=i.top+r;break;case"w":o=i.left,n=i.top+r/2;break;case"nw":o=i.left,n=i.top;break;case"ne":o=i.left+s,n=i.top;break;case"sw":o=i.left,n=i.top+r;break;case"se":o=i.left+s,n=i.top+r}return{top:n,left:o}}(e,a),t){case"n":l.set("left",s.left-o/2),l.set("bottom",I.windowHeight-s.top+i);break;case"e":l.set("left",s.left+i),l.set("top",s.top-n/2);break;case"s":l.set("left",s.left-o/2),l.set("top",s.top+i);break;case"w":l.set("top",s.top-n/2),l.set("right",I.windowWidth-s.left+i);break;case"nw":l.set("bottom",I.windowHeight-s.top+i),l.set("right",I.windowWidth-s.left-20);break;case"nw-alt":l.set("left",s.left),l.set("bottom",I.windowHeight-s.top+i);break;case"ne":l.set("left",s.left-20),l.set("bottom",I.windowHeight-s.top+i);break;case"ne-alt":l.set("bottom",I.windowHeight-s.top+i),l.set("right",I.windowWidth-s.left);break;case"sw":l.set("top",s.top+i),l.set("right",I.windowWidth-s.left-20);break;case"sw-alt":l.set("left",s.left),l.set("top",s.top+i);break;case"se":l.set("left",s.left-20),l.set("top",s.top+i);break;case"se-alt":l.set("top",s.top+i),l.set("right",I.windowWidth-s.left)}return l}}function u(c){var r=new o,u=h("#"+c.popupId);function p(t){I.isClosing=!0,I.isTipOpen=!1,I.desyncTimeout=clearInterval(I.desyncTimeout),t.data(T,!1),t.data(g,!1),v.off("click"+P),u.off(P),u.fadeOut(c.fadeOutTime,function(){var e=new x;I.activeHover=null,I.isClosing=!1,I.isFixedTipOpen=!1,u.removeClass(),e.set("top",I.currentY+c.offset),e.set("left",I.currentX+c.offset),u.css(e),t.trigger("powerTipClose")})}function f(){var e,t,o,n;!I.isFixedTipOpen&&(I.isTipOpen||I.tipOpenImminent&&u.data(i))&&(e=u.outerWidth(),t=u.outerHeight(),(o=new x).set("top",I.currentY+c.offset),o.set("left",I.currentX+c.offset),(n=M(o,e,t))!==l.none&&(1===function(e){var t=0;for(;e;)e&=e-1,t++;return t}(n)?n===l.right?o.set("left",I.scrollLeft+I.windowWidth-e):n===l.bottom&&o.set("top",I.scrollTop+I.windowHeight-t):(o.set("left",I.currentX-e-c.offset),o.set("top",I.currentY-t-c.offset))),u.css(o))}function w(n){var e,i;c.smartPlacement||c.followMouse&&n.data(g)?(e=h.fn.powerTip.smartPlacementLists[c.placement],h.each(e,function(e,t){var o=M(s(n,t),u.outerWidth(),u.outerHeight());return i=t,o!==l.none})):(s(n,c.placement),i=c.placement),u.removeClass("w nw sw e ne se n s w se-alt sw-alt ne-alt nw-alt"),u.addClass(i)}function s(e,t){var o,n,i=0,s=new x;for(s.set("top",0),s.set("left",0),u.css(s);o=u.outerWidth(),n=u.outerHeight(),s=r.compute(e,t,o,n,c.offset),u.css(s),++i<=5&&(o!==u.outerWidth()||n!==u.outerHeight()););return s}function d(){var e=!1,t=0<h.grep(["mouseleave","mouseout","blur","focusout"],function(e){return-1!==h.inArray(e,c.closeEvents)}).length;I.isTipOpen&&!I.isClosing&&!I.delayInProgress&&t&&(!1===I.activeHover.data(T)||I.activeHover.is(":disabled")?e=!0:X(I.activeHover)||I.activeHover.is(":focus")||I.activeHover.data(g)||u.data(y)&&X(u)||(e=!0),e&&p(I.activeHover))}0===u.length&&(u=h("<div/>",{id:c.popupId}),0===e.length&&(e=h("body")),e.append(u),I.tooltips=I.tooltips?I.tooltips.add(u):u),c.followMouse&&(u.data(i)||(v.on("mousemove"+P,f),n.on("scroll"+P,f),u.data(i,!0))),this.showTip=function(o){o.data(T,!0),u.queue(function(e){!function t(o){var e;if(o.data(T)){if(I.isTipOpen)return I.isClosing||p(I.activeHover),void u.delay(100).queue(function(e){t(o),e()});var n,i,s,r,a,l;o.trigger("powerTipPreRender"),r=(n=o).data(b),a=n.data(H),l=n.data(k),r?(h.isFunction(r)&&(r=r.call(n[0])),s=r):a?(h.isFunction(a)&&(a=a.call(n[0])),0<a.length&&(s=a.clone(!0,!0))):l&&0<(i=h("#"+l)).length&&(s=i.html()),(e=s)&&(u.empty().append(e),o.trigger("powerTipRender"),I.activeHover=o,I.isTipOpen=!0,u.data(y,c.mouseOnToPopup),u.addClass(c.popupClass),!c.followMouse||o.data(g)?(w(o),I.isFixedTipOpen=!0):f(),o.data(g)||c.followMouse||v.on("click"+P,function(e){var t=e.target;t!==o[0]&&(c.mouseOnToPopup&&(t===u[0]||h.contains(u[0],t))||h.powerTip.hide())}),c.mouseOnToPopup&&!c.manual&&(u.on("mouseenter"+P,function(){I.activeHover&&I.activeHover.data(m).cancel()}),u.on("mouseleave"+P,function(){I.activeHover&&I.activeHover.data(m).hide()})),u.fadeIn(c.fadeInTime,function(){I.desyncTimeout||(I.desyncTimeout=setInterval(d,500)),o.trigger("powerTipOpen")}))}}(o),e()})},this.hideTip=p,this.resetPosition=w}function p(e){return Boolean(e&&-1<h.inArray(e.type,t)&&"number"==typeof e.pageX)}function f(){I.scrollLeft=n.scrollLeft(),I.scrollTop=n.scrollTop(),I.windowWidth=n.width(),I.windowHeight=n.height()}function w(){I.windowWidth=n.width(),I.windowHeight=n.height()}function d(){var e=n.scrollLeft(),t=n.scrollTop();e!==I.scrollLeft&&(I.currentX+=e-I.scrollLeft,I.scrollLeft=e),t!==I.scrollTop&&(I.currentY+=t-I.scrollTop,I.scrollTop=t)}function C(e){I.currentX=e.pageX,I.currentY=e.pageY}function X(e){var t=e.offset(),o=e[0].getBoundingClientRect(),n=o.right-o.left,i=o.bottom-o.top;return I.currentX>=t.left&&I.currentX<=t.left+n&&I.currentY>=t.top&&I.currentY<=t.top+i}function M(e,t,o){var n=I.scrollTop,i=I.scrollLeft,s=n+I.windowHeight,r=i+I.windowWidth,a=l.none;return(e.top<n||Math.abs(e.bottom-I.windowHeight)-o<n)&&(a|=l.top),(e.top+o>s||Math.abs(e.bottom-I.windowHeight)>s)&&(a|=l.bottom),(e.left<i||e.right+t>r)&&(a|=l.left),(e.left+t>r||e.right<i)&&(a|=l.right),a}return h.fn.powerTip=function(e,t){var s,r,o=this;return o.length?"string"===h.type(e)&&h.powerTip[e]?h.powerTip[e].call(o,o,t):(s=h.extend({},h.fn.powerTip.defaults,e),h.powerTip.destroy(o),r=new u(s),I.mouseTrackingActive||(I.mouseTrackingActive=!0,f(),h(f),v.on("mousemove"+P,C),n.on("resize"+P,w),n.on("scroll"+P,d)),o.each(function(){var e=h(this),t=e.data(b),o=e.data(H),n=e.data(k),i=e.attr("title");t||n||o||!i||(e.data(b,i),e.data(a,i),e.removeAttr("title")),e.data(m,new c(e,s,r))}),s.manual||(h.each(s.openEvents,function(e,t){-1<h.inArray(t,s.closeEvents)?o.on(t+P,function(e){h.powerTip.toggle(this,e)}):o.on(t+P,function(e){h.powerTip.show(this,e)})}),h.each(s.closeEvents,function(e,t){h.inArray(t,s.openEvents)<0&&o.on(t+P,function(e){h.powerTip.hide(this,!p(e))})}),o.on("keydown"+P,function(e){27===e.keyCode&&h.powerTip.hide(this,!0)})),I.elements=I.elements?I.elements.add(o):o,o):o},h.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:!1,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:!1,offset:10,mouseOnToPopup:!1,manual:!1,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]},h.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]},h.powerTip={show:function(e,t){return p(t)?(C(t),I.previousX=t.pageX,I.previousY=t.pageY,h(e).data(m).show()):h(e).first().data(m).show(!0,!0),e},reposition:function(e){return h(e).first().data(m).resetPosition(),e},hide:function(e,t){var o;return t=!e||t,e?o=h(e).first().data(m):I.activeHover&&(o=I.activeHover.data(m)),o&&o.hide(t),e},toggle:function(e,t){return I.activeHover&&I.activeHover.is(e)?h.powerTip.hide(e,!p(t)):h.powerTip.show(e,t),e},destroy:function(e){var t=e?h(e):I.elements;return I.elements&&0!==I.elements.length&&(I.isTipOpen&&!I.isClosing&&0<t.filter(I.activeHover).length&&(I.delayInProgress&&I.activeHover.data(m).cancel(),h.powerTip.hide(I.activeHover,!0)),t.off(P).each(function(){var e=h(this),t=[a,m,T,g];e.data(a)&&(e.attr("title",e.data(a)),t.push(b)),e.removeData(t)}),I.elements=I.elements.not(t),0===I.elements.length&&(n.off(P),v.off(P),I.mouseTrackingActive=!1,I.tooltips.remove(),I.tooltips=null)),e}},h.powerTip.showTip=h.powerTip.show,h.powerTip.closeTip=h.powerTip.hide,h.powerTip});