{"version":3,"sources":["hotspot.js"],"names":["$","jQuery","Hotspot","_ref","element","container","_classCallCheck","this","_classPrivateFieldInitSpec","_label","writable","value","_description","_tooltip","hotspot","_classPrivateFieldSet","attr","x","parseFloat","y","init","appendTo","css","concat","generateTooltip","on","_this","showTooltip","e","checkIfFocusWithin","event","nextTarget","find","relatedTarget","length","removeTooltip","tooltip","label","html","_classPrivateFieldGet","description","append","hide","fadeIn","fadeOut","HotspotContainer","_ref2","id","hotspots","_this2","each","_i","push"],"mappings":"uwCAAA,IAAMA,EAAIC,O,iEAEJC,Q,WASL,SAAAA,EAAAC,GAAoC,IAAtBC,EAAsBD,EAAtBC,QAASC,EAAaF,EAAbE,UAAaC,gBAAAC,KAAAL,GAAAM,2BAAAD,KAAAE,OAAA,CAAAC,UAAA,EAAAC,WAAA,IAAAH,2BAAAD,KAAAK,aAAA,CAAAF,UAAA,EAAAC,WAAA,IAAAH,2BAAAD,KAAAM,SAAA,CAAAH,UAAA,EAAAC,WAAA,IACnCJ,KAAKO,QAAUd,EAAEI,GACjBG,KAAKF,UAAYA,EACjBU,sBAAAR,KAAAE,OAAcF,KAAKO,QAAQE,KAAK,uBAChCD,sBAAAR,KAAAK,aAAoBL,KAAKO,QAAQE,KAAK,6BACtCD,sBAAAR,KAAAM,SAAgB,IAChBN,KAAKU,EAAIC,WAAWX,KAAKO,QAAQE,KAAK,mBACtCT,KAAKY,EAAID,WAAWX,KAAKO,QAAQE,KAAK,mBACtCT,KAAKa,O,yCAnBP,WAAUnB,IAAAA,EAAAA,KAuBRM,KAAKO,QAAQO,SAASd,KAAKF,UAAUA,WAErCE,KAAKO,QAAQQ,IAAI,WAAjB,YACAf,KAAKO,QAAQQ,IAAI,OAAjB,GAAAC,OAA4BhB,KAAKU,EAAjC,MACAV,KAAKO,QAAQQ,IAAI,MAAjB,GAAAC,OAA2BhB,KAAKY,EAAhC,MAEAZ,KAAKiB,kBAvBPjB,KAAAO,QAAAW,GAAA,YAAA,WAKCC,EAAAC,gB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O,MAAAS,KAAA,0BAEDgC,SAAAD,GAAA,IAAAF,iBAAA,CACDE,GAAAA,EACA1C,UAAAL,EAAAO","file":"hotspot.js","sourcesContent":["const $ = jQuery;\n\nclass Hotspot {\n\t/**\n\t *\n\t * @param {{element: DOM, container: HotspotContainer}}\n\t */\n\t#label;\n\t#description;\n\t#tooltip;\n\n\tconstructor({ element, container }) {\n\t\tthis.hotspot = $(element);\n\t\tthis.container = container;\n\t\tthis.#label = this.hotspot.attr(\"data-hotspot-label\");\n\t\tthis.#description = this.hotspot.attr(\"data-hotspot-description\");\n\t\tthis.#tooltip = \"\";\n\t\tthis.x = parseFloat(this.hotspot.attr(\"data-hotspot-x\"));\n\t\tthis.y = parseFloat(this.hotspot.attr(\"data-hotspot-y\"));\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tthis.hotspot.appendTo(this.container.container);\n\n\t\tthis.hotspot.css(\"position\", `absolute`);\n\t\tthis.hotspot.css(\"left\", `${this.x}%`);\n\t\tthis.hotspot.css(\"top\", `${this.y}%`);\n\n\t\tthis.generateTooltip();\n\n\t\t/**\n\t\t * Handle the hotspot when it gets focus\n\t\t */\n\t\tthis.hotspot.on(\"mouseover\", () => {\n\t\t\tthis.showTooltip();\n\t\t});\n\n\t\t/**\n\t\t * Handle the hotspot when it loses focus\n\t\t */\n\t\tthis.hotspot.on(\"mouseleave\", (e) => {\n\t\t\t// Checks if the next target is a child of this hotspot\n\t\t\tconst checkIfFocusWithin = (event) => {\n\t\t\t\tconst nextTarget = this.hotspot.find(event.relatedTarget);\n\t\t\t\tif (nextTarget.length > 0) {\n\t\t\t\t\t$(nextTarget).on(\"blur\", checkIfFocusWithin);\n\t\t\t\t} else {\n\t\t\t\t\tthis.removeTooltip();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tcheckIfFocusWithin(e);\n\t\t});\n\n\t\tthis.hotspot.attr(\"data-hotspot-rendered\", \"\");\n\t}\n\n\t/**\n\t * Generates the tooltip box\n\t */\n\tgenerateTooltip() {\n\t\tconst tooltip = $(\"
\");\n\t\ttooltip.attr(\"data-vertical-align\", this.x > 50 ? \"left\" : \"right\");\n\t\tconst label = $('').html(\n\t\t\tthis.#label\n\t\t);\n\t\tconst description = $(\n\t\t\t'
'\n\t\t).html(this.#description);\n\n\t\ttooltip.append(label);\n\t\ttooltip.append(description);\n\t\ttooltip.hide();\n\n\t\tthis.#tooltip = tooltip;\n\t\tthis.hotspot.append(this.#tooltip);\n\t}\n\n\t/**\n\t * Makes the tooltip fadein\n\t */\n\tshowTooltip() {\n\t\tthis.#tooltip.fadeIn();\n\t}\n\n\t/**\n\t * Makes the tooltip fadeout\n\t */\n\tremoveTooltip() {\n\t\tthis.#tooltip.fadeOut();\n\t}\n}\n\nclass HotspotContainer {\n\tconstructor({ container, id }) {\n\t\tthis.container = $(container);\n\t\tthis.id = id;\n\t\tthis.hotspots = [];\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tthis.container.css(\"position\", \"relative\");\n\t\tthis.container.css(\"width\", \"100%\");\n\n\t\t/**\n\t\t * Create a hotspot for each hotspot with the hotspot id\n\t\t */\n\t\t$(`[data-hotspot-wrapper=\"${this.id}\"]`).each((_i, hotspot) => {\n\t\t\tthis.hotspots.push(\n\t\t\t\tnew Hotspot({\n\t\t\t\t\telement: hotspot,\n\t\t\t\t\tcontainer: this,\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\t}\n}\n\n/**\n * Hotspots init\n */\nconst hotspots = {};\n$(\"[data-hotspot-container]\").each(function () {\n\tconst id = $(this).attr(\"data-hotspot-container\");\n\thotspots[id] = new HotspotContainer({\n\t\tid,\n\t\tcontainer: $(this),\n\t});\n});\n"]}