| 5 | import Framework7Class from '../../shared/class.js'; |
| 6 | |
| 7 | class Tooltip extends Framework7Class { |
| 8 | constructor(app, params = {}) { |
| 9 | super(params, [app]); |
| 10 | |
| 11 | const tooltip = this; |
| 12 | const support = getSupport(); |
| 13 | |
| 14 | const defaults = extend({}, app.params.tooltip); |
| 15 | |
| 16 | const document = getDocument(); |
| 17 | |
| 18 | // Extend defaults with modules params |
| 19 | tooltip.useModulesParams(defaults); |
| 20 | |
| 21 | tooltip.params = extend(defaults, params); |
| 22 | if ( |
| 23 | typeof params.offset === 'undefined' && |
| 24 | support.touch && |
| 25 | tooltip.params.trigger === 'hover' |
| 26 | ) { |
| 27 | tooltip.params.offset = 10; |
| 28 | } |
| 29 | |
| 30 | const { targetEl, containerEl } = tooltip.params; |
| 31 | if (!targetEl && !tooltip.params.delegated) return tooltip; |
| 32 | |
| 33 | const $targetEl = $(targetEl); |
| 34 | if ($targetEl.length === 0 && !tooltip.params.delegated) return tooltip; |
| 35 | |
| 36 | if ($targetEl[0] && $targetEl[0].f7Tooltip && !tooltip.params.delegated) |
| 37 | return $targetEl[0].f7Tooltip; |
| 38 | |
| 39 | let $containerEl = $(containerEl || app.$el).eq(0); |
| 40 | if ($containerEl.length === 0) { |
| 41 | $containerEl = app.$el; |
| 42 | } |
| 43 | |
| 44 | const $el = $(tooltip.render()).eq(0); |
| 45 | |
| 46 | extend(tooltip, { |
| 47 | app, |
| 48 | $targetEl, |
| 49 | targetEl: $targetEl && $targetEl[0], |
| 50 | $containerEl, |
| 51 | containerEl: $containerEl && $containerEl[0], |
| 52 | $el, |
| 53 | el: $el && $el[0], |
| 54 | text: tooltip.params.text || '', |
| 55 | visible: false, |
| 56 | opened: false, |
| 57 | }); |
| 58 | |
| 59 | if ($targetEl[0]) $targetEl[0].f7Tooltip = tooltip; |
| 60 | |
| 61 | const touchesStart = {}; |
| 62 | let isTouched; |
| 63 | function handleClick() { |
| 64 | if (tooltip.opened) tooltip.hide(); |
nothing calls this directly
no outgoing calls
no test coverage detected