-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
web2.html
95 lines (84 loc) · 3.21 KB
/
web2.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
<!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>Advanced grid demo</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="demo.css" />
<script type="module" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule="" src="https://unpkg.com/ionicons@4.5.10-0/dist/ionicons/ionicons.js"></script>
<!-- support for IE -->
<script src="../dist/es5/gridstack-poly.js"></script>
<script src="../dist/es5/gridstack-all.js"></script>
<style type="text/css">
.grid-stack-item-removing {
opacity: 0.8;
filter: blur(5px);
}
.sidepanel-item {
background-color: #18bc9c;
text-align: center;
padding: 5px;
margin-bottom: 15px;
}
#trash {
background-color: rgba(255, 0, 0, 0.4);
}
ion-icon {
font-size: 300%;
}
</style>
</head>
<body>
<h1>Advanced Demo</h1>
<div class="row">
<div class="sidepanel col-md-2 d-none d-md-block">
<div id="trash" class="sidepanel-item">
<ion-icon name="trash"></ion-icon>
<div>Drop here to remove!</div>
</div>
<div class="grid-stack-item sidepanel-item">
<ion-icon name="add-circle"></ion-icon>
<div>Drag me in the dashboard!</div>
</div>
</div>
<div class="col-sm-12 col-md-10">
<div class="grid-stack"></div>
</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 children = [
{x: 0, y: 0, w: 4, h: 2, content: '1'},
{x: 4, y: 0, w: 4, h: 4, locked: true, content: 'I can\'t be moved or dragged, nor pushed by others!<br><ion-icon name="ios-lock"></ion-icon>'},
{x: 8, y: 0, w: 2, h: 2, minW: 2, noResize: true, content: '<p class="card-text text-center" style="margin-bottom: 0">Drag me!<p class="card-text text-center"style="margin-bottom: 0"><ion-icon name="hand"></ion-icon><p class="card-text text-center" style="margin-bottom: 0">...but don\'t resize me!'},
{x: 10, y: 0, w: 2, h: 2, content: '4'},
{x: 0, y: 2, w: 2, h: 2, content: '5'},
{x: 2, y: 2, w: 2, h: 4, content: '6'},
{x: 8, y: 2, w: 4, h: 2, content: '7'},
{x: 0, y: 4, w: 2, h: 2, content: '8'},
{x: 4, y: 4, w: 4, h: 2, content: '9'},
{x: 8, y: 4, w: 2, h: 2, content: '10'},
{x: 10, y: 4, w: 2, h: 2, content: '11'},
];
let insert = [ {h: 2, content: 'new item'}];
let grid = GridStack.init({
cellHeight: 70,
acceptWidgets: true,
removable: '#trash', // drag-out delete class
children
});
GridStack.setupDragIn('.sidepanel>.grid-stack-item', undefined, insert);
grid.on('added removed change', function(e, items) {
let str = '';
items.forEach(function(item) { str += ' (x,y)=' + item.x + ',' + item.y; });
console.log(e.type + ' ' + items.length + ' items:' + str );
});
</script>
</body>
</html>