Release v1.5.15

This commit is contained in:
Zeno Rocha
2016-10-22 19:37:49 -07:00
parent ce0829054b
commit 8ad16a2c6c
5 changed files with 199 additions and 163 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "clipboard", "name": "clipboard",
"version": "1.5.14", "version": "1.5.15",
"description": "Modern copy to clipboard. No Flash. Just 2kb", "description": "Modern copy to clipboard. No Flash. Just 2kb",
"license": "MIT", "license": "MIT",
"main": "dist/clipboard.js", "main": "dist/clipboard.js",

136
dist/clipboard.js vendored
View File

@@ -1,5 +1,5 @@
/*! /*!
* clipboard.js v1.5.14 * clipboard.js v1.5.15
* https://zenorocha.github.io/clipboard.js * https://zenorocha.github.io/clipboard.js
* *
* Licensed MIT © Zeno Rocha * Licensed MIT © Zeno Rocha
@@ -402,7 +402,9 @@ module.exports = E;
*/ */
ClipboardAction.prototype.resolveOptions = function resolveOptions() { _createClass(ClipboardAction, [{
key: 'resolveOptions',
value: function resolveOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.action = options.action; this.action = options.action;
@@ -412,17 +414,19 @@ module.exports = E;
this.trigger = options.trigger; this.trigger = options.trigger;
this.selectedText = ''; this.selectedText = '';
}; }
}, {
ClipboardAction.prototype.initSelection = function initSelection() { key: 'initSelection',
value: function initSelection() {
if (this.text) { if (this.text) {
this.selectFake(); this.selectFake();
} else if (this.target) { } else if (this.target) {
this.selectTarget(); this.selectTarget();
} }
}; }
}, {
ClipboardAction.prototype.selectFake = function selectFake() { key: 'selectFake',
value: function selectFake() {
var _this = this; var _this = this;
var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
@@ -456,9 +460,10 @@ module.exports = E;
this.selectedText = (0, _select2.default)(this.fakeElem); this.selectedText = (0, _select2.default)(this.fakeElem);
this.copyText(); this.copyText();
}; }
}, {
ClipboardAction.prototype.removeFake = function removeFake() { key: 'removeFake',
value: function removeFake() {
if (this.fakeHandler) { if (this.fakeHandler) {
document.body.removeEventListener('click', this.fakeHandlerCallback); document.body.removeEventListener('click', this.fakeHandlerCallback);
this.fakeHandler = null; this.fakeHandler = null;
@@ -469,14 +474,16 @@ module.exports = E;
document.body.removeChild(this.fakeElem); document.body.removeChild(this.fakeElem);
this.fakeElem = null; this.fakeElem = null;
} }
}; }
}, {
ClipboardAction.prototype.selectTarget = function selectTarget() { key: 'selectTarget',
value: function selectTarget() {
this.selectedText = (0, _select2.default)(this.target); this.selectedText = (0, _select2.default)(this.target);
this.copyText(); this.copyText();
}; }
}, {
ClipboardAction.prototype.copyText = function copyText() { key: 'copyText',
value: function copyText() {
var succeeded = void 0; var succeeded = void 0;
try { try {
@@ -486,30 +493,32 @@ module.exports = E;
} }
this.handleResult(succeeded); this.handleResult(succeeded);
}; }
}, {
ClipboardAction.prototype.handleResult = function handleResult(succeeded) { key: 'handleResult',
value: function handleResult(succeeded) {
this.emitter.emit(succeeded ? 'success' : 'error', { this.emitter.emit(succeeded ? 'success' : 'error', {
action: this.action, action: this.action,
text: this.selectedText, text: this.selectedText,
trigger: this.trigger, trigger: this.trigger,
clearSelection: this.clearSelection.bind(this) clearSelection: this.clearSelection.bind(this)
}); });
}; }
}, {
ClipboardAction.prototype.clearSelection = function clearSelection() { key: 'clearSelection',
value: function clearSelection() {
if (this.target) { if (this.target) {
this.target.blur(); this.target.blur();
} }
window.getSelection().removeAllRanges(); window.getSelection().removeAllRanges();
}; }
}, {
ClipboardAction.prototype.destroy = function destroy() { key: 'destroy',
value: function destroy() {
this.removeFake(); this.removeFake();
}; }
}, {
_createClass(ClipboardAction, [{
key: 'action', key: 'action',
set: function set() { set: function set() {
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
@@ -587,6 +596,24 @@ module.exports = E;
} }
} }
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _possibleConstructorReturn(self, call) { function _possibleConstructorReturn(self, call) {
if (!self) { if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -621,7 +648,7 @@ module.exports = E;
function Clipboard(trigger, options) { function Clipboard(trigger, options) {
_classCallCheck(this, Clipboard); _classCallCheck(this, Clipboard);
var _this = _possibleConstructorReturn(this, _Emitter.call(this)); var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
_this.resolveOptions(options); _this.resolveOptions(options);
_this.listenClick(trigger); _this.listenClick(trigger);
@@ -635,23 +662,27 @@ module.exports = E;
*/ */
Clipboard.prototype.resolveOptions = function resolveOptions() { _createClass(Clipboard, [{
key: 'resolveOptions',
value: function resolveOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.action = typeof options.action === 'function' ? options.action : this.defaultAction; this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
this.text = typeof options.text === 'function' ? options.text : this.defaultText; this.text = typeof options.text === 'function' ? options.text : this.defaultText;
}; }
}, {
Clipboard.prototype.listenClick = function listenClick(trigger) { key: 'listenClick',
value: function listenClick(trigger) {
var _this2 = this; var _this2 = this;
this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) { this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
return _this2.onClick(e); return _this2.onClick(e);
}); });
}; }
}, {
Clipboard.prototype.onClick = function onClick(e) { key: 'onClick',
value: function onClick(e) {
var trigger = e.delegateTarget || e.currentTarget; var trigger = e.delegateTarget || e.currentTarget;
if (this.clipboardAction) { if (this.clipboardAction) {
@@ -665,32 +696,37 @@ module.exports = E;
trigger: trigger, trigger: trigger,
emitter: this emitter: this
}); });
}; }
}, {
Clipboard.prototype.defaultAction = function defaultAction(trigger) { key: 'defaultAction',
value: function defaultAction(trigger) {
return getAttributeValue('action', trigger); return getAttributeValue('action', trigger);
}; }
}, {
Clipboard.prototype.defaultTarget = function defaultTarget(trigger) { key: 'defaultTarget',
value: function defaultTarget(trigger) {
var selector = getAttributeValue('target', trigger); var selector = getAttributeValue('target', trigger);
if (selector) { if (selector) {
return document.querySelector(selector); return document.querySelector(selector);
} }
}; }
}, {
Clipboard.prototype.defaultText = function defaultText(trigger) { key: 'defaultText',
value: function defaultText(trigger) {
return getAttributeValue('text', trigger); return getAttributeValue('text', trigger);
}; }
}, {
Clipboard.prototype.destroy = function destroy() { key: 'destroy',
value: function destroy() {
this.listener.destroy(); this.listener.destroy();
if (this.clipboardAction) { if (this.clipboardAction) {
this.clipboardAction.destroy(); this.clipboardAction.destroy();
this.clipboardAction = null; this.clipboardAction = null;
} }
}; }
}]);
return Clipboard; return Clipboard;
}(_tinyEmitter2.default); }(_tinyEmitter2.default);

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
Package.describe({ Package.describe({
name: "zenorocha:clipboard", name: "zenorocha:clipboard",
summary: "Modern copy to clipboard. No Flash. Just 2kb.", summary: "Modern copy to clipboard. No Flash. Just 2kb.",
version: "1.5.14", version: "1.5.15",
git: "https://github.com/zenorocha/clipboard.js" git: "https://github.com/zenorocha/clipboard.js"
}); });

View File

@@ -1,6 +1,6 @@
{ {
"name": "clipboard", "name": "clipboard",
"version": "1.5.14", "version": "1.5.15",
"description": "Modern copy to clipboard. No Flash. Just 2kb", "description": "Modern copy to clipboard. No Flash. Just 2kb",
"repository": "zenorocha/clipboard.js", "repository": "zenorocha/clipboard.js",
"license": "MIT", "license": "MIT",