move clipboard.js to npm/webpack (#10183)
- created lazy-loaded webpack chunk for clipboard.js - upgraded clipboard.js from 1.5.9 to 2.0.4 - parallelize initialization of all lazy-loaded features Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>tokarchuk/v1.17
parent
0754ceca5b
commit
4721d45c2a
@ -1,18 +0,0 @@ |
||||
The MIT License |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of |
||||
this software and associated documentation files (the 'Software'), to deal in the |
||||
Software without restriction, including without limitation the rights to use, |
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
||||
Software, and to permit persons to whom the Software is furnished to do so, |
||||
subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
File diff suppressed because one or more lines are too long
@ -0,0 +1,23 @@ |
||||
export default async function initClipboard() { |
||||
const els = document.querySelectorAll('.clipboard'); |
||||
if (!els || !els.length) return; |
||||
|
||||
const { default: ClipboardJS } = await import(/* webpackChunkName: "clipboard" */'clipboard'); |
||||
|
||||
const clipboard = new ClipboardJS(els); |
||||
clipboard.on('success', (e) => { |
||||
e.clearSelection(); |
||||
|
||||
$(`#${e.trigger.getAttribute('id')}`).popup('destroy'); |
||||
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success')); |
||||
$(`#${e.trigger.getAttribute('id')}`).popup('show'); |
||||
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); |
||||
}); |
||||
|
||||
clipboard.on('error', (e) => { |
||||
$(`#${e.trigger.getAttribute('id')}`).popup('destroy'); |
||||
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error')); |
||||
$(`#${e.trigger.getAttribute('id')}`).popup('show'); |
||||
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); |
||||
}); |
||||
} |
Loading…
Reference in new issue