gridstack.js issue base
Use this as a base for examples for gridstack.js issues.
by Alain Dumesny
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.3.0/gridstack.css">
<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.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.3.0/gridstack.jQueryUI.js"></script>
<div class="grid-stack">
<div class="grid-stack-item upper"
data-gs-width="2" data-gs-height="2">
<div class="grid-stack-item-content">item 1</div>
</div>
<div class="grid-stack-item"
data-gs-width="2" data-gs-height="2">
<div class="grid-stack-item-content">item 2</div>
</div>
</div>
CSS
.grid-stack {
margin-top:10px;
background: lightgoldenrodyellow;
}
.grid-stack-item-content {
color: #2c3e50;
text-align: center;
background-color: #18bc9c;
}
.upper .grid-stack-item-content {
background: blue;
}
JavaScript
/**
* gridstack.js 1.0.0-dev
* http://troolee.github.io/gridstack.js/
* (c) 2014-2018 Pavel Reznikov, Dylan Weiss
* gridstack.js may be freely distributed under the MIT license.
* @preserve
*/
(function(factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery', 'exports'], factory);
} else if (typeof exports !== 'undefined') {
var jQueryModule;
try { jQueryModule = require('jquery'); } catch (e) {}
factory(jQueryModule || window.jQuery, exports);
} else {
factory(window.jQuery, window);
}
})(function($, scope) {
var obsolete = function(f, oldName, newName) {
var wrapper = function() {
console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' +
'with `' + newName + '`. It will be **completely** removed in v1.0.');
return f.apply(this, arguments);
};
wrapper.prototype = f.prototype;
return wrapper;
};
var obsoleteOpts = function(oldName, newName) {
console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' +
newName + '`. It will be **completely** removed in v1.0.');
};
var Utils = {
isIntercepted: function(a, b) {
return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);
},
sort: function(nodes, dir, width) {
if (!width) {
var widths = nodes.map(function(node) { return node.x + node.width; });
width = Math.max.apply(Math, widths);
}
dir = dir != -1 ? 1 : -1;
return Utils.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); });
},
createStylesheet: function(id) {
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
...