/*! formstone v0.5.9 [tooltip.js] 2015-04-28 | MIT License | formstone.it */

!function(a,b){"use strict";function c(a){this.on(o.mouseEnter,a,e)}function d(){j(),this.off(o.namespace)}function e(a){j();var b=a.data;b.left=a.pageX,b.top=a.pageY,h(b)}function f(a){var b=a.data;p.clearTimer(b.timer),j()}function g(a){i(a.pageX,a.pageY)}function h(c){j();var d="";d+='<div class="',d+=[n.base,n[c.direction]].join(" "),d+='">',d+='<div class="'+n.content+'">',d+=c.formatter.call(c.$el,c),d+='<span class="'+n.caret+'"></span>',d+="</div>",d+="</div>",q={$tooltip:a(d),$el:c.$el},b.$body.append(q.$tooltip);var e=q.$tooltip.find(m.content),h=q.$tooltip.find(m.caret),k=c.$el.offset(),l=c.$el.outerHeight(),r=c.$el.outerWidth(),s=0,t=0,u=0,v=0,w=!1,x=!1,y=h.outerHeight(!0),z=h.outerWidth(!0),A=e.outerHeight(!0),B=e.outerWidth(!0);"right"===c.direction||"left"===c.direction?(x=(A-y)/2,v=-A/2,"right"===c.direction?u=c.margin:"left"===c.direction&&(u=-(B+c.margin))):(w=(B-z)/2,u=-B/2,"bottom"===c.direction?v=c.margin:"top"===c.direction&&(v=-(A+c.margin))),e.css({top:v,left:u}),h.css({top:x,left:w}),c.follow?c.$el.on(o.mouseMove,c,g):(c.match?"right"===c.direction||"left"===c.direction?(t=c.top,"right"===c.direction?s=k.left+r:"left"===c.direction&&(s=k.left)):(s=c.left,"bottom"===c.direction?t=k.top+l:"top"===c.direction&&(t=k.top)):"right"===c.direction||"left"===c.direction?(t=k.top+l/2,"right"===c.direction?s=k.left+r:"left"===c.direction&&(s=k.left)):(s=k.left+r/2,"bottom"===c.direction?t=k.top+l:"top"===c.direction&&(t=k.top)),i(s,t)),c.timer=p.startTimer(c.timer,c.delay,function(){q.$tooltip.addClass(n.visible)}),c.$el.one(o.mouseLeave,c,f)}function i(a,b){q&&q.$tooltip.css({left:a,top:b})}function j(){q&&(q.$el.off([o.mouseMove,o.mouseLeave].join(" ")),q.$tooltip.remove(),q=null)}function k(){return this.data("title")}var l=b.Plugin("tooltip",{widget:!0,defaults:{delay:0,direction:"top",follow:!1,formatter:k,margin:15,match:!1},classes:["content","caret","visible","top","bottom","right","left"],methods:{_construct:c,_destruct:d}}),m=l.classes,n=m.raw,o=l.events,p=l.functions,q=null}(jQuery,Formstone);