copy_tuner_client 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,1069 +0,0 @@
1
- (function () {
2
- 'use strict';
3
-
4
- var KEY_CANCEL = 3;
5
- var KEY_HELP = 6;
6
- var KEY_BACK_SPACE = 8;
7
- var KEY_TAB = 9;
8
- var KEY_CLEAR = 12;
9
- var KEY_RETURN = 13;
10
- var KEY_ENTER = 14;
11
- var KEY_SHIFT = 16;
12
- var KEY_CONTROL = 17;
13
- var KEY_ALT = 18;
14
- var KEY_PAUSE = 19;
15
- var KEY_CAPS_LOCK = 20;
16
- var KEY_ESCAPE = 27;
17
- var KEY_SPACE = 32;
18
- var KEY_PAGE_UP = 33;
19
- var KEY_PAGE_DOWN = 34;
20
- var KEY_END = 35;
21
- var KEY_HOME = 36;
22
- var KEY_LEFT = 37;
23
- var KEY_UP = 38;
24
- var KEY_RIGHT = 39;
25
- var KEY_DOWN = 40;
26
- var KEY_PRINTSCREEN = 44;
27
- var KEY_INSERT = 45;
28
- var KEY_DELETE = 46;
29
- var KEY_0 = 48;
30
- var KEY_1 = 49;
31
- var KEY_2 = 50;
32
- var KEY_3 = 51;
33
- var KEY_4 = 52;
34
- var KEY_5 = 53;
35
- var KEY_6 = 54;
36
- var KEY_7 = 55;
37
- var KEY_8 = 56;
38
- var KEY_9 = 57;
39
- var KEY_SEMICOLON = 59;
40
- var KEY_EQUALS = 61;
41
- var KEY_A = 65;
42
- var KEY_B = 66;
43
- var KEY_C = 67;
44
- var KEY_D = 68;
45
- var KEY_E = 69;
46
- var KEY_F = 70;
47
- var KEY_G = 71;
48
- var KEY_H = 72;
49
- var KEY_I = 73;
50
- var KEY_J = 74;
51
- var KEY_K = 75;
52
- var KEY_L = 76;
53
- var KEY_M = 77;
54
- var KEY_N = 78;
55
- var KEY_O = 79;
56
- var KEY_P = 80;
57
- var KEY_Q = 81;
58
- var KEY_R = 82;
59
- var KEY_S = 83;
60
- var KEY_T = 84;
61
- var KEY_U = 85;
62
- var KEY_V = 86;
63
- var KEY_W = 87;
64
- var KEY_X = 88;
65
- var KEY_Y = 89;
66
- var KEY_Z = 90;
67
- var KEY_CONTEXT_MENU = 93;
68
- var KEY_NUMPAD0 = 96;
69
- var KEY_NUMPAD1 = 97;
70
- var KEY_NUMPAD2 = 98;
71
- var KEY_NUMPAD3 = 99;
72
- var KEY_NUMPAD4 = 100;
73
- var KEY_NUMPAD5 = 101;
74
- var KEY_NUMPAD6 = 102;
75
- var KEY_NUMPAD7 = 103;
76
- var KEY_NUMPAD8 = 104;
77
- var KEY_NUMPAD9 = 105;
78
- var KEY_MULTIPLY = 106;
79
- var KEY_ADD = 107;
80
- var KEY_SEPARATOR = 108;
81
- var KEY_SUBTRACT = 109;
82
- var KEY_DECIMAL = 110;
83
- var KEY_DIVIDE = 111;
84
- var KEY_F1 = 112;
85
- var KEY_F2 = 113;
86
- var KEY_F3 = 114;
87
- var KEY_F4 = 115;
88
- var KEY_F5 = 116;
89
- var KEY_F6 = 117;
90
- var KEY_F7 = 118;
91
- var KEY_F8 = 119;
92
- var KEY_F9 = 120;
93
- var KEY_F10 = 121;
94
- var KEY_F11 = 122;
95
- var KEY_F12 = 123;
96
- var KEY_F13 = 124;
97
- var KEY_F14 = 125;
98
- var KEY_F15 = 126;
99
- var KEY_F16 = 127;
100
- var KEY_F17 = 128;
101
- var KEY_F18 = 129;
102
- var KEY_F19 = 130;
103
- var KEY_F20 = 131;
104
- var KEY_F21 = 132;
105
- var KEY_F22 = 133;
106
- var KEY_F23 = 134;
107
- var KEY_F24 = 135;
108
- var KEY_NUM_LOCK = 144;
109
- var KEY_SCROLL_LOCK = 145;
110
- var KEY_COMMA = 188;
111
- var KEY_PERIOD = 190;
112
- var KEY_SLASH = 191;
113
- var KEY_BACK_QUOTE = 192;
114
- var KEY_OPEN_BRACKET = 219;
115
- var KEY_BACK_SLASH = 220;
116
- var KEY_CLOSE_BRACKET = 221;
117
- var KEY_QUOTE = 222;
118
- var KEY_META = 224;
119
-
120
- var KeyCode = {
121
- KEY_CANCEL: KEY_CANCEL,
122
- KEY_HELP: KEY_HELP,
123
- KEY_BACK_SPACE: KEY_BACK_SPACE,
124
- KEY_TAB: KEY_TAB,
125
- KEY_CLEAR: KEY_CLEAR,
126
- KEY_RETURN: KEY_RETURN,
127
- KEY_ENTER: KEY_ENTER,
128
- KEY_SHIFT: KEY_SHIFT,
129
- KEY_CONTROL: KEY_CONTROL,
130
- KEY_ALT: KEY_ALT,
131
- KEY_PAUSE: KEY_PAUSE,
132
- KEY_CAPS_LOCK: KEY_CAPS_LOCK,
133
- KEY_ESCAPE: KEY_ESCAPE,
134
- KEY_SPACE: KEY_SPACE,
135
- KEY_PAGE_UP: KEY_PAGE_UP,
136
- KEY_PAGE_DOWN: KEY_PAGE_DOWN,
137
- KEY_END: KEY_END,
138
- KEY_HOME: KEY_HOME,
139
- KEY_LEFT: KEY_LEFT,
140
- KEY_UP: KEY_UP,
141
- KEY_RIGHT: KEY_RIGHT,
142
- KEY_DOWN: KEY_DOWN,
143
- KEY_PRINTSCREEN: KEY_PRINTSCREEN,
144
- KEY_INSERT: KEY_INSERT,
145
- KEY_DELETE: KEY_DELETE,
146
- KEY_0: KEY_0,
147
- KEY_1: KEY_1,
148
- KEY_2: KEY_2,
149
- KEY_3: KEY_3,
150
- KEY_4: KEY_4,
151
- KEY_5: KEY_5,
152
- KEY_6: KEY_6,
153
- KEY_7: KEY_7,
154
- KEY_8: KEY_8,
155
- KEY_9: KEY_9,
156
- KEY_SEMICOLON: KEY_SEMICOLON,
157
- KEY_EQUALS: KEY_EQUALS,
158
- KEY_A: KEY_A,
159
- KEY_B: KEY_B,
160
- KEY_C: KEY_C,
161
- KEY_D: KEY_D,
162
- KEY_E: KEY_E,
163
- KEY_F: KEY_F,
164
- KEY_G: KEY_G,
165
- KEY_H: KEY_H,
166
- KEY_I: KEY_I,
167
- KEY_J: KEY_J,
168
- KEY_K: KEY_K,
169
- KEY_L: KEY_L,
170
- KEY_M: KEY_M,
171
- KEY_N: KEY_N,
172
- KEY_O: KEY_O,
173
- KEY_P: KEY_P,
174
- KEY_Q: KEY_Q,
175
- KEY_R: KEY_R,
176
- KEY_S: KEY_S,
177
- KEY_T: KEY_T,
178
- KEY_U: KEY_U,
179
- KEY_V: KEY_V,
180
- KEY_W: KEY_W,
181
- KEY_X: KEY_X,
182
- KEY_Y: KEY_Y,
183
- KEY_Z: KEY_Z,
184
- KEY_CONTEXT_MENU: KEY_CONTEXT_MENU,
185
- KEY_NUMPAD0: KEY_NUMPAD0,
186
- KEY_NUMPAD1: KEY_NUMPAD1,
187
- KEY_NUMPAD2: KEY_NUMPAD2,
188
- KEY_NUMPAD3: KEY_NUMPAD3,
189
- KEY_NUMPAD4: KEY_NUMPAD4,
190
- KEY_NUMPAD5: KEY_NUMPAD5,
191
- KEY_NUMPAD6: KEY_NUMPAD6,
192
- KEY_NUMPAD7: KEY_NUMPAD7,
193
- KEY_NUMPAD8: KEY_NUMPAD8,
194
- KEY_NUMPAD9: KEY_NUMPAD9,
195
- KEY_MULTIPLY: KEY_MULTIPLY,
196
- KEY_ADD: KEY_ADD,
197
- KEY_SEPARATOR: KEY_SEPARATOR,
198
- KEY_SUBTRACT: KEY_SUBTRACT,
199
- KEY_DECIMAL: KEY_DECIMAL,
200
- KEY_DIVIDE: KEY_DIVIDE,
201
- KEY_F1: KEY_F1,
202
- KEY_F2: KEY_F2,
203
- KEY_F3: KEY_F3,
204
- KEY_F4: KEY_F4,
205
- KEY_F5: KEY_F5,
206
- KEY_F6: KEY_F6,
207
- KEY_F7: KEY_F7,
208
- KEY_F8: KEY_F8,
209
- KEY_F9: KEY_F9,
210
- KEY_F10: KEY_F10,
211
- KEY_F11: KEY_F11,
212
- KEY_F12: KEY_F12,
213
- KEY_F13: KEY_F13,
214
- KEY_F14: KEY_F14,
215
- KEY_F15: KEY_F15,
216
- KEY_F16: KEY_F16,
217
- KEY_F17: KEY_F17,
218
- KEY_F18: KEY_F18,
219
- KEY_F19: KEY_F19,
220
- KEY_F20: KEY_F20,
221
- KEY_F21: KEY_F21,
222
- KEY_F22: KEY_F22,
223
- KEY_F23: KEY_F23,
224
- KEY_F24: KEY_F24,
225
- KEY_NUM_LOCK: KEY_NUM_LOCK,
226
- KEY_SCROLL_LOCK: KEY_SCROLL_LOCK,
227
- KEY_COMMA: KEY_COMMA,
228
- KEY_PERIOD: KEY_PERIOD,
229
- KEY_SLASH: KEY_SLASH,
230
- KEY_BACK_QUOTE: KEY_BACK_QUOTE,
231
- KEY_OPEN_BRACKET: KEY_OPEN_BRACKET,
232
- KEY_BACK_SLASH: KEY_BACK_SLASH,
233
- KEY_CLOSE_BRACKET: KEY_CLOSE_BRACKET,
234
- KEY_QUOTE: KEY_QUOTE,
235
- KEY_META: KEY_META
236
- };
237
-
238
- var keycodeJs = KeyCode;
239
-
240
- var isMac = navigator.platform.toUpperCase().indexOf('MAC') !== -1;
241
-
242
- var isVisible = function isVisible(element) {
243
- return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
244
- };
245
-
246
- var getOffset = function getOffset(elment) {
247
- var box = elment.getBoundingClientRect();
248
-
249
- return {
250
- top: box.top + (window.pageYOffset - document.documentElement.clientTop),
251
- left: box.left + (window.pageXOffset - document.documentElement.clientLeft)
252
- };
253
- };
254
-
255
- var computeBoundingBox = function computeBoundingBox(element) {
256
- if (!isVisible(element)) {
257
- return null;
258
- }
259
-
260
- var boxFrame = getOffset(element);
261
- boxFrame.right = boxFrame.left + element.offsetWidth;
262
- boxFrame.bottom = boxFrame.top + element.offsetHeight;
263
-
264
- return {
265
- left: boxFrame.left,
266
- top: boxFrame.top,
267
- width: boxFrame.right - boxFrame.left,
268
- height: boxFrame.bottom - boxFrame.top
269
- };
270
- };
271
-
272
- var classCallCheck = function (instance, Constructor) {
273
- if (!(instance instanceof Constructor)) {
274
- throw new TypeError("Cannot call a class as a function");
275
- }
276
- };
277
-
278
- var createClass = function () {
279
- function defineProperties(target, props) {
280
- for (var i = 0; i < props.length; i++) {
281
- var descriptor = props[i];
282
- descriptor.enumerable = descriptor.enumerable || false;
283
- descriptor.configurable = true;
284
- if ("value" in descriptor) descriptor.writable = true;
285
- Object.defineProperty(target, descriptor.key, descriptor);
286
- }
287
- }
288
-
289
- return function (Constructor, protoProps, staticProps) {
290
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
291
- if (staticProps) defineProperties(Constructor, staticProps);
292
- return Constructor;
293
- };
294
- }();
295
-
296
- var slicedToArray = function () {
297
- function sliceIterator(arr, i) {
298
- var _arr = [];
299
- var _n = true;
300
- var _d = false;
301
- var _e = undefined;
302
-
303
- try {
304
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
305
- _arr.push(_s.value);
306
-
307
- if (i && _arr.length === i) break;
308
- }
309
- } catch (err) {
310
- _d = true;
311
- _e = err;
312
- } finally {
313
- try {
314
- if (!_n && _i["return"]) _i["return"]();
315
- } finally {
316
- if (_d) throw _e;
317
- }
318
- }
319
-
320
- return _arr;
321
- }
322
-
323
- return function (arr, i) {
324
- if (Array.isArray(arr)) {
325
- return arr;
326
- } else if (Symbol.iterator in Object(arr)) {
327
- return sliceIterator(arr, i);
328
- } else {
329
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
330
- }
331
- };
332
- }();
333
-
334
- var ZINDEX = 2000000000;
335
-
336
- var Specimen = function () {
337
- function Specimen(element, key, callback) {
338
- classCallCheck(this, Specimen);
339
-
340
- this.element = element;
341
- this.key = key;
342
- this.callback = callback;
343
- }
344
-
345
- createClass(Specimen, [{
346
- key: 'show',
347
- value: function show() {
348
- var _this = this;
349
-
350
- this.box = this.makeBox();
351
- if (this.box === null) return;
352
-
353
- this.box.addEventListener('click', function () {
354
- _this.callback(_this.key);
355
- });
356
-
357
- document.body.appendChild(this.box);
358
- }
359
- }, {
360
- key: 'remove',
361
- value: function remove() {
362
- if (!this.box) {
363
- return;
364
- }
365
- this.box.remove();
366
- this.box = null;
367
- }
368
- }, {
369
- key: 'makeBox',
370
- value: function makeBox() {
371
- var box = document.createElement('div');
372
- box.classList.add('copyray-specimen');
373
- box.classList.add('Specimen');
374
-
375
- var bounds = computeBoundingBox(this.element);
376
- if (bounds === null) return null;
377
-
378
- Object.keys(bounds).forEach(function (key) {
379
- var value = bounds[key];
380
- box.style[key] = value + 'px';
381
- });
382
- box.style.zIndex = ZINDEX;
383
-
384
- var _getComputedStyle = getComputedStyle(this.element),
385
- position = _getComputedStyle.position,
386
- top = _getComputedStyle.top,
387
- left = _getComputedStyle.left;
388
-
389
- if (position === 'fixed') {
390
- this.box.style.position = 'fixed';
391
- this.box.style.top = top + 'px';
392
- this.box.style.left = left + 'px';
393
- }
394
-
395
- box.appendChild(this.makeLabel());
396
- return box;
397
- }
398
- }, {
399
- key: 'makeLabel',
400
- value: function makeLabel() {
401
- var div = document.createElement('div');
402
- div.classList.add('copyray-specimen-handle');
403
- div.classList.add('Specimen');
404
- div.textContent = this.key;
405
- return div;
406
- }
407
- }]);
408
- return Specimen;
409
- }();
410
-
411
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
412
-
413
- /**
414
- * lodash (Custom Build) <https://lodash.com/>
415
- * Build: `lodash modularize exports="npm" -o ./`
416
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
417
- * Released under MIT license <https://lodash.com/license>
418
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
419
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
420
- */
421
-
422
- /** Used as the `TypeError` message for "Functions" methods. */
423
- var FUNC_ERROR_TEXT = 'Expected a function';
424
-
425
- /** Used as references for various `Number` constants. */
426
- var NAN = 0 / 0;
427
-
428
- /** `Object#toString` result references. */
429
- var symbolTag = '[object Symbol]';
430
-
431
- /** Used to match leading and trailing whitespace. */
432
- var reTrim = /^\s+|\s+$/g;
433
-
434
- /** Used to detect bad signed hexadecimal string values. */
435
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
436
-
437
- /** Used to detect binary string values. */
438
- var reIsBinary = /^0b[01]+$/i;
439
-
440
- /** Used to detect octal string values. */
441
- var reIsOctal = /^0o[0-7]+$/i;
442
-
443
- /** Built-in method references without a dependency on `root`. */
444
- var freeParseInt = parseInt;
445
-
446
- /** Detect free variable `global` from Node.js. */
447
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
448
-
449
- /** Detect free variable `self`. */
450
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
451
-
452
- /** Used as a reference to the global object. */
453
- var root = freeGlobal || freeSelf || Function('return this')();
454
-
455
- /** Used for built-in method references. */
456
- var objectProto = Object.prototype;
457
-
458
- /**
459
- * Used to resolve the
460
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
461
- * of values.
462
- */
463
- var objectToString = objectProto.toString;
464
-
465
- /* Built-in method references for those with the same name as other `lodash` methods. */
466
- var nativeMax = Math.max,
467
- nativeMin = Math.min;
468
-
469
- /**
470
- * Gets the timestamp of the number of milliseconds that have elapsed since
471
- * the Unix epoch (1 January 1970 00:00:00 UTC).
472
- *
473
- * @static
474
- * @memberOf _
475
- * @since 2.4.0
476
- * @category Date
477
- * @returns {number} Returns the timestamp.
478
- * @example
479
- *
480
- * _.defer(function(stamp) {
481
- * console.log(_.now() - stamp);
482
- * }, _.now());
483
- * // => Logs the number of milliseconds it took for the deferred invocation.
484
- */
485
- var now = function() {
486
- return root.Date.now();
487
- };
488
-
489
- /**
490
- * Creates a debounced function that delays invoking `func` until after `wait`
491
- * milliseconds have elapsed since the last time the debounced function was
492
- * invoked. The debounced function comes with a `cancel` method to cancel
493
- * delayed `func` invocations and a `flush` method to immediately invoke them.
494
- * Provide `options` to indicate whether `func` should be invoked on the
495
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
496
- * with the last arguments provided to the debounced function. Subsequent
497
- * calls to the debounced function return the result of the last `func`
498
- * invocation.
499
- *
500
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
501
- * invoked on the trailing edge of the timeout only if the debounced function
502
- * is invoked more than once during the `wait` timeout.
503
- *
504
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
505
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
506
- *
507
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
508
- * for details over the differences between `_.debounce` and `_.throttle`.
509
- *
510
- * @static
511
- * @memberOf _
512
- * @since 0.1.0
513
- * @category Function
514
- * @param {Function} func The function to debounce.
515
- * @param {number} [wait=0] The number of milliseconds to delay.
516
- * @param {Object} [options={}] The options object.
517
- * @param {boolean} [options.leading=false]
518
- * Specify invoking on the leading edge of the timeout.
519
- * @param {number} [options.maxWait]
520
- * The maximum time `func` is allowed to be delayed before it's invoked.
521
- * @param {boolean} [options.trailing=true]
522
- * Specify invoking on the trailing edge of the timeout.
523
- * @returns {Function} Returns the new debounced function.
524
- * @example
525
- *
526
- * // Avoid costly calculations while the window size is in flux.
527
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
528
- *
529
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
530
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
531
- * 'leading': true,
532
- * 'trailing': false
533
- * }));
534
- *
535
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
536
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
537
- * var source = new EventSource('/stream');
538
- * jQuery(source).on('message', debounced);
539
- *
540
- * // Cancel the trailing debounced invocation.
541
- * jQuery(window).on('popstate', debounced.cancel);
542
- */
543
- function debounce(func, wait, options) {
544
- var lastArgs,
545
- lastThis,
546
- maxWait,
547
- result,
548
- timerId,
549
- lastCallTime,
550
- lastInvokeTime = 0,
551
- leading = false,
552
- maxing = false,
553
- trailing = true;
554
-
555
- if (typeof func != 'function') {
556
- throw new TypeError(FUNC_ERROR_TEXT);
557
- }
558
- wait = toNumber(wait) || 0;
559
- if (isObject(options)) {
560
- leading = !!options.leading;
561
- maxing = 'maxWait' in options;
562
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
563
- trailing = 'trailing' in options ? !!options.trailing : trailing;
564
- }
565
-
566
- function invokeFunc(time) {
567
- var args = lastArgs,
568
- thisArg = lastThis;
569
-
570
- lastArgs = lastThis = undefined;
571
- lastInvokeTime = time;
572
- result = func.apply(thisArg, args);
573
- return result;
574
- }
575
-
576
- function leadingEdge(time) {
577
- // Reset any `maxWait` timer.
578
- lastInvokeTime = time;
579
- // Start the timer for the trailing edge.
580
- timerId = setTimeout(timerExpired, wait);
581
- // Invoke the leading edge.
582
- return leading ? invokeFunc(time) : result;
583
- }
584
-
585
- function remainingWait(time) {
586
- var timeSinceLastCall = time - lastCallTime,
587
- timeSinceLastInvoke = time - lastInvokeTime,
588
- result = wait - timeSinceLastCall;
589
-
590
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
591
- }
592
-
593
- function shouldInvoke(time) {
594
- var timeSinceLastCall = time - lastCallTime,
595
- timeSinceLastInvoke = time - lastInvokeTime;
596
-
597
- // Either this is the first call, activity has stopped and we're at the
598
- // trailing edge, the system time has gone backwards and we're treating
599
- // it as the trailing edge, or we've hit the `maxWait` limit.
600
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
601
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
602
- }
603
-
604
- function timerExpired() {
605
- var time = now();
606
- if (shouldInvoke(time)) {
607
- return trailingEdge(time);
608
- }
609
- // Restart the timer.
610
- timerId = setTimeout(timerExpired, remainingWait(time));
611
- }
612
-
613
- function trailingEdge(time) {
614
- timerId = undefined;
615
-
616
- // Only invoke if we have `lastArgs` which means `func` has been
617
- // debounced at least once.
618
- if (trailing && lastArgs) {
619
- return invokeFunc(time);
620
- }
621
- lastArgs = lastThis = undefined;
622
- return result;
623
- }
624
-
625
- function cancel() {
626
- if (timerId !== undefined) {
627
- clearTimeout(timerId);
628
- }
629
- lastInvokeTime = 0;
630
- lastArgs = lastCallTime = lastThis = timerId = undefined;
631
- }
632
-
633
- function flush() {
634
- return timerId === undefined ? result : trailingEdge(now());
635
- }
636
-
637
- function debounced() {
638
- var time = now(),
639
- isInvoking = shouldInvoke(time);
640
-
641
- lastArgs = arguments;
642
- lastThis = this;
643
- lastCallTime = time;
644
-
645
- if (isInvoking) {
646
- if (timerId === undefined) {
647
- return leadingEdge(lastCallTime);
648
- }
649
- if (maxing) {
650
- // Handle invocations in a tight loop.
651
- timerId = setTimeout(timerExpired, wait);
652
- return invokeFunc(lastCallTime);
653
- }
654
- }
655
- if (timerId === undefined) {
656
- timerId = setTimeout(timerExpired, wait);
657
- }
658
- return result;
659
- }
660
- debounced.cancel = cancel;
661
- debounced.flush = flush;
662
- return debounced;
663
- }
664
-
665
- /**
666
- * Checks if `value` is the
667
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
668
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
669
- *
670
- * @static
671
- * @memberOf _
672
- * @since 0.1.0
673
- * @category Lang
674
- * @param {*} value The value to check.
675
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
676
- * @example
677
- *
678
- * _.isObject({});
679
- * // => true
680
- *
681
- * _.isObject([1, 2, 3]);
682
- * // => true
683
- *
684
- * _.isObject(_.noop);
685
- * // => true
686
- *
687
- * _.isObject(null);
688
- * // => false
689
- */
690
- function isObject(value) {
691
- var type = typeof value;
692
- return !!value && (type == 'object' || type == 'function');
693
- }
694
-
695
- /**
696
- * Checks if `value` is object-like. A value is object-like if it's not `null`
697
- * and has a `typeof` result of "object".
698
- *
699
- * @static
700
- * @memberOf _
701
- * @since 4.0.0
702
- * @category Lang
703
- * @param {*} value The value to check.
704
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
705
- * @example
706
- *
707
- * _.isObjectLike({});
708
- * // => true
709
- *
710
- * _.isObjectLike([1, 2, 3]);
711
- * // => true
712
- *
713
- * _.isObjectLike(_.noop);
714
- * // => false
715
- *
716
- * _.isObjectLike(null);
717
- * // => false
718
- */
719
- function isObjectLike(value) {
720
- return !!value && typeof value == 'object';
721
- }
722
-
723
- /**
724
- * Checks if `value` is classified as a `Symbol` primitive or object.
725
- *
726
- * @static
727
- * @memberOf _
728
- * @since 4.0.0
729
- * @category Lang
730
- * @param {*} value The value to check.
731
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
732
- * @example
733
- *
734
- * _.isSymbol(Symbol.iterator);
735
- * // => true
736
- *
737
- * _.isSymbol('abc');
738
- * // => false
739
- */
740
- function isSymbol(value) {
741
- return typeof value == 'symbol' ||
742
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
743
- }
744
-
745
- /**
746
- * Converts `value` to a number.
747
- *
748
- * @static
749
- * @memberOf _
750
- * @since 4.0.0
751
- * @category Lang
752
- * @param {*} value The value to process.
753
- * @returns {number} Returns the number.
754
- * @example
755
- *
756
- * _.toNumber(3.2);
757
- * // => 3.2
758
- *
759
- * _.toNumber(Number.MIN_VALUE);
760
- * // => 5e-324
761
- *
762
- * _.toNumber(Infinity);
763
- * // => Infinity
764
- *
765
- * _.toNumber('3.2');
766
- * // => 3.2
767
- */
768
- function toNumber(value) {
769
- if (typeof value == 'number') {
770
- return value;
771
- }
772
- if (isSymbol(value)) {
773
- return NAN;
774
- }
775
- if (isObject(value)) {
776
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
777
- value = isObject(other) ? (other + '') : other;
778
- }
779
- if (typeof value != 'string') {
780
- return value === 0 ? value : +value;
781
- }
782
- value = value.replace(reTrim, '');
783
- var isBinary = reIsBinary.test(value);
784
- return (isBinary || reIsOctal.test(value))
785
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
786
- : (reIsBadHex.test(value) ? NAN : +value);
787
- }
788
-
789
- var lodash_debounce = debounce;
790
-
791
- var HIDDEN_CLASS = 'copy-tuner-hidden';
792
-
793
- var CopytunerBar = function () {
794
- function CopytunerBar(element, data, callback) {
795
- classCallCheck(this, CopytunerBar);
796
-
797
- this.element = element;
798
- this.data = data;
799
- this.callback = callback;
800
- this.searchBoxElement = element.querySelector('.js-copy-tuner-bar-search');
801
- this.logMenuElement = this.makeLogMenu();
802
- this.element.appendChild(this.logMenuElement);
803
-
804
- this.addHandler();
805
- }
806
-
807
- createClass(CopytunerBar, [{
808
- key: 'addHandler',
809
- value: function addHandler() {
810
- var _this = this;
811
-
812
- var openLogButton = this.element.querySelector('.js-copy-tuner-bar-open-log');
813
- openLogButton.addEventListener('click', function (event) {
814
- event.preventDefault();
815
- _this.toggleLogMenu();
816
- });
817
-
818
- this.searchBoxElement.addEventListener('input', lodash_debounce(this.onKeyup.bind(this), 250));
819
- }
820
- }, {
821
- key: 'show',
822
- value: function show() {
823
- this.element.classList.remove(HIDDEN_CLASS);
824
- this.searchBoxElement.focus();
825
- }
826
- }, {
827
- key: 'hide',
828
- value: function hide() {
829
- this.element.classList.add(HIDDEN_CLASS);
830
- }
831
- }, {
832
- key: 'showLogMenu',
833
- value: function showLogMenu() {
834
- this.logMenuElement.classList.remove(HIDDEN_CLASS);
835
- }
836
- }, {
837
- key: 'toggleLogMenu',
838
- value: function toggleLogMenu() {
839
- this.logMenuElement.classList.toggle(HIDDEN_CLASS);
840
- }
841
- }, {
842
- key: 'makeLogMenu',
843
- value: function makeLogMenu() {
844
- var _this2 = this;
845
-
846
- var div = document.createElement('div');
847
- div.setAttribute('id', 'copy-tuner-bar-log-menu');
848
- div.classList.add(HIDDEN_CLASS);
849
-
850
- var table = document.createElement('table');
851
- var tbody = document.createElement('tbody');
852
- tbody.classList.remove('is-not-initialized');
853
-
854
- Object.keys(this.data).sort().forEach(function (key) {
855
- var value = _this2.data[key];
856
-
857
- if (value === '') {
858
- return;
859
- }
860
-
861
- var td1 = document.createElement('td');
862
- td1.textContent = key;
863
- var td2 = document.createElement('td');
864
- td2.textContent = value;
865
- var tr = document.createElement('tr');
866
- tr.classList.add('copy-tuner-bar-log-menu__row');
867
- tr.dataset.key = key;
868
-
869
- tr.addEventListener('click', function (_ref) {
870
- var currentTarget = _ref.currentTarget;
871
-
872
- _this2.callback(currentTarget.dataset.key);
873
- });
874
-
875
- tr.appendChild(td1);
876
- tr.appendChild(td2);
877
- tbody.appendChild(tr);
878
- });
879
-
880
- table.appendChild(tbody);
881
- div.appendChild(table);
882
-
883
- return div;
884
- }
885
- }, {
886
- key: 'onKeyup',
887
- value: function onKeyup(_ref2) {
888
- var target = _ref2.target;
889
-
890
- var keyword = target.value.trim();
891
- this.showLogMenu();
892
-
893
- var rows = Array.from(this.logMenuElement.getElementsByTagName('tr'));
894
-
895
- rows.forEach(function (row) {
896
- var isShow = keyword === '' || Array.from(row.getElementsByTagName('td')).some(function (td) {
897
- return td.textContent.includes(keyword);
898
- });
899
- row.classList.toggle(HIDDEN_CLASS, !isShow);
900
- });
901
- }
902
- }]);
903
- return CopytunerBar;
904
- }();
905
-
906
- var findBlurbs = function findBlurbs() {
907
- var filterNone = function filterNone() {
908
- return NodeFilter.FILTER_ACCEPT;
909
- };
910
-
911
- var iterator = document.createNodeIterator(document.body, NodeFilter.SHOW_COMMENT, filterNone, false);
912
-
913
- var comments = [];
914
- var curNode = void 0;
915
- // eslint-disable-next-line no-cond-assign
916
- while (curNode = iterator.nextNode()) {
917
- comments.push(curNode);
918
- }
919
-
920
- return comments.filter(function (comment) {
921
- return comment.nodeValue.startsWith('COPYRAY');
922
- }).map(function (comment) {
923
- var _comment$nodeValue$ma = comment.nodeValue.match(/^COPYRAY (\S*)$/),
924
- _comment$nodeValue$ma2 = slicedToArray(_comment$nodeValue$ma, 2),
925
- key = _comment$nodeValue$ma2[1];
926
-
927
- var element = comment.parentNode;
928
- return { key: key, element: element };
929
- });
930
- };
931
-
932
- var Copyray = function () {
933
- function Copyray(baseUrl, data) {
934
- classCallCheck(this, Copyray);
935
-
936
- this.baseUrl = baseUrl;
937
- this.data = data;
938
- this.isShowing = false;
939
- this.specimens = [];
940
- this.overlay = this.makeOverlay();
941
- this.toggleButton = this.makeToggleButton();
942
- this.boundOpen = this.open.bind(this);
943
-
944
- this.copyTunerBar = new CopytunerBar(document.getElementById('copy-tuner-bar'), this.data, this.boundOpen);
945
- }
946
-
947
- createClass(Copyray, [{
948
- key: 'show',
949
- value: function show() {
950
- this.reset();
951
-
952
- document.body.appendChild(this.overlay);
953
- this.makeSpecimens();
954
-
955
- this.specimens.forEach(function (specimen) {
956
- specimen.show();
957
- });
958
-
959
- this.copyTunerBar.show();
960
- this.isShowing = true;
961
- }
962
- }, {
963
- key: 'hide',
964
- value: function hide() {
965
- this.overlay.remove();
966
- this.reset();
967
- this.copyTunerBar.hide();
968
- this.isShowing = false;
969
- }
970
- }, {
971
- key: 'toggle',
972
- value: function toggle() {
973
- if (this.isShowing) {
974
- this.hide();
975
- } else {
976
- this.show();
977
- }
978
- }
979
- }, {
980
- key: 'open',
981
- value: function open(key) {
982
- var url = this.baseUrl + '/blurbs/' + key + '/edit';
983
- window.open(url, null, 'width=700, height=600');
984
- }
985
- }, {
986
- key: 'makeSpecimens',
987
- value: function makeSpecimens() {
988
- var _this = this;
989
-
990
- findBlurbs().forEach(function (_ref) {
991
- var element = _ref.element,
992
- key = _ref.key;
993
-
994
- _this.specimens.push(new Specimen(element, key, _this.boundOpen));
995
- });
996
- }
997
- }, {
998
- key: 'makeToggleButton',
999
- value: function makeToggleButton() {
1000
- var _this2 = this;
1001
-
1002
- var element = document.createElement('a');
1003
-
1004
- element.addEventListener('click', function () {
1005
- _this2.show();
1006
- });
1007
-
1008
- element.classList.add('copyray-toggle-button');
1009
- element.classList.add('hidden-on-mobile');
1010
- element.textContent = 'Open CopyTuner';
1011
- document.body.appendChild(element);
1012
-
1013
- return element;
1014
- }
1015
- }, {
1016
- key: 'makeOverlay',
1017
- value: function makeOverlay() {
1018
- var _this3 = this;
1019
-
1020
- var div = document.createElement('div');
1021
- div.setAttribute('id', 'copyray-overlay');
1022
- div.addEventListener('click', function () {
1023
- return _this3.hide();
1024
- });
1025
- return div;
1026
- }
1027
- }, {
1028
- key: 'reset',
1029
- value: function reset() {
1030
- this.specimens.forEach(function (specimen) {
1031
- specimen.remove();
1032
- });
1033
- }
1034
- }]);
1035
- return Copyray;
1036
- }();
1037
-
1038
- var start = function start() {
1039
- var dataElement = document.getElementById('copy-tuner-data');
1040
- var copyTunerUrl = dataElement.dataset.copyTunerUrl;
1041
- var data = JSON.parse(document.getElementById('copy-tuner-data').dataset.copyTunerTranslationLog);
1042
- var copyray = new Copyray(copyTunerUrl, data);
1043
-
1044
- document.addEventListener('keydown', function (event) {
1045
- if (copyray.isShowing && event.keyCode === keycodeJs.KEY_ESCAPE) {
1046
- copyray.hide();
1047
- return;
1048
- }
1049
-
1050
- if ((isMac && event.metaKey || !isMac && event.ctrlKey) && event.shiftKey && event.keyCode === keycodeJs.KEY_K) {
1051
- copyray.toggle();
1052
- }
1053
- });
1054
-
1055
- if (console) {
1056
- // eslint-disable-next-line no-console
1057
- console.log('Ready to Copyray. Press ' + (isMac ? 'cmd+shift+k' : 'ctrl+shift+k') + ' to scan your UI.');
1058
- }
1059
-
1060
- window.copyray = copyray;
1061
- };
1062
-
1063
- if (document.readyState === 'complete' || document.readyState !== 'loading') {
1064
- start();
1065
- } else {
1066
- document.addEventListener('DOMContentLoaded', start);
1067
- }
1068
-
1069
- }());