' +
+ '
' + this.opts.placeholderText + '
').hide();
+
+ this._updateContainerHeight();
+
+ this._updateHeightsOnResize = _.throttle(function() {
+ self.cellHeight(self.cellWidth(), false);
+ }, 100);
+
+ this.onResizeHandler = function() {
+ if (isAutoCellHeight) {
+ self._updateHeightsOnResize();
+ }
+
+ if (self._isOneColumnMode() && !self.opts.disableOneColumnMode) {
+ if (oneColumnMode) {
+ return;
+ }
+ self.container.addClass(self.opts.oneColumnModeClass);
+ oneColumnMode = true;
+
+ self.grid._sortNodes();
+ _.each(self.grid.nodes, function(node) {
+ self.container.append(node.el);
+
+ if (self.opts.staticGrid) {
+ return;
+ }
+ self.dd.draggable(node.el, 'disable');
+ self.dd.resizable(node.el, 'disable');
+
+ node.el.trigger('resize');
+ });
+ } else {
+ if (!oneColumnMode) {
+ return;
+ }
+
+ self.container.removeClass(self.opts.oneColumnModeClass);
+ oneColumnMode = false;
+
+ if (self.opts.staticGrid) {
+ return;
+ }
+
+ _.each(self.grid.nodes, function(node) {
+ if (!node.noMove && !self.opts.disableDrag) {
+ self.dd.draggable(node.el, 'enable');
+ }
+ if (!node.noResize && !self.opts.disableResize) {
+ self.dd.resizable(node.el, 'enable');
+ }
+
+ node.el.trigger('resize');
+ });
+ }
+ };
+
+ $(window).resize(this.onResizeHandler);
+ this.onResizeHandler();
+
+ if (!self.opts.staticGrid && typeof self.opts.removable === 'string') {
+ var trashZone = $(self.opts.removable);
+ if (!this.dd.isDroppable(trashZone)) {
+ this.dd.droppable(trashZone, self.opts.removableOptions);
+ }
+ this.dd
+ .on(trashZone, 'dropover', function(event, ui) {
+ var el = $(ui.draggable);
+ var node = el.data('_gridstack_node');
+ if (node._grid !== self) {
+ return;
+ }
+ el.data('inTrashZone', true);
+ self._setupRemovingTimeout(el);
+ })
+ .on(trashZone, 'dropout', function(event, ui) {
+ var el = $(ui.draggable);
+ var node = el.data('_gridstack_node');
+ if (node._grid !== self) {
+ return;
+ }
+ el.data('inTrashZone', false);
+ self._clearRemovingTimeout(el);
+ });
+ }
+
+ if (!self.opts.staticGrid && self.opts.acceptWidgets) {
+ var draggingElement = null;
+
+ var onDrag = function(event, ui) {
+ var el = draggingElement;
+ var node = el.data('_gridstack_node');
+ var pos = self.getCellFromPixel({left: event.pageX, top: event.pageY}, true);
+ var x = Math.max(0, pos.x);
+ var y = Math.max(0, pos.y);
+ if (!node._added) {
+ node._added = true;
+
+ node.el = el;
+ node.autoPosition = true;
+ node.x = x;
+ node.y = y;
+ self.grid.cleanNodes();
+ self.grid.beginUpdate(node);
+ self.grid.addNode(node);
+
+ self.container.append(self.placeholder);
+ self.placeholder
+ .attr('data-gs-x', node.x)
+ .attr('data-gs-y', node.y)
+ .attr('data-gs-width', node.width)
+ .attr('data-gs-height', node.height)
+ .show();
+ node.el = self.placeholder;
+ node._beforeDragX = node.x;
+ node._beforeDragY = node.y;
+
+ self._updateContainerHeight();
+ }
+ if (!self.grid.canMoveNode(node, x, y)) {
+ return;
+ }
+ self.grid.moveNode(node, x, y);
+ self._updateContainerHeight();
+ };
+
+ this.dd
+ .droppable(self.container, {
+ accept: function(el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (node && node._grid === self) {
+ return false;
+ }
+ return el.is(self.opts.acceptWidgets === true ? '.grid-stack-item' : self.opts.acceptWidgets);
+ }
+ })
+ .on(self.container, 'dropover', function(event, ui) {
+ var offset = self.container.offset();
+ var el = $(ui.draggable);
+ var cellWidth = self.cellWidth();
+ var cellHeight = self.cellHeight();
+ var origNode = el.data('_gridstack_node');
+
+ var width = origNode ? origNode.width : (Math.ceil(el.outerWidth() / cellWidth));
+ var height = origNode ? origNode.height : (Math.ceil(el.outerHeight() / cellHeight));
+
+ draggingElement = el;
+
+ var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true});
+ el.data('_gridstack_node', node);
+ el.data('_gridstack_node_orig', origNode);
+
+ el.on('drag', onDrag);
+ })
+ .on(self.container, 'dropout', function(event, ui) {
+ var el = $(ui.draggable);
+ if (!el.data('_gridstack_node')) {
+ return;
+ }
+ el.unbind('drag', onDrag);
+ var node = el.data('_gridstack_node');
+ node.el = null;
+ self.grid.removeNode(node);
+ self.placeholder.detach();
+ self._updateContainerHeight();
+ el.data('_gridstack_node', el.data('_gridstack_node_orig'));
+ })
+ .on(self.container, 'drop', function(event, ui) {
+ self.placeholder.detach();
+
+ var node = $(ui.draggable).data('_gridstack_node');
+ node._grid = self;
+ var el = $(ui.draggable).clone(false);
+ el.data('_gridstack_node', node);
+ var originalNode = $(ui.draggable).data('_gridstack_node_orig');
+ if (typeof originalNode !== 'undefined' && typeof originalNode._grid !== 'undefined') {
+ originalNode._grid._triggerRemoveEvent();
+ }
+ $(ui.helper).remove();
+ node.el = el;
+ self.placeholder.hide();
+ Utils.removePositioningStyles(el);
+ el.find('div.ui-resizable-handle').remove();
+
+ el
+ .attr('data-gs-x', node.x)
+ .attr('data-gs-y', node.y)
+ .attr('data-gs-width', node.width)
+ .attr('data-gs-height', node.height)
+ .addClass(self.opts.itemClass)
+ .enableSelection()
+ .removeData('draggable')
+ .removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled')
+ .unbind('drag', onDrag);
+ self.container.append(el);
+ self._prepareElementsByNode(el, node);
+ self._updateContainerHeight();
+ self.grid._addedNodes.push(node);
+ self._triggerAddEvent();
+ self._triggerChangeEvent();
+
+ self.grid.endUpdate();
+ $(ui.draggable).unbind('drag', onDrag);
+ $(ui.draggable).removeData('_gridstack_node');
+ $(ui.draggable).removeData('_gridstack_node_orig');
+ });
+ }
+ };
+
+ GridStack.prototype._triggerChangeEvent = function(forceTrigger) {
+ var elements = this.grid.getDirtyNodes();
+ var hasChanges = false;
+
+ var eventParams = [];
+ if (elements && elements.length) {
+ eventParams.push(elements);
+ hasChanges = true;
+ }
+
+ if (hasChanges || forceTrigger === true) {
+ this.container.trigger('change', eventParams);
+ }
+ };
+
+ GridStack.prototype._triggerAddEvent = function() {
+ if (this.grid._addedNodes && this.grid._addedNodes.length > 0) {
+ this.container.trigger('added', [_.map(this.grid._addedNodes, _.clone)]);
+ this.grid._addedNodes = [];
+ }
+ };
+
+ GridStack.prototype._triggerRemoveEvent = function() {
+ if (this.grid._removedNodes && this.grid._removedNodes.length > 0) {
+ this.container.trigger('removed', [_.map(this.grid._removedNodes, _.clone)]);
+ this.grid._removedNodes = [];
+ }
+ };
+
+ GridStack.prototype._initStyles = function() {
+ if (this._stylesId) {
+ Utils.removeStylesheet(this._stylesId);
+ }
+ this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed();
+ this._styles = Utils.createStylesheet(this._stylesId);
+ if (this._styles !== null) {
+ this._styles._max = 0;
+ }
+ };
+
+ GridStack.prototype._updateStyles = function(maxHeight) {
+ if (this._styles === null || typeof this._styles === 'undefined') {
+ return;
+ }
+
+ var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass;
+ var self = this;
+ var getHeight;
+
+ if (typeof maxHeight == 'undefined') {
+ maxHeight = this._styles._max;
+ }
+ this._initStyles();
+ this._updateContainerHeight();
+ if (!this.opts.cellHeight) { // The rest will be handled by CSS
+ return ;
+ }
+ if (this._styles._max !== 0 && maxHeight <= this._styles._max) { // Keep this._styles._max increasing
+ return ;
+ }
+
+ if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) {
+ getHeight = function(nbRows, nbMargins) {
+ return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
+ self.opts.cellHeightUnit;
+ };
+ } else {
+ getHeight = function(nbRows, nbMargins) {
+ if (!nbRows || !nbMargins) {
+ return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) +
+ self.opts.cellHeightUnit;
+ }
+ return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' +
+ ((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')';
+ };
+ }
+
+ if (this._styles._max === 0) {
+ Utils.insertCSSRule(this._styles, prefix, 'min-height: ' + getHeight(1, 0) + ';', 0);
+ }
+
+ if (maxHeight > this._styles._max) {
+ for (var i = this._styles._max; i < maxHeight; ++i) {
+ Utils.insertCSSRule(this._styles,
+ prefix + '[data-gs-height="' + (i + 1) + '"]',
+ 'height: ' + getHeight(i + 1, i) + ';',
+ i
+ );
+ Utils.insertCSSRule(this._styles,
+ prefix + '[data-gs-min-height="' + (i + 1) + '"]',
+ 'min-height: ' + getHeight(i + 1, i) + ';',
+ i
+ );
+ Utils.insertCSSRule(this._styles,
+ prefix + '[data-gs-max-height="' + (i + 1) + '"]',
+ 'max-height: ' + getHeight(i + 1, i) + ';',
+ i
+ );
+ Utils.insertCSSRule(this._styles,
+ prefix + '[data-gs-y="' + i + '"]',
+ 'top: ' + getHeight(i, i) + ';',
+ i
+ );
+ }
+ this._styles._max = maxHeight;
+ }
+ };
+
+ GridStack.prototype._updateContainerHeight = function() {
+ if (this.grid._updateCounter) {
+ return;
+ }
+ var height = this.grid.getGridHeight();
+ // check for css min height. Each row is cellHeight + verticalMargin, until last one which has no margin below
+ var cssMinHeight = parseInt(this.container.css('min-height'));
+ if (cssMinHeight > 0) {
+ var minHeight = (cssMinHeight + this.opts.verticalMargin) / (this.cellHeight() + this.opts.verticalMargin);
+ if (height < minHeight) {
+ height = minHeight;
+ }
+ }
+ this.container.attr('data-gs-current-height', height);
+ if (!this.opts.cellHeight) {
+ return ;
+ }
+ if (!this.opts.verticalMargin) {
+ this.container.css('height', (height * (this.opts.cellHeight)) + this.opts.cellHeightUnit);
+ } else if (this.opts.cellHeightUnit === this.opts.verticalMarginUnit) {
+ this.container.css('height', (height * (this.opts.cellHeight + this.opts.verticalMargin) -
+ this.opts.verticalMargin) + this.opts.cellHeightUnit);
+ } else {
+ this.container.css('height', 'calc(' + ((height * (this.opts.cellHeight)) + this.opts.cellHeightUnit) +
+ ' + ' + ((height * (this.opts.verticalMargin - 1)) + this.opts.verticalMarginUnit) + ')');
+ }
+ };
+
+ GridStack.prototype._isOneColumnMode = function() {
+ return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <=
+ this.opts.minWidth;
+ };
+
+ GridStack.prototype._setupRemovingTimeout = function(el) {
+ var self = this;
+ var node = $(el).data('_gridstack_node');
+
+ if (node._removeTimeout || !self.opts.removable) {
+ return;
+ }
+ node._removeTimeout = setTimeout(function() {
+ el.addClass('grid-stack-item-removing');
+ node._isAboutToRemove = true;
+ }, self.opts.removeTimeout);
+ };
+
+ GridStack.prototype._clearRemovingTimeout = function(el) {
+ var node = $(el).data('_gridstack_node');
+
+ if (!node._removeTimeout) {
+ return;
+ }
+ clearTimeout(node._removeTimeout);
+ node._removeTimeout = null;
+ el.removeClass('grid-stack-item-removing');
+ node._isAboutToRemove = false;
+ };
+
+ GridStack.prototype._prepareElementsByNode = function(el, node) {
+ var self = this;
+
+ var cellWidth;
+ var cellHeight;
+
+ var dragOrResize = function(event, ui) {
+ var x = Math.round(ui.position.left / cellWidth);
+ var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight);
+ var width;
+ var height;
+
+ if (event.type != 'drag') {
+ width = Math.round(ui.size.width / cellWidth);
+ height = Math.round(ui.size.height / cellHeight);
+ }
+
+ if (event.type == 'drag') {
+ var distance = ui.position.top - node._prevYPix;
+ node._prevYPix = ui.position.top;
+ Utils.updateScrollPosition(el[0], ui, distance);
+ if (el.data('inTrashZone') || x < 0 || x >= self.grid.width || y < 0 ||
+ (!self.grid.float && y > self.grid.getGridHeight())) {
+ if (!node._temporaryRemoved) {
+ if (self.opts.removable === true) {
+ self._setupRemovingTimeout(el);
+ }
+
+ x = node._beforeDragX;
+ y = node._beforeDragY;
+
+ self.placeholder.detach();
+ self.placeholder.hide();
+ self.grid.removeNode(node);
+ self._updateContainerHeight();
+
+ node._temporaryRemoved = true;
+ }
+ } else {
+ self._clearRemovingTimeout(el);
+
+ if (node._temporaryRemoved) {
+ self.grid.addNode(node);
+ self.placeholder
+ .attr('data-gs-x', x)
+ .attr('data-gs-y', y)
+ .attr('data-gs-width', width)
+ .attr('data-gs-height', height)
+ .show();
+ self.container.append(self.placeholder);
+ node.el = self.placeholder;
+ node._temporaryRemoved = false;
+ }
+ }
+ } else if (event.type == 'resize') {
+ if (x < 0) {
+ return;
+ }
+ }
+ // width and height are undefined if not resizing
+ var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth;
+ var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight;
+ if (!self.grid.canMoveNode(node, x, y, width, height) ||
+ (node.lastTriedX === x && node.lastTriedY === y &&
+ node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) {
+ return;
+ }
+ node.lastTriedX = x;
+ node.lastTriedY = y;
+ node.lastTriedWidth = width;
+ node.lastTriedHeight = height;
+ self.grid.moveNode(node, x, y, width, height);
+ self._updateContainerHeight();
+ };
+
+ var onStartMoving = function(event, ui) {
+ self.container.append(self.placeholder);
+ var o = $(this);
+ self.grid.cleanNodes();
+ self.grid.beginUpdate(node);
+ cellWidth = self.cellWidth();
+ var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
+ cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height'));
+ self.placeholder
+ .attr('data-gs-x', o.attr('data-gs-x'))
+ .attr('data-gs-y', o.attr('data-gs-y'))
+ .attr('data-gs-width', o.attr('data-gs-width'))
+ .attr('data-gs-height', o.attr('data-gs-height'))
+ .show();
+ node.el = self.placeholder;
+ node._beforeDragX = node.x;
+ node._beforeDragY = node.y;
+ node._prevYPix = ui.position.top;
+
+ self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1));
+ self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1));
+
+ if (event.type == 'resizestart') {
+ o.find('.grid-stack-item').trigger('resizestart');
+ }
+ };
+
+ var onEndMoving = function(event, ui) {
+ var o = $(this);
+ if (!o.data('_gridstack_node')) {
+ return;
+ }
+
+ var forceNotify = false;
+ self.placeholder.detach();
+ node.el = o;
+ self.placeholder.hide();
+
+ if (node._isAboutToRemove) {
+ forceNotify = true;
+ var gridToNotify = el.data('_gridstack_node')._grid;
+ gridToNotify._triggerRemoveEvent();
+ el.removeData('_gridstack_node');
+ el.remove();
+ } else {
+ self._clearRemovingTimeout(el);
+ if (!node._temporaryRemoved) {
+ Utils.removePositioningStyles(o);
+ o
+ .attr('data-gs-x', node.x)
+ .attr('data-gs-y', node.y)
+ .attr('data-gs-width', node.width)
+ .attr('data-gs-height', node.height);
+ } else {
+ Utils.removePositioningStyles(o);
+ o
+ .attr('data-gs-x', node._beforeDragX)
+ .attr('data-gs-y', node._beforeDragY)
+ .attr('data-gs-width', node.width)
+ .attr('data-gs-height', node.height);
+ node.x = node._beforeDragX;
+ node.y = node._beforeDragY;
+ node._temporaryRemoved = false;
+ self.grid.addNode(node);
+ }
+ }
+ self._updateContainerHeight();
+ self._triggerChangeEvent(forceNotify);
+
+ self.grid.endUpdate();
+
+ var nestedGrids = o.find('.grid-stack');
+ if (nestedGrids.length && event.type == 'resizestop') {
+ nestedGrids.each(function(index, el) {
+ $(el).data('gridstack').onResizeHandler();
+ });
+ o.find('.grid-stack-item').trigger('resizestop');
+ o.find('.grid-stack-item').trigger('gsresizestop');
+ }
+ if (event.type == 'resizestop') {
+ self.container.trigger('gsresizestop', o);
+ }
+ };
+
+ this.dd
+ .draggable(el, {
+ start: onStartMoving,
+ stop: onEndMoving,
+ drag: dragOrResize
+ })
+ .resizable(el, {
+ start: onStartMoving,
+ stop: onEndMoving,
+ resize: dragOrResize
+ });
+
+ if (node.noMove || (this._isOneColumnMode() && !self.opts.disableOneColumnMode) || this.opts.disableDrag ||
+ this.opts.staticGrid) {
+ this.dd.draggable(el, 'disable');
+ }
+
+ if (node.noResize || (this._isOneColumnMode() && !self.opts.disableOneColumnMode) || this.opts.disableResize ||
+ this.opts.staticGrid) {
+ this.dd.resizable(el, 'disable');
+ }
+
+ el.attr('data-gs-locked', node.locked ? 'yes' : null);
+ };
+
+ GridStack.prototype._prepareElement = function(el, triggerAddEvent) {
+ triggerAddEvent = typeof triggerAddEvent != 'undefined' ? triggerAddEvent : false;
+ var self = this;
+ el = $(el);
+
+ el.addClass(this.opts.itemClass);
+ var node = self.grid.addNode({
+ x: parseInt(el.attr('data-gs-x'), 10),
+ y: parseInt(el.attr('data-gs-y'), 10),
+ width: el.attr('data-gs-width'),
+ height: el.attr('data-gs-height'),
+ maxWidth: el.attr('data-gs-max-width'),
+ minWidth: el.attr('data-gs-min-width'),
+ maxHeight: el.attr('data-gs-max-height'),
+ minHeight: el.attr('data-gs-min-height'),
+ autoPosition: Utils.toBool(el.attr('data-gs-auto-position')),
+ noResize: Utils.toBool(el.attr('data-gs-no-resize')),
+ noMove: Utils.toBool(el.attr('data-gs-no-move')),
+ locked: Utils.toBool(el.attr('data-gs-locked')),
+ resizeHandles: el.attr('data-gs-resize-handles'),
+ el: el,
+ id: el.attr('data-gs-id'),
+ _grid: self
+ }, triggerAddEvent);
+ el.data('_gridstack_node', node);
+
+ this._prepareElementsByNode(el, node);
+ };
+
+ GridStack.prototype.setAnimation = function(enable) {
+ if (enable) {
+ this.container.addClass('grid-stack-animate');
+ } else {
+ this.container.removeClass('grid-stack-animate');
+ }
+ };
+
+ GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth,
+ minHeight, maxHeight, id) {
+ el = $(el);
+ if (typeof x != 'undefined') { el.attr('data-gs-x', x); }
+ if (typeof y != 'undefined') { el.attr('data-gs-y', y); }
+ if (typeof width != 'undefined') { el.attr('data-gs-width', width); }
+ if (typeof height != 'undefined') { el.attr('data-gs-height', height); }
+ if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); }
+ if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); }
+ if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); }
+ if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); }
+ if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); }
+ if (typeof id != 'undefined') { el.attr('data-gs-id', id); }
+ this.container.append(el);
+ this._prepareElement(el, true);
+ this._triggerAddEvent();
+ this._updateContainerHeight();
+ this._triggerChangeEvent(true);
+
+ return el;
+ };
+
+ GridStack.prototype.makeWidget = function(el) {
+ el = $(el);
+ this._prepareElement(el, true);
+ this._triggerAddEvent();
+ this._updateContainerHeight();
+ this._triggerChangeEvent(true);
+
+ return el;
+ };
+
+ GridStack.prototype.willItFit = function(x, y, width, height, autoPosition) {
+ var node = {x: x, y: y, width: width, height: height, autoPosition: autoPosition};
+ return this.grid.canBePlacedWithRespectToHeight(node);
+ };
+
+ GridStack.prototype.removeWidget = function(el, detachNode) {
+ detachNode = typeof detachNode === 'undefined' ? true : detachNode;
+ el = $(el);
+ var node = el.data('_gridstack_node');
+
+ // For Meteor support: https://github.com/troolee/gridstack.js/pull/272
+ if (!node) {
+ node = this.grid.getNodeDataByDOMEl(el);
+ }
+
+ this.grid.removeNode(node, detachNode);
+ el.removeData('_gridstack_node');
+ this._updateContainerHeight();
+ if (detachNode) {
+ el.remove();
+ }
+ this._triggerChangeEvent(true);
+ this._triggerRemoveEvent();
+ };
+
+ GridStack.prototype.removeAll = function(detachNode) {
+ _.each(this.grid.nodes, _.bind(function(node) {
+ this.removeWidget(node.el, detachNode);
+ }, this));
+ this.grid.nodes = [];
+ this._updateContainerHeight();
+ };
+
+ GridStack.prototype.destroy = function(detachGrid) {
+ $(window).off('resize', this.onResizeHandler);
+ this.disable();
+ if (typeof detachGrid != 'undefined' && !detachGrid) {
+ this.removeAll(false);
+ this.container.removeData('gridstack');
+ } else {
+ this.container.remove();
+ }
+ Utils.removeStylesheet(this._stylesId);
+ if (this.grid) {
+ this.grid = null;
+ }
+ };
+
+ GridStack.prototype.resizable = function(el, val) {
+ var self = this;
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node === null) {
+ return;
+ }
+
+ node.noResize = !(val || false);
+ if (node.noResize || (self._isOneColumnMode() && !self.opts.disableOneColumnMode)) {
+ self.dd.resizable(el, 'disable');
+ } else {
+ self.dd.resizable(el, 'enable');
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.movable = function(el, val) {
+ var self = this;
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node === null) {
+ return;
+ }
+
+ node.noMove = !(val || false);
+ if (node.noMove || (self._isOneColumnMode() && !self.opts.disableOneColumnMode)) {
+ self.dd.draggable(el, 'disable');
+ el.removeClass('ui-draggable-handle');
+ } else {
+ self.dd.draggable(el, 'enable');
+ el.addClass('ui-draggable-handle');
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.enableMove = function(doEnable, includeNewWidgets) {
+ this.movable(this.container.children('.' + this.opts.itemClass), doEnable);
+ if (includeNewWidgets) {
+ this.opts.disableDrag = !doEnable;
+ }
+ };
+
+ GridStack.prototype.enableResize = function(doEnable, includeNewWidgets) {
+ this.resizable(this.container.children('.' + this.opts.itemClass), doEnable);
+ if (includeNewWidgets) {
+ this.opts.disableResize = !doEnable;
+ }
+ };
+
+ GridStack.prototype.disable = function() {
+ this.movable(this.container.children('.' + this.opts.itemClass), false);
+ this.resizable(this.container.children('.' + this.opts.itemClass), false);
+ this.container.trigger('disable');
+ };
+
+ GridStack.prototype.enable = function() {
+ this.movable(this.container.children('.' + this.opts.itemClass), true);
+ this.resizable(this.container.children('.' + this.opts.itemClass), true);
+ this.container.trigger('enable');
+ };
+
+ GridStack.prototype.locked = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node === null) {
+ return;
+ }
+
+ node.locked = (val || false);
+ el.attr('data-gs-locked', node.locked ? 'yes' : null);
+ });
+ return this;
+ };
+
+ GridStack.prototype.maxHeight = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node === 'undefined' || node === null) {
+ return;
+ }
+
+ if (!isNaN(val)) {
+ node.maxHeight = (val || false);
+ el.attr('data-gs-max-height', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.minHeight = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node === 'undefined' || node === null) {
+ return;
+ }
+
+ if (!isNaN(val)) {
+ node.minHeight = (val || false);
+ el.attr('data-gs-min-height', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.maxWidth = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node === 'undefined' || node === null) {
+ return;
+ }
+
+ if (!isNaN(val)) {
+ node.maxWidth = (val || false);
+ el.attr('data-gs-max-width', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype.minWidth = function(el, val) {
+ el = $(el);
+ el.each(function(index, el) {
+ el = $(el);
+ var node = el.data('_gridstack_node');
+ if (typeof node === 'undefined' || node === null) {
+ return;
+ }
+
+ if (!isNaN(val)) {
+ node.minWidth = (val || false);
+ el.attr('data-gs-min-width', val);
+ }
+ });
+ return this;
+ };
+
+ GridStack.prototype._updateElement = function(el, callback) {
+ el = $(el).first();
+ var node = el.data('_gridstack_node');
+ if (typeof node == 'undefined' || node === null) {
+ return;
+ }
+
+ var self = this;
+
+ self.grid.cleanNodes();
+ self.grid.beginUpdate(node);
+
+ callback.call(this, el, node);
+
+ self._updateContainerHeight();
+ self._triggerChangeEvent();
+
+ self.grid.endUpdate();
+ };
+
+ GridStack.prototype.resize = function(el, width, height) {
+ this._updateElement(el, function(el, node) {
+ width = (width !== null && typeof width != 'undefined') ? width : node.width;
+ height = (height !== null && typeof height != 'undefined') ? height : node.height;
+
+ this.grid.moveNode(node, node.x, node.y, width, height);
+ });
+ };
+
+ GridStack.prototype.move = function(el, x, y) {
+ this._updateElement(el, function(el, node) {
+ x = (x !== null && typeof x != 'undefined') ? x : node.x;
+ y = (y !== null && typeof y != 'undefined') ? y : node.y;
+
+ this.grid.moveNode(node, x, y, node.width, node.height);
+ });
+ };
+
+ GridStack.prototype.update = function(el, x, y, width, height) {
+ this._updateElement(el, function(el, node) {
+ x = (x !== null && typeof x != 'undefined') ? x : node.x;
+ y = (y !== null && typeof y != 'undefined') ? y : node.y;
+ width = (width !== null && typeof width != 'undefined') ? width : node.width;
+ height = (height !== null && typeof height != 'undefined') ? height : node.height;
+
+ this.grid.moveNode(node, x, y, width, height);
+ });
+ };
+
+ GridStack.prototype.verticalMargin = function(val, noUpdate) {
+ if (typeof val == 'undefined') {
+ return this.opts.verticalMargin;
+ }
+
+ var heightData = Utils.parseHeight(val);
+
+ if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) {
+ return ;
+ }
+ this.opts.verticalMarginUnit = heightData.unit;
+ this.opts.verticalMargin = heightData.height;
+
+ if (!noUpdate) {
+ this._updateStyles();
+ }
+ };
+
+ GridStack.prototype.cellHeight = function(val, noUpdate) {
+ if (typeof val == 'undefined') {
+ if (this.opts.cellHeight) {
+ return this.opts.cellHeight;
+ }
+ var o = this.container.children('.' + this.opts.itemClass).first();
+ return Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
+ }
+ var heightData = Utils.parseHeight(val);
+
+ if (this.opts.cellHeightUnit === heightData.unit && this.opts.cellHeight === heightData.height) {
+ return ;
+ }
+ this.opts.cellHeightUnit = heightData.unit;
+ this.opts.cellHeight = heightData.height;
+
+ if (!noUpdate) {
+ this._updateStyles();
+ }
+
+ };
+
+ GridStack.prototype.cellWidth = function() {
+ return Math.round(this.container.outerWidth() / this.opts.width);
+ };
+
+ GridStack.prototype.getCellFromPixel = function(position, useOffset) {
+ var containerPos = (typeof useOffset != 'undefined' && useOffset) ?
+ this.container.offset() : this.container.position();
+ var relativeLeft = position.left - containerPos.left;
+ var relativeTop = position.top - containerPos.top;
+
+ var columnWidth = Math.floor(this.container.width() / this.opts.width);
+ var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height')));
+
+ return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)};
+ };
+
+ GridStack.prototype.batchUpdate = function() {
+ this.grid.batchUpdate();
+ };
+
+ GridStack.prototype.commit = function() {
+ this.grid.commit();
+ this._updateContainerHeight();
+ };
+
+ GridStack.prototype.isAreaEmpty = function(x, y, width, height) {
+ return this.grid.isAreaEmpty(x, y, width, height);
+ };
+
+ GridStack.prototype.setStatic = function(staticValue) {
+ this.opts.staticGrid = (staticValue === true);
+ this.enableMove(!staticValue);
+ this.enableResize(!staticValue);
+ this._setStaticClass();
+ };
+
+ GridStack.prototype._setStaticClass = function() {
+ var staticClassName = 'grid-stack-static';
+
+ if (this.opts.staticGrid === true) {
+ this.container.addClass(staticClassName);
+ } else {
+ this.container.removeClass(staticClassName);
+ }
+ };
+
+ GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) {
+ this.grid._sortNodes();
+ this.grid.batchUpdate();
+ var node = {};
+ for (var i = 0; i < this.grid.nodes.length; i++) {
+ node = this.grid.nodes[i];
+ this.update(node.el, Math.round(node.x * newWidth / oldWidth), undefined,
+ Math.round(node.width * newWidth / oldWidth), undefined);
+ }
+ this.grid.commit();
+ };
+
+ GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) {
+ this.container.removeClass('grid-stack-' + this.opts.width);
+ if (doNotPropagate !== true) {
+ this._updateNodeWidths(this.opts.width, gridWidth);
+ }
+ this.opts.width = gridWidth;
+ this.grid.width = gridWidth;
+ this.container.addClass('grid-stack-' + gridWidth);
+ };
+
+ // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+ GridStackEngine.prototype.batch_update = obsolete(GridStackEngine.prototype.batchUpdate);
+ GridStackEngine.prototype._fix_collisions = obsolete(GridStackEngine.prototype._fixCollisions,
+ '_fix_collisions', '_fixCollisions');
+ GridStackEngine.prototype.is_area_empty = obsolete(GridStackEngine.prototype.isAreaEmpty,
+ 'is_area_empty', 'isAreaEmpty');
+ GridStackEngine.prototype._sort_nodes = obsolete(GridStackEngine.prototype._sortNodes,
+ '_sort_nodes', '_sortNodes');
+ GridStackEngine.prototype._pack_nodes = obsolete(GridStackEngine.prototype._packNodes,
+ '_pack_nodes', '_packNodes');
+ GridStackEngine.prototype._prepare_node = obsolete(GridStackEngine.prototype._prepareNode,
+ '_prepare_node', '_prepareNode');
+ GridStackEngine.prototype.clean_nodes = obsolete(GridStackEngine.prototype.cleanNodes,
+ 'clean_nodes', 'cleanNodes');
+ GridStackEngine.prototype.get_dirty_nodes = obsolete(GridStackEngine.prototype.getDirtyNodes,
+ 'get_dirty_nodes', 'getDirtyNodes');
+ GridStackEngine.prototype.add_node = obsolete(GridStackEngine.prototype.addNode,
+ 'add_node', 'addNode, ');
+ GridStackEngine.prototype.remove_node = obsolete(GridStackEngine.prototype.removeNode,
+ 'remove_node', 'removeNode');
+ GridStackEngine.prototype.can_move_node = obsolete(GridStackEngine.prototype.canMoveNode,
+ 'can_move_node', 'canMoveNode');
+ GridStackEngine.prototype.move_node = obsolete(GridStackEngine.prototype.moveNode,
+ 'move_node', 'moveNode');
+ GridStackEngine.prototype.get_grid_height = obsolete(GridStackEngine.prototype.getGridHeight,
+ 'get_grid_height', 'getGridHeight');
+ GridStackEngine.prototype.begin_update = obsolete(GridStackEngine.prototype.beginUpdate,
+ 'begin_update', 'beginUpdate');
+ GridStackEngine.prototype.end_update = obsolete(GridStackEngine.prototype.endUpdate,
+ 'end_update', 'endUpdate');
+ GridStackEngine.prototype.can_be_placed_with_respect_to_height =
+ obsolete(GridStackEngine.prototype.canBePlacedWithRespectToHeight,
+ 'can_be_placed_with_respect_to_height', 'canBePlacedWithRespectToHeight');
+ GridStack.prototype._trigger_change_event = obsolete(GridStack.prototype._triggerChangeEvent,
+ '_trigger_change_event', '_triggerChangeEvent');
+ GridStack.prototype._init_styles = obsolete(GridStack.prototype._initStyles,
+ '_init_styles', '_initStyles');
+ GridStack.prototype._update_styles = obsolete(GridStack.prototype._updateStyles,
+ '_update_styles', '_updateStyles');
+ GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight,
+ '_update_container_height', '_updateContainerHeight');
+ GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode,
+ '_is_one_column_mode','_isOneColumnMode');
+ GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement,
+ '_prepare_element', '_prepareElement');
+ GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation,
+ 'set_animation', 'setAnimation');
+ GridStack.prototype.add_widget = obsolete(GridStack.prototype.addWidget,
+ 'add_widget', 'addWidget');
+ GridStack.prototype.make_widget = obsolete(GridStack.prototype.makeWidget,
+ 'make_widget', 'makeWidget');
+ GridStack.prototype.will_it_fit = obsolete(GridStack.prototype.willItFit,
+ 'will_it_fit', 'willItFit');
+ GridStack.prototype.remove_widget = obsolete(GridStack.prototype.removeWidget,
+ 'remove_widget', 'removeWidget');
+ GridStack.prototype.remove_all = obsolete(GridStack.prototype.removeAll,
+ 'remove_all', 'removeAll');
+ GridStack.prototype.min_height = obsolete(GridStack.prototype.minHeight,
+ 'min_height', 'minHeight');
+ GridStack.prototype.min_width = obsolete(GridStack.prototype.minWidth,
+ 'min_width', 'minWidth');
+ GridStack.prototype._update_element = obsolete(GridStack.prototype._updateElement,
+ '_update_element', '_updateElement');
+ GridStack.prototype.cell_height = obsolete(GridStack.prototype.cellHeight,
+ 'cell_height', 'cellHeight');
+ GridStack.prototype.cell_width = obsolete(GridStack.prototype.cellWidth,
+ 'cell_width', 'cellWidth');
+ GridStack.prototype.get_cell_from_pixel = obsolete(GridStack.prototype.getCellFromPixel,
+ 'get_cell_from_pixel', 'getCellFromPixel');
+ GridStack.prototype.batch_update = obsolete(GridStack.prototype.batchUpdate,
+ 'batch_update', 'batchUpdate');
+ GridStack.prototype.is_area_empty = obsolete(GridStack.prototype.isAreaEmpty,
+ 'is_area_empty', 'isAreaEmpty');
+ GridStack.prototype.set_static = obsolete(GridStack.prototype.setStatic,
+ 'set_static', 'setStatic');
+ GridStack.prototype._set_static_class = obsolete(GridStack.prototype._setStaticClass,
+ '_set_static_class', '_setStaticClass');
+ // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
+
+ scope.GridStackUI = GridStack;
+
+ scope.GridStackUI.Utils = Utils;
+ scope.GridStackUI.Engine = GridStackEngine;
+ scope.GridStackUI.GridStackDragDropPlugin = GridStackDragDropPlugin;
+
+ $.fn.gridstack = function(opts) {
+ return this.each(function() {
+ var o = $(this);
+ if (!o.data('gridstack')) {
+ o
+ .data('gridstack', new GridStack(this, opts));
+ }
+ });
+ };
+
+ return scope.GridStackUI;
+});
diff --git a/dist/gridstack.min.css b/dist/gridstack.min.css
new file mode 100644
index 000000000..349f34c6e
--- /dev/null
+++ b/dist/gridstack.min.css
@@ -0,0 +1 @@
+:root .grid-stack-item>.ui-resizable-handle{filter:none}.grid-stack{position:relative}.grid-stack.grid-stack-rtl{direction:ltr}.grid-stack.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack .grid-stack-placeholder>.placeholder-content{border:1px dashed #d3d3d3;margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;text-align:center}.grid-stack>.grid-stack-item{min-width:8.3333333333%;position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack>.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack>.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack>.grid-stack-item.ui-draggable-dragging,.grid-stack>.grid-stack-item.ui-resizable-resizing{z-index:100}.grid-stack>.grid-stack-item.ui-draggable-dragging>.grid-stack-item-content,.grid-stack>.grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack>.grid-stack-item>.ui-resizable-se,.grid-stack>.grid-stack-item>.ui-resizable-sw{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDUxMS42MjYgNTExLjYyNyIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTExLjYyNiA1MTEuNjI3OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggZD0iTTMyOC45MDYsNDAxLjk5NGgtMzYuNTUzVjEwOS42MzZoMzYuNTUzYzQuOTQ4LDAsOS4yMzYtMS44MDksMTIuODQ3LTUuNDI2YzMuNjEzLTMuNjE1LDUuNDIxLTcuODk4LDUuNDIxLTEyLjg0NSAgIGMwLTQuOTQ5LTEuODAxLTkuMjMxLTUuNDI4LTEyLjg1MWwtNzMuMDg3LTczLjA5QzI2NS4wNDQsMS44MDksMjYwLjc2LDAsMjU1LjgxMywwYy00Ljk0OCwwLTkuMjI5LDEuODA5LTEyLjg0Nyw1LjQyNCAgIGwtNzMuMDg4LDczLjA5Yy0zLjYxOCwzLjYxOS01LjQyNCw3LjkwMi01LjQyNCwxMi44NTFjMCw0Ljk0NiwxLjgwNyw5LjIyOSw1LjQyNCwxMi44NDVjMy42MTksMy42MTcsNy45MDEsNS40MjYsMTIuODUsNS40MjYgICBoMzYuNTQ1djI5Mi4zNThoLTM2LjU0MmMtNC45NTIsMC05LjIzNSwxLjgwOC0xMi44NSw1LjQyMWMtMy42MTcsMy42MjEtNS40MjQsNy45MDUtNS40MjQsMTIuODU0ICAgYzAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);background-repeat:no-repeat;background-position:center;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.grid-stack>.grid-stack-item>.ui-resizable-se{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}.grid-stack>.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;left:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;right:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;right:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item>.ui-resizable-se{cursor:se-resize;width:20px;height:20px;right:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;left:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;left:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack>.grid-stack-item[data-gs-width='1']{width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='1']{left:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='1']{min-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='1']{max-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='2']{width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='2']{left:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='2']{min-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='2']{max-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='3']{width:25%}.grid-stack>.grid-stack-item[data-gs-x='3']{left:25%}.grid-stack>.grid-stack-item[data-gs-min-width='3']{min-width:25%}.grid-stack>.grid-stack-item[data-gs-max-width='3']{max-width:25%}.grid-stack>.grid-stack-item[data-gs-width='4']{width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='4']{left:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='4']{min-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='4']{max-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='5']{width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='5']{left:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='5']{min-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='5']{max-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='6']{width:50%}.grid-stack>.grid-stack-item[data-gs-x='6']{left:50%}.grid-stack>.grid-stack-item[data-gs-min-width='6']{min-width:50%}.grid-stack>.grid-stack-item[data-gs-max-width='6']{max-width:50%}.grid-stack>.grid-stack-item[data-gs-width='7']{width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='7']{left:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='7']{min-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='7']{max-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='8']{width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='8']{left:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='8']{min-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='8']{max-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='9']{width:75%}.grid-stack>.grid-stack-item[data-gs-x='9']{left:75%}.grid-stack>.grid-stack-item[data-gs-min-width='9']{min-width:75%}.grid-stack>.grid-stack-item[data-gs-max-width='9']{max-width:75%}.grid-stack>.grid-stack-item[data-gs-width='10']{width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='10']{left:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='10']{min-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='10']{max-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='11']{width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='11']{left:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='11']{min-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='11']{max-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='12']{width:100%}.grid-stack>.grid-stack-item[data-gs-x='12']{left:100%}.grid-stack>.grid-stack-item[data-gs-min-width='12']{min-width:100%}.grid-stack>.grid-stack-item[data-gs-max-width='12']{max-width:100%}.grid-stack.grid-stack-animate,.grid-stack.grid-stack-animate .grid-stack-item{-webkit-transition:left .3s,top .3s,height .3s,width .3s;-moz-transition:left .3s,top .3s,height .3s,width .3s;-ms-transition:left .3s,top .3s,height .3s,width .3s;-o-transition:left .3s,top .3s,height .3s,width .3s;transition:left .3s,top .3s,height .3s,width .3s}.grid-stack.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack.grid-stack-animate .grid-stack-item.ui-resizable-resizing{-webkit-transition:left 0s,top 0s,height 0s,width 0s;-moz-transition:left 0s,top 0s,height 0s,width 0s;-ms-transition:left 0s,top 0s,height 0s,width 0s;-o-transition:left 0s,top 0s,height 0s,width 0s;transition:left 0s,top 0s,height 0s,width 0s}.grid-stack.grid-stack-one-column-mode{height:auto!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item{position:relative!important;width:auto!important;left:0!important;top:auto!important;margin-bottom:20px;max-width:none!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item>.ui-resizable-handle{display:none}
\ No newline at end of file
diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js
new file mode 100644
index 000000000..cbf8b1427
--- /dev/null
+++ b/dist/gridstack.min.js
@@ -0,0 +1,2 @@
+!function(t){if("function"==typeof define&&define.amd)define(["jquery","lodash"],t);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(t){}try{_=require("lodash")}catch(t){}t(jQuery,_)}else t(jQuery,_)}(function(_,g){var t=window,e=function(t,e,i){var o=function(){return console.warn("gridstack.js: Function `"+e+"` is deprecated as of v0.2.5 and has been replaced with `"+i+"`. It will be **completely** removed in v1.0."),t.apply(this,arguments)};return o.prototype=t.prototype,o},d=function(t,e){console.warn("gridstack.js: Option `"+t+"` is deprecated as of v0.2.5 and has been replaced with `"+e+"`. It will be **completely** removed in v1.0.")},u={isIntercepted:function(t,e){return!(t.x+t.width<=e.x||e.x+e.width<=t.x||t.y+t.height<=e.y||e.y+e.height<=t.y)},sort:function(t,e,i){return i=i||g.chain(t).map(function(t){return t.x+t.width}).max().value(),e=-1!=e?1:-1,g.sortBy(t,[function(t){return e*(t.x+t.y*i)}])},createStylesheet:function(t){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.setAttribute("data-gs-style-id",t),e.styleSheet?e.styleSheet.cssText="":e.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(e),e.sheet},removeStylesheet:function(t){_("STYLE[data-gs-style-id="+t+"]").remove()},insertCSSRule:function(t,e,i,o){"function"==typeof t.insertRule?t.insertRule(e+"{"+i+"}",o):"function"==typeof t.addRule&&t.addRule(e,i,o)},toBool:function(t){return"boolean"==typeof t?t:"string"==typeof t?!(""===(t=t.toLowerCase())||"no"==t||"false"==t||"0"==t):Boolean(t)},_collisionNodeCheck:function(t){return t!=this.node&&u.isIntercepted(t,this.nn)},_didCollide:function(t){return u.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},t)},_isAddNodeIntercepted:function(t){return u.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},t)},parseHeight:function(t){var e=t,i="px";if(e&&g.isString(e)){var o=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!o)throw new Error("Invalid height");i=o[2]||"px",e=parseFloat(o[1])}return{height:e,unit:i}},removePositioningStyles:function(t){var e=t[0].style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")},getScrollParent:function(t){return null==t?null:t.scrollHeight>t.clientHeight?t:u.getScrollParent(t.parentNode)},updateScrollPosition:function(t,e,i){var o=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight;if(o.top<0||o.bottom>a){var s=o.bottom-a,r=o.top,n=u.getScrollParent(t),d=n.scrollTop;null!=n&&(o.top<0&&i<0?t.offsetHeight>a?n.scrollTop+=i:n.scrollTop+=Math.abs(r)>Math.abs(i)?i:r:0