Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0fae11

Browse files
authored
Merge pull request gridstack#1917 from adumesny/gh-pages
web v5.0.0
2 parents c66d929 + b34c9cc commit e0fae11

14 files changed

+176
-52
lines changed

demo/index.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,29 @@
77
<body>
88
<h1>Demos</h1>
99
<ul>
10-
<li><a href="anijs.html">AniJS</a></li>
11-
<li><a href="angular.ts">Angular (simple)</a></li>
1210
<li><a href="angular-ngFor.ts">Angular (ngFor partial)</a></li>
11+
<li><a href="angular.ts">Angular (simple)</a></li>
12+
<li><a href="anijs.html">AniJS</a></li>
1313
<li><a href="cell-height.html">Cell Height</a></li>
1414
<li><a href="column.html">Column</a></li>
1515
<li><a href="float.html">Float grid</a></li>
1616
<li><a href="knockout.html">Knockout.js</a></li>
17+
<li><a href="mobile.html">Mobile touch (JQ)</a></li>
1718
<li><a href="nested.html">Nested grids</a></li>
18-
<li><a href="responsive.html">Responsive</a></li>
19-
<li><a href="react.html">ReactJS</a></li>
19+
<li><a href="nested_advanced.html">Nested Advanced grids</a></li>
2020
<li><a href="react-hooks.html">ReactJS (Hooks)</a></li>
21+
<li><a href="react.html">ReactJS</a></li>
22+
<li><a href="responsive.html">Responsive</a></li>
2123
<li><a href="right-to-left(rtl).html">Right-To-Left (RTL)</a></li>
2224
<li><a href="serialization.html">Serialization</a></li>
2325
<li><a href="static.html">Static</a></li>
2426
<li><a href="two.html">Two grids</a></li>
2527
<li><a href="two_vertical.html">Two grids Vertical</a></li>
26-
<li><a href="mobile.html">Mobile touch (JQ)</a></li>
27-
<li><a href="vue3js.html">Vue3.js</a></li>
2828
<li><a href="vue2js.html">Vue2.js</a></li>
29+
<li><a href="vue3js.html">Vue3.js</a></li>
30+
<li><a href="web-comp.html">Web Component</a></li>
2931
<li><a href="web1.html">Website demo 1</a></li>
3032
<li><a href="web2.html">Website demo 2</a></li>
31-
<li><a href="web-comp.html">Web Component</a></li>
3233
</ul>
3334
</body>
3435
</html>

