Welcome to mirror list, hosted at ThFree Co, Russian Federation.

printliminator.js « src - github.com/CSS-Tricks/The-Printliminator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1910b072cbe2ad10cd7a3a797db16955edd9a3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
/* Printliminator v3.1.1 */
/* jshint expr:false */
/* global csstricksPrintliminatorVars */
;( function() {
'use strict';
var pl = {

	version : '3.1.1',

	css : {
		hilite     : '_printliminator_highlight',
		fullWidth  : '_printliminator_full_width',
		hidden     : '_printliminator_hidden',
		stylized   : '_printliminator_stylized', // class name added to body
		noSelection: '_printliminator_noSelection', // class on body while dragging

		// printliminator
		stylesheet : '_print_controls_styles', // stylesheet ID
		controls   : '_print_controls',
		icon       : '_print_controls_icon',
		wrap       : '_print_controls_wrap',
		noGraphics : '_print_controls_remove_graphics',
		stylize    : '_print_controls_stylize',
		print      : '_print_controls_print',
		close      : '_print_controls_close',
		undo       : '_print_controls_undo',
		drag       : '_print_controls_icon_drag',
		dragActive : '_print_controls_drag_active',
		keyboard   : '_print_controls_keyboard'
	},

	keys : {
		parent1   : 33,  // pageUp
		parent2   : 38,  // up arrow
		child1    : 34,  // pageDown
		child2    : 40,  // down arrow
		nextSib   : 39,  // right arrow
		prevSib   : 37,  // left arrow
		hide      : 13,  // enter
		undo      : 8,   // backspace
		fontUp    : 107, // Numpad +
		fontDown  : 109, // Numpad -
		fontReset : 106, // Numpad *
		print     : 44,  // PrtScn (keyup only)
		abort     : 27,  // Esc
		// use event key below
		opposite  : 'altKey',  // alt + click
		fullWidth : 'shiftKey' // shift + click
	},

	// elements hidden when "remove graphics" is selected
	noGraphicsSelectors : 'img, iframe:not(._print_controls), object, embed, audio, video, input[type=image], svg',
	// elements to ignore while traversing
	ignoredElm  : /^(br|meta|style|link|script)$/i,

	// iframe height with keyboard open/closed
	keyboardOpen   : 630,
	keyboardClosed : 220,

	// dragging parameters stored here
	drag : {
		el : null,
		pos : [ 0, 0 ],
		elm : [ 0, 0 ]
	},

	init : function() {

		var body = document.querySelector( 'body' );

		// need a global variable to store history & flags
		if ( typeof window.csstricksPrintliminatorVars === 'undefined' ) {
			// use object separate from pl, otherwise these values get lost
			// upon javascript injection a second time (after uses presses Esc)
			window.csstricksPrintliminatorVars = {
				history : [],
				// flags to prevent multiple applications of same action
				flags : {}
			};

			pl.addStyles();

		}

		pl.addControls();

		// highlighting elements & keyboard binding
		pl.addEvent( body, 'click', pl.bodyClick );
		pl.addEvent( body, 'mouseover', pl.bodyMouseover );
		pl.addEvent( body, 'mouseout', pl.removeHighlight );
		pl.addEvent( document, 'keyup', pl.bodyKeyUp );
		pl.addEvent( document, 'keydown', pl.bodyKeyDown );

		// drag
		pl.addEvent( document, 'mouseup', pl.docMouseUp );
		pl.addEvent( document, 'mousemove', pl.docMouseMove );

	},

	addStyles : function(){
		var el,
		body = document.querySelector( 'body' ),
		prefix = 'body.' + pl.css.stylized + ' ',
		impt = '!important;',

		// programmically added stylesheets
		styles = '' +
			// hide printliminator controls from print
			'@media print{ .' + pl.css.wrap + '{ display: none; } }' +

			// print stylesheet
			'@media print, screen {' +
			prefix + '{ margin: 0; padding: 0; line-height: 1.4;' +
				'word-spacing: 1.1pt; letter-spacing: 0.2pt; font-size: 12pt;' +
				'font-family: Garamond, "Times New Roman", serif; color: #000; background: none; }' +
			prefix + 'h1,' + prefix + 'h2,' + prefix + 'h3,' +
				prefix + 'h4,' + prefix +'h5,' + prefix +'h6' +
				'{ font-family: Helvetica, Arial, sans-serif; }' +
			prefix + 'h1 { font-size: 19pt; }' +
			prefix + 'h2 { font-size: 17pt; }' +
			prefix + 'h3 { font-size: 15pt; }' +
			prefix + 'h4, ' + prefix +'h5,' + prefix + 'h6 { font-size: 12pt; }' +
			prefix + 'code { font: 10pt Courier, monospace; }' +
			prefix + 'blockquote { margin: 1.3em; padding: 1em; font-size: 10pt; }' +
			prefix + 'hr { background-color: #ccc; }' +
			prefix + 'img { float: left; margin: 1em 1.5em 1.5em 0; }' +
			prefix + 'a img { border: none; }' +
			prefix + 'table { margin: 1px; text-align:left; border-collapse: collapse; }' +
			prefix + 'th { border: 1px solid #333; font-weight: bold; }' +
			prefix + 'td { border: 1px solid #333; }' +
			prefix + 'th, ' + prefix +' td { padding: 4px 10px; }' +
			prefix + 'tfoot { font-style: italic; }' +
			prefix + 'caption { background: #fff; margin-bottom: 20px; text-align:left; }' +
			prefix + 'thead { display: table-header-group; }' +
			prefix + 'tr { page-break-inside: avoid; }' +

			// elements hidden by Printliminator
			'.' + pl.css.hidden + ' { display: none' + impt + '}' +
			// elements set to full width/no margins
			'.' + pl.css.fullWidth + ' { width: 100%' + impt + ' min-width: 100%' + impt + ' max-width: 100%' + impt +
				'margin: 0' + impt + '}' +

			'} @media screen {' +
			prefix + '{ padding: 20px; }' +

			// printliminator controls
			'.' + pl.css.wrap + '{ width: 450px' + impt + ' height: ' + pl.keyboardClosed + 'px; position: fixed' + impt +
				'top: 20px; right: 20px; z-index: 999999' + impt + ' box-shadow: 0 0 80px black' + impt + '}' +
			'.' + pl.css.drag + '{ width: 28px' + impt + 'height: 20px' + impt + 'position: absolute' + impt +
				' top: 0' + impt + ' left: 0' + impt + 'cursor: move' + impt + '}' +
			'.' + pl.css.drag + '.' + pl.css.dragActive + '{ width: 120px' + impt + 'height:100px' + impt +
				'top:-40px' + impt + 'left:-40px' + impt + '}' +
			'.' + pl.css.wrap + ' iframe { width: 450px' + impt + ' height: ' + pl.keyboardClosed + 'px; border: 0' + impt +
				'overflow-x: hidden' + impt + ' margin: 0' + impt + ' padding: 0' + impt + '}' +

			// prevent selection
			'body.' + pl.css.noSelection + ',.' + pl.css.hilite + ',.' + pl.css.wrap + ',.' + pl.css.drag + ',.' + pl.css.wrap + ' iframe {' +
				'-webkit-user-select: none' + impt + '-moz-user-select: none' + impt + ' -ms-user-select: none' + impt +
				' user-select: none' + impt + '}' +

			// box highlighting
			'.' + pl.css.hilite + '{ outline: 3px solid red' + impt + 'cursor: default' + impt + '}' +
			'.' + pl.css.hilite + '.' + pl.css.fullWidth + '{ outline-color: blue' + impt + '}';

		// add print stylesheet
		el = document.createElement( 'style' );
		el.id = pl.css.stylesheet;
		el.innerHTML = styles;
		document.querySelector( 'head' ).appendChild( el );

	},

	// create popup
	addControls : function(){
		var frame,
			body = document.querySelector( 'body' ),
			el = document.createElement( 'div' ),

			controls = pl.css.controls,
			prefix = '.' + controls,
			button = '_print_controls_button',
			icon = pl.css.icon,

			logo = 'data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20134.4%208.7%22%3E%0A%3Cg%3E%0A%09%3Cpath%20d%3D%22M3%2C0.7H0.3C0.1%2C0.7%2C0%2C0.6%2C0%2C0.4c0-0.2%2C0.1-0.3%2C0.3-0.3h6c0.2%2C0%2C0.3%2C0.1%2C0.3%2C0.3c0%2C0.2-0.1%2C0.3-0.3%2C0.3H3.6v7.6%0A%09%09c0%2C0.2-0.1%2C0.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axMby0GiYFUeBplZ0bZUZVIE5kkRA2gbMd8J7iML8FxYpMCcMHLQ6mx8hOgFmXpEbK2mZF4RHmM4nINB/qYcBKLtsJE3czz7Sj47Zesjfo3AOJ6oVWk4m0SIIc5DEolFqaaaeMEcmHBW+tC6sQ8o0l5FyUbj6l4MwAxyTpWdZ4eQWI84bWxmzzD9PgMyDQyxJ5nrUpXMexZkfHxzjqNO31Rpjd2oE7ZXNg/w6bM6S5tqJyduLE+JSAIXO0Clg+YFvajDIqXyRYOkvfIrEsU9YCWygcSYCJwYC4KFW7xh9CGn2zzi+ABDzjwYFCTMfnxCL7dxUAmcXOdJIGUtCa1kEbOwqncAKan6kdifNpWoo55lqqVHTUTCz3vLSqAZHKGLmvju4nvj7r0efZ28wobBQUm0I089sESy9i5RlxnoPEiHPqjvTM/IgnlzXQ1lulhZl7VfmlKUm7P0OcoQExkyUj32Lxi/u3O2StF9+kBmQO8+TtCa9B5LkBovpwMH9FoJ0tr1Rlh7lacqemzUXtfm8R+mkYdSRq3oBbWBOts87UJdoDpVI+EvisejyLqUvfHINhLMrNM5hgpLymtKQRgFE/w5lJd3mlEgY6tcKCIx4hcPlf2SlHkt9WQWpcIyL63RTjCYTPboaW5LkMZd9MVBouWgaQxF3L0P6l0rYSTM1HHzLcOOrkCafCqNTStXhxL97dFmcMfCQII0AaPNM8Te/kn46+R89WOlCSYHwmmw8AuDGQKXm1AfYwAAAABJRU5ErkJggg==';

		body.appendChild( el );
		pl.addClass( el, pl.css.wrap );
		pl.addClass( el, controls );

		el.innerHTML = '<iframe class="' + pl.css.controls + '"></iframe>' +
			'<div class="' + pl.css.controls + ' ' + pl.css.drag + '"></div>';

		frame = el.querySelector( 'iframe.' + pl.css.controls ).contentWindow.document.body;
		frame.innerHTML = '<div class="' + controls + '_header">' +
			'<div class="' + pl.css.close + ' ' + controls + '_right">CLOSE <span class="' + icon + ' ' + icon + '_close"></span></div>' +
			'<div><span class="' + icon + ' ' + pl.css.drag + '"></span> DRAG</div>' +
			'</div>' +
			'<div class="' + controls + '_top">' +
			'<img class="pl_logo" src="' + logo + '" alt="The Printliminator">' +
			'<h3><span>Just click stuff on page to remove.</span> Alt-click to remove opposite.</h3>' +
			'</div>' +
			'<div class="' + controls + '_footer">' +
			'<h3>Other Useful Superpowers</h3>' +
			'<ul>' +
			'<li class="' + button + ' ' + pl.css.undo + '"><span class="' + icon + ' ' + icon + '_undo"></span>Undo<br>Last</li>' +
			'<li class="' + button + ' ' + pl.css.stylize + '"><span class="' + icon + ' ' + icon + '_stylize"></span>Add Print<br>Styles</li>' +
			'<li class="' + button + ' ' + pl.css.noGraphics + '"><span class="' + icon + ' ' + icon + '_nographics"></span>Remove<br>Graphics</li>' +
			'<li class="' + button + ' ' + pl.css.print + '"><span class="' + icon + ' ' + icon + '_print"></span>Send to<br>print</li>' +
			'</ul>' +

			'<div class="' + controls + '_keyboard-area">' +
			'<p class="keyboard-commands-toggle' + ' ' + pl.css.keyboard + '">View Keyboard Commands</p>' +

			'<table id="' + pl.css.keyboard + '" style="display:none">' +
			'<thead>' +
			'<tr><th class="key">Key</th><th>Command</th></tr>' +
			'</thead>' +
			'<tbody>' +
			'<tr><td><kbd>PageUp</kbd> <span class="lower">or</span> <kbd class="bold" title="Up Arrow">&uarr;</kbd></td><td>Find wrapper of highlighted box</td></tr>' +
			'<tr><td><kbd>PageDown</kbd> <span class="lower">or</span> <kbd class="bold" title="Down Arrow">&darr;</kbd></td><td>Find content of highlighted box</td></tr>' +
			'<tr><td><kbd class="bold" title="Right Arrow">&rarr;</kbd></td><td>Find next box inside same wrapper</td></tr>' +
			'<tr><td><kbd class="bold" title="Left Arrow">&larr;</kbd></td><td>Find previous box inside same wrapper</td></tr>' +
			'<tr><td><kbd>Enter</kbd></td><td>Remove the highlighted box</td></tr>' +
			'<tr><td><kbd>Backspace</kbd></td><td>Undo last action</td></tr>' +
			'<tr><td><kbd title="Numpad Plus">Numpad <span class="bold">+</span></kbd></td><td>Increase font-size by 1</td></tr>' +
			'<tr><td><kbd title="Numpad Minus">NumPad <span class="bold">-</span></kbd></td><td>Decrease font-size by 1</td></tr>' +
			'<tr><td><kbd title="Numpad Asterisk (Multiply)">NumPad <span class="bold asterisk">*</span></kbd></td><td>Reset font-size</td></tr>' +
			'<tr><td><kbd>Alt</kbd> + <span class="' + icon + ' ' + icon + '_left_click" title="left-click on mouse"></span></td>' +
				'<td>Remove everything but highlighted box</td></tr>' +
			'<tr><td><kbd>Shift</kbd> + <span class="' + icon + ' ' + icon + '_left_click" title="left-click on mouse"></span></td>' +
				'<td>Set box width to 100% &amp; margins to zero (highlight turns blue)</td></tr>' +
			'<tr><td><kbd title="Print Screen">PrtScn</kbd></td><td>Print Page</td></tr>' +
			'<tr><td><kbd title="Escape">Esc</kbd></td><td>Disable Printliminator, but save undo history</td></tr>' +
			'</tbody></table></div></div>' +
			'<style>' +
			'html { box-sizing: border-box; height: 100%; } *, *:before, *:after { box-sizing: inherit; }' +
			'html,body { background: #eee; min-height: ' + pl.keyboardClosed + 'px;' +
				'font-size: 14px; margin: 0; padding: 0; cursor: default; overflow: hidden;' +
				'font-family: "Lucida Grande","Lucida Sans Unicode", Tahoma, sans-serif;' +
				'-webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }' +
			prefix + '_top { background: #fff; padding: 15px; }' +
			prefix + '_footer { padding: 15px 15px 0 15px; }' +
			prefix + '_keyboard-area { margin: 0 -15px 0 -15px; padding: 15px; background: #ccc; }' +
			'.keyboard-commands-toggle { font-size: 12px; margin: 0 0 15px 0; cursor: pointer; }' +
			'h1, h3 { margin: 0 0  10px; font-weight: normal;' +
				'text-transform: uppercase; }' +
			'.pl_logo { width: 225px; height: 15px; margin: 0 0 5px 0; }' +
			'h3 { font-size: 10px; font-weight: bold; }' +
			prefix + '_top h3 { color: #ccc; margin: 0; }' + prefix + '_top h3 span { color: red; }' +
			'.' + pl.css.icon + '{ display: inline-block; background: url(' + sprite + ') no-repeat;' +
				'width: 25px; height: 25px; vertical-align: middle; }' +
			'.' + pl.css.icon + '.' + pl.css.drag + ' { background-position: 0 0; }' +
			'.' + pl.css.icon + '_print { background-position: -25px 0; }' +
			'.' + pl.css.icon + '_keys  { background-position: -50px 0; }' +
			'.' + pl.css.icon + '_close { background-position: -75px 0; width: 40px; cursor: pointer; }' +
			'.' + pl.css.icon + '_undo  { background-position: 0 -25px; }' +
			'.' + pl.css.icon + '_nographics { background-position: -25px -25px; }' +
			'.' + pl.css.icon + '_left_click { background-position: -50px -25px; }' +
			'.' + pl.css.icon + '_stylize { background-position: -75px -25px; width: 35px; }' +
			prefix + '_header,' + prefix + '_button { background: #111; color: #fff; font-size: 11px; }' +
			prefix + '_header,' + prefix + '_header > div { height: 21px; font-size: 11px; }' +
			prefix + '_header > div,' + prefix + '_button { display: inline-block; }' +
			prefix + '_right { float: right; margin-right: 6px; }' +
			prefix + '_footer ul { margin: 0 0 15px 0; padding: 0;' +
				'list-style-type: none; }' +
			prefix + '_button { padding: 4px 14px 4px 4px; line-height: 12px; font-size: 10px; text-transform: uppercase;' +
				'text-align: left; white-space: nowrap; margin: 2px; cursor: pointer; display: inline-block; }' +
			prefix + '_button:hover { background-color: #333; }' +
			prefix + '_button span { float: left; margin: 0 10px 0 0; text-align: left; }' +
			'.key { width: 30%; }' +
			'table { margin: 0 4px; }' +
			'th { text-align: left; padding: 0 0 10px 0; }' +
			'kbd { background: #fff; border: #000 1px solid; border-radius: 3px;' +
				'padding: 1px 3px; }' +
			'td { border-top: 1px solid #aaa; font-size: 12px; padding: 5px; }' +
			'</style>';

		pl.addEvent( frame.querySelector( '.' + pl.css.noGraphics ), 'click', pl.removeGraphics );
		pl.addEvent( frame.querySelector( '.' + pl.css.print ), 'click', pl.print );
		pl.addEvent( frame.querySelector( '.' + pl.css.undo ), 'click', pl.undo );
		pl.addEvent( frame.querySelector( '.' + pl.css.stylize ), 'click', pl.stylize );
		pl.addEvent( frame.querySelector( '.' + pl.css.close ), 'click', pl.abort );
		pl.addEvent( frame.querySelector( '.' + pl.css.keyboard ), 'click', pl.keyboard );
		// can't drag from within the iframe - the mouse coordinates would be within it
		pl.addEvent( document.querySelector( '.' + pl.css.drag ), 'mousedown', pl.dragInit );
		// include mouseup inside frame to stop the drag
		pl.addEvent( frame, 'mouseup', pl.docMouseUp );

	},

	bodyClick : function( event ) {
		event.preventDefault();
		event.stopImmediatePropagation();

		if ( event.target.nodeName !== 'BODY' && !pl.hasClass( event.target, pl.css.controls ) ) {
			var done, sel,
				hilite = document.querySelector( '.' + pl.css.hilite );


			// Make 100% width & zero margins (set by css)
			// Shift + click
			if ( event[ pl.keys.fullWidth ] ) {
				if ( !pl.hasClass( hilite, pl.css.fullWidth ) ) {
					pl.addClass( hilite, pl.css.fullWidth );
					csstricksPrintliminatorVars.history.push( function() {
						pl.removeClass( hilite, pl.css.fullWidth );
					});
				}
			} else {
				// show opposite (Alt + click)
				if ( event[ pl.keys.opposite ] ) {
					done = pl.getOpposite( hilite );
					sel = done.length;
					if ( !sel ) {
						// nothing left to remove
						return false;
					}
				} else {
					// hide clicked element
					done = [ hilite ];
				}
				pl.hide( done );
				csstricksPrintliminatorVars.history.push( done );
			}

			// remove any text selection
			pl.clearSelection();

		}
	},

	bodyMouseover : function( event ) {
		if ( !pl.hasClass( event.target, pl.css.controls ) ) {
			pl.addClass( event.target, pl.css.hilite );
		}
	},

	removeHighlight : function() {
		// remove all highlight class names, just in case
		var indx,
			// include body as it might also get the highlight class
			hilite = document.querySelectorAll( '.' + pl.css.hilite ),
			len = hilite.length;
		for ( indx = 0; indx < len; indx++ ) {
			pl.removeClass( hilite[ indx ], pl.css.hilite );
		}
	},

	bodyKeyUp : function( event ) {
		event.preventDefault();
		// PrntScrn only works on keyup
		if ( event.which === pl.keys.print ) {
			pl.print();
		}
	},

	bodyKeyDown : function( event ) {
		event.preventDefault();
		var n, suffix, elm, els, isBody,
			body = document.querySelectorAll( 'body' )[ 0 ],
			el = document.querySelectorAll( '.' + pl.css.hilite )[ 0 ],
			hidden = pl.css.hidden,
			highlight = pl.css.hilite;

		if ( el ) {
			isBody = el.nodeName === 'BODY';

			switch ( event.which ) {
				case pl.keys.parent1 : // pageUp
				case pl.keys.parent2 : // up arrow
					if ( !isBody && el.parentNode ) {
						pl.removeClass( el, highlight );
						pl.addClass( el.parentNode, highlight );
					}
					break;

				case pl.keys.child1 : // pageDown
				case pl.keys.child2 : // down arrow
					els = Array.prototype.filter.call( el.children, pl.filterElements );
					if ( els.length ) {
						pl.removeClass( el, highlight );
						pl.addClass( els[0], highlight );
					}
					break;

				case pl.keys.nextSib : // right arrow (siblings)
					elm = pl.getNext( el );
					if ( !isBody && elm ) {
						pl.removeClass( el, highlight );
						pl.addClass( elm, highlight );
					}
					break;

				case pl.keys.prevSib : // left arrow (siblings)
					elm = pl.getPrev( el );
					if ( !isBody && elm ) {
						pl.removeClass( el, highlight );
						pl.addClass( elm, highlight );
					}
					break;

				case pl.keys.hide : // enter
					if ( !isBody ) {
						pl.addClass( el, hidden );
						pl.addClass( el.parentNode, highlight );
						csstricksPrintliminatorVars.history.push( el );
					}
					break;

			}
		} else {
			el = event.target;
			pl.addClass( el, highlight );
		}

		n = window.getComputedStyle( body, null ).getPropertyValue( 'font-size' );
		suffix = n.match( /[a-z]+/i )[0];

		switch ( event.which ) {
			case pl.keys.fontUp : // Numpad + = Increase font size
				body.style.fontSize = ( parseFloat( n ) + 1 ) + suffix;
				break;

			case pl.keys.fontDown : // Numpad - = Decrease font size
				body.style.fontSize = ( parseFloat( n ) - 1 ) + suffix;
				break;

			case pl.keys.fontReset : // Numpad * = reset font-size
				body.style.fontSize = '';
				break;

			case pl.keys.undo : // backspace
				pl.undo();
				break;

			case pl.keys.abort : // Esc
				pl.abort();
				break;

		}
	},

	// drag code adapted from http://jsfiddle.net/tovic/Xcb8d/light/
	dragInit : function() {
		var drag = pl.drag;
		pl.addClass( document.querySelector( '.' + pl.css.drag ), pl.css.dragActive );
		drag.el = document.querySelector( '.' + pl.css.wrap );
		drag.elm[0] = drag.pos[0] - drag.el.offsetLeft;
		drag.elm[1] = drag.pos[1] - drag.el.offsetTop;
		// prevent selecting content while dragging
		pl.toggleSelection( true );

	},

	docMouseMove : function( event ) {
		var drag = pl.drag;
		drag.pos[0] = document.all ? window.event.clientX : event.pageX;
		drag.pos[1] = document.all ? window.event.clientY : event.pageY;
		if ( pl.drag.el !== null ) {
			drag.el.style.left = ( drag.pos[0] - drag.elm[0] ) + 'px';
			drag.el.style.top  = ( drag.pos[1] - drag.elm[1] ) + 'px';
		}
	},

	docMouseUp : function() {
		pl.drag.el = null;
		pl.removeClass( document.querySelector( '.' + pl.css.drag ), pl.css.dragActive );
		pl.toggleSelection();
	},

	stopSelection : function() {
		return false;
	},

	clearSelection : function() {
		// remove text selection - http://stackoverflow.com/a/3171348/145346
		var sel = window.getSelection ? window.getSelection() : document.selection;
		if ( sel ) {
			if ( sel.removeAllRanges ) {
				sel.removeAllRanges();
			} else if ( sel.empty ) {
				sel.empty();
			}
		}
	},

	toggleSelection : function( disable ) {
		var body = document.querySelector( 'body' );
		if ( disable ) {
			// save current "unselectable" value
			pl.savedUnsel = body.getAttribute( 'unselectable' );
			body.setAttribute( 'unselectable', 'on' );
			pl.addClass( body, pl.css.noSelection );
			pl.addEvent( body, 'onselectstart', pl.stopSelection );
		} else {
			if ( pl.savedUnsel ) {
				body.setAttribute( 'unselectable', pl.savedUnsel );
			}
			pl.removeClass( body, pl.css.noSelection );
			pl.removeEvent( body, 'onselectstart', pl.stopSelection );
		}
		// clear any selections
		pl.clearSelection();
	},

	removeGraphics : function() {
		if ( !csstricksPrintliminatorVars.flags.removeGraphics ) {
			var indx, bkgd,
				bkgds = [],
				body = document.querySelector( 'body' ),
				done = body.querySelectorAll( pl.noGraphicsSelectors ),
				items = body.querySelectorAll( '*:not(.' + pl.css.controls + ')' ),
				len = items.length;

			for ( indx = 0; indx < len; indx++ ) {
				bkgd = window.getComputedStyle( items[ indx ] ).getPropertyValue( 'background-image' );
				if ( bkgd && bkgd !== 'none' ) {
					bkgds.push( [ items[ indx ], bkgd ] );
					items[ indx ].style.backgroundImage = 'none';
				}
			}

			pl.removeHighlight();
			pl.hide( done );
			csstricksPrintliminatorVars.flags.removeGraphics = true;

			csstricksPrintliminatorVars.history.push( function() {
				csstricksPrintliminatorVars.flags.removeGraphics = false;
				pl.show( done );
				len = bkgds.length;
				for ( indx = 0; indx < len; indx++ ) {
					bkgds[ indx ][ 0 ].style.backgroundImage = bkgds[ indx ][ 1 ];
				}
			});
		}
	},

	// Add print style
	stylize : function() {
		if ( !csstricksPrintliminatorVars.flags.stylize ) {
			var indx,
				inline = [],
				body = document.querySelector( 'body' ),
				links = document.querySelectorAll( 'link[rel="stylesheet"], style' ),
				visibleElms = document.querySelectorAll( 'body *:not(.' + pl.css.hidden + '):not(.' + pl.css.controls + ')' ),
				len = links.length;

			for ( indx = 0; indx < len; indx++ ) {
				if ( links[ indx ].id !== pl.css.stylesheet ) {
					links[ indx ].disabled = true;
				}
			}

			// cache and remove inline styles
			Array.prototype.filter.call( visibleElms, function( elm ) {
				var style = elm.getAttribute( 'style' );
				if ( style !== null ) {
					elm.removeAttribute( 'style' );
					inline.push({
						el: elm,
						style: style
					});
				}
			});

			pl.addClass( body, pl.css.stylized );
			pl.removeHighlight();
			csstricksPrintliminatorVars.flags.stylize = true;

			csstricksPrintliminatorVars.history.push( function() {
				csstricksPrintliminatorVars.flags.stylize = false;
				pl.removeClass( body, pl.css.stylized );
				var indx,
					len = links.length;
				for ( indx = 0; indx < len; indx++ ) {
					links[ indx ].disabled = false;
				}
				len = inline.length;
				for ( indx = 0; indx < len; indx++ ) {
					inline[ indx ].el.setAttribute( 'style', inline[ indx ].style );
				}
			});
		}
	},

	print : function() {
		pl.removeHighlight();
		window.print();
	},

	// Undo
	undo : function() {
		var last = csstricksPrintliminatorVars.history.pop();
		if ( last ) {
			pl.removeHighlight();
			if ( typeof last !== 'function' ) {
				pl.show( last );
			} else {
				last.call();
			}
		}
	},

	keyboard : function() {
		var wrap = document.querySelector( '.' + pl.css.wrap ),
			iframe = wrap.querySelector( 'iframe.' + pl.css.controls ),
			ibody = iframe.contentWindow.document.body,
			kb = ibody.querySelector( '#' + pl.css.keyboard ),
			button = ibody.querySelector( '.' + pl.css.keyboard ),
			disply = kb.style.display,
			makeVisible = disply === 'none';
		button.innerHTML = makeVisible ? 'Hide Keyboard Commands' : 'View Keyboard Commands';
		kb.style.display = makeVisible ? '' : 'none';
		wrap.style.height = ( makeVisible ? pl.keyboardOpen : pl.keyboardClosed ) + 5 + 'px';
		// iframe needs to be a tiny bit taller than the body inside
		iframe.style.height = ( makeVisible ? pl.keyboardOpen : pl.keyboardClosed ) + 5 + 'px';
		ibody.style.height = ( makeVisible ? pl.keyboardOpen : pl.keyboardClosed ) + 20 + 'px';
	},

	abort : function() {
		var body = document.querySelector( 'body' );
		pl.removeHighlight();
		pl.removeEvent( body, 'click', pl.bodyClick );
		pl.removeEvent( body, 'mouseover', pl.bodyMouseover );
		pl.removeEvent( body, 'mouseout', pl.removeHighlight );
		pl.removeEvent( document,'keyup', pl.bodyKeyUp );
		pl.removeEvent( document, 'keydown', pl.bodyKeyDown );
		// drag
		pl.removeEvent( document, 'mouseup', pl.docMouseUp );
		pl.removeEvent( document, 'mousemove', pl.docMouseMove );

		body.removeChild( document.querySelector( '.' + pl.css.wrap ) );

	},

	filterElements : function( elm ) {
		return elm &&
			// element node
			elm.nodeType === 1 &&
			// not an ignored element
			!pl.ignoredElm.test( elm.nodeName ) &&
			// not controls
			!pl.hasClass( elm, pl.css.controls ) &&
			// not hidden
			!( pl.hasClass( elm, pl.css.hidden ) || elm.style.display === 'none' );
	},

	getOpposite : function( el ) {
		var sibs,
			done = [];
		// method: start from highlighted element
		// get siblings & hide them; then go to parent, get siblings & hide them...
		// rinse & repeat until we hit the body element
		while ( el.nodeName !== 'BODY' ) {
			sibs = pl.getSiblings( el );
			done = done.concat( sibs );
			el = el.parentNode;
		}
		return done;
	},

	// modified from
	// https://plainjs.com/javascript/traversing/get-siblings-of-an-element-40/
	getSiblings : function ( el ) {
		var siblings = [],
			sibling = el.parentNode.firstChild;
		for ( ; sibling; sibling = sibling.nextSibling ) {
			if ( sibling !== el && pl.filterElements( sibling ) ) {
				siblings.push( sibling );
			}
		}
		return siblings;
	},

	// modified from
	// https://plainjs.com/javascript/traversing/get-siblings-of-an-element-40/
	getNext : function ( el ) {
		while ( el = el.nextSibling ) { // jshint ignore:line
			if ( el && pl.filterElements( el ) ) {
				return el;
			}
		}
		return null;
	},

	// modified from
	// https://plainjs.com/javascript/traversing/get-siblings-of-an-element-40/
	getPrev : function( el ) {
		while ( el = el.previousSibling ) { // jshint ignore:line
			if ( el && pl.filterElements( el ) ) {
				return el;
			}
		}
		return null;
	},

	hide : function ( els ) {
		if ( els ) {
			var indx,
				len = els.length;
			// single elements have undefined length
			if ( typeof len !== 'undefined' ) {
				for ( indx = 0; indx < len; indx++ ) {
					pl.addClass( els[ indx ], pl.css.hidden );
				}
			} else {
				pl.addClass( els, pl.css.hidden );
			}
		}
	},

	show : function ( els ) {
		if ( els ) {
			var indx,
				len = els.length;
			if ( typeof len !== 'undefined' ) {
				for ( indx = 0; indx < len; indx++ ) {
					pl.removeClass( els[ indx ], pl.css.hidden );
				}
			} else {
				pl.removeClass( els, pl.css.hidden );
			}
		}
	},

	addClass : function( el, name ) {
		if ( el.classList ) {
			el.classList.add( name );
		} else if ( !pl.hasClass( el, name ) ) {
			el.className += ' ' + name;
		}
	},

	removeClass : function( el, name ) {
		if ( el.classList ) {
			el.classList.remove( name );
		} else {
			el.className = el.className.replace( new RegExp( '\\b' + name + '\\b', 'g' ), '' );
		}
	},

	hasClass : function( el, name ) {
		return el.classList ?
			el.classList.contains( name ) :
			new RegExp( '\\b' + name + '\\b' ).test( el.className );
	},

	addEvent : function( el, type, handler ) {
		if ( el.attachEvent ) {
			el.attachEvent( 'on' + type, handler );
		} else {
			el.addEventListener( type, handler );
		}
	},

	removeEvent : function( el, type, handler ) {
		if ( el.detachEvent ) {
			el.detachEvent( 'on' + type, handler );
		} else {
			el.removeEventListener( type, handler );
		}
	}

};

window.csstricksPrintliminator = function() {
	pl.init();
};

})();