1 | function _typeof(obj) {
|
2 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
3 | _typeof = function _typeof(obj) {
|
4 | return typeof obj;
|
5 | };
|
6 | } else {
|
7 | _typeof = function _typeof(obj) {
|
8 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
9 | };
|
10 | }
|
11 |
|
12 | return _typeof(obj);
|
13 | }
|
14 |
|
15 | function _classCallCheck(instance, Constructor) {
|
16 | if (!(instance instanceof Constructor)) {
|
17 | throw new TypeError("Cannot call a class as a function");
|
18 | }
|
19 | }
|
20 |
|
21 | function _defineProperties(target, props) {
|
22 | for (var i = 0; i < props.length; i++) {
|
23 | var descriptor = props[i];
|
24 | descriptor.enumerable = descriptor.enumerable || false;
|
25 | descriptor.configurable = true;
|
26 | if ("value" in descriptor) descriptor.writable = true;
|
27 | Object.defineProperty(target, descriptor.key, descriptor);
|
28 | }
|
29 | }
|
30 |
|
31 | function _createClass(Constructor, protoProps, staticProps) {
|
32 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
33 | if (staticProps) _defineProperties(Constructor, staticProps);
|
34 | return Constructor;
|
35 | }
|
36 |
|
37 | function _possibleConstructorReturn(self, call) {
|
38 | if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
39 | return call;
|
40 | }
|
41 |
|
42 | return _assertThisInitialized(self);
|
43 | }
|
44 |
|
45 | function _assertThisInitialized(self) {
|
46 | if (self === void 0) {
|
47 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
48 | }
|
49 |
|
50 | return self;
|
51 | }
|
52 |
|
53 | function _getPrototypeOf(o) {
|
54 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
55 | return o.__proto__ || Object.getPrototypeOf(o);
|
56 | };
|
57 | return _getPrototypeOf(o);
|
58 | }
|
59 |
|
60 | function _inherits(subClass, superClass) {
|
61 | if (typeof superClass !== "function" && superClass !== null) {
|
62 | throw new TypeError("Super expression must either be null or a function");
|
63 | }
|
64 |
|
65 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
66 | constructor: {
|
67 | value: subClass,
|
68 | writable: true,
|
69 | configurable: true
|
70 | }
|
71 | });
|
72 | if (superClass) _setPrototypeOf(subClass, superClass);
|
73 | }
|
74 |
|
75 | function _setPrototypeOf(o, p) {
|
76 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
77 | o.__proto__ = p;
|
78 | return o;
|
79 | };
|
80 |
|
81 | return _setPrototypeOf(o, p);
|
82 | }
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | import settings from '../../globals/js/settings';
|
92 | import mixin from '../../globals/js/misc/mixin';
|
93 | import createComponent from '../../globals/js/mixins/create-component';
|
94 | import initComponentBySearch from '../../globals/js/mixins/init-component-by-search';
|
95 | import handles from '../../globals/js/mixins/handles';
|
96 | import on from '../../globals/js/misc/on';
|
97 |
|
98 | var CopyButton =
|
99 |
|
100 | function (_mixin) {
|
101 | _inherits(CopyButton, _mixin);
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | function CopyButton(element, options) {
|
112 | var _this;
|
113 |
|
114 | _classCallCheck(this, CopyButton);
|
115 |
|
116 | _this = _possibleConstructorReturn(this, _getPrototypeOf(CopyButton).call(this, element, options));
|
117 |
|
118 | _this.manage(on(_this.element, 'click', function () {
|
119 | return _this.handleClick();
|
120 | }));
|
121 |
|
122 | return _this;
|
123 | }
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 | _createClass(CopyButton, [{
|
130 | key: "handleClick",
|
131 | value: function handleClick() {
|
132 | var _this2 = this;
|
133 |
|
134 | var feedback = this.element.querySelector(this.options.feedbackTooltip);
|
135 |
|
136 | if (feedback) {
|
137 | feedback.classList.add(this.options.classShowFeedback);
|
138 | setTimeout(function () {
|
139 | feedback.classList.remove(_this2.options.classShowFeedback);
|
140 | }, this.options.timeoutValue);
|
141 | }
|
142 | }
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | }], [{
|
150 | key: "options",
|
151 |
|
152 | |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | get: function get() {
|
164 | var prefix = settings.prefix;
|
165 | return {
|
166 | selectorInit: '[data-copy-btn]',
|
167 | feedbackTooltip: '[data-feedback]',
|
168 | classShowFeedback: "".concat(prefix, "--btn--copy__feedback--displayed"),
|
169 | timeoutValue: 2000
|
170 | };
|
171 | }
|
172 | }]);
|
173 |
|
174 | CopyButton.components = new WeakMap();
|
175 | return CopyButton;
|
176 | }(mixin(createComponent, initComponentBySearch, handles));
|
177 |
|
178 | export default CopyButton; |
\ | No newline at end of file |