File "tooltip.min.js"

Full path: /home/kosmetik/public_html/wp-content/plugins/powerpack-elements/assets/js/min/tooltip.min.js
File size: 6.53 B
MIME-type: text/plain
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

!function(f,u,i){"use strict";var s=function(t,o){this.element=f(t),this.tooltip=!1,this.tooltipBody=!1,this.callout=!1,this._firstShow=!0,this._hover=!1,this._currentPosition=!1,this.options=f.extend({template:'<div class="tooltip"><div class="pp-tooltip-body"><div class="pp-tooltip-content"></div><div class="pp-tooltip-callout"></div></div></div>',inline:this.element.data("tooltipInline")||!1,position:this.element.data("tooltipPosition")||"tt-top",hideDelay:this.element.data("tooltipHideDelay")||50,showDelay:this.element.data("tooltipShowDelay")||0,animDuration:100,animationIn:"",animationOut:"",content:this.element.data("tooltip")||"",contentElement:this.element.data("tooltipContentElement")||!1,offset:this.element.data("tooltipOffset")||7,extraClass:this.element.data("tooltipClass")||!1,toggleable:this.element.data("tooltipToggleable")||!1,alwaysOpen:this.element.data("alwaysOpen")||!1,width:this.element.data("tooltipWidth")||i,height:this.element.data("tooltipHeight")||i,zindex:this.element.data("zindex")||99},o),this.init()};s.prototype.create=function(){var t,o,i,e=this;e.tooltip&&e.destroy(),i=e.options.contentElement?e.element.find(e.options.contentElement):(t=e.element.data("tooltip")||!1,o=e.element.find(".pp-tooltip-content"),!t&&o.length?o.children():t||"No tooltip content provided"),e.tooltip=f(e.options.template),e.tooltipBody=e.tooltip.find(".pp-tooltip-content"),e.content(i,!1),e.options.inline?e.tooltip.insertAfter(e.element):e.tooltip.appendTo(document.body);var n=function(t){for(var o,i=["transition","WebkitTransition","msTransition","MozTransition","OTransition"];o=i.shift();)if("undefined"!=typeof t.style[o])return o;return!1}(e.tooltip[0])||"transform";e.tooltip.transform={prop:e.tooltip.css(n+"Property"),duration:1e3*parseFloat(e.tooltip.css(n+"Duration"),10),timing:e.tooltip.css(n+"TimingFunction")},e.options.extraClass&&e.tooltip.addClass(this.options.extraClass),e.options.width&&e.tooltip.css("width",this.options.width),e.options.height&&e.tooltip.css("height",this.options.height),e.callout=e.tooltip.find(".pp-tooltip-callout")},s.prototype.destroy=function(){this.tooltip&&this.tooltip.remove(),this.element&&this.element.removeData("tooltipInstance");var t=f.tooltips.indexOf(this);t&&f.tooltips.slice(t,1)},s.prototype.init=function(){var o=this;!0===o.options.alwaysOpen?o.show():o.options.toggleable?o.element.on("click",function(){o.tooltip||o.create(),o._visible?o.hide():(o.position(),o.show())}):o.element.on({mouseenter:function(t){o._showTimer||(o._showTimer=setTimeout(function(){o._showTimer=null,o.show()},o.options.showDelay))},mouseleave:function(t){o._showTimer&&(clearTimeout(o._showTimer),o._showTimer=null),o.hide(!0)}})},s.prototype.content=function(t,o){if(o=o||!0,!this.tooltipBody.length)throw new Error("Tooltip element is missing body");this.tooltipBody.html(t),o&&this.position()},s.prototype.position=function(t){var o,i;t=t||this.options.position;var e=this.options.inline?this.element.position():this.element.offset(),n=this.tooltip.outerHeight(),s=this.tooltip.outerWidth(),l=this.element.outerHeight(),a=this.element.outerWidth(),p=f(u).height(),h=f(u).width(),r=p+f(u).scrollTop(),d=h+f(u).scrollLeft(),c=this.options.offset;switch(t){case"tt-top":o=e.top-n-c,i=e.left+a/2-s/2;break;case"tt-bottom":o=e.top+l+c,i=e.left+a/2-s/2;break;case"tt-left":o=e.top+l/2-n/2,i=e.left-s-c;break;case"tt-right":o=e.top+l/2-n/2,i=e.left+a+c}var m=d-(e.left+a+c)>s;if(i<d-h&&m){if("tt-left"===t&&s<d)return this.position("tt-right");i=d-h}if(d<i+s&&(i=d-s),m=r-(e.top+l+c)>n,o<r-p&&m){if("tt-top"===t&&n/2<r)return this.position("tt-bottom");o=r-p}return r<o+n&&n<r&&(o=r-n),this.tooltip.css({top:o,left:i,"z-index":this.options.zindex}).removeClass("tt-top tt-bottom tt-right tt-left").addClass(t),this._currentPosition=t,this.positionCallout(),{top:o,left:i,"z-index":this.options.zindex}},s.prototype.positionCallout=function(){if(this.callout.length){var t,o;this.tooltip.show();var i=this.options.inline?this.element.position():this.element.offset(),e=this.options.inline?this.tooltip.position():this.tooltip.offset();switch(this._visible||this.tooltip.hide(),this._currentPosition){case"tt-top":t=this.tooltip.outerHeight(),o=i.left-e.left+this.element.outerWidth()/2;break;case"tt-bottom":t=0,o=i.left-e.left+this.element.outerWidth()/2;break;case"tt-left":t=i.top-e.top+this.element.outerHeight()/2,o=this.tooltip.outerWidth();break;case"tt-right":t=i.top-e.top+this.element.outerHeight()/2,o=0}this.callout.css({top:t,left:o,"z-index":this.options.zindex})}},s.prototype.show=function(){var t=this;if(t._visible)return t;t.tooltip||t.create(),t._firstShow?t.tooltip.find("[data-src]").each(function(){var t=f(this);this.src=t.data("src"),t.removeData("src")}):t._firstShow=!1,t.position(),f.each(f.tooltips,function(){this.options.toggleable||this.hide()}),t.tooltip.show(),""!==t.options.animationIn&&t.tooltip.addClass(t.options.animationIn+" animated").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){f(this).removeClass(t.options.animationIn+" animated")}),setTimeout(function(){t.tooltip.css("opacity",1)},0),setTimeout(function(){t._visible=!0},t.tooltip.transform.duration)},s.prototype.hide=function(t){var o=this;t?setTimeout(function(){o._visible&&!o._hover&&o.hide()},o.options.hideDelay):o._visible&&setTimeout(function(){""!==o.options.animationOut?o.tooltip.addClass(o.options.animationOut+" animated").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){f(this).removeClass(o.options.animationOut+" animated"),f(this).css("opacity",0),f(this).hide(),o._visible=!1}):(""!==o.options.animationIn&&o.tooltip.removeClass(o.options.animationIn+" animated"),o.tooltip.css("opacity",0),o.tooltip.hide(),o._visible=!1)},o.tooltip.transform.duration)};var t=!(f.tooltips=[]);f(u).on("resize",function(){t=t||setTimeout(function(){f.each(f.tooltips,function(){this._visible&&this.position()}),t=!1},100)}),f.fn._tooltip=function(i){var e,n=!1;return"string"==typeof i&&(e=[].slice.call(arguments,0)),this.each(function(){var t=f(this),o=t.data("tooltipInstance");if(o&&i)if("object"==typeof i)n=f.extend(o.options,i);else if("options"===i)n=o.options;else{if("function"!=typeof o[i])throw new Error("Tooltip has no option/method named "+void 0);n=o[i].apply(o,e.slice(1))}else o=new s(t,i||{}),t.data("tooltipInstance",o),f.tooltips.push(o)}),n||this},f(document).on("pageshow pageleave",function(t){f("[data-tooltip]").tooltip("pageleave"===t.type?"destroy":i)}),f(document).on("mouseenter","[data-tooltip]",function(){var t=f(this);t.data("tooltipInstance")||t.tooltip().tooltip("show")})}(jQuery,window);