Skip to content

Commit

Permalink
Allow for use in Bootstrap modals.
Browse files Browse the repository at this point in the history
Implements the container option from clipboard.js (zenorocha/clipboard.js#368)
  • Loading branch information
robmazur authored Mar 18, 2018
1 parent d1ae98d commit a8fc101
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 a8fc101

Please sign in to comment.