function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,e){for(var i=0;i0&&$.ajax({url:XIVDBTooltips.getOption("source")+"/tooltip?t="+Date.now(),method:"POST",dataType:"json",cache:!0,data:{list:i,language:this.getOption("language")},success:function(t){return t?"object"!=typeof t?void console.error("Tooltips response was not an object"):void(e&&e(t)):void console.error("Tooltips returned no response")},error:function(t,e,i){console.error("----------------"),console.error("Error loading tooltips!"),console.error(t.responseText),console.error(e,i),console.error("----------------")}})}},{key:"getDelayed",value:function(){clearTimeout(this.tooltipsTimer),this.tooltipsTimer=setTimeout(function(){XIVDBTooltips.get()},this.tooltipsDelay)}},{key:"hide",value:function(){XIVDBTooltipsDOM.hide()}},{key:"cachetime",value:function(){var t=new Date;return""+t.getFullYear()+t.getDate()}},{key:"setOptions",value:function(t){return this.options=t,window.location.href.indexOf(this.xivdb)>-1&&(this.options.includeCredits=!1),this}},{key:"getOption",value:function(t){return this.options[t]}},{key:"validateTooltipOptions",value:function(){for(var t in xivdb_tooltips_default)"undefined"==typeof this.options[t]&&(this.options[t]=xivdb_tooltips_default[t])}}]),t}(),XIVDBTooltipsDependencyClass=function(){function t(){_classCallCheck(this,t),this.jquery="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"}return _createClass(t,[{key:"pass",value:function(t){var e=this;return"undefined"!=typeof jQuery?t():void setTimeout(function(){"undefined"==typeof jQuery&&e.loadScript(e.jquery,function(){if(!e)var e=jQuery;return t()})},XIVDBTooltips.getOption("jqueryCheckDelay"))}},{key:"loadScript",value:function(t,e){var i=document.createElement("script");i.type="text/javascript",i.readyState?i.onreadystatechange=function(){("loaded"===i.readyState||"complete"===i.readyState)&&(i.onreadystatechange=null,e())}:i.onload=function(){e()},i.src=t,document.getElementsByTagName("head")[0].appendChild(i)}}]),t}(),XIVDBTooltipsDOMClass=function(){function t(){_classCallCheck(this,t),this.isActive=!1}return _createClass(t,[{key:"prepare",value:function(){var t=this,e=XIVDBTooltips.getOption("source"),i=XIVDBTooltips.cachetime();$("head").append(''),XIVDBTooltips.onMobile||($("body").append(''),$("html").on("mouseenter","[data-xivdb-key]",function(e){t.isActive=!0;var i=$(e.currentTarget),o=i.attr("data-xivdb-key"),n=XIVDBTooltipsHolder.get(o);$(".ui-draggable-dragging").length>0||($(".xivdb").html(n),t.show(e))}).on("mouseleave","*[data-xivdb-key]",function(e){t.isActive=!1;$(e.target);t.hide()}),$("html").on("mousemove",function(e){t.isActive&&t.follow(e)}),XIVDBTooltips.getOption("preventHtmlHeight")||$("html").css({height:"100%"}))}},{key:"inject",value:function(t){var e=this;for(var i in t){var o=function(o){var n=t[i][o];if(!n)return console.log("false tooltip"),"continue";var a=n.data,s=n.html,l="xivdb_"+i+"_"+a.id,r=$('[data-xivdb-key="'+l+'"]');XIVDBTooltipsHolder.add(l,s),r.each(function(t,i){var o=$(i);if(o.attr("data-xivdb-isset",1),e.checkLinkSettings(o,["replace"])){if(e.checkLinkSettings(o,["seturlname","replacename"])&&o.text(a.name),e.checkLinkSettings(o,["seturlcolor","colorname"])){var n=XIVDBTooltips.getOption("seturlcolorDarken")?"rarity-"+a.color+"-darken":"rarity-"+a.color;o.addClass(n)}if(e.checkLinkSettings(o,["seturlicon","showicon"])){var n="xivdb-ii",s=parseInt($("a[data-xivdb-key]").css("font-size"),10)+4;-1==a.icon.indexOf("finalfantasyxiv.com")&&-1==a.icon.indexOf("secure.xivdb")&&(a.icon="https://secure.xivdb.com"+a.icon),o.prepend('')}}})};for(var n in t[i]){o(n)}}}},{key:"checkLinkSettings",value:function(t,e){for(var i in e){var o=e[i],n="data-xivdb-"+o;if(XIVDBTooltips.getOption(o)===!1)return!1;if(t.attr("data-xivdb-replace"))return!1;if("undefined"!=typeof t.attr(n)&&("0"==t.attr(n)||"false"==t.attr(n).toLowerCase()))return!1}return!0}},{key:"hide",value:function(){$(".xivdb").hide().html("")}},{key:"show",value:function(t){this.follow(t),$(".xivdb").show()}},{key:"follow",value:function(t){var e=t.pageX+XIVDBTooltips.getOption("tooltipDistanceX"),i=t.pageY+XIVDBTooltips.getOption("tooltipDistanceY"),o=$(".xivdb").outerWidth(!0),n=$(".xivdb").outerHeight(!0),a=i+n,s=e+o,l=$(window).height()+$(window).scrollTop(),r=$(window).scrollLeft()+$(window).width();s>r&&(e=t.pageX-(o+XIVDBTooltips.getOption("tooltipDistanceX"))),a>l&&(i=t.pageY-(n+XIVDBTooltips.getOption("tooltipDistanceY"))),this.position(e,i)}},{key:"position",value:function(t,e){$(".xivdb").css({top:e+"px",left:t+"px"})}}]),t}(),XIVDBTooltipsHolderClass=function(){function t(){_classCallCheck(this,t),this.tooltips={}}return _createClass(t,[{key:"add",value:function(t,e){this.tooltips[t]=e}},{key:"get",value:function(t){return this.tooltips[t]}},{key:"exists",value:function(t){return this.tooltips[t]?!0:!1}}]),t}(),XIVDBTooltipsLinksClass=function(){function t(){_classCallCheck(this,t),this.links=null}return _createClass(t,[{key:"detect",value:function(){XIVDBTooltips.getOption("linkContainer");$("a, *[data-tooltip-id]").each(function(t,e){var i=$(e),o=i.attr("href"),n=i.attr("data-tooltip-id"),a=!1,s=!1;if((n||!(i.attr("data-xivdb-ignore")||"undefined"==typeof o||o.length<1))&&!i.attr("data-xivdb-tooltip")&&(XIVDBTooltips.getOption("includeHiddenLinks")||i.is(":visible"))){if(n)n=n.split("/"),a=n[0],s=n[1];else{if(o=o.toString().toLowerCase().replace("http://","").replace("https://","").replace("//","/").replace("?","").toString(),"/"!=o[0]&&-1==o.indexOf("xivdb.com"))return;if(o=o.replace("fr.","").replace("de.","").replace("ja.","").replace("cns.",""),o=o.replace("xivdb.com",""),o=o.split("/").filter(function(t){return t.toString().length>0}),-1==xivdb_tooltips_valid_types.indexOf(o[0]))return;if(a=o[0],s=o[1],"undefined"==typeof o||o.length<2)return}var l="xivdb_"+a+"_"+s;return i.attr("data-xivdb-parent")&&!i.attr("data-xivdb-key")?i.parents(i.attr("data-xivdb-parent")).attr("data-xivdb-key",l):i.attr("data-xivdb-parent")?void 0:i.attr("data-xivdb-key",l)}}),this.links=$("[data-xivdb-key]")}}]),t}(),xivdb_tooltips_default={source:"https://secure.xivdb.com",language:"en",replace:!0,seturlname:!0,seturlcolor:!0,seturlcolorDarken:!0,seturlicon:!0,includeHiddenLinks:!1,jqueryCheckDelay:500,mobileMinimumWidth:500,preventHtmlHeight:!1,tooltipDistanceX:20,tooltipDistanceY:20,event_tooltipsLoaded:null},xivdb_tooltips_valid_types=["item","achievement","action","gathering","instance","leve","enemy","emote","placename","status","title","recipe","quest","shop","npc","minion","mount","weather","fate"],XIVDBTooltips=new XIVDBTooltipsClass,XIVDBTooltipsDOM=new XIVDBTooltipsDOMClass,XIVDBTooltipsLinks=new XIVDBTooltipsLinksClass,XIVDBTooltipsHolder=new XIVDBTooltipsHolderClass,XIVDBTooltipsDependency=new XIVDBTooltipsDependencyClass;document.addEventListener("DOMContentLoaded",function(t){XIVDBTooltips.setOptions("undefined"!=typeof xivdb_tooltips?xivdb_tooltips:xivdb_tooltips_default).init()});