moodle/lib/amd/build/tooltip.min.js.map
2023-03-09 09:53:19 +08:00

1 line
6.1 KiB
Plaintext

{"version":3,"file":"tooltip.min.js","sources":["../src/tooltip.js"],"sourcesContent":["define(['jquery', 'core/aria'], function($, Aria) {\n\n /**\n * Tooltip class.\n *\n * @param {String} selector The css selector for the node(s) to enhance with tooltips.\n */\n var Tooltip = function(selector) {\n // Tooltip code matches: http://www.w3.org/WAI/PF/aria-practices/#tooltip\n this._regionSelector = selector;\n\n // For each node matching the selector - find an aria-describedby attribute pointing to an role=\"tooltip\" element.\n\n $(this._regionSelector).each(function(index, element) {\n var tooltipId = $(element).attr('aria-describedby');\n if (tooltipId) {\n var tooltipele = document.getElementById(tooltipId);\n if (tooltipele) {\n var correctRole = $(tooltipele).attr('role') == 'tooltip';\n\n if (correctRole) {\n $(tooltipele).hide();\n // Ensure the trigger for the tooltip is keyboard focusable.\n $(element).attr('tabindex', '0');\n }\n\n // Attach listeners.\n $(element).on('focus', this._handleFocus.bind(this));\n $(element).on('mouseover', this._handleMouseOver.bind(this));\n $(element).on('mouseout', this._handleMouseOut.bind(this));\n $(element).on('blur', this._handleBlur.bind(this));\n $(element).on('keydown', this._handleKeyDown.bind(this));\n }\n }\n }.bind(this));\n };\n\n /** @property {String} Selector for the page region containing the user navigation. */\n Tooltip.prototype._regionSelector = null;\n\n /**\n * Find the tooltip referred to by this element and show it.\n *\n * @param {Event} e\n */\n Tooltip.prototype._showTooltip = function(e) {\n var triggerElement = $(e.target);\n var tooltipId = triggerElement.attr('aria-describedby');\n if (tooltipId) {\n var tooltipele = $(document.getElementById(tooltipId));\n\n tooltipele.show();\n Aria.unhide(tooltipele);\n\n if (!tooltipele.is('.tooltip')) {\n // Change the markup to a bootstrap tooltip.\n var inner = $('<div class=\"tooltip-inner\"></div>');\n inner.append(tooltipele.contents());\n tooltipele.append(inner);\n tooltipele.addClass('tooltip');\n tooltipele.addClass('bottom');\n tooltipele.append('<div class=\"tooltip-arrow\"></div>');\n }\n var pos = triggerElement.offset();\n pos.top += triggerElement.height() + 10;\n $(tooltipele).offset(pos);\n }\n };\n\n /**\n * Find the tooltip referred to by this element and hide it.\n *\n * @param {Event} e\n */\n Tooltip.prototype._hideTooltip = function(e) {\n var triggerElement = $(e.target);\n var tooltipId = triggerElement.attr('aria-describedby');\n if (tooltipId) {\n var tooltipele = document.getElementById(tooltipId);\n\n $(tooltipele).hide();\n Aria.hide(tooltipele);\n }\n };\n\n /**\n * Listener for focus events.\n * @param {Event} e\n */\n Tooltip.prototype._handleFocus = function(e) {\n this._showTooltip(e);\n };\n\n /**\n * Listener for keydown events.\n * @param {Event} e\n */\n Tooltip.prototype._handleKeyDown = function(e) {\n if (e.which == 27) {\n this._hideTooltip(e);\n }\n };\n\n /**\n * Listener for mouseover events.\n * @param {Event} e\n */\n Tooltip.prototype._handleMouseOver = function(e) {\n this._showTooltip(e);\n };\n\n /**\n * Listener for mouseout events.\n * @param {Event} e\n */\n Tooltip.prototype._handleMouseOut = function(e) {\n var triggerElement = $(e.target);\n\n if (!triggerElement.is(\":focus\")) {\n this._hideTooltip(e);\n }\n };\n\n /**\n * Listener for blur events.\n * @param {Event} e\n */\n Tooltip.prototype._handleBlur = function(e) {\n this._hideTooltip(e);\n };\n\n return Tooltip;\n});\n"],"names":["define","$","Aria","Tooltip","selector","_regionSelector","this","each","index","element","tooltipId","attr","tooltipele","document","getElementById","hide","on","_handleFocus","bind","_handleMouseOver","_handleMouseOut","_handleBlur","_handleKeyDown","prototype","_showTooltip","e","triggerElement","target","show","unhide","is","inner","append","contents","addClass","pos","offset","top","height","_hideTooltip","which"],"mappings":"AAAAA,sBAAO,CAAC,SAAU,cAAc,SAASC,EAAGC,UAOpCC,QAAU,SAASC,eAEdC,gBAAkBD,SAIvBH,EAAEK,KAAKD,iBAAiBE,KAAK,SAASC,MAAOC,aACrCC,UAAYT,EAAEQ,SAASE,KAAK,uBAC5BD,UAAW,KACPE,WAAaC,SAASC,eAAeJ,cACrCE,WACgD,WAA9BX,E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