copy_tuner_client 0.4.1 → 0.4.2

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