Created
June 21, 2018 09:03
-
-
Save mmintel/b36af9d114536ac76d8c874827b9a667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Clipboard from '../lib/clipboard'; | |
| import Tooltip from '../lib/tooltip'; | |
| export default function init() { | |
| const clipboards = new Clipboard({ | |
| nodes: document.queryAll('[data-clipboard]'), | |
| targets: document.queryAll('[data-clipboard-target]'), | |
| }).init(); | |
| clipboards.each((instance) => { | |
| const tooltip = new Tooltip({ | |
| node: instance.view.node, | |
| manual: true, | |
| label: 'Copied!', | |
| }); | |
| instance.onCopy(() => { | |
| tooltip.show(); | |
| }); | |
| instance.onClear(() => { | |
| tooltip.hide(); | |
| }); | |
| }); | |
| return clipboards; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment