@@ -107,6 +107,10 @@ function readConf() {
107
107
'.k' , '{color:' + opts . property + '}' +
108
108
'.e' , '{color:' + opts . error + '}' +
109
109
'.o' , '{color:' + opts . null + '}' +
110
+ '.g' , '{float:right;margin:-4px -14px;border-radius:4px;border:1px solid ' + opts . info + ';background:#ddd}' +
111
+ '.gb' , '{font: 20px/20px serif;cursor:pointer;padding:0 2px}' +
112
+ '.gb' , ':hover{background:#ccc}' +
113
+ '.gb' , ':active{background:#999}' +
110
114
'.e' , ',.b' , '{font-weight:bold}' +
111
115
'div.e' , '{white-space:normal;font-size:120%;margin:0 0 1em}'
112
116
] . join ( rand )
@@ -355,26 +359,6 @@ function func(rand, opts, op, msg) {
355
359
}
356
360
}
357
361
358
- function onClick ( e ) {
359
- var target = e . target
360
- , isCollapsed = target . classList . contains ( COLL )
361
- e . stopPropagation ( )
362
- if ( target . tagName === "I" ) {
363
- if ( target . classList . contains ( "m" + rand ) ) {
364
- target . previousSibling . appendChild ( target . nextSibling . firstChild )
365
- target . parentNode . removeChild ( target . nextSibling )
366
- target . parentNode . removeChild ( target )
367
- } else if ( e . altKey ) {
368
- changeSiblings ( target , COLL , ! isCollapsed )
369
- } else if ( e [ mod ] ) {
370
- isCollapsed = target . nextSibling . querySelector ( "i" )
371
- if ( isCollapsed ) change ( target . nextSibling , "i" , COLL , ! isCollapsed . classList . contains ( COLL ) )
372
- } else {
373
- target . classList [ isCollapsed ? "remove" : "add" ] ( COLL )
374
- }
375
- }
376
- }
377
-
378
362
function draw ( str , to , first , box ) {
379
363
var afterColon
380
364
, spaces = ""
@@ -386,6 +370,7 @@ function func(rand, opts, op, msg) {
386
370
, path = [ ]
387
371
, lineNo = 1
388
372
, jsonp = / ^ ( [ \/ * & ; = ' " $ \w \s ] { 0 , 99 } \b [ $ a - z _ ] [ $ \w ] { 0 , 99 } \s * \( ) ( [ ^ ] + ) ( \) [ \s ; ] * ) $ / i. exec ( str )
373
+ , oldTxt = to . textContent
389
374
colon . textContent = ": "
390
375
comma . textContent = ",\n"
391
376
@@ -395,6 +380,12 @@ function func(rand, opts, op, msg) {
395
380
link . target = "_blank"
396
381
}
397
382
383
+ if ( first === 0 ) {
384
+ var btnGroup = el ( "div" , node , "g" )
385
+ , closeBtn = el ( "div" , btnGroup , "gb" )
386
+ closeBtn . textContent = "⨯"
387
+ }
388
+
398
389
if ( to === body && opts . navInfo ) try {
399
390
var nav = performance . getEntriesByType ( "navigation" ) [ 0 ]
400
391
, endNames = { request : "responseStart" }
@@ -408,7 +399,29 @@ function func(rand, opts, op, msg) {
408
399
el ( "div" , node , "e" ) . textContent = e
409
400
}
410
401
411
- node . addEventListener ( "click" , onClick , true )
402
+ node . addEventListener ( "click" , onClick , false )
403
+ function onClick ( e ) {
404
+ var target = e . target
405
+ , isCollapsed = target . classList . contains ( COLL )
406
+ e . stopPropagation ( )
407
+ if ( target . tagName === "I" ) {
408
+ if ( target . classList . contains ( "m" + rand ) ) {
409
+ target . previousSibling . appendChild ( target . nextSibling . firstChild )
410
+ target . parentNode . removeChild ( target . nextSibling )
411
+ target . parentNode . removeChild ( target )
412
+ } else if ( e . altKey ) {
413
+ changeSiblings ( target , COLL , ! isCollapsed )
414
+ } else if ( e [ mod ] ) {
415
+ isCollapsed = target . nextSibling . querySelector ( "i" )
416
+ if ( isCollapsed ) change ( target . nextSibling , "i" , COLL , ! isCollapsed . classList . contains ( COLL ) )
417
+ } else {
418
+ target . classList [ isCollapsed ? "remove" : "add" ] ( COLL )
419
+ }
420
+ } else if ( target === closeBtn ) {
421
+ to . textContent = oldTxt
422
+ }
423
+ }
424
+
412
425
if ( first ) {
413
426
to . replaceChild ( box = node , first )
414
427
} else {
0 commit comments