copy_tuner_client 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.babelrc +18 -0
- data/.eslintrc +4 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/app/assets/javascripts/copyray.js +937 -409
- data/app/assets/stylesheets/copyray.css +14 -16
- data/app/views/_copy_tuner_bar.html.erb +0 -6
- data/lib/copy_tuner_client/copyray.rb +3 -20
- data/lib/copy_tuner_client/version.rb +1 -1
- data/package-lock.json +2578 -4
- data/package.json +16 -3
- data/rollup.config.js +14 -0
- data/src/copyray.js +111 -0
- data/src/copytuner_bar.js +96 -0
- data/src/main.js +42 -0
- data/src/specimen.js +63 -0
- data/src/util.js +32 -0
- metadata +10 -4
- data/coffeelint.json +0 -135
- data/src/copyray.coffee +0 -354
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a1d2d35e0f10c245a66e5f9f1f1fe0b5e55b8f
|
4
|
+
data.tar.gz: 9f6bd6a383a8b9533c361b165e36b6895af20ac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad94cec56fa02a2bb263adb2965dacfd970369771a80cfc98653b1c5a8fc7c9a5dae7644dfee97762d6f1c1c4516f6d124f6b0c66132d11dfb6174cfca4cf1a0
|
7
|
+
data.tar.gz: 0a9704779c56a55e9efc55b2f8b781279ebee8c707e18332f72a78608c10fedcfe5b368827a5a3c4ff25aef7a4705b1533669c397cfbfdd650ad7c32b2950f32
|
data/.babelrc
ADDED
data/.eslintrc
ADDED
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
|
9
|
-
- config.copyray_js_injection_regexp_for_precompiled is no
|
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
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://
|
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
|
-
##
|
66
|
+
## JavaScript
|
67
67
|
|
68
68
|
```
|
69
|
-
$ npm run watch # Watch files for changes
|
70
|
-
$ npm run build # Compile a
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
141
|
+
function KeyCode() {}
|
13
142
|
|
14
|
-
|
143
|
+
Object.keys(keys).forEach(function (key) {
|
144
|
+
KeyCode[key] = keys[key];
|
145
|
+
});
|
15
146
|
|
16
|
-
|
147
|
+
return KeyCode;
|
148
|
+
}();
|
149
|
+
});
|
17
150
|
|
18
|
-
|
19
|
-
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
20
|
-
};
|
151
|
+
var index = KeyCode$1.default;
|
21
152
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
32
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
61
|
-
};
|
200
|
+
}
|
62
201
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
109
|
-
|
110
|
-
return Copyray.hideBar();
|
111
|
-
};
|
259
|
+
return _arr;
|
260
|
+
}
|
112
261
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
return
|
118
|
-
}
|
119
|
-
|
120
|
-
|
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
|
-
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
};
|
275
|
+
var Specimen = function () {
|
276
|
+
function Specimen(element, key, callback) {
|
277
|
+
classCallCheck(this, Specimen);
|
136
278
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
150
|
-
|
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
|
-
|
154
|
-
|
155
|
-
|
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.
|
158
|
-
this.
|
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
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
-
|
199
|
-
|
200
|
-
|
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(
|
203
|
-
div.textContent = this.
|
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
|
-
|
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
|
-
|
212
|
-
|
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
|
-
|
215
|
-
|
216
|
-
|
522
|
+
function remainingWait(time) {
|
523
|
+
var timeSinceLastCall = time - lastCallTime,
|
524
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
525
|
+
result = wait - timeSinceLastCall;
|
217
526
|
|
218
|
-
|
527
|
+
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
528
|
+
}
|
219
529
|
|
220
|
-
|
530
|
+
function shouldInvoke(time) {
|
531
|
+
var timeSinceLastCall = time - lastCallTime,
|
532
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
221
533
|
|
222
|
-
|
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
|
-
|
225
|
-
|
226
|
-
|
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
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
-
|
269
|
-
|
270
|
-
|
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
|
-
|
279
|
-
|
280
|
-
|
281
|
-
this.reset();
|
282
|
-
return Copyray.hideBar();
|
283
|
-
};
|
574
|
+
function debounced() {
|
575
|
+
var time = now(),
|
576
|
+
isInvoking = shouldInvoke(time);
|
284
577
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
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
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
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
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
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
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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
|
-
|
338
|
-
|
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
|
-
|
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
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
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
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
};
|
838
|
+
}
|
839
|
+
}]);
|
840
|
+
return CopytunerBar;
|
841
|
+
}();
|
383
842
|
|
384
|
-
|
385
|
-
|
843
|
+
var findBlurbs = function findBlurbs() {
|
844
|
+
var filterNone = function filterNone() {
|
845
|
+
return NodeFilter.FILTER_ACCEPT;
|
386
846
|
};
|
387
847
|
|
388
|
-
|
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
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
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
|
-
|
447
|
-
|
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
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
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
|
-
|
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
|
+
}());
|