/bower_components/clipboard/dist/clipboard.js |
@@ -0,0 +1,778 @@ |
/*! |
* clipboard.js v1.6.1 |
* 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){ |
var DOCUMENT_NODE_TYPE = 9; |
|
/** |
* A polyfill for Element.matches() |
*/ |
if (typeof Element !== 'undefined' && !Element.prototype.matches) { |
var proto = Element.prototype; |
|
proto.matches = proto.matchesSelector || |
proto.mozMatchesSelector || |
proto.msMatchesSelector || |
proto.oMatchesSelector || |
proto.webkitMatchesSelector; |
} |
|
/** |
* Finds the closest parent that matches a selector. |
* |
* @param {Element} element |
* @param {String} selector |
* @return {Function} |
*/ |
function closest (element, selector) { |
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { |
if (element.matches(selector)) return element; |
element = element.parentNode; |
} |
} |
|
module.exports = closest; |
|
},{}],2:[function(require,module,exports){ |
var closest = require('./closest'); |
|
/** |
* Delegates event to a selector. |
* |
* @param {Element} element |
* @param {String} selector |
* @param {String} type |
* @param {Function} callback |
* @param {Boolean} useCapture |
* @return {Object} |
*/ |
function delegate(element, selector, type, callback, useCapture) { |
var listenerFn = listener.apply(this, arguments); |
|
element.addEventListener(type, listenerFn, useCapture); |
|
return { |
destroy: function() { |
element.removeEventListener(type, listenerFn, useCapture); |
} |
} |
} |
|
/** |
* Finds closest match and invokes callback. |
* |
* @param {Element} element |
* @param {String} selector |
* @param {String} type |
* @param {Function} callback |
* @return {Function} |
*/ |
function listener(element, selector, type, callback) { |
return function(e) { |
e.delegateTarget = closest(e.target, selector); |
|
if (e.delegateTarget) { |
callback.call(element, e); |
} |
} |
} |
|
module.exports = delegate; |
|
},{"./closest":1}],3:[function(require,module,exports){ |
/** |
* Check if argument is a HTML element. |
* |
* @param {Object} value |
* @return {Boolean} |
*/ |
exports.node = function(value) { |
return value !== undefined |
&& value instanceof HTMLElement |
&& value.nodeType === 1; |
}; |
|
/** |
* Check if argument is a list of HTML elements. |
* |
* @param {Object} value |
* @return {Boolean} |
*/ |
exports.nodeList = function(value) { |
var type = Object.prototype.toString.call(value); |
|
return value !== undefined |
&& (type === '[object NodeList]' || type === '[object HTMLCollection]') |
&& ('length' in value) |
&& (value.length === 0 || exports.node(value[0])); |
}; |
|
/** |
* Check if argument is a string. |
* |
* @param {Object} value |
* @return {Boolean} |
*/ |
exports.string = function(value) { |
return typeof value === 'string' |
|| value instanceof String; |
}; |
|
/** |
* Check if argument is a function. |
* |
* @param {Object} value |
* @return {Boolean} |
*/ |
exports.fn = function(value) { |
var type = Object.prototype.toString.call(value); |
|
return type === '[object Function]'; |
}; |
|
},{}],4:[function(require,module,exports){ |
var is = require('./is'); |
var delegate = require('delegate'); |
|
/** |
* Validates all params and calls the right |
* listener function based on its target type. |
* |
* @param {String|HTMLElement|HTMLCollection|NodeList} target |
* @param {String} type |
* @param {Function} callback |
* @return {Object} |
*/ |
function listen(target, type, callback) { |
if (!target && !type && !callback) { |
throw new Error('Missing required arguments'); |
} |
|
if (!is.string(type)) { |
throw new TypeError('Second argument must be a String'); |
} |
|
if (!is.fn(callback)) { |
throw new TypeError('Third argument must be a Function'); |
} |
|
if (is.node(target)) { |
return listenNode(target, type, callback); |
} |
else if (is.nodeList(target)) { |
return listenNodeList(target, type, callback); |
} |
else if (is.string(target)) { |
return listenSelector(target, type, callback); |
} |
else { |
throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); |
} |
} |
|
/** |
* Adds an event listener to a HTML element |
* and returns a remove listener function. |
* |
* @param {HTMLElement} node |
* @param {String} type |
* @param {Function} callback |
* @return {Object} |
*/ |
function listenNode(node, type, callback) { |
node.addEventListener(type, callback); |
|
return { |
destroy: function() { |
node.removeEventListener(type, callback); |
} |
} |
} |
|
/** |
* Add an event listener to a list of HTML elements |
* and returns a remove listener function. |
* |
* @param {NodeList|HTMLCollection} nodeList |
* @param {String} type |
* @param {Function} callback |
* @return {Object} |
*/ |
function listenNodeList(nodeList, type, callback) { |
Array.prototype.forEach.call(nodeList, function(node) { |
node.addEventListener(type, callback); |
}); |
|
return { |
destroy: function() { |
Array.prototype.forEach.call(nodeList, function(node) { |
node.removeEventListener(type, callback); |
}); |
} |
} |
} |
|
/** |
* Add an event listener to a selector |
* and returns a remove listener function. |
* |
* @param {String} selector |
* @param {String} type |
* @param {Function} callback |
* @return {Object} |
*/ |
function listenSelector(selector, type, callback) { |
return delegate(document.body, selector, type, callback); |
} |
|
module.exports = listen; |
|
},{"./is":3,"delegate":2}],5:[function(require,module,exports){ |
function select(element) { |
var selectedText; |
|
if (element.nodeName === 'SELECT') { |
element.focus(); |
|
selectedText = element.value; |
} |
else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { |
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(); |
} |
|
var selection = window.getSelection(); |
var range = document.createRange(); |
|
range.selectNodeContents(element); |
selection.removeAllRanges(); |
selection.addRange(range); |
|
selectedText = selection.toString(); |
} |
|
return selectedText; |
} |
|
module.exports = select; |
|
},{}],6:[function(require,module,exports){ |
function E () { |
// Keep this empty so it's easier to inherit from |
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) |
} |
|
E.prototype = { |
on: function (name, callback, ctx) { |
var e = this.e || (this.e = {}); |
|
(e[name] || (e[name] = [])).push({ |
fn: callback, |
ctx: ctx |
}); |
|
return this; |
}, |
|
once: function (name, callback, ctx) { |
var self = this; |
function listener () { |
self.off(name, listener); |
callback.apply(ctx, arguments); |
}; |
|
listener._ = callback |
return this.on(name, listener, ctx); |
}, |
|
emit: function (name) { |
var data = [].slice.call(arguments, 1); |
var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); |
var i = 0; |
var len = evtArr.length; |
|
for (i; i < len; i++) { |
evtArr[i].fn.apply(evtArr[i].ctx, data); |
} |
|
return this; |
}, |
|
off: function (name, callback) { |
var e = this.e || (this.e = {}); |
var evts = e[name]; |
var liveEvents = []; |
|
if (evts && callback) { |
for (var i = 0, len = evts.length; i < len; i++) { |
if (evts[i].fn !== callback && evts[i].fn._ !== callback) |
liveEvents.push(evts[i]); |
} |
} |
|
// Remove event from queue to prevent memory leak |
// Suggested by https://github.com/lazd |
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 |
|
(liveEvents.length) |
? e[name] = liveEvents |
: delete e[name]; |
|
return this; |
} |
}; |
|
module.exports = E; |
|
},{}],7:[function(require,module,exports){ |
(function (global, factory) { |
if (typeof define === "function" && define.amd) { |
define(['module', 'select'], factory); |
} else if (typeof exports !== "undefined") { |
factory(module, require('select')); |
} else { |
var mod = { |
exports: {} |
}; |
factory(mod, global.select); |
global.clipboardAction = mod.exports; |
} |
})(this, function (module, _select) { |
'use strict'; |
|
var _select2 = _interopRequireDefault(_select); |
|
function _interopRequireDefault(obj) { |
return obj && obj.__esModule ? obj : { |
default: obj |
}; |
} |
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
return typeof obj; |
} : function (obj) { |
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
}; |
|
function _classCallCheck(instance, Constructor) { |
if (!(instance instanceof Constructor)) { |
throw new TypeError("Cannot call a class as a function"); |
} |
} |
|
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; |
}; |
}(); |
|
var ClipboardAction = function () { |
/** |
* @param {Object} options |
*/ |
function ClipboardAction(options) { |
_classCallCheck(this, ClipboardAction); |
|
this.resolveOptions(options); |
this.initSelection(); |
} |
|
/** |
* Defines base properties passed from constructor. |
* @param {Object} options |
*/ |
|
|
_createClass(ClipboardAction, [{ |
key: 'resolveOptions', |
value: function resolveOptions() { |
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
this.action = options.action; |
this.emitter = options.emitter; |
this.target = options.target; |
this.text = options.text; |
this.trigger = options.trigger; |
|
this.selectedText = ''; |
} |
}, { |
key: 'initSelection', |
value: function initSelection() { |
if (this.text) { |
this.selectFake(); |
} else if (this.target) { |
this.selectTarget(); |
} |
} |
}, { |
key: 'selectFake', |
value: function selectFake() { |
var _this = this; |
|
var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; |
|
this.removeFake(); |
|
this.fakeHandlerCallback = function () { |
return _this.removeFake(); |
}; |
this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true; |
|
this.fakeElem = document.createElement('textarea'); |
// Prevent zooming on iOS |
this.fakeElem.style.fontSize = '12pt'; |
// Reset box model |
this.fakeElem.style.border = '0'; |
this.fakeElem.style.padding = '0'; |
this.fakeElem.style.margin = '0'; |
// 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.style.top = yPosition + 'px'; |
|
this.fakeElem.setAttribute('readonly', ''); |
this.fakeElem.value = this.text; |
|
document.body.appendChild(this.fakeElem); |
|
this.selectedText = (0, _select2.default)(this.fakeElem); |
this.copyText(); |
} |
}, { |
key: 'removeFake', |
value: function removeFake() { |
if (this.fakeHandler) { |
document.body.removeEventListener('click', this.fakeHandlerCallback); |
this.fakeHandler = null; |
this.fakeHandlerCallback = null; |
} |
|
if (this.fakeElem) { |
document.body.removeChild(this.fakeElem); |
this.fakeElem = null; |
} |
} |
}, { |
key: 'selectTarget', |
value: function selectTarget() { |
this.selectedText = (0, _select2.default)(this.target); |
this.copyText(); |
} |
}, { |
key: 'copyText', |
value: function copyText() { |
var succeeded = void 0; |
|
try { |
succeeded = document.execCommand(this.action); |
} catch (err) { |
succeeded = false; |
} |
|
this.handleResult(succeeded); |
} |
}, { |
key: 'handleResult', |
value: function handleResult(succeeded) { |
this.emitter.emit(succeeded ? 'success' : 'error', { |
action: this.action, |
text: this.selectedText, |
trigger: this.trigger, |
clearSelection: this.clearSelection.bind(this) |
}); |
} |
}, { |
key: 'clearSelection', |
value: function clearSelection() { |
if (this.target) { |
this.target.blur(); |
} |
|
window.getSelection().removeAllRanges(); |
} |
}, { |
key: 'destroy', |
value: function destroy() { |
this.removeFake(); |
} |
}, { |
key: 'action', |
set: function set() { |
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; |
|
this._action = action; |
|
if (this._action !== 'copy' && this._action !== 'cut') { |
throw new Error('Invalid "action" value, use either "copy" or "cut"'); |
} |
}, |
get: function get() { |
return this._action; |
} |
}, { |
key: 'target', |
set: function set(target) { |
if (target !== undefined) { |
if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { |
if (this.action === 'copy' && target.hasAttribute('disabled')) { |
throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); |
} |
|
if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { |
throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); |
} |
|
this._target = target; |
} else { |
throw new Error('Invalid "target" value, use a valid Element'); |
} |
} |
}, |
get: function get() { |
return this._target; |
} |
}]); |
|
return ClipboardAction; |
}(); |
|
module.exports = ClipboardAction; |
}); |
|
},{"select":5}],8:[function(require,module,exports){ |
(function (global, factory) { |
if (typeof define === "function" && define.amd) { |
define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory); |
} else if (typeof exports !== "undefined") { |
factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener')); |
} else { |
var mod = { |
exports: {} |
}; |
factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener); |
global.clipboard = mod.exports; |
} |
})(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) { |
'use strict'; |
|
var _clipboardAction2 = _interopRequireDefault(_clipboardAction); |
|
var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); |
|
var _goodListener2 = _interopRequireDefault(_goodListener); |
|
function _interopRequireDefault(obj) { |
return obj && obj.__esModule ? obj : { |
default: obj |
}; |
} |
|
function _classCallCheck(instance, Constructor) { |
if (!(instance instanceof Constructor)) { |
throw new TypeError("Cannot call a class as a function"); |
} |
} |
|
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) { |
if (!self) { |
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
} |
|
return call && (typeof call === "object" || typeof call === "function") ? call : self; |
} |
|
function _inherits(subClass, superClass) { |
if (typeof superClass !== "function" && superClass !== null) { |
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); |
} |
|
subClass.prototype = Object.create(superClass && superClass.prototype, { |
constructor: { |
value: subClass, |
enumerable: false, |
writable: true, |
configurable: true |
} |
}); |
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; |
} |
|
var Clipboard = function (_Emitter) { |
_inherits(Clipboard, _Emitter); |
|
/** |
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger |
* @param {Object} options |
*/ |
function Clipboard(trigger, options) { |
_classCallCheck(this, Clipboard); |
|
var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); |
|
_this.resolveOptions(options); |
_this.listenClick(trigger); |
return _this; |
} |
|
/** |
* Defines if attributes would be resolved using internal setter functions |
* or custom functions that were passed in the constructor. |
* @param {Object} options |
*/ |
|
|
_createClass(Clipboard, [{ |
key: 'resolveOptions', |
value: function resolveOptions() { |
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
this.action = typeof options.action === 'function' ? options.action : this.defaultAction; |
this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; |
this.text = typeof options.text === 'function' ? options.text : this.defaultText; |
} |
}, { |
key: 'listenClick', |
value: function listenClick(trigger) { |
var _this2 = this; |
|
this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) { |
return _this2.onClick(e); |
}); |
} |
}, { |
key: 'onClick', |
value: function onClick(e) { |
var trigger = e.delegateTarget || e.currentTarget; |
|
if (this.clipboardAction) { |
this.clipboardAction = null; |
} |
|
this.clipboardAction = new _clipboardAction2.default({ |
action: this.action(trigger), |
target: this.target(trigger), |
text: this.text(trigger), |
trigger: trigger, |
emitter: this |
}); |
} |
}, { |
key: 'defaultAction', |
value: function defaultAction(trigger) { |
return getAttributeValue('action', trigger); |
} |
}, { |
key: 'defaultTarget', |
value: function defaultTarget(trigger) { |
var selector = getAttributeValue('target', trigger); |
|
if (selector) { |
return document.querySelector(selector); |
} |
} |
}, { |
key: 'defaultText', |
value: function defaultText(trigger) { |
return getAttributeValue('text', trigger); |
} |
}, { |
key: 'destroy', |
value: function destroy() { |
this.listener.destroy(); |
|
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); |
|
/** |
* Helper function to retrieve attribute value. |
* @param {String} suffix |
* @param {Element} element |
*/ |
function getAttributeValue(suffix, element) { |
var attribute = 'data-clipboard-' + suffix; |
|
if (!element.hasAttribute(attribute)) { |
return; |
} |
|
return element.getAttribute(attribute); |
} |
|
module.exports = Clipboard; |
}); |
|
},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8) |
}); |
/bower_components/clipboard/dist/clipboard.min.js |
@@ -0,0 +1,7 @@ |
/*! |
* clipboard.js v1.6.1 |
* https://zenorocha.github.io/clipboard.js |
* |
* Licensed MIT © Zeno Rocha |
*/ |
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Clipboard=e()}}(function(){var e,t,n;return function e(t,n,o){function i(a,c){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,function(e){var n=t[a][1][e];return i(n?n:e)},s,s.exports,e,t,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(e,t,n){function o(e,t){for(;e&&e.nodeType!==i;){if(e.matches(t))return e;e=e.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=o},{}],2:[function(e,t,n){function o(e,t,n,o,r){var a=i.apply(this,arguments);return e.addEventListener(n,a,r),{destroy:function(){e.removeEventListener(n,a,r)}}}function i(e,t,n,o){return function(n){n.delegateTarget=r(n.target,t),n.delegateTarget&&o.call(e,n)}}var r=e("./closest");t.exports=o},{"./closest":1}],3:[function(e,t,n){n.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},n.nodeList=function(e){var t=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===t||"[object HTMLCollection]"===t)&&"length"in e&&(0===e.length||n.node(e[0]))},n.string=function(e){return"string"==typeof e||e instanceof String},n.fn=function(e){var t=Object.prototype.toString.call(e);return"[object Function]"===t}},{}],4:[function(e,t,n){function o(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!c.string(t))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(e))return i(e,t,n);if(c.nodeList(e))return r(e,t,n);if(c.string(e))return a(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}function r(e,t,n){return Array.prototype.forEach.call(e,function(e){e.addEventListener(t,n)}),{destroy:function(){Array.prototype.forEach.call(e,function(e){e.removeEventListener(t,n)})}}}function a(e,t,n){return l(document.body,e,t,n)}var c=e("./is"),l=e("delegate");t.exports=o},{"./is":3,delegate:2}],5:[function(e,t,n){function o(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var o=window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),t=o.toString()}return t}t.exports=o},{}],6:[function(e,t,n){function o(){}o.prototype={on:function(e,t,n){var o=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){function o(){i.off(e,o),t.apply(n,arguments)}var i=this;return o._=t,this.on(e,o,n)},emit:function(e){var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),o=n[e],i=[];if(o&&t)for(var r=0,a=o.length;r<a;r++)o[r].fn!==t&&o[r].fn._!==t&&i.push(o[r]);return i.length?n[e]=i:delete n[e],this}},t.exports=o},{}],7:[function(t,n,o){!function(i,r){if("function"==typeof e&&e.amd)e(["module","select"],r);else if("undefined"!=typeof o)r(n,t("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(e,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(t),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(){function e(t){o(this,e),this.resolveOptions(t),this.initSelection()}return a(e,[{key:"resolveOptions",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function e(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function e(){var t=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function e(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function e(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function e(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function e(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function e(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function e(){this.removeFake()}},{key:"action",set:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function e(){return this._action}},{key:"target",set:function e(t){if(void 0!==t){if(!t||"object"!==("undefined"==typeof t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function e(){return this._target}}]),e}();e.exports=c})},{select:5}],8:[function(t,n,o){!function(i,r){if("function"==typeof e&&e.amd)e(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,t("./clipboard-action"),t("tiny-emitter"),t("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(e,t,n,o){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}var u=i(t),s=i(n),f=i(o),d=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),h=function(e){function t(e,n){r(this,t);var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.resolveOptions(n),o.listenClick(e),o}return c(t,e),d(t,[{key:"resolveOptions",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText}},{key:"listenClick",value:function e(t){var n=this;this.listener=(0,f.default)(t,"click",function(e){return n.onClick(e)})}},{key:"onClick",value:function e(t){var n=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})}},{key:"defaultAction",value:function e(t){return l("action",t)}},{key:"defaultTarget",value:function e(t){var n=l("target",t);if(n)return document.querySelector(n)}},{key:"defaultText",value:function e(t){return l("text",t)}},{key:"destroy",value:function e(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof t?[t]:t,o=!!document.queryCommandSupported;return n.forEach(function(e){o=o&&!!document.queryCommandSupported(e)}),o}}]),t}(s.default);e.exports=h})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)}); |
/bower_components/clipboard/readme.md |
@@ -0,0 +1,175 @@ |
# clipboard.js |
|
[![Build Status](http://img.shields.io/travis/zenorocha/clipboard.js/master.svg?style=flat)](https://travis-ci.org/zenorocha/clipboard.js) |
![Killing Flash](https://img.shields.io/badge/killing-flash-brightgreen.svg?style=flat) |
|
> Modern copy to clipboard. No Flash. Just 3kb gzipped. |
|
<a href="https://clipboardjs.com/"><img width="728" src="https://cloud.githubusercontent.com/assets/398893/16165747/a0f6fc46-349a-11e6-8c9b-c5fd58d9099c.png" alt="Demo"></a> |
|
## Why |
|
Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated framework. |
|
That's why clipboard.js exists. |
|
## Install |
|
You can get it on npm. |
|
``` |
npm install clipboard --save |
``` |
|
Or bower, too. |
|
``` |
bower install clipboard --save |
``` |
|
If you're not into package management, just [download a ZIP](https://github.com/zenorocha/clipboard.js/archive/master.zip) file. |
|
## Setup |
|
First, include the script located on the `dist` folder or load it from [a third-party CDN provider](https://github.com/zenorocha/clipboard.js/wiki/CDN-Providers). |
|
```html |
<script src="dist/clipboard.min.js"></script> |
``` |
|
Now, you need to instantiate it by [passing a DOM selector](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-selector.html#L18), [HTML element](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-node.html#L16-L17), or [list of HTML elements](https://github.com/zenorocha/clipboard.js/blob/master/demo/constructor-nodelist.html#L18-L19). |
|
```js |
new Clipboard('.btn'); |
``` |
|
Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. But guess what? If you have hundreds of matches, this operation can consume a lot of memory. |
|
For this reason we use [event delegation](http://stackoverflow.com/questions/1687296/what-is-dom-event-delegation) which replaces multiple event listeners with just a single listener. After all, [#perfmatters](https://twitter.com/hashtag/perfmatters). |
|
# Usage |
|
We're living a _declarative renaissance_, that's why we decided to take advantage of [HTML5 data attributes](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes) for better usability. |
|
### Copy text from another element |
|
A pretty common use case is to copy content from another element. You can do that by adding a `data-clipboard-target` attribute in your trigger element. |
|
The value you include on this attribute needs to match another's element selector. |
|
<a href="https://clipboardjs.com/#example-target"><img width="473" alt="example-2" src="https://cloud.githubusercontent.com/assets/398893/9983467/a4946aaa-5fb1-11e5-9780-f09fcd7ca6c8.png"></a> |
|
```html |
<!-- Target --> |
<input id="foo" value="https://github.com/zenorocha/clipboard.js.git"> |
|
<!-- Trigger --> |
<button class="btn" data-clipboard-target="#foo"> |
<img src="assets/clippy.svg" alt="Copy to clipboard"> |
</button> |
``` |
|
### Cut text from another element |
|
Additionally, you can define a `data-clipboard-action` attribute to specify if you want to either `copy` or `cut` content. |
|
If you omit this attribute, `copy` will be used by default. |
|
<a href="https://clipboardjs.com/#example-action"><img width="473" alt="example-3" src="https://cloud.githubusercontent.com/assets/398893/10000358/7df57b9c-6050-11e5-9cd1-fbc51d2fd0a7.png"></a> |
|
```html |
<!-- Target --> |
<textarea id="bar">Mussum ipsum cacilds...</textarea> |
|
<!-- Trigger --> |
<button class="btn" data-clipboard-action="cut" data-clipboard-target="#bar"> |
Cut to clipboard |
</button> |
``` |
|
As you may expect, the `cut` action only works on `<input>` or `<textarea>` elements. |
|
### Copy text from attribute |
|
Truth is, you don't even need another element to copy its content from. You can just include a `data-clipboard-text` attribute in your trigger element. |
|
<a href="https://clipboardjs.com/#example-text"><img width="147" alt="example-1" src="https://cloud.githubusercontent.com/assets/398893/10000347/6e16cf8c-6050-11e5-9883-1c5681f9ec45.png"></a> |
|
```html |
<!-- Trigger --> |
<button class="btn" data-clipboard-text="Just because you can doesn't mean you should — clipboard.js"> |
Copy to clipboard |
</button> |
``` |
|
## Events |
|
There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation. |
|
That's why we fire custom events such as `success` and `error` for you to listen and implement your custom logic. |
|
```js |
var clipboard = new Clipboard('.btn'); |
|
clipboard.on('success', function(e) { |
console.info('Action:', e.action); |
console.info('Text:', e.text); |
console.info('Trigger:', e.trigger); |
|
e.clearSelection(); |
}); |
|
clipboard.on('error', function(e) { |
console.error('Action:', e.action); |
console.error('Trigger:', e.trigger); |
}); |
``` |
|
For a live demonstration, open this [site](https://clipboardjs.com/) and just your console :) |
|
## Advanced Options |
|
If you don't want to modify your HTML, there's a pretty handy imperative API for you to use. All you need to do is declare a function, do your thing, and return a value. |
|
For instance, if you want to dynamically set a `target`, you'll need to return a Node. |
|
```js |
new Clipboard('.btn', { |
target: function(trigger) { |
return trigger.nextElementSibling; |
} |
}); |
``` |
|
If you want to dynamically set a `text`, you'll return a String. |
|
```js |
new Clipboard('.btn', { |
text: function(trigger) { |
return trigger.getAttribute('aria-label'); |
} |
}); |
``` |
|
Also, if you are working with single page apps, you may want to manage the lifecycle of the DOM more precisely. Here's how you clean up the events and objects that we create. |
|
```js |
var clipboard = new Clipboard('.btn'); |
clipboard.destroy(); |
``` |
|
## Browser Support |
|
This library relies on both [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) and [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand) APIs. The first one is [supported by all browsers](http://caniuse.com/#search=selection) while the second one is supported in the following browsers. |
|
| <img src="https://clipboardjs.com/assets/images/chrome.png" width="48px" height="48px" alt="Chrome logo"> | <img src="https://clipboardjs.com/assets/images/edge.png" width="48px" height="48px" alt="Edge logo"> | <img src="https://clipboardjs.com/assets/images/firefox.png" width="48px" height="48px" alt="Firefox logo"> | <img src="https://clipboardjs.com/assets/images/ie.png" width="48px" height="48px" alt="Internet Explorer logo"> | <img src="https://clipboardjs.com/assets/images/opera.png" width="48px" height="48px" alt="Opera logo"> | <img src="https://clipboardjs.com/assets/images/safari.png" width="48px" height="48px" alt="Safari logo"> | |
|:---:|:---:|:---:|:---:|:---:|:---:| |
| 42+ ✔ | 12+ ✔ | 41+ ✔ | 9+ ✔ | 29+ ✔ | 10+ ✔ | |
|
The good news is that clipboard.js gracefully degrades if you need to support older browsers. All you have to do is show a tooltip saying `Copied!` when `success` event is called and `Press Ctrl+C to copy` when `error` event is called because the text is already selected. |
|
You can also check if clipboard.js is supported or not by running `Clipboard.isSupported()`, that way you can hide copy/cut buttons from the UI. |
|
## License |
|
[MIT License](http://zenorocha.mit-license.org/) © Zeno Rocha |