Fixed copy to clipboard error

pull/1/head
ioedeveloper 5 years ago committed by Liana Husikyan
parent c94def2aa6
commit 1f0d4bef66
  1. 2
      src/app/tabs/settings-tab.js
  2. 4
      src/app/ui/copy-to-clipboard.js

@ -73,7 +73,7 @@ module.exports = class SettingsTab extends ViewPlugin {
if (token) gistAccessToken.value = token
var gistAddToken = yo`<input class="${css.savegisttoken} btn btn-sm btn-primary" id="savegisttoken" data-id="settingsTabSaveGistToken" onclick=${() => { this.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">`
var gistRemoveToken = yo`<input class="btn btn-sm btn-primary" id="removegisttoken" data-id="settingsTabRemoveGistToken" onclick=${() => { gistAccessToken.value = ''; this.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">`
this._view.gistToken = yo`<div class="${css.checkboxText}">${gistAccessToken}${copyToClipboard(() => this.config.get('settings/gist-access-token'))}${gistAddToken}${gistRemoveToken}</div>`
this._view.gistToken = yo`<div class="${css.checkboxText}">${gistAccessToken}${copyToClipboard(() => gistAccessToken.value )}${gistAddToken}${gistRemoveToken}</div>`
this._view.optionVM = yo`<input onchange=${onchangeOption} class="align-middle form-check-input" id="alwaysUseVM" data-id="settingsTabAlwaysUseVM" type="checkbox">`
if (this.config.get('settings/always-use-vm') === undefined) this.config.set('settings/always-use-vm', true)
if (this.config.get('settings/always-use-vm')) this._view.optionVM.setAttribute('checked', '')

@ -12,7 +12,7 @@ var css = csjs`
}
`
module.exports = function copyToClipboard (getContent, tip = 'Copy value to clipboard', icon = 'fa-copy') {
module.exports = function copyToClipboard (getContent, tip = 'Copied value to clipboard', icon = 'fa-copy') {
var copyIcon = yo`<i title="${tip}" class="${css.copyIcon} far ${icon}" data-id="copyToClipboardCopyIcon" aria-hidden="true"></i>`
copyIcon.onclick = (event) => {
event.stopPropagation()
@ -31,6 +31,8 @@ module.exports = function copyToClipboard (getContent, tip = 'Copy value to clip
} catch (e) {}
copy(copiableContent)
addTooltip(tip)
} else {
addTooltip('Cannot copy empty content!')
}
}
return copyIcon

Loading…
Cancel
Save