diff --git a/README.md b/README.md index 8856ee2..2c79049 100644 --- a/README.md +++ b/README.md @@ -443,6 +443,7 @@ Changes - `'auto'` value for `cellHeight` option - fix `setStatic` method - add `setAnimation` method to API +- add `setGridWidth` method ([#227](https://github.com/troolee/gridstack.js/issues/227)) #### v0.2.4 (2016-02-15) diff --git a/dist/gridstack.js b/dist/gridstack.js index c2182c4..e27de5a 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -1256,6 +1256,25 @@ } }; + 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) { + this.container.removeClass('grid-stack-' + this.opts.width); + this._updateNodeWidths(this.opts.width, gridWidth); + this.opts.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, diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 4f5c1dd..a207561 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -16,5 +16,5 @@ h.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){ // jscs:enable requireCamelCaseOrUpperCaseIdentifiers return i.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},i.prototype._initStyles=function(){this._stylesId&&a('[data-gs-id="'+this._stylesId+'"]').remove(),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=f.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},i.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&f.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;a>e;++e)f.insertCSSRule(this._styles,c+'[data-gs-height="'+(e+1)+'"]',"height: "+b(e+1,e)+";",e),f.insertCSSRule(this._styles,c+'[data-gs-min-height="'+(e+1)+'"]',"min-height: "+b(e+1,e)+";",e),f.insertCSSRule(this._styles,c+'[data-gs-max-height="'+(e+1)+'"]',"max-height: "+b(e+1,e)+";",e),f.insertCSSRule(this._styles,c+'[data-gs-y="'+e+'"]',"top: "+b(e,e)+";",e);this._styles._max=a}}},i.prototype._updateContainerHeight=function(){if(!this.grid._updateCounter){var a=this.grid.getGridHeight();this.container.attr("data-gs-current-height",a),this.opts.cellHeight&&(this.opts.verticalMargin?this.opts.cellHeightUnit===this.opts.verticalMarginUnit?this.container.css("height",a*(this.opts.cellHeight+this.opts.verticalMargin)-this.opts.verticalMargin+this.opts.cellHeightUnit):this.container.css("height","calc("+(a*this.opts.cellHeight+this.opts.cellHeightUnit)+" + "+(a*(this.opts.verticalMargin-1)+this.opts.verticalMarginUnit)+")"):this.container.css("height",a*this.opts.cellHeight+this.opts.cellHeightUnit))}},i.prototype._isOneColumnMode=function(){return(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=this.opts.minWidth},i.prototype._prepareElement=function(c){var d=this;c=a(c),c.addClass(this.opts.itemClass);var e=d.grid.addNode({x:c.attr("data-gs-x"),y:c.attr("data-gs-y"),width:c.attr("data-gs-width"),height:c.attr("data-gs-height"),maxWidth:c.attr("data-gs-max-width"),minWidth:c.attr("data-gs-min-width"),maxHeight:c.attr("data-gs-max-height"),minHeight:c.attr("data-gs-min-height"),autoPosition:f.toBool(c.attr("data-gs-auto-position")),noResize:f.toBool(c.attr("data-gs-no-resize")),noMove:f.toBool(c.attr("data-gs-no-move")),locked:f.toBool(c.attr("data-gs-locked")),el:c});c.data("_gridstack_node",e);var g,h,i=function(a,b){var c,f,i=Math.round(b.position.left/g),j=Math.floor((b.position.top+h/2)/h);"drag"!=a.type&&(c=Math.round(b.size.width/g),f=Math.round(b.size.height/h)),d.grid.canMoveNode(e,i,j,c,f)&&(d.grid.moveNode(e,i,j,c,f),d._updateContainerHeight())},j=function(b,f){d.container.append(d.placeholder);var i=a(this);d.grid.cleanNodes(),d.grid.beginUpdate(e),g=Math.ceil(i.outerWidth()/i.attr("data-gs-width"));var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));h=d.container.height()/parseInt(d.container.attr("data-gs-current-height")),d.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),e.el=d.placeholder,c.resizable("option","minWidth",g*(e.minWidth||1)),c.resizable("option","minHeight",j*(e.minHeight||1)),"resizestart"==b.type&&i.find(".grid-stack-item").trigger("resizestart")},k=function(b,c){d.placeholder.detach();var f=a(this);e.el=f,d.placeholder.hide(),f.attr("data-gs-x",e.x).attr("data-gs-y",e.y).attr("data-gs-width",e.width).attr("data-gs-height",e.height).removeAttr("style"),d._updateContainerHeight(),d._triggerChangeEvent(),d.grid.endUpdate();var g=f.find(".grid-stack");g.length&&"resizestop"==b.type&&(g.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),f.find(".grid-stack-item").trigger("resizestop"))};c.draggable(b.extend(this.opts.draggable,{containment:this.opts.isNested?this.container.parent():null,start:j,stop:k,drag:i})).resizable(b.extend(this.opts.resizable,{start:j,stop:k,resize:i})),(e.noMove||this._isOneColumnMode()||this.opts.staticGrid||this.opts.disableDrag)&&c.draggable("disable"),(e.noResize||this._isOneColumnMode()||this.opts.staticGrid||this.opts.disableResize)&&c.resizable("disable"),c.attr("data-gs-locked",e.locked?"yes":null)},i.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},i.prototype.addWidget=function(b,c,d,e,f,g){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),this.container.append(b),this._prepareElement(b),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},i.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},i.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},i.prototype.removeWidget=function(b,c){c="undefined"==typeof c?!0:c,b=a(b);var d=b.data("_gridstack_node"); // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0)},i.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},i.prototype.destroy=function(){a(window).off("resize",this.onResizeHandler),this.disable(),this.container.remove(),f.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},i.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?e.resizable("disable"):e.resizable("enable"))}),this},i.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(e.draggable("disable"),e.removeClass("ui-draggable-handle")):(e.draggable("enable"),e.addClass("ui-draggable-handle")))}),this},i.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},i.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},i.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},i.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},i.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},i.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},i.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},i.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},i.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},i.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},i.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},i.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},i.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},i.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=f.parseHeight(a);(this.opts.verticalMarginUnit!==c.unit||this.opts.height!==c.height)&&(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},i.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=f.parseHeight(a);(this.opts.cellHeightUnit!==d.heightUnit||this.opts.height!==d.height)&&(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},i.prototype.cellWidth=function(){var a=this.container.children("."+this.opts.itemClass).first();return Math.ceil(a.outerWidth()/a.attr("data-gs-width"))},i.prototype.getCellFromPixel=function(a){var b=this.container.position(),c=a.left-b.left,d=a.top-b.top,e=Math.floor(this.container.width()/this.opts.width),f=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(c/e),y:Math.floor(d/f)}},i.prototype.batchUpdate=function(){this.grid.batchUpdate()},i.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},i.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},i.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},i.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},h.prototype.batch_update=d(h.prototype.batchUpdate),h.prototype._fix_collisions=d(h.prototype._fixCollisions,"_fix_collisions","_fixCollisions"),h.prototype.is_area_empty=d(h.prototype.isAreaEmpty,"is_area_empty","isAreaEmpty"),h.prototype._sort_nodes=d(h.prototype._sortNodes,"_sort_nodes","_sortNodes"),h.prototype._pack_nodes=d(h.prototype._packNodes,"_pack_nodes","_packNodes"),h.prototype._prepare_node=d(h.prototype._prepareNode,"_prepare_node","_prepareNode"),h.prototype.clean_nodes=d(h.prototype.cleanNodes,"clean_nodes","cleanNodes"),h.prototype.get_dirty_nodes=d(h.prototype.getDirtyNodes,"get_dirty_nodes","getDirtyNodes"),h.prototype.add_node=d(h.prototype.addNode,"add_node","addNode, "),h.prototype.remove_node=d(h.prototype.removeNode,"remove_node","removeNode"),h.prototype.can_move_node=d(h.prototype.canMoveNode,"can_move_node","canMoveNode"),h.prototype.move_node=d(h.prototype.moveNode,"move_node","moveNode"),h.prototype.get_grid_height=d(h.prototype.getGridHeight,"get_grid_height","getGridHeight"),h.prototype.begin_update=d(h.prototype.beginUpdate,"begin_update","beginUpdate"),h.prototype.end_update=d(h.prototype.endUpdate,"end_update","endUpdate"),h.prototype.can_be_placed_with_respect_to_height=d(h.prototype.canBePlacedWithRespectToHeight,"can_be_placed_with_respect_to_height","canBePlacedWithRespectToHeight"),i.prototype._trigger_change_event=d(i.prototype._triggerChangeEvent,"_trigger_change_event","_triggerChangeEvent"),i.prototype._init_styles=d(i.prototype._initStyles,"_init_styles","_initStyles"),i.prototype._update_styles=d(i.prototype._updateStyles,"_update_styles","_updateStyles"),i.prototype._update_container_height=d(i.prototype._updateContainerHeight,"_update_container_height","_updateContainerHeight"),i.prototype._is_one_column_mode=d(i.prototype._isOneColumnMode,"_is_one_column_mode"," _isOneColumnMode"),i.prototype._prepare_element=d(i.prototype._prepareElement,"_prepare_element","_prepareElement"),i.prototype.set_animation=d(i.prototype.setAnimation,"set_animation","setAnimation"),i.prototype.add_widget=d(i.prototype.addWidget,"add_widget","addWidget"),i.prototype.make_widget=d(i.prototype.makeWidget,"make_widget","makeWidget"),i.prototype.will_it_fit=d(i.prototype.willItFit,"will_it_fit","willItFit"),i.prototype.remove_widget=d(i.prototype.removeWidget,"remove_widget","removeWidget"),i.prototype.remove_all=d(i.prototype.removeAll,"remove_all","removeAll"),i.prototype.min_height=d(i.prototype.minHeight,"min_height","minHeight"),i.prototype.min_width=d(i.prototype.minWidth,"min_width","minWidth"),i.prototype._update_element=d(i.prototype._updateElement,"_update_element","_updateElement"),i.prototype.cell_height=d(i.prototype.cellHeight,"cell_height","cellHeight"),i.prototype.cell_width=d(i.prototype.cellWidth,"cell_width","cellWidth"),i.prototype.get_cell_from_pixel=d(i.prototype.getCellFromPixel,"get_cell_from_pixel","getCellFromPixel"),i.prototype.batch_update=d(i.prototype.batchUpdate,"batch_update","batchUpdate"),i.prototype.is_area_empty=d(i.prototype.isAreaEmpty,"is_area_empty","isAreaEmpty"),i.prototype.set_static=d(i.prototype.setStatic,"set_static","setStatic"),i.prototype._set_static_class=d(i.prototype._setStaticClass,"_set_static_class","_setStaticClass"),c.GridStackUI=i,c.GridStackUI.Utils=f,a.fn.gridstack=function(b){return this.each(function(){var c=a(this);c.data("gridstack")||c.data("gridstack",new i(this,b))})},c.GridStackUI}); +d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0)},i.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},i.prototype.destroy=function(){a(window).off("resize",this.onResizeHandler),this.disable(),this.container.remove(),f.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},i.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?e.resizable("disable"):e.resizable("enable"))}),this},i.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(e.draggable("disable"),e.removeClass("ui-draggable-handle")):(e.draggable("enable"),e.addClass("ui-draggable-handle")))}),this},i.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},i.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},i.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},i.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},i.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},i.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},i.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},i.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},i.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},i.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},i.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},i.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},i.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},i.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=f.parseHeight(a);(this.opts.verticalMarginUnit!==c.unit||this.opts.height!==c.height)&&(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},i.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=f.parseHeight(a);(this.opts.cellHeightUnit!==d.heightUnit||this.opts.height!==d.height)&&(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},i.prototype.cellWidth=function(){var a=this.container.children("."+this.opts.itemClass).first();return Math.ceil(a.outerWidth()/a.attr("data-gs-width"))},i.prototype.getCellFromPixel=function(a){var b=this.container.position(),c=a.left-b.left,d=a.top-b.top,e=Math.floor(this.container.width()/this.opts.width),f=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(c/e),y:Math.floor(d/f)}},i.prototype.batchUpdate=function(){this.grid.batchUpdate()},i.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},i.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},i.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},i.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},i.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d