-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathprint.html
More file actions
70 lines (64 loc) · 2.25 KB
/
Copy pathprint.html
File metadata and controls
70 lines (64 loc) · 2.25 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Print Grid Demo (Default Flow Mode)</title>
<link rel="stylesheet" href="demo.css"/>
<script src="../dist/gridstack-all.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>Print Grid Demo</h1>
<p>
Default v13.1+ Print Behavior (Flow Mode), 6 column. Notice how large items span across multiple printed pages automatically without being sliced.<br/>
<strong>Drawback:</strong> Cannot force exact layout, and manual page breaks/orientations may not work well.
</p>
<div class="gs-print-hide">
<a class="btn btn-primary" onClick="window.print()" href="#">Print Page</a>
<label style="margin-left: 15px;">
<input type="checkbox" id="printModeToggle" onchange="togglePrintMode()"> Exact Print Mode
</label>
</div>
<br><br>
<div class="grid-stack" id="grid2"></div>
</div>
<script type="text/javascript">
// NOTE: REAL apps would sanitize-html or DOMPurify before blinding setting innerHTML. see #2736
GridStack.renderCB = function(el, w) {
el.innerHTML = w.content;
};
let options = {
float: true,
cellHeight: 100,
margin: 10,
};
let grid2 = GridStack.init({...options, column: 6}, '#grid2');
let items2 = [];
for (let i = 0; i < 15; i++) {
let h = Math.round(1 + 3 * Math.random());
if (i === 2 || i === 8) {
h = 14; // Large item to span multiple pages
}
// Calculate a number of lines that roughly fits the height (cellHeight is 100px)
let lines = Math.floor(h * 3.5);
items2.push({
w: Math.round(1 + 3 * Math.random()),
h: h,
content: `Random ${i+1}` + (h > 10 ? '<br>(Spans pages)<br>' : '<br>') + 'Line<br>'.repeat(lines)
});
}
grid2.load(items2);
function togglePrintMode() {
let isExact = document.getElementById('printModeToggle').checked;
let el = document.getElementById('grid2');
if (isExact) {
el.classList.add('gs-print-exact');
} else {
el.classList.remove('gs-print-exact');
}
}
</script>
</body>
</html>