{"version":3,"file":"ToolTip.js","names":["defineDs","m","controller","options","trigger","text","show","toolTip","document","querySelector","toolTipRect","getBoundingClientRect","toolTipTrigger","toolTipTriggerRect","toolTipTriggerCenter","x","width","placeAbove","tooltipPosition","style","top","height","bottom","xLeft","xRight","left","screen","right","tooltipArrowPosition","arrow","view","class"],"sources":["DanskeSpil/Domain/Poker/Script/ToolTip.js"],"sourcesContent":["defineDs('DanskeSpil/Domain/Poker/Script/ToolTip',\r\n [\r\n 'Shared/Framework/Mithril/Scripts/Core/Mithril'\r\n ], function (m) {\r\n\r\n return {\r\n controller: function (options) {\r\n this.trigger = options.trigger;\r\n this.text = options.text;\r\n this.show = options.show;\r\n this.toolTip = document.querySelector('.tooltip');\r\n this.toolTipRect = this.toolTip ? this.toolTip.getBoundingClientRect() : null;\r\n this.toolTipTrigger = document.querySelector(options.trigger);\r\n this.toolTipTriggerRect = this.toolTipTrigger.getBoundingClientRect();\r\n this.toolTipTriggerCenter = this.toolTipTriggerRect.x + (this.toolTipTriggerRect.width / 2);\r\n this.placeAbove = false;\r\n\r\n this.tooltipPosition = function () {\r\n var style = {};\r\n\r\n if (!this.toolTip || this.toolTipRect.width <= 0) return style;\r\n\r\n // Y-position\r\n this.placeAbove = this.toolTipTriggerRect.top - this.toolTipRect.height - 10 > 0;\r\n\r\n if (this.placeAbove) {\r\n style.top = (this.toolTipTriggerRect.top - this.toolTipRect.height - 10) + 'px';\r\n } else {\r\n style.top = (this.toolTipTriggerRect.bottom + 10) + 'px';\r\n }\r\n\r\n // X-position\r\n var xLeft = this.toolTipTriggerCenter - (this.toolTipRect.width / 2);\r\n var xRight = this.toolTipTriggerCenter + (this.toolTipRect.width / 2);\r\n\r\n if (xLeft < 20) style.left = 20 + 'px';\r\n else if (xRight > screen.width - 20) style.right = 20 + 'px';\r\n else style.left = this.toolTipTriggerCenter - (this.toolTipRect.width / 2) + 'px';\r\n\r\n return style;\r\n };\r\n\r\n this.tooltipArrowPosition = function () {\r\n var style = {};\r\n var arrow = document.querySelector('.tooltip__arrow');\r\n\r\n if (arrow && arrow.getBoundingClientRect().width > 0 && this.toolTipRect) {\r\n style.left = (this.toolTipTriggerCenter - 20 - (arrow.getBoundingClientRect().width / 3) - (this.toolTipRect.x - 20)) + 'px';\r\n\r\n if (!this.placeAbove) {\r\n style.top = -5 + 'px';\r\n }\r\n }\r\n\r\n return style;\r\n };\r\n },\r\n\r\n view: function (controller) {\r\n controller.toolTip = document.querySelector('.tooltip');\r\n controller.toolTipRect = controller.toolTip ? controller.toolTip.getBoundingClientRect() : null;\r\n controller.toolTipTrigger = document.querySelector(controller.trigger);\r\n controller.toolTipTriggerRect = controller.toolTipTrigger.getBoundingClientRect();\r\n controller.toolTipTriggerCenter = controller.toolTipTriggerRect.x + (controller.toolTipTriggerRect.width / 2);\r\n\r\n return m('.tooltip', {\r\n class: controller.show() ? 'tooltip--show' : '',\r\n style: controller.tooltipPosition()\r\n }, [\r\n m('.tooltip__content', controller.text),\r\n m('.tooltip__arrow', {\r\n style: controller.tooltipArrowPosition()\r\n })\r\n ]);\r\n }\r\n };\r\n });\r\n\r\n"],"mappings":"AAAAA,QAAQ,CAAC,wCAAwC,EAC/C,CACE,+CAA+C,CAChD,EAAE,UAAUC,CAAC,EAAE;EAEd,OAAO;IACLC,UAAU,EAAE,SAAAA,CAAUC,OAAO,EAAE;MAC7B,IAAI,CAACC,OAAO,GAAGD,OAAO,CAACC,OAAO;MAC9B,IAAI,CAACC,IAAI,GAAGF,OAAO,CAACE,IAAI;MACxB,IAAI,CAACC,IAAI,GAAGH,OAAO,CAACG,IAAI;MACxB,IAAI,CAACC,OAAO,GAAGC,QAAQ,CAACC,aAAa,CAAC,UAAU,CAAC;MACjD,IAAI,CAACC,WAAW,GAAG,IAAI,CAACH,OAAO,GAAG,IAAI,CAACA,OAAO,CAACI,qBAAqB,CAAC,CAAC,GAAG,IAAI;MAC7E,IAAI,CAACC,cAAc,GAAGJ,QAAQ,CAACC,aAAa,CAACN,OAAO,CAACC,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