Skip to content

Commit

Permalink
Merge pull request #23 from robmazur/master
Browse files Browse the repository at this point in the history
Allow for use in Bootstrap modals.
  • Loading branch information
Inndy authored Mar 19, 2018
2 parents d1ae98d + a8fc101 commit 6755e12
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vue-clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ var Clipboard = require('clipboard/dist/clipboard.min.js') // FIXME: workaround

var VueClipboard = {
install: function (Vue) {
Vue.prototype.$copyText = function (text) {
Vue.prototype.$copyText = function (text, container) {
return new Promise(function (resolve, reject) {
var fake_el = document.createElement('button');
var clipboard = new Clipboard(fake_el, {
text: function () { return text },
action: function () { return 'copy' }
action: function () { return 'copy' },
container: typeof container === 'object' ? container : document.body
});
clipboard.on('success', function (e) {
clipboard.destroy();
Expand Down

0 comments on commit 6755e12

Please sign in to comment.