Skip to content

Commit

Permalink
Add config.autoSetContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Inndy committed Jun 14, 2018
1 parent eafa278 commit 2a2522e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vue-clipboard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
var Clipboard = require('clipboard/dist/clipboard.min.js') // FIXME: workaround for browserify

var VueClipboardConfig = {
autoSetContainer: false
};

var VueClipboard = {
install: function (Vue) {
Vue.prototype.$clipboardConfig = VueClipboardConfig;
Vue.prototype.$copyText = function (text, container) {
return new Promise(function (resolve, reject) {
var fake_el = document.createElement('button');
Expand Down Expand Up @@ -31,7 +36,8 @@ var VueClipboard = {
} else {
var clipboard = new Clipboard(el, {
text: function () { return binding.value },
action: function () { return binding.arg === 'cut' ? 'cut' : 'copy' }
action: function () { return binding.arg === 'cut' ? 'cut' : 'copy' },
container: VueClipboardConfig.autoSetContainer ? el : undefined
})
clipboard.on('success', function (e) {
var callback = el._v_clipboard_success
Expand Down Expand Up @@ -65,7 +71,8 @@ var VueClipboard = {
}
}
})
}
},
config: VueClipboard
}

if (typeof exports == "object") {
Expand Down

0 comments on commit 2a2522e

Please sign in to comment.