mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Release v1.5.13
This commit is contained in:
parent
fce625f151
commit
26a9e9d56c
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "clipboard",
|
"name": "clipboard",
|
||||||
"version": "1.5.12",
|
"version": "1.5.13",
|
||||||
"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",
|
||||||
|
|
218
dist/clipboard.js
vendored
218
dist/clipboard.js
vendored
|
@ -1,23 +1,124 @@
|
||||||
/*!
|
/*!
|
||||||
* clipboard.js v1.5.12
|
* clipboard.js v1.5.13
|
||||||
* https://zenorocha.github.io/clipboard.js
|
* https://zenorocha.github.io/clipboard.js
|
||||||
*
|
*
|
||||||
* Licensed MIT © Zeno Rocha
|
* 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){
|
(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){
|
||||||
var matches = require('matches-selector')
|
/**
|
||||||
|
* Module Dependencies
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = function (element, selector, checkYoSelf) {
|
try {
|
||||||
var parent = checkYoSelf ? element : element.parentNode
|
var matches = require('matches-selector')
|
||||||
|
} catch (err) {
|
||||||
while (parent && parent !== document) {
|
var matches = require('component-matches-selector')
|
||||||
if (matches(parent, selector)) return parent;
|
|
||||||
parent = parent.parentNode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},{"matches-selector":5}],2:[function(require,module,exports){
|
/**
|
||||||
var closest = require('closest');
|
* Export `closest`
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = closest
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closest
|
||||||
|
*
|
||||||
|
* @param {Element} el
|
||||||
|
* @param {String} selector
|
||||||
|
* @param {Element} scope (optional)
|
||||||
|
*/
|
||||||
|
|
||||||
|
function closest (el, selector, scope) {
|
||||||
|
scope = scope || document.documentElement;
|
||||||
|
|
||||||
|
// walk up the dom
|
||||||
|
while (el && el !== scope) {
|
||||||
|
if (matches(el, selector)) return el;
|
||||||
|
el = el.parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check scope for match
|
||||||
|
return matches(el, selector) ? el : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
},{"component-matches-selector":2,"matches-selector":2}],2:[function(require,module,exports){
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
try {
|
||||||
|
var query = require('query');
|
||||||
|
} catch (err) {
|
||||||
|
var query = require('component-query');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element prototype.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var proto = Element.prototype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vendor function.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var vendor = proto.matches
|
||||||
|
|| proto.webkitMatchesSelector
|
||||||
|
|| proto.mozMatchesSelector
|
||||||
|
|| proto.msMatchesSelector
|
||||||
|
|| proto.oMatchesSelector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `match()`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = match;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match `el` to `selector`.
|
||||||
|
*
|
||||||
|
* @param {Element} el
|
||||||
|
* @param {String} selector
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function match(el, selector) {
|
||||||
|
if (!el || el.nodeType !== 1) return false;
|
||||||
|
if (vendor) return vendor.call(el, selector);
|
||||||
|
var nodes = query.all(selector, el.parentNode);
|
||||||
|
for (var i = 0; i < nodes.length; ++i) {
|
||||||
|
if (nodes[i] == el) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
},{"component-query":3,"query":3}],3:[function(require,module,exports){
|
||||||
|
function one(selector, el) {
|
||||||
|
return el.querySelector(selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports = module.exports = function(selector, el){
|
||||||
|
el = el || document;
|
||||||
|
return one(selector, el);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.all = function(selector, el){
|
||||||
|
el = el || document;
|
||||||
|
return el.querySelectorAll(selector);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.engine = function(obj){
|
||||||
|
if (!obj.one) throw new Error('.one callback required');
|
||||||
|
if (!obj.all) throw new Error('.all callback required');
|
||||||
|
one = obj.one;
|
||||||
|
exports.all = obj.all;
|
||||||
|
return exports;
|
||||||
|
};
|
||||||
|
|
||||||
|
},{}],4:[function(require,module,exports){
|
||||||
|
var closest = require('component-closest');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delegates event to a selector.
|
* Delegates event to a selector.
|
||||||
|
@ -62,7 +163,7 @@ function listener(element, selector, type, callback) {
|
||||||
|
|
||||||
module.exports = delegate;
|
module.exports = delegate;
|
||||||
|
|
||||||
},{"closest":1}],3:[function(require,module,exports){
|
},{"component-closest":1}],5:[function(require,module,exports){
|
||||||
/**
|
/**
|
||||||
* Check if argument is a HTML element.
|
* Check if argument is a HTML element.
|
||||||
*
|
*
|
||||||
|
@ -113,7 +214,7 @@ exports.fn = function(value) {
|
||||||
return type === '[object Function]';
|
return type === '[object Function]';
|
||||||
};
|
};
|
||||||
|
|
||||||
},{}],4:[function(require,module,exports){
|
},{}],6:[function(require,module,exports){
|
||||||
var is = require('./is');
|
var is = require('./is');
|
||||||
var delegate = require('delegate');
|
var delegate = require('delegate');
|
||||||
|
|
||||||
|
@ -210,52 +311,16 @@ function listenSelector(selector, type, callback) {
|
||||||
|
|
||||||
module.exports = listen;
|
module.exports = listen;
|
||||||
|
|
||||||
},{"./is":3,"delegate":2}],5:[function(require,module,exports){
|
},{"./is":5,"delegate":4}],7:[function(require,module,exports){
|
||||||
|
|
||||||
/**
|
|
||||||
* Element prototype.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var proto = Element.prototype;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Vendor function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var vendor = proto.matchesSelector
|
|
||||||
|| proto.webkitMatchesSelector
|
|
||||||
|| proto.mozMatchesSelector
|
|
||||||
|| proto.msMatchesSelector
|
|
||||||
|| proto.oMatchesSelector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expose `match()`.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = match;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Match `el` to `selector`.
|
|
||||||
*
|
|
||||||
* @param {Element} el
|
|
||||||
* @param {String} selector
|
|
||||||
* @return {Boolean}
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
|
|
||||||
function match(el, selector) {
|
|
||||||
if (vendor) return vendor.call(el, selector);
|
|
||||||
var nodes = el.parentNode.querySelectorAll(selector);
|
|
||||||
for (var i = 0; i < nodes.length; ++i) {
|
|
||||||
if (nodes[i] == el) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},{}],6:[function(require,module,exports){
|
|
||||||
function select(element) {
|
function select(element) {
|
||||||
var selectedText;
|
var selectedText;
|
||||||
|
|
||||||
if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
if (element.nodeName === 'SELECT') {
|
||||||
|
element.focus();
|
||||||
|
|
||||||
|
selectedText = element.value;
|
||||||
|
}
|
||||||
|
else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
||||||
element.focus();
|
element.focus();
|
||||||
element.setSelectionRange(0, element.value.length);
|
element.setSelectionRange(0, element.value.length);
|
||||||
|
|
||||||
|
@ -281,14 +346,14 @@ function select(element) {
|
||||||
|
|
||||||
module.exports = select;
|
module.exports = select;
|
||||||
|
|
||||||
},{}],7:[function(require,module,exports){
|
},{}],8:[function(require,module,exports){
|
||||||
function E () {
|
function E () {
|
||||||
// Keep this empty so it's easier to inherit from
|
// Keep this empty so it's easier to inherit from
|
||||||
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
||||||
}
|
}
|
||||||
|
|
||||||
E.prototype = {
|
E.prototype = {
|
||||||
on: function (name, callback, ctx) {
|
on: function (name, callback, ctx) {
|
||||||
var e = this.e || (this.e = {});
|
var e = this.e || (this.e = {});
|
||||||
|
|
||||||
(e[name] || (e[name] = [])).push({
|
(e[name] || (e[name] = [])).push({
|
||||||
|
@ -349,7 +414,7 @@ E.prototype = {
|
||||||
|
|
||||||
module.exports = E;
|
module.exports = E;
|
||||||
|
|
||||||
},{}],8:[function(require,module,exports){
|
},{}],9:[function(require,module,exports){
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
if (typeof define === "function" && define.amd) {
|
if (typeof define === "function" && define.amd) {
|
||||||
define(['module', 'select'], factory);
|
define(['module', 'select'], factory);
|
||||||
|
@ -407,7 +472,6 @@ module.exports = E;
|
||||||
/**
|
/**
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ClipboardAction(options) {
|
function ClipboardAction(options) {
|
||||||
_classCallCheck(this, ClipboardAction);
|
_classCallCheck(this, ClipboardAction);
|
||||||
|
|
||||||
|
@ -464,7 +528,10 @@ module.exports = E;
|
||||||
this.fakeElem.style.position = 'absolute';
|
this.fakeElem.style.position = 'absolute';
|
||||||
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
|
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
|
||||||
// Move element to the same position vertically
|
// Move element to the same position vertically
|
||||||
this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
|
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.setAttribute('readonly', '');
|
||||||
this.fakeElem.value = this.text;
|
this.fakeElem.value = this.text;
|
||||||
|
|
||||||
|
@ -493,7 +560,7 @@ module.exports = E;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClipboardAction.prototype.copyText = function copyText() {
|
ClipboardAction.prototype.copyText = function copyText() {
|
||||||
var succeeded = undefined;
|
var succeeded = void 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
succeeded = document.execCommand(this.action);
|
succeeded = document.execCommand(this.action);
|
||||||
|
@ -505,20 +572,12 @@ module.exports = E;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
|
ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
|
||||||
if (succeeded) {
|
this.emitter.emit(succeeded ? 'success' : 'error', {
|
||||||
this.emitter.emit('success', {
|
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)
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.emitter.emit('error', {
|
|
||||||
action: this.action,
|
|
||||||
trigger: this.trigger,
|
|
||||||
clearSelection: this.clearSelection.bind(this)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ClipboardAction.prototype.clearSelection = function clearSelection() {
|
ClipboardAction.prototype.clearSelection = function clearSelection() {
|
||||||
|
@ -577,7 +636,7 @@ module.exports = E;
|
||||||
module.exports = ClipboardAction;
|
module.exports = ClipboardAction;
|
||||||
});
|
});
|
||||||
|
|
||||||
},{"select":6}],9:[function(require,module,exports){
|
},{"select":7}],10:[function(require,module,exports){
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
if (typeof define === "function" && define.amd) {
|
if (typeof define === "function" && define.amd) {
|
||||||
define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
|
define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
|
||||||
|
@ -642,7 +701,6 @@ module.exports = E;
|
||||||
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
|
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Clipboard(trigger, options) {
|
function Clipboard(trigger, options) {
|
||||||
_classCallCheck(this, Clipboard);
|
_classCallCheck(this, Clipboard);
|
||||||
|
|
||||||
|
@ -738,5 +796,5 @@ module.exports = E;
|
||||||
module.exports = Clipboard;
|
module.exports = Clipboard;
|
||||||
});
|
});
|
||||||
|
|
||||||
},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)
|
},{"./clipboard-action":9,"good-listener":6,"tiny-emitter":8}]},{},[10])(10)
|
||||||
});
|
});
|
4
dist/clipboard.min.js
vendored
4
dist/clipboard.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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.12",
|
version: "1.5.13",
|
||||||
git: "https://github.com/zenorocha/clipboard.js"
|
git: "https://github.com/zenorocha/clipboard.js"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "clipboard",
|
"name": "clipboard",
|
||||||
"version": "1.5.12",
|
"version": "1.5.13",
|
||||||
"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",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user