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

Skip to content

Commit c992f3f

Browse files
committed
add floating sample
1 parent bfaa893 commit c992f3f

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

demo/float.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<!--[if lt IE 9]>
5+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
6+
<![endif]-->
7+
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<title>Float grid demo</title>
12+
13+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
14+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css"/>
15+
<link rel="stylesheet" href="../gridstack.css"/>
16+
17+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
18+
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
19+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
20+
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
21+
<script src="../gridstack.js"></script>
22+
23+
<style type="text/css">
24+
.grid-stack {
25+
background: lightgoldenrodyellow;
26+
}
27+
28+
.grid-stack-item-content {
29+
color: #2c3e50;
30+
text-align: center;
31+
background-color: #18bc9c;
32+
}
33+
</style>
34+
</head>
35+
<body>
36+
<div class="container-fluid">
37+
<h1>Float grid demo</h1>
38+
39+
<div>
40+
<a class="btn btn-default" id="add-new-widget" href="#">Add Widget</a>
41+
</div>
42+
43+
<br/>
44+
45+
<div class="grid-stack">
46+
</div>
47+
</div>
48+
49+
50+
<script type="text/javascript">
51+
$(function () {
52+
var options = {
53+
float: true
54+
};
55+
$('.grid-stack').gridstack(options);
56+
57+
new function () {
58+
this.items = [
59+
{x: 0, y: 0, width: 2, height: 2},
60+
{x: 3, y: 1, width: 1, height: 2},
61+
{x: 4, y: 1, width: 1, height: 1},
62+
{x: 2, y: 3, width: 3, height: 1},
63+
// {x: 1, y: 4, width: 1, height: 1},
64+
// {x: 1, y: 3, width: 1, height: 1},
65+
// {x: 2, y: 4, width: 1, height: 1},
66+
{x: 2, y: 5, width: 1, height: 1}
67+
];
68+
69+
this.grid = $('.grid-stack').data('gridstack');
70+
71+
this.add_new_widget = function () {
72+
var node = this.items.pop() || {
73+
x: 12 * Math.random(),
74+
y: 5 * Math.random(),
75+
width: 1 + 3 * Math.random(),
76+
height: 1 + 3 * Math.random()
77+
};
78+
this.grid.add_widget($('<div><div class="grid-stack-item-content" /><div/>'),
79+
node.x, node.y, node.width, node.height);
80+
}.bind(this);
81+
82+
$('#add-new-widget').click(this.add_new_widget);
83+
};
84+
});
85+
</script>
86+
</body>
87+
</html>

0 commit comments

Comments
 (0)