|
10 | 10 | var contentId = document.currentScript.dataset.id; |
11 | 11 | } |
12 | 12 |
|
13 | | - Tracy.getAjaxHeader = function() { |
14 | | - return contentId; |
15 | | - }; |
| 13 | + Tracy.getAjaxHeader = () => contentId; |
16 | 14 |
|
17 | 15 | Tracy.panelZIndex = Tracy.panelZIndex || 20000; |
18 | 16 |
|
|
30 | 28 | Panel.zIndexCounter = 1; |
31 | 29 |
|
32 | 30 | Panel.prototype.init = function() { |
33 | | - var _this = this, elem = this.elem; |
| 31 | + var elem = this.elem; |
34 | 32 |
|
35 | 33 | this.init = function() {}; |
36 | 34 | elem.innerHTML = elem.dataset.tracyContent; |
|
41 | 39 |
|
42 | 40 | draggable(elem, { |
43 | 41 | handles: elem.querySelectorAll('h1'), |
44 | | - start: function() { |
45 | | - if (!_this.is(Panel.FLOAT)) { |
46 | | - _this.toFloat(); |
| 42 | + start: () => { |
| 43 | + if (!this.is(Panel.FLOAT)) { |
| 44 | + this.toFloat(); |
47 | 45 | } |
48 | | - _this.focus(); |
| 46 | + this.focus(); |
49 | 47 | } |
50 | 48 | }); |
51 | 49 |
|
52 | | - elem.addEventListener('mousedown', function() { |
53 | | - _this.focus(); |
| 50 | + elem.addEventListener('mousedown', () => { |
| 51 | + this.focus(); |
54 | 52 | }); |
55 | 53 |
|
56 | | - elem.addEventListener('mouseenter', function() { |
| 54 | + elem.addEventListener('mouseenter', () => { |
57 | 55 | clearTimeout(elem.Tracy.displayTimeout); |
58 | 56 | }); |
59 | 57 |
|
60 | | - elem.addEventListener('mouseleave', function() { |
61 | | - _this.blur(); |
| 58 | + elem.addEventListener('mouseleave', () => { |
| 59 | + this.blur(); |
62 | 60 | }); |
63 | 61 |
|
64 | | - elem.addEventListener('mousemove', function(e) { |
65 | | - if (e.buttons && !_this.is(Panel.RESIZED) && (elem.style.width || elem.style.height)) { |
| 62 | + elem.addEventListener('mousemove', e => { |
| 63 | + if (e.buttons && !this.is(Panel.RESIZED) && (elem.style.width || elem.style.height)) { |
66 | 64 | elem.classList.add(Panel.RESIZED); |
67 | 65 | } |
68 | 66 | }); |
69 | 67 |
|
70 | | - elem.addEventListener('tracy-toggle', function() { |
71 | | - _this.reposition(); |
| 68 | + elem.addEventListener('tracy-toggle', () => { |
| 69 | + this.reposition(); |
72 | 70 | }); |
73 | 71 |
|
74 | | - forEach(elem.querySelectorAll('.tracy-icons a'), function(a) { |
75 | | - a.addEventListener('click', function(e) { |
| 72 | + forEach(elem.querySelectorAll('.tracy-icons a'), link => { |
| 73 | + link.addEventListener('click', e => { |
76 | 74 | clearTimeout(elem.Tracy.displayTimeout); |
77 | | - if (this.rel === 'close') { |
78 | | - _this.toPeek(); |
79 | | - } else if (this.rel === 'window') { |
80 | | - _this.toWindow(); |
| 75 | + if (link.rel === 'close') { |
| 76 | + this.toPeek(); |
| 77 | + } else if (link.rel === 'window') { |
| 78 | + this.toWindow(); |
81 | 79 | } |
82 | 80 | e.preventDefault(); |
83 | 81 | }); |
|
98 | 96 | elem.Tracy.window.focus(); |
99 | 97 | } else { |
100 | 98 | clearTimeout(elem.Tracy.displayTimeout); |
101 | | - elem.Tracy.displayTimeout = setTimeout(function() { |
| 99 | + elem.Tracy.displayTimeout = setTimeout(() => { |
102 | 100 | elem.classList.add(Panel.FOCUSED); |
103 | 101 | elem.style.zIndex = Tracy.panelZIndex + Panel.zIndexCounter++; |
104 | 102 | if (callback) { |
|
112 | 110 | var elem = this.elem; |
113 | 111 | if (this.is(Panel.PEEK)) { |
114 | 112 | clearTimeout(elem.Tracy.displayTimeout); |
115 | | - elem.Tracy.displayTimeout = setTimeout(function() { |
| 113 | + elem.Tracy.displayTimeout = setTimeout(() => { |
116 | 114 | elem.classList.remove(Panel.FOCUSED); |
117 | 115 | }, 50); |
118 | 116 | } |
|
158 | 156 | doc.title = this.elem.querySelector('h1').textContent; |
159 | 157 | } |
160 | 158 |
|
161 | | - var _this = this; |
162 | | - win.addEventListener('beforeunload', function() { |
163 | | - _this.toPeek(); |
| 159 | + win.addEventListener('beforeunload', () => { |
| 160 | + this.toPeek(); |
164 | 161 | win.close(); // forces closing, can be invoked by F5 |
165 | 162 | }); |
166 | 163 |
|
167 | | - doc.addEventListener('keyup', function(e) { |
| 164 | + doc.addEventListener('keyup', e => { |
168 | 165 | if (e.keyCode === 27 && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { |
169 | 166 | win.close(); |
170 | 167 | } |
|
237 | 234 | draggedClass: 'tracy-dragged' |
238 | 235 | }); |
239 | 236 |
|
240 | | - this.elem.addEventListener('mousedown', function(e) { |
| 237 | + this.elem.addEventListener('mousedown', e => { |
241 | 238 | e.preventDefault(); |
242 | 239 | }); |
243 | 240 |
|
|
246 | 243 | }; |
247 | 244 |
|
248 | 245 | Bar.prototype.initTabs = function(elem) { |
249 | | - var _this = this; |
250 | | - |
251 | | - forEach(elem.getElementsByTagName('a'), function(a) { |
252 | | - a.addEventListener('click', function(e) { |
253 | | - if (this.rel === 'close') { |
254 | | - _this.close(); |
| 246 | + forEach(elem.getElementsByTagName('a'), link => { |
| 247 | + link.addEventListener('click', e => { |
| 248 | + if (link.rel === 'close') { |
| 249 | + this.close(); |
255 | 250 |
|
256 | | - } else if (this.rel) { |
257 | | - var panel = Debug.panels[this.rel]; |
| 251 | + } else if (link.rel) { |
| 252 | + var panel = Debug.panels[link.rel]; |
258 | 253 | panel.init(); |
259 | 254 |
|
260 | 255 | if (e.shiftKey) { |
|
266 | 261 |
|
267 | 262 | } else { |
268 | 263 | panel.toFloat(); |
269 | | - panel.reposition(-Math.round(Math.random() * 100) - 20, (Math.round(Math.random() * 100) + 20) * (_this.isAtTop() ? 1 : -1)); |
| 264 | + panel.reposition(-Math.round(Math.random() * 100) - 20, (Math.round(Math.random() * 100) + 20) * (this.isAtTop() ? 1 : -1)); |
270 | 265 | } |
271 | 266 | } |
272 | 267 | e.preventDefault(); |
273 | 268 | }); |
274 | 269 |
|
275 | | - a.addEventListener('mouseenter', function(e) { |
276 | | - if (!e.buttons && this.rel && this.rel !== 'close' && !elem.classList.contains('tracy-dragged')) { |
277 | | - var panel = Debug.panels[this.rel], link = this; |
278 | | - panel.focus(function() { |
| 270 | + link.addEventListener('mouseenter', e => { |
| 271 | + if (!e.buttons && link.rel && link.rel !== 'close' && !elem.classList.contains('tracy-dragged')) { |
| 272 | + var panel = Debug.panels[link.rel]; |
| 273 | + panel.focus(() => { |
279 | 274 | if (panel.is(Panel.PEEK)) { |
280 | 275 | panel.init(); |
281 | 276 |
|
282 | 277 | var pos = getPosition(panel.elem); |
283 | 278 | setPosition(panel.elem, { |
284 | 279 | left: getOffset(link).left + getPosition(link).width + 4 - pos.width, |
285 | | - top: _this.isAtTop() |
286 | | - ? getOffset(_this.elem).top + getPosition(_this.elem).height + 4 |
287 | | - : getOffset(_this.elem).top - pos.height - 4 |
| 280 | + top: this.isAtTop() |
| 281 | + ? getOffset(this.elem).top + getPosition(this.elem).height + 4 |
| 282 | + : getOffset(this.elem).top - pos.height - 4 |
288 | 283 | }); |
289 | 284 | } |
290 | 285 | }); |
291 | 286 | } |
292 | 287 | }); |
293 | 288 |
|
294 | | - a.addEventListener('mouseleave', function() { |
295 | | - if (this.rel && this.rel !== 'close' && !elem.classList.contains('tracy-dragged')) { |
296 | | - Debug.panels[this.rel].blur(); |
| 289 | + link.addEventListener('mouseleave', () => { |
| 290 | + if (link.rel && link.rel !== 'close' && !elem.classList.contains('tracy-dragged')) { |
| 291 | + Debug.panels[link.rel].blur(); |
297 | 292 | } |
298 | 293 | }); |
299 | 294 | }); |
|
354 | 349 | Debug.layer.style.display = 'block'; |
355 | 350 | Debug.bar.init(); |
356 | 351 |
|
357 | | - forEach(document.querySelectorAll('.tracy-panel'), function(panel) { |
| 352 | + forEach(document.querySelectorAll('.tracy-panel'), panel => { |
358 | 353 | Debug.panels[panel.id] = new Panel(panel.id); |
359 | 354 | Debug.panels[panel.id].dumps = dumps; |
360 | 355 | Debug.panels[panel.id].restorePosition(); |
|
365 | 360 | }; |
366 | 361 |
|
367 | 362 | Debug.loadAjax = function(content, dumps) { |
368 | | - forEach(Debug.layer.querySelectorAll('.tracy-panel.tracy-ajax'), function(panel) { |
| 363 | + forEach(Debug.layer.querySelectorAll('.tracy-panel.tracy-ajax'), panel => { |
369 | 364 | Debug.panels[panel.id].savePosition(); |
370 | 365 | delete Debug.panels[panel.id]; |
371 | 366 | panel.parentNode.removeChild(panel); |
|
383 | 378 | Debug.bar.elem.appendChild(ajaxBar); |
384 | 379 | Debug.bar.restorePosition(); |
385 | 380 |
|
386 | | - forEach(document.querySelectorAll('.tracy-panel'), function(panel) { |
| 381 | + forEach(document.querySelectorAll('.tracy-panel'), panel => { |
387 | 382 | if (!Debug.panels[panel.id]) { |
388 | 383 | Debug.panels[panel.id] = new Panel(panel.id); |
389 | 384 | Debug.panels[panel.id].dumps = dumps; |
|
397 | 392 | Debug.captureWindow = function() { |
398 | 393 | var size = getWindowSize(); |
399 | 394 |
|
400 | | - window.addEventListener('resize', function() { |
| 395 | + window.addEventListener('resize', () => { |
401 | 396 | var newSize = getWindowSize(); |
402 | 397 |
|
403 | 398 | Debug.bar.reposition(newSize.width - size.width, newSize.height - size.height); |
|
409 | 404 | size = newSize; |
410 | 405 | }); |
411 | 406 |
|
412 | | - window.addEventListener('unload', function() { |
| 407 | + window.addEventListener('unload', () => { |
413 | 408 | Debug.bar.savePosition(); |
414 | 409 | for (var id in Debug.panels) { |
415 | 410 | Debug.panels[id].savePosition(); |
|
474 | 469 | }; |
475 | 470 |
|
476 | 471 | function evalScripts(elem) { |
477 | | - forEach(elem.getElementsByTagName('script'), function(script) { |
| 472 | + forEach(elem.getElementsByTagName('script'), script => { |
478 | 473 | if ((!script.hasAttribute('type') || script.type === 'text/javascript' || script.type === 'application/javascript') && !script.tracyEvaluated) { |
479 | 474 | var dolly = script.ownerDocument.createElement('script'); |
480 | 475 | dolly.textContent = script.textContent; |
|
0 commit comments