PageSourceSearch

https://www.therobinsonnest.com/wp-content/themes/smash_theme/smash/js/clipboard.js

js therobinsonnest.com collected 2026-09-27 02:24:53 UTC 29,524 bytes, 974 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.