273
273
padding-left : 2em ;
274
274
font-style : italic;
275
275
}
276
+ </ style >
277
+ < script >
278
+ ( function ( ) {
279
+ function beforePrint ( ) {
280
+ console . debug ( "opening details before printing" ) ;
281
+ var algoDetails = document . querySelectorAll ( '.algorithm details' ) ;
282
+ var c = 0 ;
283
+ for ( var dt of algoDetails ) {
284
+
285
+ if ( ! dt . open ) {
286
+ dt . setAttribute ( "data-was-closed" , "" ) ;
287
+ dt . open = true ;
288
+ c += 1 ;
289
+ }
290
+ }
291
+ console . debug ( c , "details opended before printing" ) ;
292
+ }
276
293
277
- /* required if we chose to put OLs *outside* the details,
278
- to force them visible when printing */
279
- @media screen {
280
- .algorithm details : not ([open ]) + ol {
281
- display : none;
294
+ function afterPrint ( ) {
295
+ console . debug ( "closing details after printing" ) ;
296
+ var algoDetails = document . querySelectorAll ( '.algorithm details' ) ;
297
+ var c = 0 ;
298
+ for ( var dt of algoDetails ) {
299
+ if ( dt . hasAttribute ( "data-was-closed" ) ) {
300
+ dt . removeAttribute ( "data-was-closed" ) ;
301
+ dt . open = false ;
302
+ c += 1 ;
303
+ }
304
+ }
305
+ console . debug ( c , "details closed after printing" ) ;
282
306
}
283
- }
284
307
285
- </ style >
308
+ // using matchMedia
309
+ window . matchMedia ( 'print' ) . addListener ( function ( mql ) {
310
+ if ( mql . matches ) {
311
+ beforePrint ( ) ;
312
+ } else {
313
+ afterPrint ( ) ;
314
+ }
315
+ } ) ;
316
+ // using events
317
+ window . addEventListener ( 'beforeprint' , beforePrint ) ;
318
+ window . addEventListener ( 'afterprint' , afterPrint ) ;
319
+ } ) ( ) ;
320
+ </ script >
286
321
</ head >
287
322
288
323
< body >
@@ -1091,8 +1126,7 @@ <h3>Algorithm</h3>
1091
1126
For each item < var > context</ var > in < var > local context</ var > :
1092
1127
< ol >
1093
1128
< li > If < var > context</ var > is < code > null</ code > :
1094
- < details > < summary > clear context (unless protected)</ summary > </ details >
1095
- < ol >
1129
+ < details > < summary > clear context (unless protected)</ summary > < ol >
1096
1130
< li class ="changed "> If < var > override protected</ var > is < code > false</ code > and < var > active context</ var >
1097
1131
contains any < a > protected</ a > < a > term definitions</ a > ,
1098
1132
an < a data-link-for ="JsonLdErrorCode "> invalid context nullification</ a >
@@ -1105,7 +1139,7 @@ <h3>Algorithm</h3>
1105
1139
< span class ="note "> In [[[JSON-LD]]], the < a > base IRI</ a > was given
1106
1140
a default value here; this is now described conditionally
1107
1141
in < a href ="#the-application-programming-interface " class ="sectionRef "> </ a > .</ span > </ li >
1108
- </ ol >
1142
+ </ ol > </ details >
1109
1143
</ li >
1110
1144
< li > If < var > context</ var > is a < a > string</ a > :
1111
1145
< details > < summary > dereference and process</ summary > < ol >
0 commit comments