2015-03-13 03:55:13 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<!--[if lt IE 9]>
|
|
|
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
|
|
|
<![endif]-->
|
|
|
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Float grid demo</title>
|
|
|
|
|
2016-08-12 03:21:00 +02:00
|
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
2015-03-21 06:13:24 +01:00
|
|
|
<link rel="stylesheet" href="../dist/gridstack.css"/>
|
2015-03-13 03:55:13 +01:00
|
|
|
|
2016-08-12 03:21:00 +02:00
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
|
|
|
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
|
2015-03-21 06:13:24 +01:00
|
|
|
<script src="../dist/gridstack.js"></script>
|
2015-03-13 03:55:13 +01:00
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
.grid-stack {
|
|
|
|
background: lightgoldenrodyellow;
|
|
|
|
}
|
|
|
|
|
|
|
|
.grid-stack-item-content {
|
|
|
|
color: #2c3e50;
|
|
|
|
text-align: center;
|
|
|
|
background-color: #18bc9c;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container-fluid">
|
|
|
|
<h1>Float grid demo</h1>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<a class="btn btn-default" id="add-new-widget" href="#">Add Widget</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<div class="grid-stack">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function () {
|
|
|
|
var options = {
|
|
|
|
float: true
|
|
|
|
};
|
|
|
|
$('.grid-stack').gridstack(options);
|
|
|
|
|
|
|
|
new function () {
|
|
|
|
this.items = [
|
|
|
|
{x: 0, y: 0, width: 2, height: 2},
|
|
|
|
{x: 3, y: 1, width: 1, height: 2},
|
|
|
|
{x: 4, y: 1, width: 1, height: 1},
|
|
|
|
{x: 2, y: 3, width: 3, height: 1},
|
|
|
|
// {x: 1, y: 4, width: 1, height: 1},
|
|
|
|
// {x: 1, y: 3, width: 1, height: 1},
|
|
|
|
// {x: 2, y: 4, width: 1, height: 1},
|
|
|
|
{x: 2, y: 5, width: 1, height: 1}
|
|
|
|
];
|
|
|
|
|
|
|
|
this.grid = $('.grid-stack').data('gridstack');
|
|
|
|
|
2016-02-18 03:48:03 +01:00
|
|
|
this.addNewWidget = function () {
|
2015-03-13 03:55:13 +01:00
|
|
|
var node = this.items.pop() || {
|
|
|
|
x: 12 * Math.random(),
|
|
|
|
y: 5 * Math.random(),
|
|
|
|
width: 1 + 3 * Math.random(),
|
|
|
|
height: 1 + 3 * Math.random()
|
|
|
|
};
|
2016-02-18 03:48:03 +01:00
|
|
|
this.grid.addWidget($('<div><div class="grid-stack-item-content" /><div/>'),
|
2015-03-13 03:55:13 +01:00
|
|
|
node.x, node.y, node.width, node.height);
|
2016-02-18 03:48:03 +01:00
|
|
|
return false;
|
2015-03-13 03:55:13 +01:00
|
|
|
}.bind(this);
|
|
|
|
|
2016-02-18 03:48:03 +01:00
|
|
|
$('#add-new-widget').click(this.addNewWidget);
|
2015-03-13 03:55:13 +01:00
|
|
|
};
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|