1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
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() {
|
18 | var __webpack_modules__ = ({
|
19 |
|
20 | 134:
|
21 | (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
22 |
|
23 | "use strict";
|
24 |
|
25 |
|
26 | __webpack_require__.d(__webpack_exports__, {
|
27 | "default": function() { return clipboard; }
|
28 | });
|
29 |
|
30 |
|
31 | var tiny_emitter = __webpack_require__(279);
|
32 | var tiny_emitter_default = __webpack_require__.n(tiny_emitter);
|
33 |
|
34 | var listen = __webpack_require__(370);
|
35 | var listen_default = __webpack_require__.n(listen);
|
36 |
|
37 | var src_select = __webpack_require__(817);
|
38 | var select_default = __webpack_require__.n(src_select);
|
39 | ;
|
40 | 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); }
|
41 |
|
42 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
43 |
|
44 | 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); } }
|
45 |
|
46 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | var ClipboardAction = function () {
|
55 | |
56 |
|
57 |
|
58 | function ClipboardAction(options) {
|
59 | _classCallCheck(this, ClipboardAction);
|
60 |
|
61 | this.resolveOptions(options);
|
62 | this.initSelection();
|
63 | }
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | _createClass(ClipboardAction, [{
|
71 | key: "resolveOptions",
|
72 | value: function resolveOptions() {
|
73 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
74 | this.action = options.action;
|
75 | this.container = options.container;
|
76 | this.emitter = options.emitter;
|
77 | this.target = options.target;
|
78 | this.text = options.text;
|
79 | this.trigger = options.trigger;
|
80 | this.selectedText = '';
|
81 | }
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 | }, {
|
88 | key: "initSelection",
|
89 | value: function initSelection() {
|
90 | if (this.text) {
|
91 | this.selectFake();
|
92 | } else if (this.target) {
|
93 | this.selectTarget();
|
94 | }
|
95 | }
|
96 | |
97 |
|
98 |
|
99 |
|
100 | }, {
|
101 | key: "createFakeElement",
|
102 | value: function createFakeElement() {
|
103 | var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
104 | this.fakeElem = document.createElement('textarea');
|
105 |
|
106 | this.fakeElem.style.fontSize = '12pt';
|
107 |
|
108 | this.fakeElem.style.border = '0';
|
109 | this.fakeElem.style.padding = '0';
|
110 | this.fakeElem.style.margin = '0';
|
111 |
|
112 | this.fakeElem.style.position = 'absolute';
|
113 | this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
|
114 |
|
115 | var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
116 | this.fakeElem.style.top = "".concat(yPosition, "px");
|
117 | this.fakeElem.setAttribute('readonly', '');
|
118 | this.fakeElem.value = this.text;
|
119 | return this.fakeElem;
|
120 | }
|
121 | |
122 |
|
123 |
|
124 |
|
125 |
|
126 | }, {
|
127 | key: "selectFake",
|
128 | value: function selectFake() {
|
129 | var _this = this;
|
130 |
|
131 | var fakeElem = this.createFakeElement();
|
132 |
|
133 | this.fakeHandlerCallback = function () {
|
134 | return _this.removeFake();
|
135 | };
|
136 |
|
137 | this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
|
138 | this.container.appendChild(fakeElem);
|
139 | this.selectedText = select_default()(fakeElem);
|
140 | this.copyText();
|
141 | this.removeFake();
|
142 | }
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 | }, {
|
149 | key: "removeFake",
|
150 | value: function removeFake() {
|
151 | if (this.fakeHandler) {
|
152 | this.container.removeEventListener('click', this.fakeHandlerCallback);
|
153 | this.fakeHandler = null;
|
154 | this.fakeHandlerCallback = null;
|
155 | }
|
156 |
|
157 | if (this.fakeElem) {
|
158 | this.container.removeChild(this.fakeElem);
|
159 | this.fakeElem = null;
|
160 | }
|
161 | }
|
162 | |
163 |
|
164 |
|
165 |
|
166 | }, {
|
167 | key: "selectTarget",
|
168 | value: function selectTarget() {
|
169 | this.selectedText = select_default()(this.target);
|
170 | this.copyText();
|
171 | }
|
172 | |
173 |
|
174 |
|
175 |
|
176 | }, {
|
177 | key: "copyText",
|
178 | value: function copyText() {
|
179 | var succeeded;
|
180 |
|
181 | try {
|
182 | succeeded = document.execCommand(this.action);
|
183 | } catch (err) {
|
184 | succeeded = false;
|
185 | }
|
186 |
|
187 | this.handleResult(succeeded);
|
188 | }
|
189 | |
190 |
|
191 |
|
192 |
|
193 |
|
194 | }, {
|
195 | key: "handleResult",
|
196 | value: function handleResult(succeeded) {
|
197 | this.emitter.emit(succeeded ? 'success' : 'error', {
|
198 | action: this.action,
|
199 | text: this.selectedText,
|
200 | trigger: this.trigger,
|
201 | clearSelection: this.clearSelection.bind(this)
|
202 | });
|
203 | }
|
204 | |
205 |
|
206 |
|
207 |
|
208 | }, {
|
209 | key: "clearSelection",
|
210 | value: function clearSelection() {
|
211 | if (this.trigger) {
|
212 | this.trigger.focus();
|
213 | }
|
214 |
|
215 | document.activeElement.blur();
|
216 | window.getSelection().removeAllRanges();
|
217 | }
|
218 | |
219 |
|
220 |
|
221 |
|
222 |
|
223 | }, {
|
224 | key: "destroy",
|
225 |
|
226 | |
227 |
|
228 |
|
229 | value: function destroy() {
|
230 | this.removeFake();
|
231 | }
|
232 | }, {
|
233 | key: "action",
|
234 | set: function set() {
|
235 | var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
|
236 | this._action = action;
|
237 |
|
238 | if (this._action !== 'copy' && this._action !== 'cut') {
|
239 | throw new Error('Invalid "action" value, use either "copy" or "cut"');
|
240 | }
|
241 | }
|
242 | |
243 |
|
244 |
|
245 |
|
246 | ,
|
247 | get: function get() {
|
248 | return this._action;
|
249 | }
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | }, {
|
257 | key: "target",
|
258 | set: function set(target) {
|
259 | if (target !== undefined) {
|
260 | if (target && _typeof(target) === 'object' && target.nodeType === 1) {
|
261 | if (this.action === 'copy' && target.hasAttribute('disabled')) {
|
262 | throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
|
263 | }
|
264 |
|
265 | if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
|
266 | throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
|
267 | }
|
268 |
|
269 | this._target = target;
|
270 | } else {
|
271 | throw new Error('Invalid "target" value, use a valid Element');
|
272 | }
|
273 | }
|
274 | }
|
275 | |
276 |
|
277 |
|
278 |
|
279 | ,
|
280 | get: function get() {
|
281 | return this._target;
|
282 | }
|
283 | }]);
|
284 |
|
285 | return ClipboardAction;
|
286 | }();
|
287 |
|
288 | var clipboard_action = (ClipboardAction);
|
289 | ;
|
290 | 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); }
|
291 |
|
292 | function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
293 |
|
294 | function clipboard_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); } }
|
295 |
|
296 | function clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) clipboard_defineProperties(Constructor, staticProps); return Constructor; }
|
297 |
|
298 | 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); }
|
299 |
|
300 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
301 |
|
302 | 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); }; }
|
303 |
|
304 | function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
305 |
|
306 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
307 |
|
308 | 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; } }
|
309 |
|
310 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 | function getAttributeValue(suffix, element) {
|
322 | var attribute = "data-clipboard-".concat(suffix);
|
323 |
|
324 | if (!element.hasAttribute(attribute)) {
|
325 | return;
|
326 | }
|
327 |
|
328 | return element.getAttribute(attribute);
|
329 | }
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 | var Clipboard = function (_Emitter) {
|
337 | _inherits(Clipboard, _Emitter);
|
338 |
|
339 | var _super = _createSuper(Clipboard);
|
340 |
|
341 | |
342 |
|
343 |
|
344 |
|
345 | function Clipboard(trigger, options) {
|
346 | var _this;
|
347 |
|
348 | clipboard_classCallCheck(this, Clipboard);
|
349 |
|
350 | _this = _super.call(this);
|
351 |
|
352 | _this.resolveOptions(options);
|
353 |
|
354 | _this.listenClick(trigger);
|
355 |
|
356 | return _this;
|
357 | }
|
358 | |
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | clipboard_createClass(Clipboard, [{
|
366 | key: "resolveOptions",
|
367 | value: function resolveOptions() {
|
368 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
369 | this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
|
370 | this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
|
371 | this.text = typeof options.text === 'function' ? options.text : this.defaultText;
|
372 | this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
|
373 | }
|
374 | |
375 |
|
376 |
|
377 |
|
378 |
|
379 | }, {
|
380 | key: "listenClick",
|
381 | value: function listenClick(trigger) {
|
382 | var _this2 = this;
|
383 |
|
384 | this.listener = listen_default()(trigger, 'click', function (e) {
|
385 | return _this2.onClick(e);
|
386 | });
|
387 | }
|
388 | |
389 |
|
390 |
|
391 |
|
392 |
|
393 | }, {
|
394 | key: "onClick",
|
395 | value: function onClick(e) {
|
396 | var trigger = e.delegateTarget || e.currentTarget;
|
397 |
|
398 | if (this.clipboardAction) {
|
399 | this.clipboardAction = null;
|
400 | }
|
401 |
|
402 | this.clipboardAction = new clipboard_action({
|
403 | action: this.action(trigger),
|
404 | target: this.target(trigger),
|
405 | text: this.text(trigger),
|
406 | container: this.container,
|
407 | trigger: trigger,
|
408 | emitter: this
|
409 | });
|
410 | }
|
411 | |
412 |
|
413 |
|
414 |
|
415 |
|
416 | }, {
|
417 | key: "defaultAction",
|
418 | value: function defaultAction(trigger) {
|
419 | return getAttributeValue('action', trigger);
|
420 | }
|
421 | |
422 |
|
423 |
|
424 |
|
425 |
|
426 | }, {
|
427 | key: "defaultTarget",
|
428 | value: function defaultTarget(trigger) {
|
429 | var selector = getAttributeValue('target', trigger);
|
430 |
|
431 | if (selector) {
|
432 | return document.querySelector(selector);
|
433 | }
|
434 | }
|
435 | |
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 | }, {
|
442 | key: "defaultText",
|
443 |
|
444 | |
445 |
|
446 |
|
447 |
|
448 | value: function defaultText(trigger) {
|
449 | return getAttributeValue('text', trigger);
|
450 | }
|
451 | |
452 |
|
453 |
|
454 |
|
455 | }, {
|
456 | key: "destroy",
|
457 | value: function destroy() {
|
458 | this.listener.destroy();
|
459 |
|
460 | if (this.clipboardAction) {
|
461 | this.clipboardAction.destroy();
|
462 | this.clipboardAction = null;
|
463 | }
|
464 | }
|
465 | }], [{
|
466 | key: "isSupported",
|
467 | value: function isSupported() {
|
468 | var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
|
469 | var actions = typeof action === 'string' ? [action] : action;
|
470 | var support = !!document.queryCommandSupported;
|
471 | actions.forEach(function (action) {
|
472 | support = support && !!document.queryCommandSupported(action);
|
473 | });
|
474 | return support;
|
475 | }
|
476 | }]);
|
477 |
|
478 | return Clipboard;
|
479 | }((tiny_emitter_default()));
|
480 |
|
481 | var clipboard = (Clipboard);
|
482 |
|
483 | }),
|
484 |
|
485 | 828:
|
486 | (function(module) {
|
487 |
|
488 | var DOCUMENT_NODE_TYPE = 9;
|
489 |
|
490 |
|
491 |
|
492 |
|
493 | if (typeof Element !== 'undefined' && !Element.prototype.matches) {
|
494 | var proto = Element.prototype;
|
495 |
|
496 | proto.matches = proto.matchesSelector ||
|
497 | proto.mozMatchesSelector ||
|
498 | proto.msMatchesSelector ||
|
499 | proto.oMatchesSelector ||
|
500 | proto.webkitMatchesSelector;
|
501 | }
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 | function closest (element, selector) {
|
511 | while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
|
512 | if (typeof element.matches === 'function' &&
|
513 | element.matches(selector)) {
|
514 | return element;
|
515 | }
|
516 | element = element.parentNode;
|
517 | }
|
518 | }
|
519 |
|
520 | module.exports = closest;
|
521 |
|
522 |
|
523 | }),
|
524 |
|
525 | 438:
|
526 | (function(module, __unused_webpack_exports, __webpack_require__) {
|
527 |
|
528 | var closest = __webpack_require__(828);
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | function _delegate(element, selector, type, callback, useCapture) {
|
541 | var listenerFn = listener.apply(this, arguments);
|
542 |
|
543 | element.addEventListener(type, listenerFn, useCapture);
|
544 |
|
545 | return {
|
546 | destroy: function() {
|
547 | element.removeEventListener(type, listenerFn, useCapture);
|
548 | }
|
549 | }
|
550 | }
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | function delegate(elements, selector, type, callback, useCapture) {
|
563 |
|
564 | if (typeof elements.addEventListener === 'function') {
|
565 | return _delegate.apply(null, arguments);
|
566 | }
|
567 |
|
568 |
|
569 | if (typeof type === 'function') {
|
570 |
|
571 |
|
572 | return _delegate.bind(null, document).apply(null, arguments);
|
573 | }
|
574 |
|
575 |
|
576 | if (typeof elements === 'string') {
|
577 | elements = document.querySelectorAll(elements);
|
578 | }
|
579 |
|
580 |
|
581 | return Array.prototype.map.call(elements, function (element) {
|
582 | return _delegate(element, selector, type, callback, useCapture);
|
583 | });
|
584 | }
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 | function listener(element, selector, type, callback) {
|
596 | return function(e) {
|
597 | e.delegateTarget = closest(e.target, selector);
|
598 |
|
599 | if (e.delegateTarget) {
|
600 | callback.call(element, e);
|
601 | }
|
602 | }
|
603 | }
|
604 |
|
605 | module.exports = delegate;
|
606 |
|
607 |
|
608 | }),
|
609 |
|
610 | 879:
|
611 | (function(__unused_webpack_module, exports) {
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | exports.node = function(value) {
|
620 | return value !== undefined
|
621 | && value instanceof HTMLElement
|
622 | && value.nodeType === 1;
|
623 | };
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 | exports.nodeList = function(value) {
|
632 | var type = Object.prototype.toString.call(value);
|
633 |
|
634 | return value !== undefined
|
635 | && (type === '[object NodeList]' || type === '[object HTMLCollection]')
|
636 | && ('length' in value)
|
637 | && (value.length === 0 || exports.node(value[0]));
|
638 | };
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 | exports.string = function(value) {
|
647 | return typeof value === 'string'
|
648 | || value instanceof String;
|
649 | };
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 | exports.fn = function(value) {
|
658 | var type = Object.prototype.toString.call(value);
|
659 |
|
660 | return type === '[object Function]';
|
661 | };
|
662 |
|
663 |
|
664 | }),
|
665 |
|
666 | 370:
|
667 | (function(module, __unused_webpack_exports, __webpack_require__) {
|
668 |
|
669 | var is = __webpack_require__(879);
|
670 | var delegate = __webpack_require__(438);
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 | function listen(target, type, callback) {
|
682 | if (!target && !type && !callback) {
|
683 | throw new Error('Missing required arguments');
|
684 | }
|
685 |
|
686 | if (!is.string(type)) {
|
687 | throw new TypeError('Second argument must be a String');
|
688 | }
|
689 |
|
690 | if (!is.fn(callback)) {
|
691 | throw new TypeError('Third argument must be a Function');
|
692 | }
|
693 |
|
694 | if (is.node(target)) {
|
695 | return listenNode(target, type, callback);
|
696 | }
|
697 | else if (is.nodeList(target)) {
|
698 | return listenNodeList(target, type, callback);
|
699 | }
|
700 | else if (is.string(target)) {
|
701 | return listenSelector(target, type, callback);
|
702 | }
|
703 | else {
|
704 | throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
|
705 | }
|
706 | }
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 | function listenNode(node, type, callback) {
|
718 | node.addEventListener(type, callback);
|
719 |
|
720 | return {
|
721 | destroy: function() {
|
722 | node.removeEventListener(type, callback);
|
723 | }
|
724 | }
|
725 | }
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 | function listenNodeList(nodeList, type, callback) {
|
737 | Array.prototype.forEach.call(nodeList, function(node) {
|
738 | node.addEventListener(type, callback);
|
739 | });
|
740 |
|
741 | return {
|
742 | destroy: function() {
|
743 | Array.prototype.forEach.call(nodeList, function(node) {
|
744 | node.removeEventListener(type, callback);
|
745 | });
|
746 | }
|
747 | }
|
748 | }
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 | function listenSelector(selector, type, callback) {
|
760 | return delegate(document.body, selector, type, callback);
|
761 | }
|
762 |
|
763 | module.exports = listen;
|
764 |
|
765 |
|
766 | }),
|
767 |
|
768 | 817:
|
769 | (function(module) {
|
770 |
|
771 | function select(element) {
|
772 | var selectedText;
|
773 |
|
774 | if (element.nodeName === 'SELECT') {
|
775 | element.focus();
|
776 |
|
777 | selectedText = element.value;
|
778 | }
|
779 | else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
780 | var isReadOnly = element.hasAttribute('readonly');
|
781 |
|
782 | if (!isReadOnly) {
|
783 | element.setAttribute('readonly', '');
|
784 | }
|
785 |
|
786 | element.select();
|
787 | element.setSelectionRange(0, element.value.length);
|
788 |
|
789 | if (!isReadOnly) {
|
790 | element.removeAttribute('readonly');
|
791 | }
|
792 |
|
793 | selectedText = element.value;
|
794 | }
|
795 | else {
|
796 | if (element.hasAttribute('contenteditable')) {
|
797 | element.focus();
|
798 | }
|
799 |
|
800 | var selection = window.getSelection();
|
801 | var range = document.createRange();
|
802 |
|
803 | range.selectNodeContents(element);
|
804 | selection.removeAllRanges();
|
805 | selection.addRange(range);
|
806 |
|
807 | selectedText = selection.toString();
|
808 | }
|
809 |
|
810 | return selectedText;
|
811 | }
|
812 |
|
813 | module.exports = select;
|
814 |
|
815 |
|
816 | }),
|
817 |
|
818 | 279:
|
819 | (function(module) {
|
820 |
|
821 | function E () {
|
822 |
|
823 |
|
824 | }
|
825 |
|
826 | E.prototype = {
|
827 | on: function (name, callback, ctx) {
|
828 | var e = this.e || (this.e = {});
|
829 |
|
830 | (e[name] || (e[name] = [])).push({
|
831 | fn: callback,
|
832 | ctx: ctx
|
833 | });
|
834 |
|
835 | return this;
|
836 | },
|
837 |
|
838 | once: function (name, callback, ctx) {
|
839 | var self = this;
|
840 | function listener () {
|
841 | self.off(name, listener);
|
842 | callback.apply(ctx, arguments);
|
843 | };
|
844 |
|
845 | listener._ = callback
|
846 | return this.on(name, listener, ctx);
|
847 | },
|
848 |
|
849 | emit: function (name) {
|
850 | var data = [].slice.call(arguments, 1);
|
851 | var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
852 | var i = 0;
|
853 | var len = evtArr.length;
|
854 |
|
855 | for (i; i < len; i++) {
|
856 | evtArr[i].fn.apply(evtArr[i].ctx, data);
|
857 | }
|
858 |
|
859 | return this;
|
860 | },
|
861 |
|
862 | off: function (name, callback) {
|
863 | var e = this.e || (this.e = {});
|
864 | var evts = e[name];
|
865 | var liveEvents = [];
|
866 |
|
867 | if (evts && callback) {
|
868 | for (var i = 0, len = evts.length; i < len; i++) {
|
869 | if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
870 | liveEvents.push(evts[i]);
|
871 | }
|
872 | }
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 | (liveEvents.length)
|
879 | ? e[name] = liveEvents
|
880 | : delete e[name];
|
881 |
|
882 | return this;
|
883 | }
|
884 | };
|
885 |
|
886 | module.exports = E;
|
887 | module.exports.TinyEmitter = E;
|
888 |
|
889 |
|
890 | })
|
891 |
|
892 | });
|
893 |
|
894 |
|
895 | var __webpack_module_cache__ = {};
|
896 |
|
897 |
|
898 | function __webpack_require__(moduleId) {
|
899 |
|
900 | if(__webpack_module_cache__[moduleId]) {
|
901 | return __webpack_module_cache__[moduleId].exports;
|
902 | }
|
903 |
|
904 | var module = __webpack_module_cache__[moduleId] = {
|
905 |
|
906 |
|
907 | exports: {}
|
908 | };
|
909 |
|
910 |
|
911 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
912 |
|
913 |
|
914 | return module.exports;
|
915 | }
|
916 |
|
917 |
|
918 |
|
919 | !function() {
|
920 |
|
921 | __webpack_require__.n = function(module) {
|
922 | var getter = module && module.__esModule ?
|
923 | function() { return module['default']; } :
|
924 | function() { return module; };
|
925 | __webpack_require__.d(getter, { a: getter });
|
926 | return getter;
|
927 | };
|
928 | }();
|
929 |
|
930 |
|
931 | !function() {
|
932 |
|
933 | __webpack_require__.d = function(exports, definition) {
|
934 | for(var key in definition) {
|
935 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
936 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
937 | }
|
938 | }
|
939 | };
|
940 | }();
|
941 |
|
942 |
|
943 | !function() {
|
944 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
945 | }();
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 | return __webpack_require__(134);
|
952 | })()
|
953 | .default;
|
954 | }); |
\ | No newline at end of file |