星火管控前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clipboard.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. /*!
  2. * clipboard.js v2.0.11
  3. * https://clipboardjs.com/
  4. *
  5. * Licensed MIT © Zeno Rocha
  6. */
  7. (function webpackUniversalModuleDefinition(root, factory) {
  8. if(typeof exports === 'object' && typeof module === 'object')
  9. module.exports = factory();
  10. else if(typeof define === 'function' && define.amd)
  11. define([], factory);
  12. else if(typeof exports === 'object')
  13. exports["ClipboardJS"] = factory();
  14. else
  15. root["ClipboardJS"] = factory();
  16. })(this, function() {
  17. return /******/ (function() { // webpackBootstrap
  18. /******/ var __webpack_modules__ = ({
  19. /***/ 686:
  20. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  21. "use strict";
  22. // EXPORTS
  23. __webpack_require__.d(__webpack_exports__, {
  24. "default": function() { return /* binding */ clipboard; }
  25. });
  26. // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  27. var tiny_emitter = __webpack_require__(279);
  28. var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);
  29. // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  30. var listen = __webpack_require__(370);
  31. var listen_default = /*#__PURE__*/__webpack_require__.n(listen);
  32. // EXTERNAL MODULE: ./node_modules/select/src/select.js
  33. var src_select = __webpack_require__(817);
  34. var select_default = /*#__PURE__*/__webpack_require__.n(src_select);
  35. ;// CONCATENATED MODULE: ./src/common/command.js
  36. /**
  37. * Executes a given operation type.
  38. * @param {String} type
  39. * @return {Boolean}
  40. */
  41. function command(type) {
  42. try {
  43. return document.execCommand(type);
  44. } catch (err) {
  45. return false;
  46. }
  47. }
  48. ;// CONCATENATED MODULE: ./src/actions/cut.js
  49. /**
  50. * Cut action wrapper.
  51. * @param {String|HTMLElement} target
  52. * @return {String}
  53. */
  54. var ClipboardActionCut = function ClipboardActionCut(target) {
  55. var selectedText = select_default()(target);
  56. command('cut');
  57. return selectedText;
  58. };
  59. /* harmony default export */ var actions_cut = (ClipboardActionCut);
  60. ;// CONCATENATED MODULE: ./src/common/create-fake-element.js
  61. /**
  62. * Creates a fake textarea element with a value.
  63. * @param {String} value
  64. * @return {HTMLElement}
  65. */
  66. function createFakeElement(value) {
  67. var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  68. var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS
  69. fakeElement.style.fontSize = '12pt'; // Reset box model
  70. fakeElement.style.border = '0';
  71. fakeElement.style.padding = '0';
  72. fakeElement.style.margin = '0'; // Move element out of screen horizontally
  73. fakeElement.style.position = 'absolute';
  74. fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  75. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  76. fakeElement.style.top = "".concat(yPosition, "px");
  77. fakeElement.setAttribute('readonly', '');
  78. fakeElement.value = value;
  79. return fakeElement;
  80. }
  81. ;// CONCATENATED MODULE: ./src/actions/copy.js
  82. /**
  83. * Create fake copy action wrapper using a fake element.
  84. * @param {String} target
  85. * @param {Object} options
  86. * @return {String}
  87. */
  88. var fakeCopyAction = function fakeCopyAction(value, options) {
  89. var fakeElement = createFakeElement(value);
  90. options.container.appendChild(fakeElement);
  91. var selectedText = select_default()(fakeElement);
  92. command('copy');
  93. fakeElement.remove();
  94. return selectedText;
  95. };
  96. /**
  97. * Copy action wrapper.
  98. * @param {String|HTMLElement} target
  99. * @param {Object} options
  100. * @return {String}
  101. */
  102. var ClipboardActionCopy = function ClipboardActionCopy(target) {
  103. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  104. container: document.body
  105. };
  106. var selectedText = '';
  107. if (typeof target === 'string') {
  108. selectedText = fakeCopyAction(target, options);
  109. } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {
  110. // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
  111. selectedText = fakeCopyAction(target.value, options);
  112. } else {
  113. selectedText = select_default()(target);
  114. command('copy');
  115. }
  116. return selectedText;
  117. };
  118. /* harmony default export */ var actions_copy = (ClipboardActionCopy);
  119. ;// CONCATENATED MODULE: ./src/actions/default.js
  120. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  121. /**
  122. * Inner function which performs selection from either `text` or `target`
  123. * properties and then executes copy or cut operations.
  124. * @param {Object} options
  125. */
  126. var ClipboardActionDefault = function ClipboardActionDefault() {
  127. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  128. // Defines base properties passed from constructor.
  129. var _options$action = options.action,
  130. action = _options$action === void 0 ? 'copy' : _options$action,
  131. container = options.container,
  132. target = options.target,
  133. text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
  134. if (action !== 'copy' && action !== 'cut') {
  135. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  136. } // Sets the `target` property using an element that will be have its content copied.
  137. if (target !== undefined) {
  138. if (target && _typeof(target) === 'object' && target.nodeType === 1) {
  139. if (action === 'copy' && target.hasAttribute('disabled')) {
  140. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  141. }
  142. if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  143. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  144. }
  145. } else {
  146. throw new Error('Invalid "target" value, use a valid Element');
  147. }
  148. } // Define selection strategy based on `text` property.
  149. if (text) {
  150. return actions_copy(text, {
  151. container: container
  152. });
  153. } // Defines which selection strategy based on `target` property.
  154. if (target) {
  155. return action === 'cut' ? actions_cut(target) : actions_copy(target, {
  156. container: container
  157. });
  158. }
  159. };
  160. /* harmony default export */ var actions_default = (ClipboardActionDefault);
  161. ;// CONCATENATED MODULE: ./src/clipboard.js
  162. function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
  163. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  164. 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); } }
  165. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  166. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  167. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  168. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  169. function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  170. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  171. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  172. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  173. /**
  174. * Helper function to retrieve attribute value.
  175. * @param {String} suffix
  176. * @param {Element} element
  177. */
  178. function getAttributeValue(suffix, element) {
  179. var attribute = "data-clipboard-".concat(suffix);
  180. if (!element.hasAttribute(attribute)) {
  181. return;
  182. }
  183. return element.getAttribute(attribute);
  184. }
  185. /**
  186. * Base class which takes one or more elements, adds event listeners to them,
  187. * and instantiates a new `ClipboardAction` on each click.
  188. */
  189. var Clipboard = /*#__PURE__*/function (_Emitter) {
  190. _inherits(Clipboard, _Emitter);
  191. var _super = _createSuper(Clipboard);
  192. /**
  193. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  194. * @param {Object} options
  195. */
  196. function Clipboard(trigger, options) {
  197. var _this;
  198. _classCallCheck(this, Clipboard);
  199. _this = _super.call(this);
  200. _this.resolveOptions(options);
  201. _this.listenClick(trigger);
  202. return _this;
  203. }
  204. /**
  205. * Defines if attributes would be resolved using internal setter functions
  206. * or custom functions that were passed in the constructor.
  207. * @param {Object} options
  208. */
  209. _createClass(Clipboard, [{
  210. key: "resolveOptions",
  211. value: function resolveOptions() {
  212. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  213. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  214. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  215. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  216. this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
  217. }
  218. /**
  219. * Adds a click event listener to the passed trigger.
  220. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  221. */
  222. }, {
  223. key: "listenClick",
  224. value: function listenClick(trigger) {
  225. var _this2 = this;
  226. this.listener = listen_default()(trigger, 'click', function (e) {
  227. return _this2.onClick(e);
  228. });
  229. }
  230. /**
  231. * Defines a new `ClipboardAction` on each click event.
  232. * @param {Event} e
  233. */
  234. }, {
  235. key: "onClick",
  236. value: function onClick(e) {
  237. var trigger = e.delegateTarget || e.currentTarget;
  238. var action = this.action(trigger) || 'copy';
  239. var text = actions_default({
  240. action: action,
  241. container: this.container,
  242. target: this.target(trigger),
  243. text: this.text(trigger)
  244. }); // Fires an event based on the copy operation result.
  245. this.emit(text ? 'success' : 'error', {
  246. action: action,
  247. text: text,
  248. trigger: trigger,
  249. clearSelection: function clearSelection() {
  250. if (trigger) {
  251. trigger.focus();
  252. }
  253. window.getSelection().removeAllRanges();
  254. }
  255. });
  256. }
  257. /**
  258. * Default `action` lookup function.
  259. * @param {Element} trigger
  260. */
  261. }, {
  262. key: "defaultAction",
  263. value: function defaultAction(trigger) {
  264. return getAttributeValue('action', trigger);
  265. }
  266. /**
  267. * Default `target` lookup function.
  268. * @param {Element} trigger
  269. */
  270. }, {
  271. key: "defaultTarget",
  272. value: function defaultTarget(trigger) {
  273. var selector = getAttributeValue('target', trigger);
  274. if (selector) {
  275. return document.querySelector(selector);
  276. }
  277. }
  278. /**
  279. * Allow fire programmatically a copy action
  280. * @param {String|HTMLElement} target
  281. * @param {Object} options
  282. * @returns Text copied.
  283. */
  284. }, {
  285. key: "defaultText",
  286. /**
  287. * Default `text` lookup function.
  288. * @param {Element} trigger
  289. */
  290. value: function defaultText(trigger) {
  291. return getAttributeValue('text', trigger);
  292. }
  293. /**
  294. * Destroy lifecycle.
  295. */
  296. }, {
  297. key: "destroy",
  298. value: function destroy() {
  299. this.listener.destroy();
  300. }
  301. }], [{
  302. key: "copy",
  303. value: function copy(target) {
  304. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  305. container: document.body
  306. };
  307. return actions_copy(target, options);
  308. }
  309. /**
  310. * Allow fire programmatically a cut action
  311. * @param {String|HTMLElement} target
  312. * @returns Text cutted.
  313. */
  314. }, {
  315. key: "cut",
  316. value: function cut(target) {
  317. return actions_cut(target);
  318. }
  319. /**
  320. * Returns the support of the given action, or all actions if no action is
  321. * given.
  322. * @param {String} [action]
  323. */
  324. }, {
  325. key: "isSupported",
  326. value: function isSupported() {
  327. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  328. var actions = typeof action === 'string' ? [action] : action;
  329. var support = !!document.queryCommandSupported;
  330. actions.forEach(function (action) {
  331. support = support && !!document.queryCommandSupported(action);
  332. });
  333. return support;
  334. }
  335. }]);
  336. return Clipboard;
  337. }((tiny_emitter_default()));
  338. /* harmony default export */ var clipboard = (Clipboard);
  339. /***/ }),
  340. /***/ 828:
  341. /***/ (function(module) {
  342. var DOCUMENT_NODE_TYPE = 9;
  343. /**
  344. * A polyfill for Element.matches()
  345. */
  346. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  347. var proto = Element.prototype;
  348. proto.matches = proto.matchesSelector ||
  349. proto.mozMatchesSelector ||
  350. proto.msMatchesSelector ||
  351. proto.oMatchesSelector ||
  352. proto.webkitMatchesSelector;
  353. }
  354. /**
  355. * Finds the closest parent that matches a selector.
  356. *
  357. * @param {Element} element
  358. * @param {String} selector
  359. * @return {Function}
  360. */
  361. function closest (element, selector) {
  362. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  363. if (typeof element.matches === 'function' &&
  364. element.matches(selector)) {
  365. return element;
  366. }
  367. element = element.parentNode;
  368. }
  369. }
  370. module.exports = closest;
  371. /***/ }),
  372. /***/ 438:
  373. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  374. var closest = __webpack_require__(828);
  375. /**
  376. * Delegates event to a selector.
  377. *
  378. * @param {Element} element
  379. * @param {String} selector
  380. * @param {String} type
  381. * @param {Function} callback
  382. * @param {Boolean} useCapture
  383. * @return {Object}
  384. */
  385. function _delegate(element, selector, type, callback, useCapture) {
  386. var listenerFn = listener.apply(this, arguments);
  387. element.addEventListener(type, listenerFn, useCapture);
  388. return {
  389. destroy: function() {
  390. element.removeEventListener(type, listenerFn, useCapture);
  391. }
  392. }
  393. }
  394. /**
  395. * Delegates event to a selector.
  396. *
  397. * @param {Element|String|Array} [elements]
  398. * @param {String} selector
  399. * @param {String} type
  400. * @param {Function} callback
  401. * @param {Boolean} useCapture
  402. * @return {Object}
  403. */
  404. function delegate(elements, selector, type, callback, useCapture) {
  405. // Handle the regular Element usage
  406. if (typeof elements.addEventListener === 'function') {
  407. return _delegate.apply(null, arguments);
  408. }
  409. // Handle Element-less usage, it defaults to global delegation
  410. if (typeof type === 'function') {
  411. // Use `document` as the first parameter, then apply arguments
  412. // This is a short way to .unshift `arguments` without running into deoptimizations
  413. return _delegate.bind(null, document).apply(null, arguments);
  414. }
  415. // Handle Selector-based usage
  416. if (typeof elements === 'string') {
  417. elements = document.querySelectorAll(elements);
  418. }
  419. // Handle Array-like based usage
  420. return Array.prototype.map.call(elements, function (element) {
  421. return _delegate(element, selector, type, callback, useCapture);
  422. });
  423. }
  424. /**
  425. * Finds closest match and invokes callback.
  426. *
  427. * @param {Element} element
  428. * @param {String} selector
  429. * @param {String} type
  430. * @param {Function} callback
  431. * @return {Function}
  432. */
  433. function listener(element, selector, type, callback) {
  434. return function(e) {
  435. e.delegateTarget = closest(e.target, selector);
  436. if (e.delegateTarget) {
  437. callback.call(element, e);
  438. }
  439. }
  440. }
  441. module.exports = delegate;
  442. /***/ }),
  443. /***/ 879:
  444. /***/ (function(__unused_webpack_module, exports) {
  445. /**
  446. * Check if argument is a HTML element.
  447. *
  448. * @param {Object} value
  449. * @return {Boolean}
  450. */
  451. exports.node = function(value) {
  452. return value !== undefined
  453. && value instanceof HTMLElement
  454. && value.nodeType === 1;
  455. };
  456. /**
  457. * Check if argument is a list of HTML elements.
  458. *
  459. * @param {Object} value
  460. * @return {Boolean}
  461. */
  462. exports.nodeList = function(value) {
  463. var type = Object.prototype.toString.call(value);
  464. return value !== undefined
  465. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  466. && ('length' in value)
  467. && (value.length === 0 || exports.node(value[0]));
  468. };
  469. /**
  470. * Check if argument is a string.
  471. *
  472. * @param {Object} value
  473. * @return {Boolean}
  474. */
  475. exports.string = function(value) {
  476. return typeof value === 'string'
  477. || value instanceof String;
  478. };
  479. /**
  480. * Check if argument is a function.
  481. *
  482. * @param {Object} value
  483. * @return {Boolean}
  484. */
  485. exports.fn = function(value) {
  486. var type = Object.prototype.toString.call(value);
  487. return type === '[object Function]';
  488. };
  489. /***/ }),
  490. /***/ 370:
  491. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  492. var is = __webpack_require__(879);
  493. var delegate = __webpack_require__(438);
  494. /**
  495. * Validates all params and calls the right
  496. * listener function based on its target type.
  497. *
  498. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  499. * @param {String} type
  500. * @param {Function} callback
  501. * @return {Object}
  502. */
  503. function listen(target, type, callback) {
  504. if (!target && !type && !callback) {
  505. throw new Error('Missing required arguments');
  506. }
  507. if (!is.string(type)) {
  508. throw new TypeError('Second argument must be a String');
  509. }
  510. if (!is.fn(callback)) {
  511. throw new TypeError('Third argument must be a Function');
  512. }
  513. if (is.node(target)) {
  514. return listenNode(target, type, callback);
  515. }
  516. else if (is.nodeList(target)) {
  517. return listenNodeList(target, type, callback);
  518. }
  519. else if (is.string(target)) {
  520. return listenSelector(target, type, callback);
  521. }
  522. else {
  523. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  524. }
  525. }
  526. /**
  527. * Adds an event listener to a HTML element
  528. * and returns a remove listener function.
  529. *
  530. * @param {HTMLElement} node
  531. * @param {String} type
  532. * @param {Function} callback
  533. * @return {Object}
  534. */
  535. function listenNode(node, type, callback) {
  536. node.addEventListener(type, callback);
  537. return {
  538. destroy: function() {
  539. node.removeEventListener(type, callback);
  540. }
  541. }
  542. }
  543. /**
  544. * Add an event listener to a list of HTML elements
  545. * and returns a remove listener function.
  546. *
  547. * @param {NodeList|HTMLCollection} nodeList
  548. * @param {String} type
  549. * @param {Function} callback
  550. * @return {Object}
  551. */
  552. function listenNodeList(nodeList, type, callback) {
  553. Array.prototype.forEach.call(nodeList, function(node) {
  554. node.addEventListener(type, callback);
  555. });
  556. return {
  557. destroy: function() {
  558. Array.prototype.forEach.call(nodeList, function(node) {
  559. node.removeEventListener(type, callback);
  560. });
  561. }
  562. }
  563. }
  564. /**
  565. * Add an event listener to a selector
  566. * and returns a remove listener function.
  567. *
  568. * @param {String} selector
  569. * @param {String} type
  570. * @param {Function} callback
  571. * @return {Object}
  572. */
  573. function listenSelector(selector, type, callback) {
  574. return delegate(document.body, selector, type, callback);
  575. }
  576. module.exports = listen;
  577. /***/ }),
  578. /***/ 817:
  579. /***/ (function(module) {
  580. function select(element) {
  581. var selectedText;
  582. if (element.nodeName === 'SELECT') {
  583. element.focus();
  584. selectedText = element.value;
  585. }
  586. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  587. var isReadOnly = element.hasAttribute('readonly');
  588. if (!isReadOnly) {
  589. element.setAttribute('readonly', '');
  590. }
  591. element.select();
  592. element.setSelectionRange(0, element.value.length);
  593. if (!isReadOnly) {
  594. element.removeAttribute('readonly');
  595. }
  596. selectedText = element.value;
  597. }
  598. else {
  599. if (element.hasAttribute('contenteditable')) {
  600. element.focus();
  601. }
  602. var selection = window.getSelection();
  603. var range = document.createRange();
  604. range.selectNodeContents(element);
  605. selection.removeAllRanges();
  606. selection.addRange(range);
  607. selectedText = selection.toString();
  608. }
  609. return selectedText;
  610. }
  611. module.exports = select;
  612. /***/ }),
  613. /***/ 279:
  614. /***/ (function(module) {
  615. function E () {
  616. // Keep this empty so it's easier to inherit from
  617. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  618. }
  619. E.prototype = {
  620. on: function (name, callback, ctx) {
  621. var e = this.e || (this.e = {});
  622. (e[name] || (e[name] = [])).push({
  623. fn: callback,
  624. ctx: ctx
  625. });
  626. return this;
  627. },
  628. once: function (name, callback, ctx) {
  629. var self = this;
  630. function listener () {
  631. self.off(name, listener);
  632. callback.apply(ctx, arguments);
  633. };
  634. listener._ = callback
  635. return this.on(name, listener, ctx);
  636. },
  637. emit: function (name) {
  638. var data = [].slice.call(arguments, 1);
  639. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  640. var i = 0;
  641. var len = evtArr.length;
  642. for (i; i < len; i++) {
  643. evtArr[i].fn.apply(evtArr[i].ctx, data);
  644. }
  645. return this;
  646. },
  647. off: function (name, callback) {
  648. var e = this.e || (this.e = {});
  649. var evts = e[name];
  650. var liveEvents = [];
  651. if (evts && callback) {
  652. for (var i = 0, len = evts.length; i < len; i++) {
  653. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  654. liveEvents.push(evts[i]);
  655. }
  656. }
  657. // Remove event from queue to prevent memory leak
  658. // Suggested by https://github.com/lazd
  659. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  660. (liveEvents.length)
  661. ? e[name] = liveEvents
  662. : delete e[name];
  663. return this;
  664. }
  665. };
  666. module.exports = E;
  667. module.exports.TinyEmitter = E;
  668. /***/ })
  669. /******/ });
  670. /************************************************************************/
  671. /******/ // The module cache
  672. /******/ var __webpack_module_cache__ = {};
  673. /******/
  674. /******/ // The require function
  675. /******/ function __webpack_require__(moduleId) {
  676. /******/ // Check if module is in cache
  677. /******/ if(__webpack_module_cache__[moduleId]) {
  678. /******/ return __webpack_module_cache__[moduleId].exports;
  679. /******/ }
  680. /******/ // Create a new module (and put it into the cache)
  681. /******/ var module = __webpack_module_cache__[moduleId] = {
  682. /******/ // no module.id needed
  683. /******/ // no module.loaded needed
  684. /******/ exports: {}
  685. /******/ };
  686. /******/
  687. /******/ // Execute the module function
  688. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  689. /******/
  690. /******/ // Return the exports of the module
  691. /******/ return module.exports;
  692. /******/ }
  693. /******/
  694. /************************************************************************/
  695. /******/ /* webpack/runtime/compat get default export */
  696. /******/ !function() {
  697. /******/ // getDefaultExport function for compatibility with non-harmony modules
  698. /******/ __webpack_require__.n = function(module) {
  699. /******/ var getter = module && module.__esModule ?
  700. /******/ function() { return module['default']; } :
  701. /******/ function() { return module; };
  702. /******/ __webpack_require__.d(getter, { a: getter });
  703. /******/ return getter;
  704. /******/ };
  705. /******/ }();
  706. /******/
  707. /******/ /* webpack/runtime/define property getters */
  708. /******/ !function() {
  709. /******/ // define getter functions for harmony exports
  710. /******/ __webpack_require__.d = function(exports, definition) {
  711. /******/ for(var key in definition) {
  712. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  713. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  714. /******/ }
  715. /******/ }
  716. /******/ };
  717. /******/ }();
  718. /******/
  719. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  720. /******/ !function() {
  721. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  722. /******/ }();
  723. /******/
  724. /************************************************************************/
  725. /******/ // module exports must be returned from runtime so entry inlining is disabled
  726. /******/ // startup
  727. /******/ // Load entry module and return exports
  728. /******/ return __webpack_require__(686);
  729. /******/ })()
  730. .default;
  731. });