vendor/assets/javascripts/clipboard.js in clipboard-rails-1.5.16 vs vendor/assets/javascripts/clipboard.js in clipboard-rails-1.6.0
- old
+ new
@@ -1,7 +1,7 @@
/*!
- * clipboard.js v1.5.16
+ * clipboard.js v1.6.0
* https://zenorocha.github.io/clipboard.js
*
* Licensed MIT © Zeno Rocha
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@@ -238,13 +238,23 @@
element.focus();
selectedText = element.value;
}
else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
- element.focus();
+ var isReadOnly = element.hasAttribute('readonly');
+
+ if (!isReadOnly) {
+ element.setAttribute('readonly', '');
+ }
+
+ element.select();
element.setSelectionRange(0, element.value.length);
+ if (!isReadOnly) {
+ element.removeAttribute('readonly');
+ }
+
selectedText = element.value;
}
else {
if (element.hasAttribute('contenteditable')) {
element.focus();
@@ -450,11 +460,10 @@
// Move element out of screen horizontally
this.fakeElem.style.position = 'absolute';
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
// Move element to the same position vertically
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
- this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition));
this.fakeElem.style.top = yPosition + 'px';
this.fakeElem.setAttribute('readonly', '');
this.fakeElem.value = this.text;
@@ -725,9 +734,23 @@
if (this.clipboardAction) {
this.clipboardAction.destroy();
this.clipboardAction = null;
}
+ }
+ }], [{
+ key: 'isSupported',
+ value: function isSupported() {
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
+
+ var actions = typeof action === 'string' ? [action] : action;
+ var support = !!document.queryCommandSupported;
+
+ actions.forEach(function (action) {
+ support = support && !!document.queryCommandSupported(action);
+ });
+
+ return support;
}
}]);
return Clipboard;
}(_tinyEmitter2.default);
\ No newline at end of file