demo/nested.html

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,34 @@
99
<link rel="stylesheet" href="../node_modules/gridstack/dist/gridstack-extra.min.css"/>
1010
<script src="../node_modules/gridstack/dist/gridstack-h5.js"></script>
1111
<style type="text/css">
12-
.grid-stack .grid-stack {
13-
background: rgba(255, 255, 255, 0.3);
12+
/* make nested grids have slightly darker bg */
13+
.grid-stack.grid-stack-nested {
14+
background: #e4e4c1;
1415
}
15-
.grid-stack .grid-stack .grid-stack-item-content {
16-
background: lightpink;
16+
/* make nested grid take almost all space (need some to tell them apart) so items inside can have similar to external size+margin */
17+
.grid-stack > .grid-stack-item.grid-stack-nested > .grid-stack-item-content {
18+
/* inset: 0 2px; not IE */
19+
top: 0;
20+
bottom: 0;
21+
left: 2px;
22+
right: 2px;
23+
}
24+
/* make nested grid take entire item content */
25+
.grid-stack-item-content .grid-stack {
26+
min-height: 100%;
27+
min-width: 100%;
1728
}
1829
</style>
1930
</head>
2031
<body>
2132
<div class="container-fluid">
2233
<h1>Nested grids demo</h1>
23-
<p>This example uses new v3.1 API to load the entire nested grid from JSON, and shows dragging between nested grid items (pink) vs dragging higher grid items (green)</p>
24-
<p>Note: HTML5 release doesn't yet support 'dragOut:false' constrain so use JQ version if you need that.</p>
34+
<p>This example shows v5.x dragging between nested grids (dark yellow) and parent grid (bright yellow.)<br>
35+
Uses v3.1 API to load the entire nested grid from JSON.<br>
36+
Nested grids uses new <b>column:'auto'</b> to keep items same size during resize.</p>
2537
<a class="btn btn-primary" onClick="addNested()" href="#">Add Widget</a>
26-
<a class="btn btn-primary" onClick="addNewWidget('.nested1')" href="#">Add Widget Grid1</a>
27-
<a class="btn btn-primary" onClick="addNewWidget('.nested2')" href="#">Add Widget Grid2</a>
38+
<a class="btn btn-primary" onClick="addNewWidget('.sub1')" href="#">Add Widget Grid1</a>
39+
<a class="btn btn-primary" onClick="addNewWidget('.sub2')" href="#">Add Widget Grid2</a>
2840
<span>entire save/re-create:</span>
2941
<a class="btn btn-primary" onClick="save()" href="#">Save</a>
3042
<a class="btn btn-primary" onClick="destroy()" href="#">Destroy</a>
@@ -44,24 +56,29 @@ <h1>Nested grids demo</h1>
4456
let count = 0;
4557
[...sub1, ...sub2].forEach(d => d.content = String(count++));
4658
let subOptions = {
47-
cellHeight: 30,
48-
column: 4, // make sure to include gridstack-extra.min.css
49-
itemClass: 'sub', // style sub items differently and use to prevent dragging in/out
50-
acceptWidgets: '.grid-stack-item.sub', // only pink sub items can be inserted, otherwise grid-items causes all sort of issues
51-
minWidth: 300, // min to go 1 column mode
52-
margin: 1
59+
cellHeight: 50, // should be 50 - top/bottom
60+
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
61+
acceptWidgets: true, // will accept .grid-stack-item by default
62+
margin: 5,
63+
};
64+
let options = { // main grid options
65+
cellHeight: 50,
66+
margin: 5,
67+
minRow: 2, // don't collapse when empty
68+
acceptWidgets: true,
69+
id: 'main',
70+
children: [
71+
{y:0, content: 'regular item'},
72+
{x:1, w:4, h:4, subGrid: {children: sub1, dragOut: true, class: 'sub1', ...subOptions}},
73+
{x:5, w:3, h:4, subGrid: {children: sub2, class: 'sub2', ...subOptions}},
74+
]
5375
};
54-
let json = {cellHeight: 70, minRow: 2, children: [
55-
{y:0, content: 'regular item'},
56-
{x:1, w:4, h:4, content: 'nested 1 - can drag items out', subGrid: {children: sub1, dragOut: true, class: 'nested1', ...subOptions}},
57-
{x:5, w:4, h:4, content: 'nested 2 - constrained to parent (default)', subGrid: {children: sub2, class: 'nested2', ...subOptions}},
58-
]};
5976

6077
// create and load it all from JSON above
61-
let grid = GridStack.addGrid(document.querySelector('.container-fluid'), json);
78+
let grid = GridStack.addGrid(document.querySelector('.container-fluid'), options);
6279

6380
addNested = function() {
64-
grid.addWidget({x:0, y:0, w:3, h:3, content:"nested add", subGrid: {children: sub1, dragOut: true, class: 'nested1', ...subOptions}});
81+
grid.addWidget({x:0, y:100, content:"new item"});
6582
}
6683

6784
addNewWidget = function(selector) {
@@ -78,9 +95,9 @@ <h1>Nested grids demo</h1>
7895
};
7996

8097
save = function(content = true, full = true) {
81-
json = grid.save(content, full);
82-
console.log(json);
83-
// console.log(JSON.stringify(json));
98+
options = grid.save(content, full);
99+
console.log(options);
100+
// console.log(JSON.stringify(options));
84101
}
85102
destroy = function(full = true) {
86103
if (full) {
@@ -92,9 +109,9 @@ <h1>Nested grids demo</h1>
92109
}
93110
load = function(full = true) {
94111
if (full) {
95-
grid = GridStack.addGrid(document.querySelector('.container-fluid'), json);
112+
grid = GridStack.addGrid(document.querySelector('.container-fluid'), options);
96113
} else {
97-
grid.load(json);
114+
grid.load(options);
98115
}
99116
}
100117

demo/nested_advanced.html

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Nested grids demo (ES6)</title>
8+
<link rel="stylesheet" href="demo.css"/>
9+
<link rel="stylesheet" href="../node_modules/gridstack/dist/gridstack-extra.min.css"/>
10+
<script src="../node_modules/gridstack/dist/gridstack-h5.js"></script>
11+
<style type="text/css">
12+
.grid-stack.grid-stack-nested {
13+
background: rgba(255, 255, 255, 0.3);
14+
}
15+
.grid-stack-item.sub .grid-stack-item-content {
16+
background: lightpink;
17+
}
18+
</style>
19+
</head>
20+
<body>
21+
<div class="container-fluid">
22+
<h1>Advanced Nested grids demo</h1>
23+
<p>This example shows sub-grids only accepting pink items, while parent accept all.</p>
24+
<a class="btn btn-primary" onClick="addNested()" href="#">Add Widget</a>
25+
<a class="btn btn-primary" onClick="addNewWidget('.sub1')" href="#">Add Widget Grid1</a>
26+
<a class="btn btn-primary" onClick="addNewWidget('.sub2')" href="#">Add Widget Grid2</a>
27+
<span>entire save/re-create:</span>
28+
<a class="btn btn-primary" onClick="save()" href="#">Save</a>
29+
<a class="btn btn-primary" onClick="destroy()" href="#">Destroy</a>
30+
<a class="btn btn-primary" onClick="load()" href="#">Create</a>
31+
<span>partial save/load:</span>
32+
<a class="btn btn-primary" onClick="save(true, false)" href="#">Save list</a>
33+
<a class="btn btn-primary" onClick="save(false, false)" href="#">Save no content</a>
34+
<a class="btn btn-primary" onClick="destroy(false)" href="#">Clear</a>
35+
<a class="btn btn-primary" onClick="load(false)" href="#">Load</a>
36+
<br><br>
37+
<!-- grid will be added here -->
38+
</div>
39+
40+
<script type="text/javascript">
41+
let sub1 = [ {x:0, y:0}, {x:1, y:0}, {x:2, y:0}, {x:3, y:0}, {x:0, y:1}, {x:1, y:1}];
42+
let sub2 = [ {x:0, y:0}, {x:0, y:1, w:2}];
43+
let count = 0;
44+
[...sub1, ...sub2].forEach(d => d.content = String(count++));
45+
let subOptions = {
46+
cellHeight: 50,
47+
column: 'auto', // size to match container. make sure to include gridstack-extra.min.css
48+
itemClass: 'sub', // style sub items differently and use to prevent dragging in/out
49+
acceptWidgets: '.grid-stack-item.sub', // only pink sub items can be inserted
50+
margin: 2,
51+
minRow: 1, // don't collapse when empty
52+
};
53+
let options = { // main grid options
54+
cellHeight: 50,
55+
margin: 5,
56+
minRow: 2, // don't collapse when empty
57+
acceptWidgets: true,
58+
id: 'main',
59+
children: [
60+
{y:0, content: 'regular item'},
61+
{x:1, w:4, h:4, content: 'nested 1 - can drag items out', subGrid: {children: sub1, dragOut: true, class: 'sub1', ...subOptions}},
62+
{x:5, w:4, h:4, content: 'nested 2 - constrained to parent (JQ only)', subGrid: {children: sub2, class: 'sub2', ...subOptions}},
63+
]
64+
};
65+
66+
// create and load it all from JSON above
67+
let grid = GridStack.addGrid(document.querySelector('.container-fluid'), options);
68+
69+
addNested = function() {
70+
grid.addWidget({x:0, y:100, content:"new item"});
71+
}
72+
73+
addNewWidget = function(selector) {
74+
let subGrid = document.querySelector(selector).gridstack;
75+
let node = {
76+
x: Math.round(6 * Math.random()),
77+
y: Math.round(5 * Math.random()),
78+
w: Math.round(1 + 1 * Math.random()),
79+
h: Math.round(1 + 1 * Math.random()),
80+
content: String(count++)
81+
};
82+
subGrid.addWidget(node);
83+
return false;
84+
};
85+
86+
save = function(content = true, full = true) {
87+
options = grid.save(content, full);
88+
console.log(options);
89+
// console.log(JSON.stringify(options));
90+
}
91+
destroy = function(full = true) {
92+
if (full) {
93+
grid.destroy();
94+
grid = undefined;
95+
} else {
96+
grid.removeAll();
97+
}
98+
}
99+
load = function(full = true) {
100+
if (full) {
101+
grid = GridStack.addGrid(document.querySelector('.container-fluid'), options);
102+
} else {
103+
grid.load(options);
104+
}
105+
}
106+
107+
</script>
108+
</body>
109+
</html>

node_modules/gridstack/dist/es5/gridstack-jq.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/es5/gridstack-jq.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/es5/gridstack-poly.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/gridstack-h5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/gridstack-h5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/gridstack-jq.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/gridstack-jq.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/gridstack/dist/gridstack.css

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)