From ed01b037ab6040554a6857ede3cdbf267f0851c1 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Mon, 27 May 2019 20:03:34 +0200 Subject: [PATCH] makes tooltip work with DOM element as an inpput --- src/app/files/fileManager.js | 8 +++++++- src/app/ui/tooltip.js | 37 ++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 41da3187bb..2a9ad8e177 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -149,7 +149,13 @@ class FileManager extends FileSystemApi { }}>Save As Copy ` } - await toaster(yo`
${this.currentRequest.from} is modyfing ${path}
`, actions, { time: 4000 }) + await toaster(yo` +
+ + + ${this.currentRequest.from} is modyfing ${path} + +
`, actions, { time: 4000 }) if (reject) throw new Error(`set file operation on ${path} aborted by user.`) if (savedAsAnotherFile) return } diff --git a/src/app/ui/tooltip.js b/src/app/ui/tooltip.js index caa28b4b03..bf66c16e6a 100644 --- a/src/app/ui/tooltip.js +++ b/src/app/ui/tooltip.js @@ -24,33 +24,38 @@ class Toaster { } render (tooltipText, action, opts) { opts = defaultOptions(opts) - - if (typeof tooltipText === 'object') { - if (tooltipText.message) { - tooltipText = tooltipText.message - } else { - try { - tooltipText = JSON.stringify(tooltipText) - } catch (e) { + let canShorten = true + if (tooltipText instanceof Element) + { + canShorten = false + } else { + if (typeof tooltipText === 'object') { + if (tooltipText.message) { + tooltipText = tooltipText.message + } else { + try { + tooltipText = JSON.stringify(tooltipText) + } catch (e) { + } } } } 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` ` : `` this.tooltip = yo` -
{ over() }} onmouseleave=${() => { out() }}> - - ${shortTooltipText} - ${button} - - ${action} -
` +
{ over() }} onmouseleave=${() => { out() }}> + + ${shortTooltipText} + ${button} + + ${action} +
` let timeOut = () => { return setTimeout(() => { if (this.id) {