/* Tooltip component for jQuery ( AMD Module ) | MIT Licenses | 2013-12-14 */
define(function(){var t={content:null,duration:200,easing:"swing",effects:null,maxWidth:200,position:"top",trigger:"mouseenter",zIndex:9900,unClose:!1,space:12},p=$.browser.msie&&"6.0"===$.browser.version,q=$(window),l=!1,m={},r,f={init:function(a){var c=a.trigger,b=a.unClose,d=a.target,e;if("mouseenter"===c){if(d.on("mouseenter.tooltip",function(){var b=this;clearTimeout(e);e=setTimeout(function(){f.open(a,b)},50)}),!b)d.on("mouseleave.tooltip",function(){clearTimeout(e);e=null;f.close(a)})}else if(d.on(c+
".tooltip",function(){f.open(a,this)}),"focus"===c&&!b)d.on("blur.tooltip",function(){f.close(a)})},open:function(a,c){var b=$(c),d=a.trigger,e=c[$.expando],h,k;if(void 0!==m[e])"click"===d&&f.close(a);else{m[e]=!0;k=a.content||b.attr("data-title");if(void 0===k){k=b.attr("title");if(void 0===k)return;b.removeAttr("title").attr("data-title",k)}a.width=b.outerWidth();a.height=b.outerHeight();h=f.createTip(l);h.appendTo(a.context.body);h.data("targetIndex",e);h.find("s.tt_arrow")[0].className="tt_arrow tt_arrow_"+
a.position;h.find("div.tt_content").html(k);a.btnClose=h.find("a.tt_btn_close");a.tipElem=h;a.currentTarget=b;l=!0;f.initStyle(a,c);b.trigger("likeopen");f.patterns[a.effects].show(a);if("mouseenter"!==d&&"focus"!==d||a.unClose)q.on("resize.tooltip",function(){f.setPosition(a,!0)})}},createTip:function(){var a;return function(c){a&&a.is(":animated")&&(a.stop(!0,!0),c=!1);return a=a&&!c?a:$('<div class="eui_tooltip" style="z-index:'+r++ +'"><div class="tt_wrapper"><s class="tt_arrow"></s><a href="#" class="tt_btn_close">&times;</a><div class="tt_content"></div></div></div>')}}(),
setPosition:function(a,c){var b={},d=a.space,e=a.tipElem,h=a.wrapElem,k=a.position,f=a.width,g=a.height,n=a.currentTarget.offset(),l=n.top,n=n.left,m="top"===k,p="left"===k,q=h.outerWidth(),h=h.outerHeight();if(m||"bottom"===k)b.left=n-q/2+f/2+"px",b.top=m?l-h-d+"px":l+g+d+"px";else if(p||"right"===k)b.top=l-h/2+g/2+"px",b.left=p?n-q-d+"px":n+f+d+"px";c||(b.visibility="",b.display="none");e.css(b)},initStyle:function(a){var c=a.tipElem,b=a.trigger,d=a.btnClose,e=c.find("div.tt_wrapper");"mouseenter"!==
b&&"focus"!==b||a.unClose?(e.css("paddingRight","25px"),d.css("display","block").on("click.tooltip",function(b){f.close(a);b.preventDefault()})):(e.css("paddingRight","10px"),d.css("display","none").off("click.tooltip"));c.css({visibility:"hidden",display:"block"});e.css({width:"",display:"inline-block"});p&&(e[0].style.display="inline",e[0].style.zoom=1);c=e.width();c=Math.min(a.maxWidth,c);e.css("width",c+"px");a.wrapElem=e;f.setPosition(a)},close:function(a){var c=a.trigger,b=a.tipElem;b&&(b.is(":animated")&&
b.stop(!0,!0),b=b.data("targetIndex"),delete m[b],a.currentTarget&&(a.currentTarget.trigger("likeclose"),delete a.currentTarget),f.patterns[a.effects].hide(a),("mouseenter"!==c&&"focus"!==c||a.unClose)&&q.off("resize.tooltip"))},patterns:{normal:{show:function(a){a.tipElem.css("display","block")},hide:function(a){a.tipElem.css("display","none").remove();delete a.tipElem}},fade:{show:function(a){a.tipElem.fadeIn(a.duration,a.easing)},hide:function(a){a.tipElem.fadeOut(a.duration,a.easing,function(){a.tipElem.remove();
delete a.tipElem;l=!1})}},slide:{}}};$.each(["show","hide"],function(a,c){f.patterns.slide[c]=function(a){if(a.tipElem){var d=a.tipElem,e=d.css("top"),h=d.css("left"),k="from",f="to",g={};"hide"===c&&(k="to",f="from",g.complete=function(){d.css({display:"none",opacity:""}).remove();delete a.tipElem;l=!1});g[k]={opacity:"0"};g[f]={opacity:"1"};switch(a.position){case "top":g[k].top=parseInt(e)-30+"px";g[f].top=e;break;case "bottom":g[k].top=parseInt(e)+30+"px";g[f].top=e;break;case "left":g[k].left=
parseInt(h)-30+"px";g[f].left=h;break;case "right":g[k].left=parseInt(h)+30+"px",g[f].left=h}g.easing=a.easing;g.duration=a.duration;d.css("display","block").css(g.from).animate(g.to,g.duration,g.easing,g.complete)}}});var s=function(a,c){a=$(a);c=c||{};if(a.length){var b=$.extend({},t,c);b.effects=b.effects||"normal";p&&(b.space-=6);r=b.zIndex;b.target=a;b.context=a[0].ownerDocument;f.init(b);this.__o__=b}};s.prototype={destroy:function(){if(this.__o__){var a=this.__o__,c=a.trigger,a=a.target,c=
("mouseenter"===c?"mouseenter.tooltip mouseleave.tooltip":"focus"===c?"focus.tooltip blur.tooltip":c+".tooltip")+" likeopen likeclose";a.off(c).each(function(){var a=$(this),c=a.attr("data-title");a.attr("title",c).removeAttr("data-title")});this.__o__=a=a=null;delete this.__o__}},on:function(a,c){if(this.__o__){var b=this;b.__o__.target.on("like"+a,function(d){d.type=a;c.call(b,d);d.stopPropagation()})}return this},un:function(a){this.__o__&&this.__o__.target.off("like"+a);return this}};$.ui||($.ui=
{});$.ui.Tooltip=s});
