懒羊羊
2023-08-30 1ac2bc1590406d9babec036e154d8d08f34a6aa1
提交 | 用户 | 时间
1ac2bc 1 /*!
2  * clipboard.js v2.0.4
3  * https://zenorocha.github.io/clipboard.js
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 if (window.layui && layui.define) {  // layui加载
15         layui.define(function (exports) {
16             exports('ClipboardJS', factory());
17         });
18     } else {
19         root["ClipboardJS"] = factory();
20     }
21 })(this, function () {
22     return /******/ (function (modules) { // webpackBootstrap
23         /******/     // The module cache
24         /******/
25         var installedModules = {};
26         /******/
27         /******/     // The require function
28         /******/
29         function __webpack_require__(moduleId) {
30             /******/
31             /******/         // Check if module is in cache
32             /******/
33             if (installedModules[moduleId]) {
34                 /******/
35                 return installedModules[moduleId].exports;
36                 /******/
37             }
38             /******/         // Create a new module (and put it into the cache)
39             /******/
40             var module = installedModules[moduleId] = {
41                 /******/            i: moduleId,
42                 /******/            l: false,
43                 /******/            exports: {}
44                 /******/
45             };
46             /******/
47             /******/         // Execute the module function
48             /******/
49             modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
50             /******/
51             /******/         // Flag the module as loaded
52             /******/
53             module.l = true;
54             /******/
55             /******/         // Return the exports of the module
56             /******/
57             return module.exports;
58             /******/
59         }
60
61         /******/
62         /******/
63         /******/     // expose the modules object (__webpack_modules__)
64         /******/
65         __webpack_require__.m = modules;
66         /******/
67         /******/     // expose the module cache
68         /******/
69         __webpack_require__.c = installedModules;
70         /******/
71         /******/     // define getter function for harmony exports
72         /******/
73         __webpack_require__.d = function (exports, name, getter) {
74             /******/
75             if (!__webpack_require__.o(exports, name)) {
76                 /******/
77                 Object.defineProperty(exports, name, {enumerable: true, get: getter});
78                 /******/
79             }
80             /******/
81         };
82         /******/
83         /******/     // define __esModule on exports
84         /******/
85         __webpack_require__.r = function (exports) {
86             /******/
87             if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
88                 /******/
89                 Object.defineProperty(exports, Symbol.toStringTag, {value: 'Module'});
90                 /******/
91             }
92             /******/
93             Object.defineProperty(exports, '__esModule', {value: true});
94             /******/
95         };
96         /******/
97         /******/     // create a fake namespace object
98         /******/     // mode & 1: value is a module id, require it
99         /******/     // mode & 2: merge all properties of value into the ns
100         /******/     // mode & 4: return value when already ns object
101         /******/     // mode & 8|1: behave like require
102         /******/
103         __webpack_require__.t = function (value, mode) {
104             /******/
105             if (mode & 1) value = __webpack_require__(value);
106             /******/
107             if (mode & 8) return value;
108             /******/
109             if ((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
110             /******/
111             var ns = Object.create(null);
112             /******/
113             __webpack_require__.r(ns);
114             /******/
115             Object.defineProperty(ns, 'default', {enumerable: true, value: value});
116             /******/
117             if (mode & 2 && typeof value != 'string') for (var key in value) __webpack_require__.d(ns, key, function (key) {
118                 return value[key];
119             }.bind(null, key));
120             /******/
121             return ns;
122             /******/
123         };
124         /******/
125         /******/     // getDefaultExport function for compatibility with non-harmony modules
126         /******/
127         __webpack_require__.n = function (module) {
128             /******/
129             var getter = module && module.__esModule ?
130                 /******/            function getDefault() {
131                     return module['default'];
132                 } :
133                 /******/            function getModuleExports() {
134                     return module;
135                 };
136             /******/
137             __webpack_require__.d(getter, 'a', getter);
138             /******/
139             return getter;
140             /******/
141         };
142         /******/
143         /******/     // Object.prototype.hasOwnProperty.call
144         /******/
145         __webpack_require__.o = function (object, property) {
146             return Object.prototype.hasOwnProperty.call(object, property);
147         };
148         /******/
149         /******/     // __webpack_public_path__
150         /******/
151         __webpack_require__.p = "";
152         /******/
153         /******/
154         /******/     // Load entry module and return exports
155         /******/
156         return __webpack_require__(__webpack_require__.s = 0);
157         /******/
158     })
159     /************************************************************************/
160     /******/([
161         /* 0 */
162         /***/ (function (module, exports, __webpack_require__) {
163
164             "use strict";
165
166
167             var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
168                 return typeof obj;
169             } : function (obj) {
170                 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
171             };
172
173             var _createClass = function () {
174                 function defineProperties(target, props) {
175                     for (var i = 0; i < props.length; i++) {
176                         var descriptor = props[i];
177                         descriptor.enumerable = descriptor.enumerable || false;
178                         descriptor.configurable = true;
179                         if ("value" in descriptor) descriptor.writable = true;
180                         Object.defineProperty(target, descriptor.key, descriptor);
181                     }
182                 }
183
184                 return function (Constructor, protoProps, staticProps) {
185                     if (protoProps) defineProperties(Constructor.prototype, protoProps);
186                     if (staticProps) defineProperties(Constructor, staticProps);
187                     return Constructor;
188                 };
189             }();
190
191             var _clipboardAction = __webpack_require__(1);
192
193             var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
194
195             var _tinyEmitter = __webpack_require__(3);
196
197             var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
198
199             var _goodListener = __webpack_require__(4);
200
201             var _goodListener2 = _interopRequireDefault(_goodListener);
202
203             function _interopRequireDefault(obj) {
204                 return obj && obj.__esModule ? obj : {default: obj};
205             }
206
207             function _classCallCheck(instance, Constructor) {
208                 if (!(instance instanceof Constructor)) {
209                     throw new TypeError("Cannot call a class as a function");
210                 }
211             }
212
213             function _possibleConstructorReturn(self, call) {
214                 if (!self) {
215                     throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
216                 }
217                 return call && (typeof call === "object" || typeof call === "function") ? call : self;
218             }
219
220             function _inherits(subClass, superClass) {
221                 if (typeof superClass !== "function" && superClass !== null) {
222                     throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
223                 }
224                 subClass.prototype = Object.create(superClass && superClass.prototype, {
225                     constructor: {
226                         value: subClass,
227                         enumerable: false,
228                         writable: true,
229                         configurable: true
230                     }
231                 });
232                 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
233             }
234
235             /**
236              * Base class which takes one or more elements, adds event listeners to them,
237              * and instantiates a new `ClipboardAction` on each click.
238              */
239             var Clipboard = function (_Emitter) {
240                 _inherits(Clipboard, _Emitter);
241
242                 /**
243                  * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
244                  * @param {Object} options
245                  */
246                 function Clipboard(trigger, options) {
247                     _classCallCheck(this, Clipboard);
248
249                     var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
250
251                     _this.resolveOptions(options);
252                     _this.listenClick(trigger);
253                     return _this;
254                 }
255
256                 /**
257                  * Defines if attributes would be resolved using internal setter functions
258                  * or custom functions that were passed in the constructor.
259                  * @param {Object} options
260                  */
261
262
263                 _createClass(Clipboard, [{
264                     key: 'resolveOptions',
265                     value: function resolveOptions() {
266                         var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
267
268                         this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
269                         this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
270                         this.text = typeof options.text === 'function' ? options.text : this.defaultText;
271                         this.container = _typeof(options.container) === 'object' ? options.container : document.body;
272                     }
273
274                     /**
275                      * Adds a click event listener to the passed trigger.
276                      * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
277                      */
278
279                 }, {
280                     key: 'listenClick',
281                     value: function listenClick(trigger) {
282                         var _this2 = this;
283
284                         this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
285                             return _this2.onClick(e);
286                         });
287                     }
288
289                     /**
290                      * Defines a new `ClipboardAction` on each click event.
291                      * @param {Event} e
292                      */
293
294                 }, {
295                     key: 'onClick',
296                     value: function onClick(e) {
297                         var trigger = e.delegateTarget || e.currentTarget;
298
299                         if (this.clipboardAction) {
300                             this.clipboardAction = null;
301                         }
302
303                         this.clipboardAction = new _clipboardAction2.default({
304                             action: this.action(trigger),
305                             target: this.target(trigger),
306                             text: this.text(trigger),
307                             container: this.container,
308                             trigger: trigger,
309                             emitter: this
310                         });
311                     }
312
313                     /**
314                      * Default `action` lookup function.
315                      * @param {Element} trigger
316                      */
317
318                 }, {
319                     key: 'defaultAction',
320                     value: function defaultAction(trigger) {
321                         return getAttributeValue('action', trigger);
322                     }
323
324                     /**
325                      * Default `target` lookup function.
326                      * @param {Element} trigger
327                      */
328
329                 }, {
330                     key: 'defaultTarget',
331                     value: function defaultTarget(trigger) {
332                         var selector = getAttributeValue('target', trigger);
333
334                         if (selector) {
335                             return document.querySelector(selector);
336                         }
337                     }
338
339                     /**
340                      * Returns the support of the given action, or all actions if no action is
341                      * given.
342                      * @param {String} [action]
343                      */
344
345                 }, {
346                     key: 'defaultText',
347
348
349                     /**
350                      * Default `text` lookup function.
351                      * @param {Element} trigger
352                      */
353                     value: function defaultText(trigger) {
354                         return getAttributeValue('text', trigger);
355                     }
356
357                     /**
358                      * Destroy lifecycle.
359                      */
360
361                 }, {
362                     key: 'destroy',
363                     value: function destroy() {
364                         this.listener.destroy();
365
366                         if (this.clipboardAction) {
367                             this.clipboardAction.destroy();
368                             this.clipboardAction = null;
369                         }
370                     }
371                 }], [{
372                     key: 'isSupported',
373                     value: function isSupported() {
374                         var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
375
376                         var actions = typeof action === 'string' ? [action] : action;
377                         var support = !!document.queryCommandSupported;
378
379                         actions.forEach(function (action) {
380                             support = support && !!document.queryCommandSupported(action);
381                         });
382
383                         return support;
384                     }
385                 }]);
386
387                 return Clipboard;
388             }(_tinyEmitter2.default);
389
390             /**
391              * Helper function to retrieve attribute value.
392              * @param {String} suffix
393              * @param {Element} element
394              */
395
396
397             function getAttributeValue(suffix, element) {
398                 var attribute = 'data-clipboard-' + suffix;
399
400                 if (!element.hasAttribute(attribute)) {
401                     return;
402                 }
403
404                 return element.getAttribute(attribute);
405             }
406
407             module.exports = Clipboard;
408
409             /***/
410         }),
411         /* 1 */
412         /***/ (function (module, exports, __webpack_require__) {
413
414             "use strict";
415
416
417             var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
418                 return typeof obj;
419             } : function (obj) {
420                 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
421             };
422
423             var _createClass = function () {
424                 function defineProperties(target, props) {
425                     for (var i = 0; i < props.length; i++) {
426                         var descriptor = props[i];
427                         descriptor.enumerable = descriptor.enumerable || false;
428                         descriptor.configurable = true;
429                         if ("value" in descriptor) descriptor.writable = true;
430                         Object.defineProperty(target, descriptor.key, descriptor);
431                     }
432                 }
433
434                 return function (Constructor, protoProps, staticProps) {
435                     if (protoProps) defineProperties(Constructor.prototype, protoProps);
436                     if (staticProps) defineProperties(Constructor, staticProps);
437                     return Constructor;
438                 };
439             }();
440
441             var _select = __webpack_require__(2);
442
443             var _select2 = _interopRequireDefault(_select);
444
445             function _interopRequireDefault(obj) {
446                 return obj && obj.__esModule ? obj : {default: obj};
447             }
448
449             function _classCallCheck(instance, Constructor) {
450                 if (!(instance instanceof Constructor)) {
451                     throw new TypeError("Cannot call a class as a function");
452                 }
453             }
454
455             /**
456              * Inner class which performs selection from either `text` or `target`
457              * properties and then executes copy or cut operations.
458              */
459             var ClipboardAction = function () {
460                 /**
461                  * @param {Object} options
462                  */
463                 function ClipboardAction(options) {
464                     _classCallCheck(this, ClipboardAction);
465
466                     this.resolveOptions(options);
467                     this.initSelection();
468                 }
469
470                 /**
471                  * Defines base properties passed from constructor.
472                  * @param {Object} options
473                  */
474
475
476                 _createClass(ClipboardAction, [{
477                     key: 'resolveOptions',
478                     value: function resolveOptions() {
479                         var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
480
481                         this.action = options.action;
482                         this.container = options.container;
483                         this.emitter = options.emitter;
484                         this.target = options.target;
485                         this.text = options.text;
486                         this.trigger = options.trigger;
487
488                         this.selectedText = '';
489                     }
490
491                     /**
492                      * Decides which selection strategy is going to be applied based
493                      * on the existence of `text` and `target` properties.
494                      */
495
496                 }, {
497                     key: 'initSelection',
498                     value: function initSelection() {
499                         if (this.text) {
500                             this.selectFake();
501                         } else if (this.target) {
502                             this.selectTarget();
503                         }
504                     }
505
506                     /**
507                      * Creates a fake textarea element, sets its value from `text` property,
508                      * and makes a selection on it.
509                      */
510
511                 }, {
512                     key: 'selectFake',
513                     value: function selectFake() {
514                         var _this = this;
515
516                         var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
517
518                         this.removeFake();
519
520                         this.fakeHandlerCallback = function () {
521                             return _this.removeFake();
522                         };
523                         this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
524
525                         this.fakeElem = document.createElement('textarea');
526                         // Prevent zooming on iOS
527                         this.fakeElem.style.fontSize = '12pt';
528                         // Reset box model
529                         this.fakeElem.style.border = '0';
530                         this.fakeElem.style.padding = '0';
531                         this.fakeElem.style.margin = '0';
532                         // Move element out of screen horizontally
533                         this.fakeElem.style.position = 'absolute';
534                         this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
535                         // Move element to the same position vertically
536                         var yPosition = window.pageYOffset || document.documentElement.scrollTop;
537                         this.fakeElem.style.top = yPosition + 'px';
538
539                         this.fakeElem.setAttribute('readonly', '');
540                         this.fakeElem.value = this.text;
541
542                         this.container.appendChild(this.fakeElem);
543
544                         this.selectedText = (0, _select2.default)(this.fakeElem);
545                         this.copyText();
546                     }
547
548                     /**
549                      * Only removes the fake element after another click event, that way
550                      * a user can hit `Ctrl+C` to copy because selection still exists.
551                      */
552
553                 }, {
554                     key: 'removeFake',
555                     value: function removeFake() {
556                         if (this.fakeHandler) {
557                             this.container.removeEventListener('click', this.fakeHandlerCallback);
558                             this.fakeHandler = null;
559                             this.fakeHandlerCallback = null;
560                         }
561
562                         if (this.fakeElem) {
563                             this.container.removeChild(this.fakeElem);
564                             this.fakeElem = null;
565                         }
566                     }
567
568                     /**
569                      * Selects the content from element passed on `target` property.
570                      */
571
572                 }, {
573                     key: 'selectTarget',
574                     value: function selectTarget() {
575                         this.selectedText = (0, _select2.default)(this.target);
576                         this.copyText();
577                     }
578
579                     /**
580                      * Executes the copy operation based on the current selection.
581                      */
582
583                 }, {
584                     key: 'copyText',
585                     value: function copyText() {
586                         var succeeded = void 0;
587
588                         try {
589                             succeeded = document.execCommand(this.action);
590                         } catch (err) {
591                             succeeded = false;
592                         }
593
594                         this.handleResult(succeeded);
595                     }
596
597                     /**
598                      * Fires an event based on the copy operation result.
599                      * @param {Boolean} succeeded
600                      */
601
602                 }, {
603                     key: 'handleResult',
604                     value: function handleResult(succeeded) {
605                         this.emitter.emit(succeeded ? 'success' : 'error', {
606                             action: this.action,
607                             text: this.selectedText,
608                             trigger: this.trigger,
609                             clearSelection: this.clearSelection.bind(this)
610                         });
611                     }
612
613                     /**
614                      * Moves focus away from `target` and back to the trigger, removes current selection.
615                      */
616
617                 }, {
618                     key: 'clearSelection',
619                     value: function clearSelection() {
620                         if (this.trigger) {
621                             this.trigger.focus();
622                         }
623
624                         window.getSelection().removeAllRanges();
625                     }
626
627                     /**
628                      * Sets the `action` to be performed which can be either 'copy' or 'cut'.
629                      * @param {String} action
630                      */
631
632                 }, {
633                     key: 'destroy',
634
635
636                     /**
637                      * Destroy lifecycle.
638                      */
639                     value: function destroy() {
640                         this.removeFake();
641                     }
642                 }, {
643                     key: 'action',
644                     set: function set() {
645                         var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
646
647                         this._action = action;
648
649                         if (this._action !== 'copy' && this._action !== 'cut') {
650                             throw new Error('Invalid "action" value, use either "copy" or "cut"');
651                         }
652                     }
653
654                     /**
655                      * Gets the `action` property.
656                      * @return {String}
657                      */
658                     ,
659                     get: function get() {
660                         return this._action;
661                     }
662
663                     /**
664                      * Sets the `target` property using an element
665                      * that will be have its content copied.
666                      * @param {Element} target
667                      */
668
669                 }, {
670                     key: 'target',
671                     set: function set(target) {
672                         if (target !== undefined) {
673                             if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
674                                 if (this.action === 'copy' && target.hasAttribute('disabled')) {
675                                     throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
676                                 }
677
678                                 if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
679                                     throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
680                                 }
681
682                                 this._target = target;
683                             } else {
684                                 throw new Error('Invalid "target" value, use a valid Element');
685                             }
686                         }
687                     }
688
689                     /**
690                      * Gets the `target` property.
691                      * @return {String|HTMLElement}
692                      */
693                     ,
694                     get: function get() {
695                         return this._target;
696                     }
697                 }]);
698
699                 return ClipboardAction;
700             }();
701
702             module.exports = ClipboardAction;
703
704             /***/
705         }),
706         /* 2 */
707         /***/ (function (module, exports) {
708
709             function select(element) {
710                 var selectedText;
711
712                 if (element.nodeName === 'SELECT') {
713                     element.focus();
714
715                     selectedText = element.value;
716                 }
717                 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
718                     var isReadOnly = element.hasAttribute('readonly');
719
720                     if (!isReadOnly) {
721                         element.setAttribute('readonly', '');
722                     }
723
724                     element.select();
725                     element.setSelectionRange(0, element.value.length);
726
727                     if (!isReadOnly) {
728                         element.removeAttribute('readonly');
729                     }
730
731                     selectedText = element.value;
732                 }
733                 else {
734                     if (element.hasAttribute('contenteditable')) {
735                         element.focus();
736                     }
737
738                     var selection = window.getSelection();
739                     var range = document.createRange();
740
741                     range.selectNodeContents(element);
742                     selection.removeAllRanges();
743                     selection.addRange(range);
744
745                     selectedText = selection.toString();
746                 }
747
748                 return selectedText;
749             }
750
751             module.exports = select;
752
753
754             /***/
755         }),
756         /* 3 */
757         /***/ (function (module, exports) {
758
759             function E() {
760                 // Keep this empty so it's easier to inherit from
761                 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
762             }
763
764             E.prototype = {
765                 on: function (name, callback, ctx) {
766                     var e = this.e || (this.e = {});
767
768                     (e[name] || (e[name] = [])).push({
769                         fn: callback,
770                         ctx: ctx
771                     });
772
773                     return this;
774                 },
775
776                 once: function (name, callback, ctx) {
777                     var self = this;
778
779                     function listener() {
780                         self.off(name, listener);
781                         callback.apply(ctx, arguments);
782                     };
783
784                     listener._ = callback
785                     return this.on(name, listener, ctx);
786                 },
787
788                 emit: function (name) {
789                     var data = [].slice.call(arguments, 1);
790                     var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
791                     var i = 0;
792                     var len = evtArr.length;
793
794                     for (i; i < len; i++) {
795                         evtArr[i].fn.apply(evtArr[i].ctx, data);
796                     }
797
798                     return this;
799                 },
800
801                 off: function (name, callback) {
802                     var e = this.e || (this.e = {});
803                     var evts = e[name];
804                     var liveEvents = [];
805
806                     if (evts && callback) {
807                         for (var i = 0, len = evts.length; i < len; i++) {
808                             if (evts[i].fn !== callback && evts[i].fn._ !== callback)
809                                 liveEvents.push(evts[i]);
810                         }
811                     }
812
813                     // Remove event from queue to prevent memory leak
814                     // Suggested by https://github.com/lazd
815                     // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
816
817                     (liveEvents.length)
818                         ? e[name] = liveEvents
819                         : delete e[name];
820
821                     return this;
822                 }
823             };
824
825             module.exports = E;
826
827
828             /***/
829         }),
830         /* 4 */
831         /***/ (function (module, exports, __webpack_require__) {
832
833             var is = __webpack_require__(5);
834             var delegate = __webpack_require__(6);
835
836             /**
837              * Validates all params and calls the right
838              * listener function based on its target type.
839              *
840              * @param {String|HTMLElement|HTMLCollection|NodeList} target
841              * @param {String} type
842              * @param {Function} callback
843              * @return {Object}
844              */
845             function listen(target, type, callback) {
846                 if (!target && !type && !callback) {
847                     throw new Error('Missing required arguments');
848                 }
849
850                 if (!is.string(type)) {
851                     throw new TypeError('Second argument must be a String');
852                 }
853
854                 if (!is.fn(callback)) {
855                     throw new TypeError('Third argument must be a Function');
856                 }
857
858                 if (is.node(target)) {
859                     return listenNode(target, type, callback);
860                 }
861                 else if (is.nodeList(target)) {
862                     return listenNodeList(target, type, callback);
863                 }
864                 else if (is.string(target)) {
865                     return listenSelector(target, type, callback);
866                 }
867                 else {
868                     throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
869                 }
870             }
871
872             /**
873              * Adds an event listener to a HTML element
874              * and returns a remove listener function.
875              *
876              * @param {HTMLElement} node
877              * @param {String} type
878              * @param {Function} callback
879              * @return {Object}
880              */
881             function listenNode(node, type, callback) {
882                 node.addEventListener(type, callback);
883
884                 return {
885                     destroy: function () {
886                         node.removeEventListener(type, callback);
887                     }
888                 }
889             }
890
891             /**
892              * Add an event listener to a list of HTML elements
893              * and returns a remove listener function.
894              *
895              * @param {NodeList|HTMLCollection} nodeList
896              * @param {String} type
897              * @param {Function} callback
898              * @return {Object}
899              */
900             function listenNodeList(nodeList, type, callback) {
901                 Array.prototype.forEach.call(nodeList, function (node) {
902                     node.addEventListener(type, callback);
903                 });
904
905                 return {
906                     destroy: function () {
907                         Array.prototype.forEach.call(nodeList, function (node) {
908                             node.removeEventListener(type, callback);
909                         });
910                     }
911                 }
912             }
913
914             /**
915              * Add an event listener to a selector
916              * and returns a remove listener function.
917              *
918              * @param {String} selector
919              * @param {String} type
920              * @param {Function} callback
921              * @return {Object}
922              */
923             function listenSelector(selector, type, callback) {
924                 return delegate(document.body, selector, type, callback);
925             }
926
927             module.exports = listen;
928
929
930             /***/
931         }),
932         /* 5 */
933         /***/ (function (module, exports) {
934
935             /**
936              * Check if argument is a HTML element.
937              *
938              * @param {Object} value
939              * @return {Boolean}
940              */
941             exports.node = function (value) {
942                 return value !== undefined
943                     && value instanceof HTMLElement
944                     && value.nodeType === 1;
945             };
946
947             /**
948              * Check if argument is a list of HTML elements.
949              *
950              * @param {Object} value
951              * @return {Boolean}
952              */
953             exports.nodeList = function (value) {
954                 var type = Object.prototype.toString.call(value);
955
956                 return value !== undefined
957                     && (type === '[object NodeList]' || type === '[object HTMLCollection]')
958                     && ('length' in value)
959                     && (value.length === 0 || exports.node(value[0]));
960             };
961
962             /**
963              * Check if argument is a string.
964              *
965              * @param {Object} value
966              * @return {Boolean}
967              */
968             exports.string = function (value) {
969                 return typeof value === 'string'
970                     || value instanceof String;
971             };
972
973             /**
974              * Check if argument is a function.
975              *
976              * @param {Object} value
977              * @return {Boolean}
978              */
979             exports.fn = function (value) {
980                 var type = Object.prototype.toString.call(value);
981
982                 return type === '[object Function]';
983             };
984
985
986             /***/
987         }),
988         /* 6 */
989         /***/ (function (module, exports, __webpack_require__) {
990
991             var closest = __webpack_require__(7);
992
993             /**
994              * Delegates event to a selector.
995              *
996              * @param {Element} element
997              * @param {String} selector
998              * @param {String} type
999              * @param {Function} callback
1000              * @param {Boolean} useCapture
1001              * @return {Object}
1002              */
1003             function _delegate(element, selector, type, callback, useCapture) {
1004                 var listenerFn = listener.apply(this, arguments);
1005
1006                 element.addEventListener(type, listenerFn, useCapture);
1007
1008                 return {
1009                     destroy: function () {
1010                         element.removeEventListener(type, listenerFn, useCapture);
1011                     }
1012                 }
1013             }
1014
1015             /**
1016              * Delegates event to a selector.
1017              *
1018              * @param {Element|String|Array} [elements]
1019              * @param {String} selector
1020              * @param {String} type
1021              * @param {Function} callback
1022              * @param {Boolean} useCapture
1023              * @return {Object}
1024              */
1025             function delegate(elements, selector, type, callback, useCapture) {
1026                 // Handle the regular Element usage
1027                 if (typeof elements.addEventListener === 'function') {
1028                     return _delegate.apply(null, arguments);
1029                 }
1030
1031                 // Handle Element-less usage, it defaults to global delegation
1032                 if (typeof type === 'function') {
1033                     // Use `document` as the first parameter, then apply arguments
1034                     // This is a short way to .unshift `arguments` without running into deoptimizations
1035                     return _delegate.bind(null, document).apply(null, arguments);
1036                 }
1037
1038                 // Handle Selector-based usage
1039                 if (typeof elements === 'string') {
1040                     elements = document.querySelectorAll(elements);
1041                 }
1042
1043                 // Handle Array-like based usage
1044                 return Array.prototype.map.call(elements, function (element) {
1045                     return _delegate(element, selector, type, callback, useCapture);
1046                 });
1047             }
1048
1049             /**
1050              * Finds closest match and invokes callback.
1051              *
1052              * @param {Element} element
1053              * @param {String} selector
1054              * @param {String} type
1055              * @param {Function} callback
1056              * @return {Function}
1057              */
1058             function listener(element, selector, type, callback) {
1059                 return function (e) {
1060                     e.delegateTarget = closest(e.target, selector);
1061
1062                     if (e.delegateTarget) {
1063                         callback.call(element, e);
1064                     }
1065                 }
1066             }
1067
1068             module.exports = delegate;
1069
1070
1071             /***/
1072         }),
1073         /* 7 */
1074         /***/ (function (module, exports) {
1075
1076             var DOCUMENT_NODE_TYPE = 9;
1077
1078             /**
1079              * A polyfill for Element.matches()
1080              */
1081             if (typeof Element !== 'undefined' && !Element.prototype.matches) {
1082                 var proto = Element.prototype;
1083
1084                 proto.matches = proto.matchesSelector ||
1085                     proto.mozMatchesSelector ||
1086                     proto.msMatchesSelector ||
1087                     proto.oMatchesSelector ||
1088                     proto.webkitMatchesSelector;
1089             }
1090
1091             /**
1092              * Finds the closest parent that matches a selector.
1093              *
1094              * @param {Element} element
1095              * @param {String} selector
1096              * @return {Function}
1097              */
1098             function closest(element, selector) {
1099                 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
1100                     if (typeof element.matches === 'function' &&
1101                         element.matches(selector)) {
1102                         return element;
1103                     }
1104                     element = element.parentNode;
1105                 }
1106             }
1107
1108             module.exports = closest;
1109
1110
1111             /***/
1112         })
1113         /******/]);
1114 });