/
preview-plus-printing.html
195 lines (157 loc) · 4.42 KB
/
preview-plus-printing.html
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
<!DOCTYPE html>
<html>
<head>
<title>jQuery Print-in-Page demo: Preview & Printing</title>
<style>
html, body, h1, p, div
{
font-size: 16px;
line-height: 22px;
margin: 0;
padding: 0;
}
ul
{
font-size: 16px;
line-height: 22px;
}
h1
{
font-size: 18px;
line-height: 22px;
margin: 0;
padding: 0;
}
p
{
font-size: 12px;
line-height: 16px;
margin: 0;
padding: 0;
}
div
{
padding: 0 6px;
margin: 3px;
border: 1px solid #888;
}
body
{
padding: 6px;
}
div.content-A
{
background-color: #fee;
}
div.content-B
{
background-color: #eee;
}
div.content-C
{
background-color: #eef;
}
div.content-D
{
background-color: #efe;
}
.print-buttons, .previewPanel
{
background-color: #ffe;
border: 2px solid grey;
padding: 1em 2em;
text-align: center;
margin-top: 2em;
}
.print-buttons button, .previewPanel button
{
min-width: 20em;
margin: 0 2em;
}
.previewPanel p
{
font-size: 14px;
font-style: italic;
margin-bottom: 1em;
}
/* using styles to hide/show printing content */
.pip-do-not-print
{
display: none !important;
}
.pip-print
{
}
.pip-print-parent
{
}
.pip-print-root
{
padding: 1em;
border: 6px solid red;
margin: 1em;
}
/* this bit of the DOM stays hidden until the preview need it: */
.previewPanel
{
display: none;
}
</style>
</head>
<body>
<div class="content-A">
<h1>content A</h1>
<p>Bla bla bla</p>
</div>
<div class="content-B">
<h1>content B</h1>
<p>Bla bla bla</p>
<div class="content-C">
<h1>content C inside B</h1>
<p>Bla bla bla</p>
</div>
<div class="content-D">
<h1>content D inside B</h1>
<p>Bla bla bla</p>
</div>
</div>
<div class="content-A">
<h1>more content A</h1>
<p>Bla bla bla</p>
</div>
<div class="content-A">
<h1>even more content A</h1>
<p>Bla bla bla</p>
</div>
<div class="content-B">
<h1>more content B</h1>
<p>Bla bla bla</p>
<div class="content-C">
<h1>more content C inside B</h1>
<p>Bla bla bla</p>
</div>
<div class="content-D">
<h1>more content D inside B</h1>
<p>Bla bla bla</p>
</div>
</div>
<div class="print-buttons">
<div style="margin-bottom: 1em; text-align: left; border: 0; background-color: #eed;">
<input name="only-div-nodes" id="only-div-nodes" type="checkbox" />
<label for="only-div-nodes">Only edit <code>DIV</code> nodes in the DOM <em>(watch the effect on the 'B' content being included in the printed result or not... this being due to the <code>P</code> and <code>H1</code> DOM nodes being hidden as siblings of the 'C' & 'D' <code>DIV</code>s.)</em></label>
</div>
<button class="click-to-print print-area-A">Click to Print 'A' sections only</button>
<button class="click-to-print print-area-C">Click to Print 'C' sections only (nested inside 'B' sections...)</button>
<button class="click-to-print print-area-C print-area-B" title="HINT: this will result in each entire 'B' chunk being printed; the print-in-page plugin does not mind you effectively specified the C sections _twice_">Click to Print 'C' plus 'B' sections == all 'B' sections</button>
<button class="click-to-print print-area-A print-area-D">Click to Print 'A' + 'D' sections</button>
</div>
<div class="previewPanel">
<hr />
<p>Now that you see this preview above, are you sure you want to print this stuff? Hit the <code>YES</code> button if you want to, otherwise click on the <code>NO/ABORT</code> button when you wish to abort the print action now.</p>
<button id="preview-okay">YES</button>
<button id="preview-abort">NO / ABORT</button>
</div>
<!-- Check the console -->
<script data-main="../scripts/main" src="../libs/require.js"></script>
</body>
</html>