/** * Calls custom functions after shown */ function finish() { self.Status = 'shown'; // trigger any show method custom callbacks and reset them for (var i = 0; i < self.callbacks.show.length; i++) { self.callbacks.show[i].call(self.element); } self.callbacks.show = []; } // if this origin already has its tooltip open if (self.Status !== 'hidden') { // the timer (if any) will start (or restart) right now var extraTime = 0; // if it was disappearing, cancel that if (self.Status === 'disappearing') { self.Status = 'appearing'; if (supportsTransitions()) { t_removeClass(self.tooltip, 'tooltipster-dying'); t_addClass(self.tooltip, 'tooltipster-' + self.options.animation + '-show'); self.tooltip.addEventListener('animationend', function () { finish(); }); } else { // in case the tooltip was currently fading out, bring it back to life t_fadeIn(self.tooltip, self.options.speed, finish); } } else if (self.Status === 'shown') { // if the tooltip is already open, we still need to trigger the method custom callback finish(); } } else { // if the tooltip isn't already open, open that sucker up! self.Status = 'appearing'; // the timer (if any) will start when the tooltip has fully appeared after its transition var extraTime = self.options.speed; // disable horizontal scrollbar to keep overflowing tooltips from jacking with it and then restore it to its previous value self.bodyOverflowX = getComputedStyle(body, null).overflowX; body.style.overflowX = 'hidden'; // get some other settings related to building the tooltip var animation = 'tooltipster-' + self.options.animation; // prettier-ignore var animationSpeed = '-webkit-transition-duration: ' + self.options.speed + 'ms;' + '-webkit-animation-duration: ' + self.options.speed + 'ms;' + '-moz-transition-duration: ' + self.options.speed + 'ms;' + '-moz-animation-duration: ' + self.options.speed + 'ms;' + '-o-transition-duration: ' + self.options.speed + 'ms;' + '-o-animation-duration: ' + self.options.speed + 'ms;' + '-ms-transition-duration: ' + self.options.speed + 'ms;' + '-ms-animation-duration: ' + self.options.speed + 'ms;' + 'transition-duration: ' + self.options.speed + 'ms;' + 'animation-duration: ' + self.options.speed + 'ms;'; var minWidth = self.options.minWidth ? 'min-width:' + Math.round(self.options.minWidth) + 'px;' : ''; var maxWidth = self.options.maxWidth ? 'max-width:' + Math.round(self.options.maxWidth) + 'px;' : ''; var pointerEvents = self.options.interactive ? 'pointer-events: auto;' : ''; // build the base of our tooltip var div = document.createElement('div'); div.role = 'tooltip'; t_addClass(div, 'tooltipster-base ' + self.options.theme); div.style = minWidth + ' ' + maxWidth + ' ' + pointerEvents + ' ' + animationSpeed; div.innerHTML = '<div class="tooltipster-content"></div>'; self.tooltip = div; // only add the animation class if the user has a browser that supports animations if (supportsTransitions()) t_addClass(self.tooltip, animation); // insert the content self._content_insert();