Files
laps/js/laps.min.js
T
2015-01-03 21:06:11 +02:00

1 line
8.0 KiB
JavaScript

+function(t){'use strict';var e=function(t,e){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.t$=null;this.init('tooltip',t,e)};e.VERSION='3.3.1';e.TRANSITION_DURATION=150;e.DEFAULTS={animation:!0,placement:'top',selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:'hover focus',title:'',delay:0,html:!1,container:!1,viewport:{selector:'body',padding:0}};e.prototype.init=function(e,i,s){this.enabled=!0;this.type=e;this.t$=t(i);this.options=this.getOptions(s);this.o$=this.options.viewport&&t(this.options.viewport.selector||this.options.viewport);var r=this.options.trigger.split(' ');for(var n=r.length;n--;){var o=r[n];if(o=='click'){this.t$.on('click.'+this.type,this.options.selector,t.proxy(this.toggle,this))}else if(o!='manual'){var a=o=='hover'?'mouseenter':'focusin',p=o=='hover'?'mouseleave':'focusout';this.t$.on(a+'.'+this.type,this.options.selector,t.proxy(this.enter,this));this.t$.on(p+'.'+this.type,this.options.selector,t.proxy(this.leave,this))}};this.options.selector?(this.i$=t.extend({},this.options,{trigger:'manual',selector:''})):this.fixTitle()};e.prototype.getDefaults=function(){return e.DEFAULTS};e.prototype.getOptions=function(e){e=t.extend({},this.getDefaults(),this.t$.data(),e);if(e.delay&&typeof e.delay=='number'){e.delay={show:e.delay,hide:e.delay}};return e};e.prototype.getDelegateOptions=function(){var e={};var i=this.getDefaults();this.i$&&t.each(this.i$,function(t,o){if(i[t]!=o)e[t]=o});return e};e.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(i&&i.e$&&i.e$.is(':visible')){i.hoverState='in';return};if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};clearTimeout(i.timeout);i.hoverState='in';if(!i.options.delay||!i.options.delay.show)return i.show();i.timeout=setTimeout(function(){if(i.hoverState=='in')i.show()},i.options.delay.show)};e.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)};clearTimeout(i.timeout);i.hoverState='out';if(!i.options.delay||!i.options.delay.hide)return i.hide();i.timeout=setTimeout(function(){if(i.hoverState=='out')i.hide()},i.options.delay.hide)};e.prototype.show=function(){var u=t.Event('show.bs.'+this.type);if(this.hasContent()&&this.enabled){this.t$.trigger(u);var d=t.contains(this.t$[0].ownerDocument.documentElement,this.t$[0]);if(u.isDefaultPrevented()||!d)return;var s=this,o=this.tip(),c=this.getUID(this.type);this.setContent();o.attr('id',c);this.t$.attr('aria-describedby',c);if(this.options.animation)o.addClass('fade');var i=typeof this.options.placement=='function'?this.options.placement.call(this,o[0],this.t$[0]):this.options.placement,f=/\s?auto?\s?/i,l=f.test(i);if(l)i=i.replace(f,'')||'top';o.detach().css({top:0,left:0,display:'block'}).addClass(i).data('bs.'+this.type,this);this.options.container?o.appendTo(this.options.container):o.insertAfter(this.t$);var n=this.getPosition(),a=o[0].offsetWidth,p=o[0].offsetHeight;if(l){var g=i,y=this.options.container?t(this.options.container):this.t$.parent(),r=this.getPosition(y);i=i=='bottom'&&n.bottom+p>r.bottom?'top':i=='top'&&n.top-p<r.top?'bottom':i=='right'&&n.right+a>r.width?'left':i=='left'&&n.left-a<r.left?'right':i;o.removeClass(g).addClass(i)};var v=this.getCalculatedOffset(i,n,a,p);this.applyPlacement(v,i);var h=function(){var t=s.hoverState;s.t$.trigger('shown.bs.'+s.type);s.hoverState=null;if(t=='out')s.leave(s)};t.support.transition&&this.e$.hasClass('fade')?o.one('bsTransitionEnd',h).emulateTransitionEnd(e.TRANSITION_DURATION):h()}};e.prototype.applyPlacement=function(e,o){var i=this.tip(),u=i[0].offsetWidth,h=i[0].offsetHeight,r=parseInt(i.css('margin-top'),10),p=parseInt(i.css('margin-left'),10);if(isNaN(r))r=0;if(isNaN(p))p=0;e.top=e.top+r;e.left=e.left+p;t.offset.setOffset(i[0],t.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0);i.addClass('in');var l=i[0].offsetWidth,n=i[0].offsetHeight;if(o=='top'&&n!=h){e.top=e.top+h-n};var s=this.getViewportAdjustedDelta(o,e,l,n);if(s.left)e.left+=s.left;else e.top+=s.top;var a=/top|bottom/.test(o),f=a?s.left*2-u+l:s.top*2-h+n,c=a?'offsetWidth':'offsetHeight';i.offset(e);this.replaceArrow(f,i[0][c],a)};e.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?'left':'top',50*(1-t/e)+'%').css(i?'top':'left','')};e.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find('.tooltip-inner')[this.options.html?'html':'text'](e);t.removeClass('fade in top bottom left right')};e.prototype.hide=function(i){var s=this,o=this.tip(),r=t.Event('hide.bs.'+this.type);function n(){if(s.hoverState!='in')o.detach();s.t$.removeAttr('aria-describedby').trigger('hidden.bs.'+s.type);i&&i()};this.t$.trigger(r);if(r.isDefaultPrevented())return;o.removeClass('in');t.support.transition&&this.e$.hasClass('fade')?o.one('bsTransitionEnd',n).emulateTransitionEnd(e.TRANSITION_DURATION):n();this.hoverState=null;return this};e.prototype.fixTitle=function(){var t=this.t$;if(t.attr('title')||typeof(t.attr('data-original-title'))!='string'){t.attr('data-original-title',t.attr('title')||'').attr('title','')}};e.prototype.hasContent=function(){return this.getTitle()};e.prototype.getPosition=function(e){e=e||this.t$;var s=e[0],o=s.tagName=='BODY',i=s.getBoundingClientRect();if(i.width==null){i=t.extend({},i,{width:i.right-i.left,height:i.bottom-i.top})};var n=o?{top:0,left:0}:e.offset();var a={scroll:o?document.documentElement.scrollTop||document.body.scrollTop:e.scrollTop()};var r=o?{width:t(window).width(),height:t(window).height()}:null;return t.extend({},i,a,r,n)};e.prototype.getCalculatedOffset=function(e,t,i,o){return e=='bottom'?{top:t.top+t.height,left:t.left+t.width/2-i/2}:e=='top'?{top:t.top-o,left:t.left+t.width/2-i/2}:e=='left'?{top:t.top+t.height/2-o/2,left:t.left-i}:{top:t.top+t.height/2-o/2,left:t.left+t.width}};e.prototype.getViewportAdjustedDelta=function(t,i,n,p){var o={top:0,left:0};if(!this.o$)return o;var s=this.options.viewport&&this.options.viewport.padding||0,e=this.getPosition(this.o$);if(/right|left/.test(t)){var l=i.top-s-e.scroll,r=i.top+s-e.scroll+p;if(l<e.top){o.top=e.top-l}else if(r>e.top+e.height){o.top=e.top+e.height-r}}else{var h=i.left-s,a=i.left+s+n;if(h<e.left){o.left=e.left-h}else if(a>e.width){o.left=e.left+e.width-a}};return o};e.prototype.getTitle=function(){var i,e=this.t$,t=this.options;i=e.attr('data-original-title')||(typeof t.title=='function'?t.title.call(e[0]):t.title);return i};e.prototype.getUID=function(t){do t+=~~(Math.random()*1000000);while(document.getElementById(t))return t};e.prototype.tip=function(){return(this.e$=this.e$||t(this.options.template))};e.prototype.arrow=function(){return(this.s$=this.s$||this.tip().find('.tooltip-arrow'))};e.prototype.enable=function(){this.enabled=!0};e.prototype.disable=function(){this.enabled=!1};e.prototype.toggleEnabled=function(){this.enabled=!this.enabled};e.prototype.toggle=function(e){var i=this;if(e){i=t(e.currentTarget).data('bs.'+this.type);if(!i){i=new this.constructor(e.currentTarget,this.getDelegateOptions());t(e.currentTarget).data('bs.'+this.type,i)}};i.tip().hasClass('in')?i.leave(i):i.enter(i)};e.prototype.destroy=function(){var t=this;clearTimeout(this.timeout);this.hide(function(){t.t$.off('.'+t.type).removeData('bs.'+t.type)})};function i(i){return this.each(function(){var r=t(this),o=r.data('bs.tooltip'),s=typeof i=='object'&&i,n=s&&s.selector;if(!o&&i=='destroy')return;if(n){if(!o)r.data('bs.tooltip',(o={}));if(!o[n])o[n]=new e(this,s)}else{if(!o)r.data('bs.tooltip',(o=new e(this,s)))};if(typeof i=='string')o[i]()})};var o=t.fn.tooltip;t.fn.tooltip=i;t.fn.tooltip.Constructor=e;t.fn.tooltip.noConflict=function(){t.fn.tooltip=o;return this}}(jQuery);jQuery.fn.lapstooltip=jQuery.fn.tooltip.noConflict();jQuery(document).ready(function(){jQuery('.laps-timeline .event').lapstooltip({container:'#wpadminbar',placement:'bottom',html:!0,animation:!1})});