[Notice] Announcing the End of Demo Server [Read me]
js: Upgrade Clipboard.js to 2.0
Clipboard api is introduced by browsers natively. It is needed to upgrade Clipboard.js library.
@1ae2c41966025cf304b5af4aa7212fc8255993fc
--- app/views/code/history.scala.html
+++ app/views/code/history.scala.html
... | ... | @@ -231,7 +231,7 @@ |
231 | 231 |
|
232 | 232 |
// zclip() works only in visible element |
233 | 233 |
welBtnCopy.on("mouseenter", function(){ |
234 |
- if (Clipboard && Clipboard.isSupported()) { |
|
234 |
+ if (ClipboardJS && ClipboardJS.isSupported()) { |
|
235 | 235 |
// Using clipboard.min.js if supports clipboard api. |
236 | 236 |
if (clipboard) { |
237 | 237 |
clipboard.destroy(); // Destroy previous instance before locate new instance. |
--- app/views/issue/view.scala.html
+++ app/views/issue/view.scala.html
... | ... | @@ -535,8 +535,8 @@ |
535 | 535 |
}); |
536 | 536 |
}); |
537 | 537 |
|
538 |
- if (Clipboard.isSupported()) { |
|
539 |
- var clipboard = new Clipboard('#copyEmailBtn'); |
|
538 |
+ if (ClipboardJS.isSupported()) { |
|
539 |
+ var clipboard = new ClipboardJS('#copyEmailBtn'); |
|
540 | 540 |
|
541 | 541 |
clipboard.on('success', function(e) { |
542 | 542 |
$yobi.alert('@Messages("button.copy.email.success.message")'); |
--- app/views/project/home.scala.html
+++ app/views/project/home.scala.html
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 |
@if(project.menuSetting.code) { |
52 | 52 |
<div class="project-clone-wrap span3 hide-in-mobile"> |
53 | 53 |
<input type="text" class="project-clone-url" id="cloneURL" readonly="readonly" value="@if(project.isGit){@CodeApp.getURLWithLoginId(project)} else {@CodeApp.getURL(project)}"> |
54 |
- <button class="ybtn project-clone-button" id="cloneURLBtn">@Messages("code.copyUrl")</button> |
|
54 |
+ <button class="ybtn project-clone-button" data-clipboard-target="cloneURL" id="cloneURLBtn">@Messages("code.copyUrl")</button> |
|
55 | 55 |
</div> |
56 | 56 |
} |
57 | 57 |
</div> |
--- minify-js.sh
+++ minify-js.sh
... | ... | @@ -12,8 +12,14 @@ |
12 | 12 |
# for dev |
13 | 13 |
#cat $PUBLIC_JAVASCRIPTS/lib/nprogress/nprogress.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery-3.3.1.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.browser.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.pjax.js $PUBLIC_JAVASCRIPTS/common/yobi.Common.js > $OUT_DIR/yona-layout.js |
14 | 14 |
|
15 |
+################# |
|
15 | 16 |
# yona-common.js |
16 |
-java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.tmpl.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.form.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.validate.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.requestAs.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.search.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.zclip.min.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.placeholder.min.js $PUBLIC/bootstrap/js/bootstrap.js $PUBLIC_JAVASCRIPTS/lib/rgbcolor.js $PUBLIC_JAVASCRIPTS/lib/humanize.js $PUBLIC_JAVASCRIPTS/lib/validate.js $PUBLIC_JAVASCRIPTS/lib/xss.js $PUBLIC_JAVASCRIPTS/lib/clipboard.min.js --js_output_file $OUT_DIR/yona-common.js |
|
17 |
+################# |
|
18 |
+ |
|
19 |
+#java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.tmpl.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.form.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.validate.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.requestAs.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.search.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.zclip.min.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.placeholder.min.js $PUBLIC/bootstrap/js/bootstrap.js $PUBLIC_JAVASCRIPTS/lib/rgbcolor.js $PUBLIC_JAVASCRIPTS/lib/humanize.js $PUBLIC_JAVASCRIPTS/lib/validate.js $PUBLIC_JAVASCRIPTS/lib/xss.js $PUBLIC_JAVASCRIPTS/lib/clipboard.js --js_output_file $OUT_DIR/yona-common.js |
|
20 |
+ |
|
21 |
+# for dev |
|
22 |
+cat $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.tmpl.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.form.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.validate.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.requestAs.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.search.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.zclip.min.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.placeholder.min.js $PUBLIC/bootstrap/js/bootstrap.js $PUBLIC_JAVASCRIPTS/lib/rgbcolor.js $PUBLIC_JAVASCRIPTS/lib/humanize.js $PUBLIC_JAVASCRIPTS/lib/validate.js $PUBLIC_JAVASCRIPTS/lib/xss.js $PUBLIC_JAVASCRIPTS/lib/clipboard.js > $OUT_DIR/yona-common.js |
|
17 | 23 |
|
18 | 24 |
# yona-lib.js |
19 | 25 |
java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/common/yobi.Attachments.js $PUBLIC_JAVASCRIPTS/common/yobi.Files.js $PUBLIC_JAVASCRIPTS/common/yobi.Mention.js $PUBLIC_JAVASCRIPTS/common/yobi.Markdown.js $PUBLIC_JAVASCRIPTS/common/yobi.Pagination.js $PUBLIC_JAVASCRIPTS/common/yobi.ShortcutKey.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Dropdown.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Typeahead.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Dialog.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Toast.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Tabs.js $PUBLIC_JAVASCRIPTS/common/yobi.OriginalMessage.js --js_output_file $OUT_DIR/yona-lib.js |
+++ public/javascripts/lib/clipboard.js
... | ... | @@ -0,0 +1,939 @@ |
1 | +/*! | |
2 | + * clipboard.js v2.0.0 | |
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 | |
15 | + root["ClipboardJS"] = factory(); | |
16 | +})(this, function() { | |
17 | +return /******/ (function(modules) { // webpackBootstrap | |
18 | +/******/ // The module cache | |
19 | +/******/ var installedModules = {}; | |
20 | +/******/ | |
21 | +/******/ // The require function | |
22 | +/******/ function __webpack_require__(moduleId) { | |
23 | +/******/ | |
24 | +/******/ // Check if module is in cache | |
25 | +/******/ if(installedModules[moduleId]) { | |
26 | +/******/ return installedModules[moduleId].exports; | |
27 | +/******/ } | |
28 | +/******/ // Create a new module (and put it into the cache) | |
29 | +/******/ var module = installedModules[moduleId] = { | |
30 | +/******/ i: moduleId, | |
31 | +/******/ l: false, | |
32 | +/******/ exports: {} | |
33 | +/******/ }; | |
34 | +/******/ | |
35 | +/******/ // Execute the module function | |
36 | +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | |
37 | +/******/ | |
38 | +/******/ // Flag the module as loaded | |
39 | +/******/ module.l = true; | |
40 | +/******/ | |
41 | +/******/ // Return the exports of the module | |
42 | +/******/ return module.exports; | |
43 | +/******/ } | |
44 | +/******/ | |
45 | +/******/ | |
46 | +/******/ // expose the modules object (__webpack_modules__) | |
47 | +/******/ __webpack_require__.m = modules; | |
48 | +/******/ | |
49 | +/******/ // expose the module cache | |
50 | +/******/ __webpack_require__.c = installedModules; | |
51 | +/******/ | |
52 | +/******/ // identity function for calling harmony imports with the correct context | |
53 | +/******/ __webpack_require__.i = function(value) { return value; }; | |
54 | +/******/ | |
55 | +/******/ // define getter function for harmony exports | |
56 | +/******/ __webpack_require__.d = function(exports, name, getter) { | |
57 | +/******/ if(!__webpack_require__.o(exports, name)) { | |
58 | +/******/ Object.defineProperty(exports, name, { | |
59 | +/******/ configurable: false, | |
60 | +/******/ enumerable: true, | |
61 | +/******/ get: getter | |
62 | +/******/ }); | |
63 | +/******/ } | |
64 | +/******/ }; | |
65 | +/******/ | |
66 | +/******/ // getDefaultExport function for compatibility with non-harmony modules | |
67 | +/******/ __webpack_require__.n = function(module) { | |
68 | +/******/ var getter = module && module.__esModule ? | |
69 | +/******/ function getDefault() { return module['default']; } : | |
70 | +/******/ function getModuleExports() { return module; }; | |
71 | +/******/ __webpack_require__.d(getter, 'a', getter); | |
72 | +/******/ return getter; | |
73 | +/******/ }; | |
74 | +/******/ | |
75 | +/******/ // Object.prototype.hasOwnProperty.call | |
76 | +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | |
77 | +/******/ | |
78 | +/******/ // __webpack_public_path__ | |
79 | +/******/ __webpack_require__.p = ""; | |
80 | +/******/ | |
81 | +/******/ // Load entry module and return exports | |
82 | +/******/ return __webpack_require__(__webpack_require__.s = 3); | |
83 | +/******/ }) | |
84 | +/************************************************************************/ | |
85 | +/******/ ([ | |
86 | +/* 0 */ | |
87 | +/***/ (function(module, exports, __webpack_require__) { | |
88 | + | |
89 | +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { | |
90 | + if (true) { | |
91 | + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(7)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | |
92 | + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | |
93 | + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | |
94 | + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | |
95 | + } else if (typeof exports !== "undefined") { | |
96 | + factory(module, require('select')); | |
97 | + } else { | |
98 | + var mod = { | |
99 | + exports: {} | |
100 | + }; | |
101 | + factory(mod, global.select); | |
102 | + global.clipboardAction = mod.exports; | |
103 | + } | |
104 | +})(this, function (module, _select) { | |
105 | + 'use strict'; | |
106 | + | |
107 | + var _select2 = _interopRequireDefault(_select); | |
108 | + | |
109 | + function _interopRequireDefault(obj) { | |
110 | + return obj && obj.__esModule ? obj : { | |
111 | + default: obj | |
112 | + }; | |
113 | + } | |
114 | + | |
115 | + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | |
116 | + return typeof obj; | |
117 | + } : function (obj) { | |
118 | + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | |
119 | + }; | |
120 | + | |
121 | + function _classCallCheck(instance, Constructor) { | |
122 | + if (!(instance instanceof Constructor)) { | |
123 | + throw new TypeError("Cannot call a class as a function"); | |
124 | + } | |
125 | + } | |
126 | + | |
127 | + var _createClass = function () { | |
128 | + function defineProperties(target, props) { | |
129 | + for (var i = 0; i < props.length; i++) { | |
130 | + var descriptor = props[i]; | |
131 | + descriptor.enumerable = descriptor.enumerable || false; | |
132 | + descriptor.configurable = true; | |
133 | + if ("value" in descriptor) descriptor.writable = true; | |
134 | + Object.defineProperty(target, descriptor.key, descriptor); | |
135 | + } | |
136 | + } | |
137 | + | |
138 | + return function (Constructor, protoProps, staticProps) { | |
139 | + if (protoProps) defineProperties(Constructor.prototype, protoProps); | |
140 | + if (staticProps) defineProperties(Constructor, staticProps); | |
141 | + return Constructor; | |
142 | + }; | |
143 | + }(); | |
144 | + | |
145 | + var ClipboardAction = function () { | |
146 | + /** | |
147 | + * @param {Object} options | |
148 | + */ | |
149 | + function ClipboardAction(options) { | |
150 | + _classCallCheck(this, ClipboardAction); | |
151 | + | |
152 | + this.resolveOptions(options); | |
153 | + this.initSelection(); | |
154 | + } | |
155 | + | |
156 | + /** | |
157 | + * Defines base properties passed from constructor. | |
158 | + * @param {Object} options | |
159 | + */ | |
160 | + | |
161 | + | |
162 | + _createClass(ClipboardAction, [{ | |
163 | + key: 'resolveOptions', | |
164 | + value: function resolveOptions() { | |
165 | + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | |
166 | + | |
167 | + this.action = options.action; | |
168 | + this.container = options.container; | |
169 | + this.emitter = options.emitter; | |
170 | + this.target = options.target; | |
171 | + this.text = options.text; | |
172 | + this.trigger = options.trigger; | |
173 | + | |
174 | + this.selectedText = ''; | |
175 | + } | |
176 | + }, { | |
177 | + key: 'initSelection', | |
178 | + value: function initSelection() { | |
179 | + if (this.text) { | |
180 | + this.selectFake(); | |
181 | + } else if (this.target) { | |
182 | + this.selectTarget(); | |
183 | + } | |
184 | + } | |
185 | + }, { | |
186 | + key: 'selectFake', | |
187 | + value: function selectFake() { | |
188 | + var _this = this; | |
189 | + | |
190 | + var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; | |
191 | + | |
192 | + this.removeFake(); | |
193 | + | |
194 | + this.fakeHandlerCallback = function () { | |
195 | + return _this.removeFake(); | |
196 | + }; | |
197 | + this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; | |
198 | + | |
199 | + this.fakeElem = document.createElement('textarea'); | |
200 | + // Prevent zooming on iOS | |
201 | + this.fakeElem.style.fontSize = '12pt'; | |
202 | + // Reset box model | |
203 | + this.fakeElem.style.border = '0'; | |
204 | + this.fakeElem.style.padding = '0'; | |
205 | + this.fakeElem.style.margin = '0'; | |
206 | + // Move element out of screen horizontally | |
207 | + this.fakeElem.style.position = 'absolute'; | |
208 | + this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; | |
209 | + // Move element to the same position vertically | |
210 | + var yPosition = window.pageYOffset || document.documentElement.scrollTop; | |
211 | + this.fakeElem.style.top = yPosition + 'px'; | |
212 | + | |
213 | + this.fakeElem.setAttribute('readonly', ''); | |
214 | + this.fakeElem.value = this.text; | |
215 | + | |
216 | + this.container.appendChild(this.fakeElem); | |
217 | + | |
218 | + this.selectedText = (0, _select2.default)(this.fakeElem); | |
219 | + this.copyText(); | |
220 | + } | |
221 | + }, { | |
222 | + key: 'removeFake', | |
223 | + value: function removeFake() { | |
224 | + if (this.fakeHandler) { | |
225 | + this.container.removeEventListener('click', this.fakeHandlerCallback); | |
226 | + this.fakeHandler = null; | |
227 | + this.fakeHandlerCallback = null; | |
228 | + } | |
229 | + | |
230 | + if (this.fakeElem) { | |
231 | + this.container.removeChild(this.fakeElem); | |
232 | + this.fakeElem = null; | |
233 | + } | |
234 | + } | |
235 | + }, { | |
236 | + key: 'selectTarget', | |
237 | + value: function selectTarget() { | |
238 | + this.selectedText = (0, _select2.default)(this.target); | |
239 | + this.copyText(); | |
240 | + } | |
241 | + }, { | |
242 | + key: 'copyText', | |
243 | + value: function copyText() { | |
244 | + var succeeded = void 0; | |
245 | + | |
246 | + try { | |
247 | + succeeded = document.execCommand(this.action); | |
248 | + } catch (err) { | |
249 | + succeeded = false; | |
250 | + } | |
251 | + | |
252 | + this.handleResult(succeeded); | |
253 | + } | |
254 | + }, { | |
255 | + key: 'handleResult', | |
256 | + value: function handleResult(succeeded) { | |
257 | + this.emitter.emit(succeeded ? 'success' : 'error', { | |
258 | + action: this.action, | |
259 | + text: this.selectedText, | |
260 | + trigger: this.trigger, | |
261 | + clearSelection: this.clearSelection.bind(this) | |
262 | + }); | |
263 | + } | |
264 | + }, { | |
265 | + key: 'clearSelection', | |
266 | + value: function clearSelection() { | |
267 | + if (this.trigger) { | |
268 | + this.trigger.focus(); | |
269 | + } | |
270 | + | |
271 | + window.getSelection().removeAllRanges(); | |
272 | + } | |
273 | + }, { | |
274 | + key: 'destroy', | |
275 | + value: function destroy() { | |
276 | + this.removeFake(); | |
277 | + } | |
278 | + }, { | |
279 | + key: 'action', | |
280 | + set: function set() { | |
281 | + var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; | |
282 | + | |
283 | + this._action = action; | |
284 | + | |
285 | + if (this._action !== 'copy' && this._action !== 'cut') { | |
286 | + throw new Error('Invalid "action" value, use either "copy" or "cut"'); | |
287 | + } | |
288 | + }, | |
289 | + get: function get() { | |
290 | + return this._action; | |
291 | + } | |
292 | + }, { | |
293 | + key: 'target', | |
294 | + set: function set(target) { | |
295 | + if (target !== undefined) { | |
296 | + if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { | |
297 | + if (this.action === 'copy' && target.hasAttribute('disabled')) { | |
298 | + throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); | |
299 | + } | |
300 | + | |
301 | + if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { | |
302 | + throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); | |
303 | + } | |
304 | + | |
305 | + this._target = target; | |
306 | + } else { | |
307 | + throw new Error('Invalid "target" value, use a valid Element'); | |
308 | + } | |
309 | + } | |
310 | + }, | |
311 | + get: function get() { | |
312 | + return this._target; | |
313 | + } | |
314 | + }]); | |
315 | + | |
316 | + return ClipboardAction; | |
317 | + }(); | |
318 | + | |
319 | + module.exports = ClipboardAction; | |
320 | +}); | |
321 | + | |
322 | +/***/ }), | |
323 | +/* 1 */ | |
324 | +/***/ (function(module, exports, __webpack_require__) { | |
325 | + | |
326 | +var is = __webpack_require__(6); | |
327 | +var delegate = __webpack_require__(5); | |
328 | + | |
329 | +/** | |
330 | + * Validates all params and calls the right | |
331 | + * listener function based on its target type. | |
332 | + * | |
333 | + * @param {String|HTMLElement|HTMLCollection|NodeList} target | |
334 | + * @param {String} type | |
335 | + * @param {Function} callback | |
336 | + * @return {Object} | |
337 | + */ | |
338 | +function listen(target, type, callback) { | |
339 | + if (!target && !type && !callback) { | |
340 | + throw new Error('Missing required arguments'); | |
341 | + } | |
342 | + | |
343 | + if (!is.string(type)) { | |
344 | + throw new TypeError('Second argument must be a String'); | |
345 | + } | |
346 | + | |
347 | + if (!is.fn(callback)) { | |
348 | + throw new TypeError('Third argument must be a Function'); | |
349 | + } | |
350 | + | |
351 | + if (is.node(target)) { | |
352 | + return listenNode(target, type, callback); | |
353 | + } | |
354 | + else if (is.nodeList(target)) { | |
355 | + return listenNodeList(target, type, callback); | |
356 | + } | |
357 | + else if (is.string(target)) { | |
358 | + return listenSelector(target, type, callback); | |
359 | + } | |
360 | + else { | |
361 | + throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); | |
362 | + } | |
363 | +} | |
364 | + | |
365 | +/** | |
366 | + * Adds an event listener to a HTML element | |
367 | + * and returns a remove listener function. | |
368 | + * | |
369 | + * @param {HTMLElement} node | |
370 | + * @param {String} type | |
371 | + * @param {Function} callback | |
372 | + * @return {Object} | |
373 | + */ | |
374 | +function listenNode(node, type, callback) { | |
375 | + node.addEventListener(type, callback); | |
376 | + | |
377 | + return { | |
378 | + destroy: function() { | |
379 | + node.removeEventListener(type, callback); | |
380 | + } | |
381 | + } | |
382 | +} | |
383 | + | |
384 | +/** | |
385 | + * Add an event listener to a list of HTML elements | |
386 | + * and returns a remove listener function. | |
387 | + * | |
388 | + * @param {NodeList|HTMLCollection} nodeList | |
389 | + * @param {String} type | |
390 | + * @param {Function} callback | |
391 | + * @return {Object} | |
392 | + */ | |
393 | +function listenNodeList(nodeList, type, callback) { | |
394 | + Array.prototype.forEach.call(nodeList, function(node) { | |
395 | + node.addEventListener(type, callback); | |
396 | + }); | |
397 | + | |
398 | + return { | |
399 | + destroy: function() { | |
400 | + Array.prototype.forEach.call(nodeList, function(node) { | |
401 | + node.removeEventListener(type, callback); | |
402 | + }); | |
403 | + } | |
404 | + } | |
405 | +} | |
406 | + | |
407 | +/** | |
408 | + * Add an event listener to a selector | |
409 | + * and returns a remove listener function. | |
410 | + * | |
411 | + * @param {String} selector | |
412 | + * @param {String} type | |
413 | + * @param {Function} callback | |
414 | + * @return {Object} | |
415 | + */ | |
416 | +function listenSelector(selector, type, callback) { | |
417 | + return delegate(document.body, selector, type, callback); | |
418 | +} | |
419 | + | |
420 | +module.exports = listen; | |
421 | + | |
422 | + | |
423 | +/***/ }), | |
424 | +/* 2 */ | |
425 | +/***/ (function(module, exports) { | |
426 | + | |
427 | +function E () { | |
428 | + // Keep this empty so it's easier to inherit from | |
429 | + // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) | |
430 | +} | |
431 | + | |
432 | +E.prototype = { | |
433 | + on: function (name, callback, ctx) { | |
434 | + var e = this.e || (this.e = {}); | |
435 | + | |
436 | + (e[name] || (e[name] = [])).push({ | |
437 | + fn: callback, | |
438 | + ctx: ctx | |
439 | + }); | |
440 | + | |
441 | + return this; | |
442 | + }, | |
443 | + | |
444 | + once: function (name, callback, ctx) { | |
445 | + var self = this; | |
446 | + function listener () { | |
447 | + self.off(name, listener); | |
448 | + callback.apply(ctx, arguments); | |
449 | + }; | |
450 | + | |
451 | + listener._ = callback | |
452 | + return this.on(name, listener, ctx); | |
453 | + }, | |
454 | + | |
455 | + emit: function (name) { | |
456 | + var data = [].slice.call(arguments, 1); | |
457 | + var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); | |
458 | + var i = 0; | |
459 | + var len = evtArr.length; | |
460 | + | |
461 | + for (i; i < len; i++) { | |
462 | + evtArr[i].fn.apply(evtArr[i].ctx, data); | |
463 | + } | |
464 | + | |
465 | + return this; | |
466 | + }, | |
467 | + | |
468 | + off: function (name, callback) { | |
469 | + var e = this.e || (this.e = {}); | |
470 | + var evts = e[name]; | |
471 | + var liveEvents = []; | |
472 | + | |
473 | + if (evts && callback) { | |
474 | + for (var i = 0, len = evts.length; i < len; i++) { | |
475 | + if (evts[i].fn !== callback && evts[i].fn._ !== callback) | |
476 | + liveEvents.push(evts[i]); | |
477 | + } | |
478 | + } | |
479 | + | |
480 | + // Remove event from queue to prevent memory leak | |
481 | + // Suggested by https://github.com/lazd | |
482 | + // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 | |
483 | + | |
484 | + (liveEvents.length) | |
485 | + ? e[name] = liveEvents | |
486 | + : delete e[name]; | |
487 | + | |
488 | + return this; | |
489 | + } | |
490 | +}; | |
491 | + | |
492 | +module.exports = E; | |
493 | + | |
494 | + | |
495 | +/***/ }), | |
496 | +/* 3 */ | |
497 | +/***/ (function(module, exports, __webpack_require__) { | |
498 | + | |
499 | +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { | |
500 | + if (true) { | |
501 | + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(0), __webpack_require__(2), __webpack_require__(1)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | |
502 | + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | |
503 | + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | |
504 | + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | |
505 | + } else if (typeof exports !== "undefined") { | |
506 | + factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener')); | |
507 | + } else { | |
508 | + var mod = { | |
509 | + exports: {} | |
510 | + }; | |
511 | + factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener); | |
512 | + global.clipboard = mod.exports; | |
513 | + } | |
514 | +})(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) { | |
515 | + 'use strict'; | |
516 | + | |
517 | + var _clipboardAction2 = _interopRequireDefault(_clipboardAction); | |
518 | + | |
519 | + var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); | |
520 | + | |
521 | + var _goodListener2 = _interopRequireDefault(_goodListener); | |
522 | + | |
523 | + function _interopRequireDefault(obj) { | |
524 | + return obj && obj.__esModule ? obj : { | |
525 | + default: obj | |
526 | + }; | |
527 | + } | |
528 | + | |
529 | + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | |
530 | + return typeof obj; | |
531 | + } : function (obj) { | |
532 | + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | |
533 | + }; | |
534 | + | |
535 | + function _classCallCheck(instance, Constructor) { | |
536 | + if (!(instance instanceof Constructor)) { | |
537 | + throw new TypeError("Cannot call a class as a function"); | |
538 | + } | |
539 | + } | |
540 | + | |
541 | + var _createClass = function () { | |
542 | + function defineProperties(target, props) { | |
543 | + for (var i = 0; i < props.length; i++) { | |
544 | + var descriptor = props[i]; | |
545 | + descriptor.enumerable = descriptor.enumerable || false; | |
546 | + descriptor.configurable = true; | |
547 | + if ("value" in descriptor) descriptor.writable = true; | |
548 | + Object.defineProperty(target, descriptor.key, descriptor); | |
549 | + } | |
550 | + } | |
551 | + | |
552 | + return function (Constructor, protoProps, staticProps) { | |
553 | + if (protoProps) defineProperties(Constructor.prototype, protoProps); | |
554 | + if (staticProps) defineProperties(Constructor, staticProps); | |
555 | + return Constructor; | |
556 | + }; | |
557 | + }(); | |
558 | + | |
559 | + function _possibleConstructorReturn(self, call) { | |
560 | + if (!self) { | |
561 | + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | |
562 | + } | |
563 | + | |
564 | + return call && (typeof call === "object" || typeof call === "function") ? call : self; | |
565 | + } | |
566 | + | |
567 | + function _inherits(subClass, superClass) { | |
568 | + if (typeof superClass !== "function" && superClass !== null) { | |
569 | + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); | |
570 | + } | |
571 | + | |
572 | + subClass.prototype = Object.create(superClass && superClass.prototype, { | |
573 | + constructor: { | |
574 | + value: subClass, | |
575 | + enumerable: false, | |
576 | + writable: true, | |
577 | + configurable: true | |
578 | + } | |
579 | + }); | |
580 | + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; | |
581 | + } | |
582 | + | |
583 | + var Clipboard = function (_Emitter) { | |
584 | + _inherits(Clipboard, _Emitter); | |
585 | + | |
586 | + /** | |
587 | + * @param {String|HTMLElement|HTMLCollection|NodeList} trigger | |
588 | + * @param {Object} options | |
589 | + */ | |
590 | + function Clipboard(trigger, options) { | |
591 | + _classCallCheck(this, Clipboard); | |
592 | + | |
593 | + var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); | |
594 | + | |
595 | + _this.resolveOptions(options); | |
596 | + _this.listenClick(trigger); | |
597 | + return _this; | |
598 | + } | |
599 | + | |
600 | + /** | |
601 | + * Defines if attributes would be resolved using internal setter functions | |
602 | + * or custom functions that were passed in the constructor. | |
603 | + * @param {Object} options | |
604 | + */ | |
605 | + | |
606 | + | |
607 | + _createClass(Clipboard, [{ | |
608 | + key: 'resolveOptions', | |
609 | + value: function resolveOptions() { | |
610 | + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | |
611 | + | |
612 | + this.action = typeof options.action === 'function' ? options.action : this.defaultAction; | |
613 | + this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; | |
614 | + this.text = typeof options.text === 'function' ? options.text : this.defaultText; | |
615 | + this.container = _typeof(options.container) === 'object' ? options.container : document.body; | |
616 | + } | |
617 | + }, { | |
618 | + key: 'listenClick', | |
619 | + value: function listenClick(trigger) { | |
620 | + var _this2 = this; | |
621 | + | |
622 | + this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) { | |
623 | + return _this2.onClick(e); | |
624 | + }); | |
625 | + } | |
626 | + }, { | |
627 | + key: 'onClick', | |
628 | + value: function onClick(e) { | |
629 | + var trigger = e.delegateTarget || e.currentTarget; | |
630 | + | |
631 | + if (this.clipboardAction) { | |
632 | + this.clipboardAction = null; | |
633 | + } | |
634 | + | |
635 | + this.clipboardAction = new _clipboardAction2.default({ | |
636 | + action: this.action(trigger), | |
637 | + target: this.target(trigger), | |
638 | + text: this.text(trigger), | |
639 | + container: this.container, | |
640 | + trigger: trigger, | |
641 | + emitter: this | |
642 | + }); | |
643 | + } | |
644 | + }, { | |
645 | + key: 'defaultAction', | |
646 | + value: function defaultAction(trigger) { | |
647 | + return getAttributeValue('action', trigger); | |
648 | + } | |
649 | + }, { | |
650 | + key: 'defaultTarget', | |
651 | + value: function defaultTarget(trigger) { | |
652 | + var selector = getAttributeValue('target', trigger); | |
653 | + | |
654 | + if (selector) { | |
655 | + return document.querySelector(selector); | |
656 | + } | |
657 | + } | |
658 | + }, { | |
659 | + key: 'defaultText', | |
660 | + value: function defaultText(trigger) { | |
661 | + return getAttributeValue('text', trigger); | |
662 | + } | |
663 | + }, { | |
664 | + key: 'destroy', | |
665 | + value: function destroy() { | |
666 | + this.listener.destroy(); | |
667 | + | |
668 | + if (this.clipboardAction) { | |
669 | + this.clipboardAction.destroy(); | |
670 | + this.clipboardAction = null; | |
671 | + } | |
672 | + } | |
673 | + }], [{ | |
674 | + key: 'isSupported', | |
675 | + value: function isSupported() { | |
676 | + var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; | |
677 | + | |
678 | + var actions = typeof action === 'string' ? [action] : action; | |
679 | + var support = !!document.queryCommandSupported; | |
680 | + | |
681 | + actions.forEach(function (action) { | |
682 | + support = support && !!document.queryCommandSupported(action); | |
683 | + }); | |
684 | + | |
685 | + return support; | |
686 | + } | |
687 | + }]); | |
688 | + | |
689 | + return Clipboard; | |
690 | + }(_tinyEmitter2.default); | |
691 | + | |
692 | + /** | |
693 | + * Helper function to retrieve attribute value. | |
694 | + * @param {String} suffix | |
695 | + * @param {Element} element | |
696 | + */ | |
697 | + function getAttributeValue(suffix, element) { | |
698 | + var attribute = 'data-clipboard-' + suffix; | |
699 | + | |
700 | + if (!element.hasAttribute(attribute)) { | |
701 | + return; | |
702 | + } | |
703 | + | |
704 | + return element.getAttribute(attribute); | |
705 | + } | |
706 | + | |
707 | + module.exports = Clipboard; | |
708 | +}); | |
709 | + | |
710 | +/***/ }), | |
711 | +/* 4 */ | |
712 | +/***/ (function(module, exports) { | |
713 | + | |
714 | +var DOCUMENT_NODE_TYPE = 9; | |
715 | + | |
716 | +/** | |
717 | + * A polyfill for Element.matches() | |
718 | + */ | |
719 | +if (typeof Element !== 'undefined' && !Element.prototype.matches) { | |
720 | + var proto = Element.prototype; | |
721 | + | |
722 | + proto.matches = proto.matchesSelector || | |
723 | + proto.mozMatchesSelector || | |
724 | + proto.msMatchesSelector || | |
725 | + proto.oMatchesSelector || | |
726 | + proto.webkitMatchesSelector; | |
727 | +} | |
728 | + | |
729 | +/** | |
730 | + * Finds the closest parent that matches a selector. | |
731 | + * | |
732 | + * @param {Element} element | |
733 | + * @param {String} selector | |
734 | + * @return {Function} | |
735 | + */ | |
736 | +function closest (element, selector) { | |
737 | + while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { | |
738 | + if (typeof element.matches === 'function' && | |
739 | + element.matches(selector)) { | |
740 | + return element; | |
741 | + } | |
742 | + element = element.parentNode; | |
743 | + } | |
744 | +} | |
745 | + | |
746 | +module.exports = closest; | |
747 | + | |
748 | + | |
749 | +/***/ }), | |
750 | +/* 5 */ | |
751 | +/***/ (function(module, exports, __webpack_require__) { | |
752 | + | |
753 | +var closest = __webpack_require__(4); | |
754 | + | |
755 | +/** | |
756 | + * Delegates event to a selector. | |
757 | + * | |
758 | + * @param {Element} element | |
759 | + * @param {String} selector | |
760 | + * @param {String} type | |
761 | + * @param {Function} callback | |
762 | + * @param {Boolean} useCapture | |
763 | + * @return {Object} | |
764 | + */ | |
765 | +function _delegate(element, selector, type, callback, useCapture) { | |
766 | + var listenerFn = listener.apply(this, arguments); | |
767 | + | |
768 | + element.addEventListener(type, listenerFn, useCapture); | |
769 | + | |
770 | + return { | |
771 | + destroy: function() { | |
772 | + element.removeEventListener(type, listenerFn, useCapture); | |
773 | + } | |
774 | + } | |
775 | +} | |
776 | + | |
777 | +/** | |
778 | + * Delegates event to a selector. | |
779 | + * | |
780 | + * @param {Element|String|Array} [elements] | |
781 | + * @param {String} selector | |
782 | + * @param {String} type | |
783 | + * @param {Function} callback | |
784 | + * @param {Boolean} useCapture | |
785 | + * @return {Object} | |
786 | + */ | |
787 | +function delegate(elements, selector, type, callback, useCapture) { | |
788 | + // Handle the regular Element usage | |
789 | + if (typeof elements.addEventListener === 'function') { | |
790 | + return _delegate.apply(null, arguments); | |
791 | + } | |
792 | + | |
793 | + // Handle Element-less usage, it defaults to global delegation | |
794 | + if (typeof type === 'function') { | |
795 | + // Use `document` as the first parameter, then apply arguments | |
796 | + // This is a short way to .unshift `arguments` without running into deoptimizations | |
797 | + return _delegate.bind(null, document).apply(null, arguments); | |
798 | + } | |
799 | + | |
800 | + // Handle Selector-based usage | |
801 | + if (typeof elements === 'string') { | |
802 | + elements = document.querySelectorAll(elements); | |
803 | + } | |
804 | + | |
805 | + // Handle Array-like based usage | |
806 | + return Array.prototype.map.call(elements, function (element) { | |
807 | + return _delegate(element, selector, type, callback, useCapture); | |
808 | + }); | |
809 | +} | |
810 | + | |
811 | +/** | |
812 | + * Finds closest match and invokes callback. | |
813 | + * | |
814 | + * @param {Element} element | |
815 | + * @param {String} selector | |
816 | + * @param {String} type | |
817 | + * @param {Function} callback | |
818 | + * @return {Function} | |
819 | + */ | |
820 | +function listener(element, selector, type, callback) { | |
821 | + return function(e) { | |
822 | + e.delegateTarget = closest(e.target, selector); | |
823 | + | |
824 | + if (e.delegateTarget) { | |
825 | + callback.call(element, e); | |
826 | + } | |
827 | + } | |
828 | +} | |
829 | + | |
830 | +module.exports = delegate; | |
831 | + | |
832 | + | |
833 | +/***/ }), | |
834 | +/* 6 */ | |
835 | +/***/ (function(module, exports) { | |
836 | + | |
837 | +/** | |
838 | + * Check if argument is a HTML element. | |
839 | + * | |
840 | + * @param {Object} value | |
841 | + * @return {Boolean} | |
842 | + */ | |
843 | +exports.node = function(value) { | |
844 | + return value !== undefined | |
845 | + && value instanceof HTMLElement | |
846 | + && value.nodeType === 1; | |
847 | +}; | |
848 | + | |
849 | +/** | |
850 | + * Check if argument is a list of HTML elements. | |
851 | + * | |
852 | + * @param {Object} value | |
853 | + * @return {Boolean} | |
854 | + */ | |
855 | +exports.nodeList = function(value) { | |
856 | + var type = Object.prototype.toString.call(value); | |
857 | + | |
858 | + return value !== undefined | |
859 | + && (type === '[object NodeList]' || type === '[object HTMLCollection]') | |
860 | + && ('length' in value) | |
861 | + && (value.length === 0 || exports.node(value[0])); | |
862 | +}; | |
863 | + | |
864 | +/** | |
865 | + * Check if argument is a string. | |
866 | + * | |
867 | + * @param {Object} value | |
868 | + * @return {Boolean} | |
869 | + */ | |
870 | +exports.string = function(value) { | |
871 | + return typeof value === 'string' | |
872 | + || value instanceof String; | |
873 | +}; | |
874 | + | |
875 | +/** | |
876 | + * Check if argument is a function. | |
877 | + * | |
878 | + * @param {Object} value | |
879 | + * @return {Boolean} | |
880 | + */ | |
881 | +exports.fn = function(value) { | |
882 | + var type = Object.prototype.toString.call(value); | |
883 | + | |
884 | + return type === '[object Function]'; | |
885 | +}; | |
886 | + | |
887 | + | |
888 | +/***/ }), | |
889 | +/* 7 */ | |
890 | +/***/ (function(module, exports) { | |
891 | + | |
892 | +function select(element) { | |
893 | + var selectedText; | |
894 | + | |
895 | + if (element.nodeName === 'SELECT') { | |
896 | + element.focus(); | |
897 | + | |
898 | + selectedText = element.value; | |
899 | + } | |
900 | + else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { | |
901 | + var isReadOnly = element.hasAttribute('readonly'); | |
902 | + | |
903 | + if (!isReadOnly) { | |
904 | + element.setAttribute('readonly', ''); | |
905 | + } | |
906 | + | |
907 | + element.select(); | |
908 | + element.setSelectionRange(0, element.value.length); | |
909 | + | |
910 | + if (!isReadOnly) { | |
911 | + element.removeAttribute('readonly'); | |
912 | + } | |
913 | + | |
914 | + selectedText = element.value; | |
915 | + } | |
916 | + else { | |
917 | + if (element.hasAttribute('contenteditable')) { | |
918 | + element.focus(); | |
919 | + } | |
920 | + | |
921 | + var selection = window.getSelection(); | |
922 | + var range = document.createRange(); | |
923 | + | |
924 | + range.selectNodeContents(element); | |
925 | + selection.removeAllRanges(); | |
926 | + selection.addRange(range); | |
927 | + | |
928 | + selectedText = selection.toString(); | |
929 | + } | |
930 | + | |
931 | + return selectedText; | |
932 | +} | |
933 | + | |
934 | +module.exports = select; | |
935 | + | |
936 | + | |
937 | +/***/ }) | |
938 | +/******/ ]); | |
939 | +});(No newline at end of file) |
--- public/javascripts/lib/clipboard.min.js
... | ... | @@ -1,7 +0,0 @@ |
1 | -/*! | |
2 | - * clipboard.js v1.7.1 | |
3 | - * https://zenorocha.github.io/clipboard.js | |
4 | - * | |
5 | - * Licensed MIT © Zeno Rocha | |
6 | - */ | |
7 | -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n||t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){function o(t,e){for(;t&&t.nodeType!==i;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e),n.delegateTarget&&o.call(t,n)}}var r=t("./closest");e.exports=o},{"./closest":1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return l(document.body,t,e,n)}var c=t("./is"),l=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),i=document.createRange();i.selectNodeContents(t),o.removeAllRanges(),o.addRange(i),e=o.toString()}return e}e.exports=o},{}],6:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;r<a;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],7:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if(void 0!==o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return a(t,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function t(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function t(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function t(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function t(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function t(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function t(){this.removeFake()}},{key:"action",set:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:5}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if(void 0!==o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function l(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var s=i(e),u=i(n),f=i(o),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),p=function(t){function e(t,n){r(this,e);var o=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return o.resolveOptions(n),o.listenClick(t),o}return c(e,t),h(e,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})}},{key:"onClick",value:function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(n),target:this.target(n),text:this.text(n),container:this.container,trigger:n,emitter:this})}},{key:"defaultAction",value:function t(e){return l("action",e)}},{key:"defaultTarget",value:function t(e){var n=l("target",e);if(n)return document.querySelector(n)}},{key:"defaultText",value:function t(e){return l("text",e)}},{key:"destroy",value:function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof e?[e]:e,o=!!document.queryCommandSupported;return n.forEach(function(t){o=o&&!!document.queryCommandSupported(t)}),o}}]),e}(u.default);t.exports=p})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});(No newline at end of file) |
--- public/javascripts/service/yobi.project.Home.js
+++ public/javascripts/service/yobi.project.Home.js
... | ... | @@ -68,9 +68,9 @@ |
68 | 68 |
function _attachEvent(){ |
69 | 69 |
htElement.welRepoURL.click(_onClickRepoURL); |
70 | 70 |
|
71 |
- if (Clipboard && Clipboard.isSupported()) { |
|
71 |
+ if (ClipboardJS && ClipboardJS.isSupported()) { |
|
72 | 72 |
// Using clipboard.min.js if supports clipboard api. |
73 |
- new Clipboard(htElement.welBtnCopy[0], { |
|
73 |
+ new ClipboardJS(htElement.welBtnCopy[0], { |
|
74 | 74 |
target: function() { |
75 | 75 |
return document.getElementById('cloneURL'); |
76 | 76 |
} |
--- public/javascripts/yona-common.js
+++ public/javascripts/yona-common.js
... | ... | @@ -7633,11 +7633,942 @@ |
7633 | 7633 |
|
7634 | 7634 |
return exports; |
7635 | 7635 |
|
7636 |
-})); |
|
7637 |
-/*! |
|
7638 |
- * clipboard.js v1.7.1 |
|
7636 |
+}));/*! |
|
7637 |
+ * clipboard.js v2.0.0 |
|
7639 | 7638 |
* https://zenorocha.github.io/clipboard.js |
7640 |
- * |
|
7639 |
+ * |
|
7641 | 7640 |
* Licensed MIT © Zeno Rocha |
7642 | 7641 |
*/ |
7643 |
-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n||t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){function o(t,e){for(;t&&t.nodeType!==i;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e),n.delegateTarget&&o.call(t,n)}}var r=t("./closest");e.exports=o},{"./closest":1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return l(document.body,t,e,n)}var c=t("./is"),l=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),i=document.createRange();i.selectNodeContents(t),o.removeAllRanges(),o.addRange(i),e=o.toString()}return e}e.exports=o},{}],6:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;r<a;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],7:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if(void 0!==o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return a(t,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function t(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function t(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function t(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function t(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function t(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function t(){this.removeFake()}},{key:"action",set:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:5}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if(void 0!==o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function l(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var s=i(e),u=i(n),f=i(o),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),p=function(t){function e(t,n){r(this,e);var o=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return o.resolveOptions(n),o.listenClick(t),o}return c(e,t),h(e,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})}},{key:"onClick",value:function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(n),target:this.target(n),text:this.text(n),container:this.container,trigger:n,emitter:this})}},{key:"defaultAction",value:function t(e){return l("action",e)}},{key:"defaultTarget",value:function t(e){var n=l("target",e);if(n)return document.querySelector(n)}},{key:"defaultText",value:function t(e){return l("text",e)}},{key:"destroy",value:function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof e?[e]:e,o=!!document.queryCommandSupported;return n.forEach(function(t){o=o&&!!document.queryCommandSupported(t)}),o}}]),e}(u.default);t.exports=p})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)}); |
|
7642 |
+(function webpackUniversalModuleDefinition(root, factory) { |
|
7643 |
+ if(typeof exports === 'object' && typeof module === 'object') |
|
7644 |
+ module.exports = factory(); |
|
7645 |
+ else if(typeof define === 'function' && define.amd) |
|
7646 |
+ define([], factory); |
|
7647 |
+ else if(typeof exports === 'object') |
|
7648 |
+ exports["ClipboardJS"] = factory(); |
|
7649 |
+ else |
|
7650 |
+ root["ClipboardJS"] = factory(); |
|
7651 |
+})(this, function() { |
|
7652 |
+return /******/ (function(modules) { // webpackBootstrap |
|
7653 |
+/******/ // The module cache |
|
7654 |
+/******/ var installedModules = {}; |
|
7655 |
+/******/ |
|
7656 |
+/******/ // The require function |
|
7657 |
+/******/ function __webpack_require__(moduleId) { |
|
7658 |
+/******/ |
|
7659 |
+/******/ // Check if module is in cache |
|
7660 |
+/******/ if(installedModules[moduleId]) { |
|
7661 |
+/******/ return installedModules[moduleId].exports; |
|
7662 |
+/******/ } |
|
7663 |
+/******/ // Create a new module (and put it into the cache) |
|
7664 |
+/******/ var module = installedModules[moduleId] = { |
|
7665 |
+/******/ i: moduleId, |
|
7666 |
+/******/ l: false, |
|
7667 |
+/******/ exports: {} |
|
7668 |
+/******/ }; |
|
7669 |
+/******/ |
|
7670 |
+/******/ // Execute the module function |
|
7671 |
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
7672 |
+/******/ |
|
7673 |
+/******/ // Flag the module as loaded |
|
7674 |
+/******/ module.l = true; |
|
7675 |
+/******/ |
|
7676 |
+/******/ // Return the exports of the module |
|
7677 |
+/******/ return module.exports; |
|
7678 |
+/******/ } |
|
7679 |
+/******/ |
|
7680 |
+/******/ |
|
7681 |
+/******/ // expose the modules object (__webpack_modules__) |
|
7682 |
+/******/ __webpack_require__.m = modules; |
|
7683 |
+/******/ |
|
7684 |
+/******/ // expose the module cache |
|
7685 |
+/******/ __webpack_require__.c = installedModules; |
|
7686 |
+/******/ |
|
7687 |
+/******/ // identity function for calling harmony imports with the correct context |
|
7688 |
+/******/ __webpack_require__.i = function(value) { return value; }; |
|
7689 |
+/******/ |
|
7690 |
+/******/ // define getter function for harmony exports |
|
7691 |
+/******/ __webpack_require__.d = function(exports, name, getter) { |
|
7692 |
+/******/ if(!__webpack_require__.o(exports, name)) { |
|
7693 |
+/******/ Object.defineProperty(exports, name, { |
|
7694 |
+/******/ configurable: false, |
|
7695 |
+/******/ enumerable: true, |
|
7696 |
+/******/ get: getter |
|
7697 |
+/******/ }); |
|
7698 |
+/******/ } |
|
7699 |
+/******/ }; |
|
7700 |
+/******/ |
|
7701 |
+/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
7702 |
+/******/ __webpack_require__.n = function(module) { |
|
7703 |
+/******/ var getter = module && module.__esModule ? |
|
7704 |
+/******/ function getDefault() { return module['default']; } : |
|
7705 |
+/******/ function getModuleExports() { return module; }; |
|
7706 |
+/******/ __webpack_require__.d(getter, 'a', getter); |
|
7707 |
+/******/ return getter; |
|
7708 |
+/******/ }; |
|
7709 |
+/******/ |
|
7710 |
+/******/ // Object.prototype.hasOwnProperty.call |
|
7711 |
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
7712 |
+/******/ |
|
7713 |
+/******/ // __webpack_public_path__ |
|
7714 |
+/******/ __webpack_require__.p = ""; |
|
7715 |
+/******/ |
|
7716 |
+/******/ // Load entry module and return exports |
|
7717 |
+/******/ return __webpack_require__(__webpack_require__.s = 3); |
|
7718 |
+/******/ }) |
|
7719 |
+/************************************************************************/ |
|
7720 |
+/******/ ([ |
|
7721 |
+/* 0 */ |
|
7722 |
+/***/ (function(module, exports, __webpack_require__) { |
|
7723 |
+ |
|
7724 |
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { |
|
7725 |
+ if (true) { |
|
7726 |
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(7)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
|
7727 |
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
|
7728 |
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), |
|
7729 |
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
7730 |
+ } else if (typeof exports !== "undefined") { |
|
7731 |
+ factory(module, require('select')); |
|
7732 |
+ } else { |
|
7733 |
+ var mod = { |
|
7734 |
+ exports: {} |
|
7735 |
+ }; |
|
7736 |
+ factory(mod, global.select); |
|
7737 |
+ global.clipboardAction = mod.exports; |
|
7738 |
+ } |
|
7739 |
+})(this, function (module, _select) { |
|
7740 |
+ 'use strict'; |
|
7741 |
+ |
|
7742 |
+ var _select2 = _interopRequireDefault(_select); |
|
7743 |
+ |
|
7744 |
+ function _interopRequireDefault(obj) { |
|
7745 |
+ return obj && obj.__esModule ? obj : { |
|
7746 |
+ default: obj |
|
7747 |
+ }; |
|
7748 |
+ } |
|
7749 |
+ |
|
7750 |
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
|
7751 |
+ return typeof obj; |
|
7752 |
+ } : function (obj) { |
|
7753 |
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
7754 |
+ }; |
|
7755 |
+ |
|
7756 |
+ function _classCallCheck(instance, Constructor) { |
|
7757 |
+ if (!(instance instanceof Constructor)) { |
|
7758 |
+ throw new TypeError("Cannot call a class as a function"); |
|
7759 |
+ } |
|
7760 |
+ } |
|
7761 |
+ |
|
7762 |
+ var _createClass = function () { |
|
7763 |
+ function defineProperties(target, props) { |
|
7764 |
+ for (var i = 0; i < props.length; i++) { |
|
7765 |
+ var descriptor = props[i]; |
|
7766 |
+ descriptor.enumerable = descriptor.enumerable || false; |
|
7767 |
+ descriptor.configurable = true; |
|
7768 |
+ if ("value" in descriptor) descriptor.writable = true; |
|
7769 |
+ Object.defineProperty(target, descriptor.key, descriptor); |
|
7770 |
+ } |
|
7771 |
+ } |
|
7772 |
+ |
|
7773 |
+ return function (Constructor, protoProps, staticProps) { |
|
7774 |
+ if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
7775 |
+ if (staticProps) defineProperties(Constructor, staticProps); |
|
7776 |
+ return Constructor; |
|
7777 |
+ }; |
|
7778 |
+ }(); |
|
7779 |
+ |
|
7780 |
+ var ClipboardAction = function () { |
|
7781 |
+ /** |
|
7782 |
+ * @param {Object} options |
|
7783 |
+ */ |
|
7784 |
+ function ClipboardAction(options) { |
|
7785 |
+ _classCallCheck(this, ClipboardAction); |
|
7786 |
+ |
|
7787 |
+ this.resolveOptions(options); |
|
7788 |
+ this.initSelection(); |
|
7789 |
+ } |
|
7790 |
+ |
|
7791 |
+ /** |
|
7792 |
+ * Defines base properties passed from constructor. |
|
7793 |
+ * @param {Object} options |
|
7794 |
+ */ |
|
7795 |
+ |
|
7796 |
+ |
|
7797 |
+ _createClass(ClipboardAction, [{ |
|
7798 |
+ key: 'resolveOptions', |
|
7799 |
+ value: function resolveOptions() { |
|
7800 |
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
7801 |
+ |
|
7802 |
+ this.action = options.action; |
|
7803 |
+ this.container = options.container; |
|
7804 |
+ this.emitter = options.emitter; |
|
7805 |
+ this.target = options.target; |
|
7806 |
+ this.text = options.text; |
|
7807 |
+ this.trigger = options.trigger; |
|
7808 |
+ |
|
7809 |
+ this.selectedText = ''; |
|
7810 |
+ } |
|
7811 |
+ }, { |
|
7812 |
+ key: 'initSelection', |
|
7813 |
+ value: function initSelection() { |
|
7814 |
+ if (this.text) { |
|
7815 |
+ this.selectFake(); |
|
7816 |
+ } else if (this.target) { |
|
7817 |
+ this.selectTarget(); |
|
7818 |
+ } |
|
7819 |
+ } |
|
7820 |
+ }, { |
|
7821 |
+ key: 'selectFake', |
|
7822 |
+ value: function selectFake() { |
|
7823 |
+ var _this = this; |
|
7824 |
+ |
|
7825 |
+ var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; |
|
7826 |
+ |
|
7827 |
+ this.removeFake(); |
|
7828 |
+ |
|
7829 |
+ this.fakeHandlerCallback = function () { |
|
7830 |
+ return _this.removeFake(); |
|
7831 |
+ }; |
|
7832 |
+ this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true; |
|
7833 |
+ |
|
7834 |
+ this.fakeElem = document.createElement('textarea'); |
|
7835 |
+ // Prevent zooming on iOS |
|
7836 |
+ this.fakeElem.style.fontSize = '12pt'; |
|
7837 |
+ // Reset box model |
|
7838 |
+ this.fakeElem.style.border = '0'; |
|
7839 |
+ this.fakeElem.style.padding = '0'; |
|
7840 |
+ this.fakeElem.style.margin = '0'; |
|
7841 |
+ // Move element out of screen horizontally |
|
7842 |
+ this.fakeElem.style.position = 'absolute'; |
|
7843 |
+ this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; |
|
7844 |
+ // Move element to the same position vertically |
|
7845 |
+ var yPosition = window.pageYOffset || document.documentElement.scrollTop; |
|
7846 |
+ this.fakeElem.style.top = yPosition + 'px'; |
|
7847 |
+ |
|
7848 |
+ this.fakeElem.setAttribute('readonly', ''); |
|
7849 |
+ this.fakeElem.value = this.text; |
|
7850 |
+ |
|
7851 |
+ this.container.appendChild(this.fakeElem); |
|
7852 |
+ |
|
7853 |
+ this.selectedText = (0, _select2.default)(this.fakeElem); |
|
7854 |
+ this.copyText(); |
|
7855 |
+ } |
|
7856 |
+ }, { |
|
7857 |
+ key: 'removeFake', |
|
7858 |
+ value: function removeFake() { |
|
7859 |
+ if (this.fakeHandler) { |
|
7860 |
+ this.container.removeEventListener('click', this.fakeHandlerCallback); |
|
7861 |
+ this.fakeHandler = null; |
|
7862 |
+ this.fakeHandlerCallback = null; |
|
7863 |
+ } |
|
7864 |
+ |
|
7865 |
+ if (this.fakeElem) { |
|
7866 |
+ this.container.removeChild(this.fakeElem); |
|
7867 |
+ this.fakeElem = null; |
|
7868 |
+ } |
|
7869 |
+ } |
|
7870 |
+ }, { |
|
7871 |
+ key: 'selectTarget', |
|
7872 |
+ value: function selectTarget() { |
|
7873 |
+ this.selectedText = (0, _select2.default)(this.target); |
|
7874 |
+ this.copyText(); |
|
7875 |
+ } |
|
7876 |
+ }, { |
|
7877 |
+ key: 'copyText', |
|
7878 |
+ value: function copyText() { |
|
7879 |
+ var succeeded = void 0; |
|
7880 |
+ |
|
7881 |
+ try { |
|
7882 |
+ succeeded = document.execCommand(this.action); |
|
7883 |
+ } catch (err) { |
|
7884 |
+ succeeded = false; |
|
7885 |
+ } |
|
7886 |
+ |
|
7887 |
+ this.handleResult(succeeded); |
|
7888 |
+ } |
|
7889 |
+ }, { |
|
7890 |
+ key: 'handleResult', |
|
7891 |
+ value: function handleResult(succeeded) { |
|
7892 |
+ this.emitter.emit(succeeded ? 'success' : 'error', { |
|
7893 |
+ action: this.action, |
|
7894 |
+ text: this.selectedText, |
|
7895 |
+ trigger: this.trigger, |
|
7896 |
+ clearSelection: this.clearSelection.bind(this) |
|
7897 |
+ }); |
|
7898 |
+ } |
|
7899 |
+ }, { |
|
7900 |
+ key: 'clearSelection', |
|
7901 |
+ value: function clearSelection() { |
|
7902 |
+ if (this.trigger) { |
|
7903 |
+ this.trigger.focus(); |
|
7904 |
+ } |
|
7905 |
+ |
|
7906 |
+ window.getSelection().removeAllRanges(); |
|
7907 |
+ } |
|
7908 |
+ }, { |
|
7909 |
+ key: 'destroy', |
|
7910 |
+ value: function destroy() { |
|
7911 |
+ this.removeFake(); |
|
7912 |
+ } |
|
7913 |
+ }, { |
|
7914 |
+ key: 'action', |
|
7915 |
+ set: function set() { |
|
7916 |
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; |
|
7917 |
+ |
|
7918 |
+ this._action = action; |
|
7919 |
+ |
|
7920 |
+ if (this._action !== 'copy' && this._action !== 'cut') { |
|
7921 |
+ throw new Error('Invalid "action" value, use either "copy" or "cut"'); |
|
7922 |
+ } |
|
7923 |
+ }, |
|
7924 |
+ get: function get() { |
|
7925 |
+ return this._action; |
|
7926 |
+ } |
|
7927 |
+ }, { |
|
7928 |
+ key: 'target', |
|
7929 |
+ set: function set(target) { |
|
7930 |
+ if (target !== undefined) { |
|
7931 |
+ if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { |
|
7932 |
+ if (this.action === 'copy' && target.hasAttribute('disabled')) { |
|
7933 |
+ throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); |
|
7934 |
+ } |
|
7935 |
+ |
|
7936 |
+ if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { |
|
7937 |
+ throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); |
|
7938 |
+ } |
|
7939 |
+ |
|
7940 |
+ this._target = target; |
|
7941 |
+ } else { |
|
7942 |
+ throw new Error('Invalid "target" value, use a valid Element'); |
|
7943 |
+ } |
|
7944 |
+ } |
|
7945 |
+ }, |
|
7946 |
+ get: function get() { |
|
7947 |
+ return this._target; |
|
7948 |
+ } |
|
7949 |
+ }]); |
|
7950 |
+ |
|
7951 |
+ return ClipboardAction; |
|
7952 |
+ }(); |
|
7953 |
+ |
|
7954 |
+ module.exports = ClipboardAction; |
|
7955 |
+}); |
|
7956 |
+ |
|
7957 |
+/***/ }), |
|
7958 |
+/* 1 */ |
|
7959 |
+/***/ (function(module, exports, __webpack_require__) { |
|
7960 |
+ |
|
7961 |
+var is = __webpack_require__(6); |
|
7962 |
+var delegate = __webpack_require__(5); |
|
7963 |
+ |
|
7964 |
+/** |
|
7965 |
+ * Validates all params and calls the right |
|
7966 |
+ * listener function based on its target type. |
|
7967 |
+ * |
|
7968 |
+ * @param {String|HTMLElement|HTMLCollection|NodeList} target |
|
7969 |
+ * @param {String} type |
|
7970 |
+ * @param {Function} callback |
|
7971 |
+ * @return {Object} |
|
7972 |
+ */ |
|
7973 |
+function listen(target, type, callback) { |
|
7974 |
+ if (!target && !type && !callback) { |
|
7975 |
+ throw new Error('Missing required arguments'); |
|
7976 |
+ } |
|
7977 |
+ |
|
7978 |
+ if (!is.string(type)) { |
|
7979 |
+ throw new TypeError('Second argument must be a String'); |
|
7980 |
+ } |
|
7981 |
+ |
|
7982 |
+ if (!is.fn(callback)) { |
|
7983 |
+ throw new TypeError('Third argument must be a Function'); |
|
7984 |
+ } |
|
7985 |
+ |
|
7986 |
+ if (is.node(target)) { |
|
7987 |
+ return listenNode(target, type, callback); |
|
7988 |
+ } |
|
7989 |
+ else if (is.nodeList(target)) { |
|
7990 |
+ return listenNodeList(target, type, callback); |
|
7991 |
+ } |
|
7992 |
+ else if (is.string(target)) { |
|
7993 |
+ return listenSelector(target, type, callback); |
|
7994 |
+ } |
|
7995 |
+ else { |
|
7996 |
+ throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); |
|
7997 |
+ } |
|
7998 |
+} |
|
7999 |
+ |
|
8000 |
+/** |
|
8001 |
+ * Adds an event listener to a HTML element |
|
8002 |
+ * and returns a remove listener function. |
|
8003 |
+ * |
|
8004 |
+ * @param {HTMLElement} node |
|
8005 |
+ * @param {String} type |
|
8006 |
+ * @param {Function} callback |
|
8007 |
+ * @return {Object} |
|
8008 |
+ */ |
|
8009 |
+function listenNode(node, type, callback) { |
|
8010 |
+ node.addEventListener(type, callback); |
|
8011 |
+ |
|
8012 |
+ return { |
|
8013 |
+ destroy: function() { |
|
8014 |
+ node.removeEventListener(type, callback); |
|
8015 |
+ } |
|
8016 |
+ } |
|
8017 |
+} |
|
8018 |
+ |
|
8019 |
+/** |
|
8020 |
+ * Add an event listener to a list of HTML elements |
|
8021 |
+ * and returns a remove listener function. |
|
8022 |
+ * |
|
8023 |
+ * @param {NodeList|HTMLCollection} nodeList |
|
8024 |
+ * @param {String} type |
|
8025 |
+ * @param {Function} callback |
|
8026 |
+ * @return {Object} |
|
8027 |
+ */ |
|
8028 |
+function listenNodeList(nodeList, type, callback) { |
|
8029 |
+ Array.prototype.forEach.call(nodeList, function(node) { |
|
8030 |
+ node.addEventListener(type, callback); |
|
8031 |
+ }); |
|
8032 |
+ |
|
8033 |
+ return { |
|
8034 |
+ destroy: function() { |
|
8035 |
+ Array.prototype.forEach.call(nodeList, function(node) { |
|
8036 |
+ node.removeEventListener(type, callback); |
|
8037 |
+ }); |
|
8038 |
+ } |
|
8039 |
+ } |
|
8040 |
+} |
|
8041 |
+ |
|
8042 |
+/** |
|
8043 |
+ * Add an event listener to a selector |
|
8044 |
+ * and returns a remove listener function. |
|
8045 |
+ * |
|
8046 |
+ * @param {String} selector |
|
8047 |
+ * @param {String} type |
|
8048 |
+ * @param {Function} callback |
|
8049 |
+ * @return {Object} |
|
8050 |
+ */ |
|
8051 |
+function listenSelector(selector, type, callback) { |
|
8052 |
+ return delegate(document.body, selector, type, callback); |
|
8053 |
+} |
|
8054 |
+ |
|
8055 |
+module.exports = listen; |
|
8056 |
+ |
|
8057 |
+ |
|
8058 |
+/***/ }), |
|
8059 |
+/* 2 */ |
|
8060 |
+/***/ (function(module, exports) { |
|
8061 |
+ |
|
8062 |
+function E () { |
|
8063 |
+ // Keep this empty so it's easier to inherit from |
|
8064 |
+ // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) |
|
8065 |
+} |
|
8066 |
+ |
|
8067 |
+E.prototype = { |
|
8068 |
+ on: function (name, callback, ctx) { |
|
8069 |
+ var e = this.e || (this.e = {}); |
|
8070 |
+ |
|
8071 |
+ (e[name] || (e[name] = [])).push({ |
|
8072 |
+ fn: callback, |
|
8073 |
+ ctx: ctx |
|
8074 |
+ }); |
|
8075 |
+ |
|
8076 |
+ return this; |
|
8077 |
+ }, |
|
8078 |
+ |
|
8079 |
+ once: function (name, callback, ctx) { |
|
8080 |
+ var self = this; |
|
8081 |
+ function listener () { |
|
8082 |
+ self.off(name, listener); |
|
8083 |
+ callback.apply(ctx, arguments); |
|
8084 |
+ }; |
|
8085 |
+ |
|
8086 |
+ listener._ = callback |
|
8087 |
+ return this.on(name, listener, ctx); |
|
8088 |
+ }, |
|
8089 |
+ |
|
8090 |
+ emit: function (name) { |
|
8091 |
+ var data = [].slice.call(arguments, 1); |
|
8092 |
+ var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); |
|
8093 |
+ var i = 0; |
|
8094 |
+ var len = evtArr.length; |
|
8095 |
+ |
|
8096 |
+ for (i; i < len; i++) { |
|
8097 |
+ evtArr[i].fn.apply(evtArr[i].ctx, data); |
|
8098 |
+ } |
|
8099 |
+ |
|
8100 |
+ return this; |
|
8101 |
+ }, |
|
8102 |
+ |
|
8103 |
+ off: function (name, callback) { |
|
8104 |
+ var e = this.e || (this.e = {}); |
|
8105 |
+ var evts = e[name]; |
|
8106 |
+ var liveEvents = []; |
|
8107 |
+ |
|
8108 |
+ if (evts && callback) { |
|
8109 |
+ for (var i = 0, len = evts.length; i < len; i++) { |
|
8110 |
+ if (evts[i].fn !== callback && evts[i].fn._ !== callback) |
|
8111 |
+ liveEvents.push(evts[i]); |
|
8112 |
+ } |
|
8113 |
+ } |
|
8114 |
+ |
|
8115 |
+ // Remove event from queue to prevent memory leak |
|
8116 |
+ // Suggested by https://github.com/lazd |
|
8117 |
+ // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 |
|
8118 |
+ |
|
8119 |
+ (liveEvents.length) |
|
8120 |
+ ? e[name] = liveEvents |
|
8121 |
+ : delete e[name]; |
|
8122 |
+ |
|
8123 |
+ return this; |
|
8124 |
+ } |
|
8125 |
+}; |
|
8126 |
+ |
|
8127 |
+module.exports = E; |
|
8128 |
+ |
|
8129 |
+ |
|
8130 |
+/***/ }), |
|
8131 |
+/* 3 */ |
|
8132 |
+/***/ (function(module, exports, __webpack_require__) { |
|
8133 |
+ |
|
8134 |
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { |
|
8135 |
+ if (true) { |
|
8136 |
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, __webpack_require__(0), __webpack_require__(2), __webpack_require__(1)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
|
8137 |
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
|
8138 |
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), |
|
8139 |
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
8140 |
+ } else if (typeof exports !== "undefined") { |
|
8141 |
+ factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener')); |
|
8142 |
+ } else { |
|
8143 |
+ var mod = { |
|
8144 |
+ exports: {} |
|
8145 |
+ }; |
|
8146 |
+ factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener); |
|
8147 |
+ global.clipboard = mod.exports; |
|
8148 |
+ } |
|
8149 |
+})(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) { |
|
8150 |
+ 'use strict'; |
|
8151 |
+ |
|
8152 |
+ var _clipboardAction2 = _interopRequireDefault(_clipboardAction); |
|
8153 |
+ |
|
8154 |
+ var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); |
|
8155 |
+ |
|
8156 |
+ var _goodListener2 = _interopRequireDefault(_goodListener); |
|
8157 |
+ |
|
8158 |
+ function _interopRequireDefault(obj) { |
|
8159 |
+ return obj && obj.__esModule ? obj : { |
|
8160 |
+ default: obj |
|
8161 |
+ }; |
|
8162 |
+ } |
|
8163 |
+ |
|
8164 |
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
|
8165 |
+ return typeof obj; |
|
8166 |
+ } : function (obj) { |
|
8167 |
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
8168 |
+ }; |
|
8169 |
+ |
|
8170 |
+ function _classCallCheck(instance, Constructor) { |
|
8171 |
+ if (!(instance instanceof Constructor)) { |
|
8172 |
+ throw new TypeError("Cannot call a class as a function"); |
|
8173 |
+ } |
|
8174 |
+ } |
|
8175 |
+ |
|
8176 |
+ var _createClass = function () { |
|
8177 |
+ function defineProperties(target, props) { |
|
8178 |
+ for (var i = 0; i < props.length; i++) { |
|
8179 |
+ var descriptor = props[i]; |
|
8180 |
+ descriptor.enumerable = descriptor.enumerable || false; |
|
8181 |
+ descriptor.configurable = true; |
|
8182 |
+ if ("value" in descriptor) descriptor.writable = true; |
|
8183 |
+ Object.defineProperty(target, descriptor.key, descriptor); |
|
8184 |
+ } |
|
8185 |
+ } |
|
8186 |
+ |
|
8187 |
+ return function (Constructor, protoProps, staticProps) { |
|
8188 |
+ if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
8189 |
+ if (staticProps) defineProperties(Constructor, staticProps); |
|
8190 |
+ return Constructor; |
|
8191 |
+ }; |
|
8192 |
+ }(); |
|
8193 |
+ |
|
8194 |
+ function _possibleConstructorReturn(self, call) { |
|
8195 |
+ if (!self) { |
|
8196 |
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
8197 |
+ } |
|
8198 |
+ |
|
8199 |
+ return call && (typeof call === "object" || typeof call === "function") ? call : self; |
|
8200 |
+ } |
|
8201 |
+ |
|
8202 |
+ function _inherits(subClass, superClass) { |
|
8203 |
+ if (typeof superClass !== "function" && superClass !== null) { |
|
8204 |
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); |
|
8205 |
+ } |
|
8206 |
+ |
|
8207 |
+ subClass.prototype = Object.create(superClass && superClass.prototype, { |
|
8208 |
+ constructor: { |
|
8209 |
+ value: subClass, |
|
8210 |
+ enumerable: false, |
|
8211 |
+ writable: true, |
|
8212 |
+ configurable: true |
|
8213 |
+ } |
|
8214 |
+ }); |
|
8215 |
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; |
|
8216 |
+ } |
|
8217 |
+ |
|
8218 |
+ var Clipboard = function (_Emitter) { |
|
8219 |
+ _inherits(Clipboard, _Emitter); |
|
8220 |
+ |
|
8221 |
+ /** |
|
8222 |
+ * @param {String|HTMLElement|HTMLCollection|NodeList} trigger |
|
8223 |
+ * @param {Object} options |
|
8224 |
+ */ |
|
8225 |
+ function Clipboard(trigger, options) { |
|
8226 |
+ _classCallCheck(this, Clipboard); |
|
8227 |
+ |
|
8228 |
+ var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); |
|
8229 |
+ |
|
8230 |
+ _this.resolveOptions(options); |
|
8231 |
+ _this.listenClick(trigger); |
|
8232 |
+ return _this; |
|
8233 |
+ } |
|
8234 |
+ |
|
8235 |
+ /** |
|
8236 |
+ * Defines if attributes would be resolved using internal setter functions |
|
8237 |
+ * or custom functions that were passed in the constructor. |
|
8238 |
+ * @param {Object} options |
|
8239 |
+ */ |
|
8240 |
+ |
|
8241 |
+ |
|
8242 |
+ _createClass(Clipboard, [{ |
|
8243 |
+ key: 'resolveOptions', |
|
8244 |
+ value: function resolveOptions() { |
|
8245 |
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8246 |
+ |
|
8247 |
+ this.action = typeof options.action === 'function' ? options.action : this.defaultAction; |
|
8248 |
+ this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; |
|
8249 |
+ this.text = typeof options.text === 'function' ? options.text : this.defaultText; |
|
8250 |
+ this.container = _typeof(options.container) === 'object' ? options.container : document.body; |
|
8251 |
+ } |
|
8252 |
+ }, { |
|
8253 |
+ key: 'listenClick', |
|
8254 |
+ value: function listenClick(trigger) { |
|
8255 |
+ var _this2 = this; |
|
8256 |
+ |
|
8257 |
+ this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) { |
|
8258 |
+ return _this2.onClick(e); |
|
8259 |
+ }); |
|
8260 |
+ } |
|
8261 |
+ }, { |
|
8262 |
+ key: 'onClick', |
|
8263 |
+ value: function onClick(e) { |
|
8264 |
+ var trigger = e.delegateTarget || e.currentTarget; |
|
8265 |
+ |
|
8266 |
+ if (this.clipboardAction) { |
|
8267 |
+ this.clipboardAction = null; |
|
8268 |
+ } |
|
8269 |
+ |
|
8270 |
+ this.clipboardAction = new _clipboardAction2.default({ |
|
8271 |
+ action: this.action(trigger), |
|
8272 |
+ target: this.target(trigger), |
|
8273 |
+ text: this.text(trigger), |
|
8274 |
+ container: this.container, |
|
8275 |
+ trigger: trigger, |
|
8276 |
+ emitter: this |
|
8277 |
+ }); |
|
8278 |
+ } |
|
8279 |
+ }, { |
|
8280 |
+ key: 'defaultAction', |
|
8281 |
+ value: function defaultAction(trigger) { |
|
8282 |
+ return getAttributeValue('action', trigger); |
|
8283 |
+ } |
|
8284 |
+ }, { |
|
8285 |
+ key: 'defaultTarget', |
|
8286 |
+ value: function defaultTarget(trigger) { |
|
8287 |
+ var selector = getAttributeValue('target', trigger); |
|
8288 |
+ |
|
8289 |
+ if (selector) { |
|
8290 |
+ return document.querySelector(selector); |
|
8291 |
+ } |
|
8292 |
+ } |
|
8293 |
+ }, { |
|
8294 |
+ key: 'defaultText', |
|
8295 |
+ value: function defaultText(trigger) { |
|
8296 |
+ return getAttributeValue('text', trigger); |
|
8297 |
+ } |
|
8298 |
+ }, { |
|
8299 |
+ key: 'destroy', |
|
8300 |
+ value: function destroy() { |
|
8301 |
+ this.listener.destroy(); |
|
8302 |
+ |
|
8303 |
+ if (this.clipboardAction) { |
|
8304 |
+ this.clipboardAction.destroy(); |
|
8305 |
+ this.clipboardAction = null; |
|
8306 |
+ } |
|
8307 |
+ } |
|
8308 |
+ }], [{ |
|
8309 |
+ key: 'isSupported', |
|
8310 |
+ value: function isSupported() { |
|
8311 |
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; |
|
8312 |
+ |
|
8313 |
+ var actions = typeof action === 'string' ? [action] : action; |
|
8314 |
+ var support = !!document.queryCommandSupported; |
|
8315 |
+ |
|
8316 |
+ actions.forEach(function (action) { |
|
8317 |
+ support = support && !!document.queryCommandSupported(action); |
|
8318 |
+ }); |
|
8319 |
+ |
|
8320 |
+ return support; |
|
8321 |
+ } |
|
8322 |
+ }]); |
|
8323 |
+ |
|
8324 |
+ return Clipboard; |
|
8325 |
+ }(_tinyEmitter2.default); |
|
8326 |
+ |
|
8327 |
+ /** |
|
8328 |
+ * Helper function to retrieve attribute value. |
|
8329 |
+ * @param {String} suffix |
|
8330 |
+ * @param {Element} element |
|
8331 |
+ */ |
|
8332 |
+ function getAttributeValue(suffix, element) { |
|
8333 |
+ var attribute = 'data-clipboard-' + suffix; |
|
8334 |
+ |
|
8335 |
+ if (!element.hasAttribute(attribute)) { |
|
8336 |
+ return; |
|
8337 |
+ } |
|
8338 |
+ |
|
8339 |
+ return element.getAttribute(attribute); |
|
8340 |
+ } |
|
8341 |
+ |
|
8342 |
+ module.exports = Clipboard; |
|
8343 |
+}); |
|
8344 |
+ |
|
8345 |
+/***/ }), |
|
8346 |
+/* 4 */ |
|
8347 |
+/***/ (function(module, exports) { |
|
8348 |
+ |
|
8349 |
+var DOCUMENT_NODE_TYPE = 9; |
|
8350 |
+ |
|
8351 |
+/** |
|
8352 |
+ * A polyfill for Element.matches() |
|
8353 |
+ */ |
|
8354 |
+if (typeof Element !== 'undefined' && !Element.prototype.matches) { |
|
8355 |
+ var proto = Element.prototype; |
|
8356 |
+ |
|
8357 |
+ proto.matches = proto.matchesSelector || |
|
8358 |
+ proto.mozMatchesSelector || |
|
8359 |
+ proto.msMatchesSelector || |
|
8360 |
+ proto.oMatchesSelector || |
|
8361 |
+ proto.webkitMatchesSelector; |
|
8362 |
+} |
|
8363 |
+ |
|
8364 |
+/** |
|
8365 |
+ * Finds the closest parent that matches a selector. |
|
8366 |
+ * |
|
8367 |
+ * @param {Element} element |
|
8368 |
+ * @param {String} selector |
|
8369 |
+ * @return {Function} |
|
8370 |
+ */ |
|
8371 |
+function closest (element, selector) { |
|
8372 |
+ while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { |
|
8373 |
+ if (typeof element.matches === 'function' && |
|
8374 |
+ element.matches(selector)) { |
|
8375 |
+ return element; |
|
8376 |
+ } |
|
8377 |
+ element = element.parentNode; |
|
8378 |
+ } |
|
8379 |
+} |
|
8380 |
+ |
|
8381 |
+module.exports = closest; |
|
8382 |
+ |
|
8383 |
+ |
|
8384 |
+/***/ }), |
|
8385 |
+/* 5 */ |
|
8386 |
+/***/ (function(module, exports, __webpack_require__) { |
|
8387 |
+ |
|
8388 |
+var closest = __webpack_require__(4); |
|
8389 |
+ |
|
8390 |
+/** |
|
8391 |
+ * Delegates event to a selector. |
|
8392 |
+ * |
|
8393 |
+ * @param {Element} element |
|
8394 |
+ * @param {String} selector |
|
8395 |
+ * @param {String} type |
|
8396 |
+ * @param {Function} callback |
|
8397 |
+ * @param {Boolean} useCapture |
|
8398 |
+ * @return {Object} |
|
8399 |
+ */ |
|
8400 |
+function _delegate(element, selector, type, callback, useCapture) { |
|
8401 |
+ var listenerFn = listener.apply(this, arguments); |
|
8402 |
+ |
|
8403 |
+ element.addEventListener(type, listenerFn, useCapture); |
|
8404 |
+ |
|
8405 |
+ return { |
|
8406 |
+ destroy: function() { |
|
8407 |
+ element.removeEventListener(type, listenerFn, useCapture); |
|
8408 |
+ } |
|
8409 |
+ } |
|
8410 |
+} |
|
8411 |
+ |
|
8412 |
+/** |
|
8413 |
+ * Delegates event to a selector. |
|
8414 |
+ * |
|
8415 |
+ * @param {Element|String|Array} [elements] |
|
8416 |
+ * @param {String} selector |
|
8417 |
+ * @param {String} type |
|
8418 |
+ * @param {Function} callback |
|
8419 |
+ * @param {Boolean} useCapture |
|
8420 |
+ * @return {Object} |
|
8421 |
+ */ |
|
8422 |
+function delegate(elements, selector, type, callback, useCapture) { |
|
8423 |
+ // Handle the regular Element usage |
|
8424 |
+ if (typeof elements.addEventListener === 'function') { |
|
8425 |
+ return _delegate.apply(null, arguments); |
|
8426 |
+ } |
|
8427 |
+ |
|
8428 |
+ // Handle Element-less usage, it defaults to global delegation |
|
8429 |
+ if (typeof type === 'function') { |
|
8430 |
+ // Use `document` as the first parameter, then apply arguments |
|
8431 |
+ // This is a short way to .unshift `arguments` without running into deoptimizations |
|
8432 |
+ return _delegate.bind(null, document).apply(null, arguments); |
|
8433 |
+ } |
|
8434 |
+ |
|
8435 |
+ // Handle Selector-based usage |
|
8436 |
+ if (typeof elements === 'string') { |
|
8437 |
+ elements = document.querySelectorAll(elements); |
|
8438 |
+ } |
|
8439 |
+ |
|
8440 |
+ // Handle Array-like based usage |
|
8441 |
+ return Array.prototype.map.call(elements, function (element) { |
|
8442 |
+ return _delegate(element, selector, type, callback, useCapture); |
|
8443 |
+ }); |
|
8444 |
+} |
|
8445 |
+ |
|
8446 |
+/** |
|
8447 |
+ * Finds closest match and invokes callback. |
|
8448 |
+ * |
|
8449 |
+ * @param {Element} element |
|
8450 |
+ * @param {String} selector |
|
8451 |
+ * @param {String} type |
|
8452 |
+ * @param {Function} callback |
|
8453 |
+ * @return {Function} |
|
8454 |
+ */ |
|
8455 |
+function listener(element, selector, type, callback) { |
|
8456 |
+ return function(e) { |
|
8457 |
+ e.delegateTarget = closest(e.target, selector); |
|
8458 |
+ |
|
8459 |
+ if (e.delegateTarget) { |
|
8460 |
+ callback.call(element, e); |
|
8461 |
+ } |
|
8462 |
+ } |
|
8463 |
+} |
|
8464 |
+ |
|
8465 |
+module.exports = delegate; |
|
8466 |
+ |
|
8467 |
+ |
|
8468 |
+/***/ }), |
|
8469 |
+/* 6 */ |
|
8470 |
+/***/ (function(module, exports) { |
|
8471 |
+ |
|
8472 |
+/** |
|
8473 |
+ * Check if argument is a HTML element. |
|
8474 |
+ * |
|
8475 |
+ * @param {Object} value |
|
8476 |
+ * @return {Boolean} |
|
8477 |
+ */ |
|
8478 |
+exports.node = function(value) { |
|
8479 |
+ return value !== undefined |
|
8480 |
+ && value instanceof HTMLElement |
|
8481 |
+ && value.nodeType === 1; |
|
8482 |
+}; |
|
8483 |
+ |
|
8484 |
+/** |
|
8485 |
+ * Check if argument is a list of HTML elements. |
|
8486 |
+ * |
|
8487 |
+ * @param {Object} value |
|
8488 |
+ * @return {Boolean} |
|
8489 |
+ */ |
|
8490 |
+exports.nodeList = function(value) { |
|
8491 |
+ var type = Object.prototype.toString.call(value); |
|
8492 |
+ |
|
8493 |
+ return value !== undefined |
|
8494 |
+ && (type === '[object NodeList]' || type === '[object HTMLCollection]') |
|
8495 |
+ && ('length' in value) |
|
8496 |
+ && (value.length === 0 || exports.node(value[0])); |
|
8497 |
+}; |
|
8498 |
+ |
|
8499 |
+/** |
|
8500 |
+ * Check if argument is a string. |
|
8501 |
+ * |
|
8502 |
+ * @param {Object} value |
|
8503 |
+ * @return {Boolean} |
|
8504 |
+ */ |
|
8505 |
+exports.string = function(value) { |
|
8506 |
+ return typeof value === 'string' |
|
8507 |
+ || value instanceof String; |
|
8508 |
+}; |
|
8509 |
+ |
|
8510 |
+/** |
|
8511 |
+ * Check if argument is a function. |
|
8512 |
+ * |
|
8513 |
+ * @param {Object} value |
|
8514 |
+ * @return {Boolean} |
|
8515 |
+ */ |
|
8516 |
+exports.fn = function(value) { |
|
8517 |
+ var type = Object.prototype.toString.call(value); |
|
8518 |
+ |
|
8519 |
+ return type === '[object Function]'; |
|
8520 |
+}; |
|
8521 |
+ |
|
8522 |
+ |
|
8523 |
+/***/ }), |
|
8524 |
+/* 7 */ |
|
8525 |
+/***/ (function(module, exports) { |
|
8526 |
+ |
|
8527 |
+function select(element) { |
|
8528 |
+ var selectedText; |
|
8529 |
+ |
|
8530 |
+ if (element.nodeName === 'SELECT') { |
|
8531 |
+ element.focus(); |
|
8532 |
+ |
|
8533 |
+ selectedText = element.value; |
|
8534 |
+ } |
|
8535 |
+ else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { |
|
8536 |
+ var isReadOnly = element.hasAttribute('readonly'); |
|
8537 |
+ |
|
8538 |
+ if (!isReadOnly) { |
|
8539 |
+ element.setAttribute('readonly', ''); |
|
8540 |
+ } |
|
8541 |
+ |
|
8542 |
+ element.select(); |
|
8543 |
+ element.setSelectionRange(0, element.value.length); |
|
8544 |
+ |
|
8545 |
+ if (!isReadOnly) { |
|
8546 |
+ element.removeAttribute('readonly'); |
|
8547 |
+ } |
|
8548 |
+ |
|
8549 |
+ selectedText = element.value; |
|
8550 |
+ } |
|
8551 |
+ else { |
|
8552 |
+ if (element.hasAttribute('contenteditable')) { |
|
8553 |
+ element.focus(); |
|
8554 |
+ } |
|
8555 |
+ |
|
8556 |
+ var selection = window.getSelection(); |
|
8557 |
+ var range = document.createRange(); |
|
8558 |
+ |
|
8559 |
+ range.selectNodeContents(element); |
|
8560 |
+ selection.removeAllRanges(); |
|
8561 |
+ selection.addRange(range); |
|
8562 |
+ |
|
8563 |
+ selectedText = selection.toString(); |
|
8564 |
+ } |
|
8565 |
+ |
|
8566 |
+ return selectedText; |
|
8567 |
+} |
|
8568 |
+ |
|
8569 |
+module.exports = select; |
|
8570 |
+ |
|
8571 |
+ |
|
8572 |
+/***/ }) |
|
8573 |
+/******/ ]); |
|
8574 |
+});(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?