|
|
@ -24,33 +24,38 @@ class Toaster { |
|
|
|
} |
|
|
|
} |
|
|
|
render (tooltipText, action, opts) { |
|
|
|
render (tooltipText, action, opts) { |
|
|
|
opts = defaultOptions(opts) |
|
|
|
opts = defaultOptions(opts) |
|
|
|
|
|
|
|
let canShorten = true |
|
|
|
if (typeof tooltipText === 'object') { |
|
|
|
if (tooltipText instanceof Element) |
|
|
|
if (tooltipText.message) { |
|
|
|
{ |
|
|
|
tooltipText = tooltipText.message |
|
|
|
canShorten = false |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
try { |
|
|
|
if (typeof tooltipText === 'object') { |
|
|
|
tooltipText = JSON.stringify(tooltipText) |
|
|
|
if (tooltipText.message) { |
|
|
|
} catch (e) { |
|
|
|
tooltipText = tooltipText.message |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
tooltipText = JSON.stringify(tooltipText) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
const shortTooltipText = tooltipText.length > 201 ? tooltipText.substring(0, 200) + '...' : tooltipText |
|
|
|
const shortTooltipText = (canShorten && tooltipText.length > 201) ? tooltipText.substring(0, 200) + '...' : tooltipText |
|
|
|
|
|
|
|
|
|
|
|
let button = tooltipText.length > 201 ? yo` |
|
|
|
let button = tooltipText.length > 201 ? yo` |
|
|
|
<button class="btn btn-secondary btn-sm" onclick=${() => { modal.alert(tooltipText) }}>show full message</button> |
|
|
|
<button class="btn btn-secondary btn-sm" onclick=${() => { modal.alert(tooltipText) }}>show full message</button> |
|
|
|
` : `` |
|
|
|
` : `` |
|
|
|
|
|
|
|
|
|
|
|
this.tooltip = yo` |
|
|
|
this.tooltip = yo` |
|
|
|
<div class="${css.tooltip} alert alert-info" onmouseenter=${() => { over() }} onmouseleave=${() => { out() }}> |
|
|
|
<div class="${css.tooltip} alert alert-info" onmouseenter=${() => { over() }} onmouseleave=${() => { out() }}> |
|
|
|
<span> |
|
|
|
<span> |
|
|
|
${shortTooltipText} |
|
|
|
${shortTooltipText} |
|
|
|
${button} |
|
|
|
${button} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
${action} |
|
|
|
${action} |
|
|
|
</div>` |
|
|
|
</div>` |
|
|
|
let timeOut = () => { |
|
|
|
let timeOut = () => { |
|
|
|
return setTimeout(() => { |
|
|
|
return setTimeout(() => { |
|
|
|
if (this.id) { |
|
|
|
if (this.id) { |
|
|
|