iot-backend/software/dashboard/grafana/csv/Node-RED_files/gridstack.min.js
2023-02-27 17:21:01 +01:00

9 lines
34 KiB
JavaScript

/**
* gridstack.js 0.6.4
* https://gridstackjs.com/
* (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov
* gridstack.js may be freely distributed under the MIT license.
* @preserve
*/
!function(t){if("function"==typeof define&&define.amd)define(["jquery","exports"],t);else if("undefined"!=typeof exports){var e;try{e=require("jquery")}catch(t){}t(e||window.jQuery,exports)}else t(window.jQuery,window)}(function(m,t){function n(t,e,i,o){void 0!==t[e]&&(t[i]=t[e],console.warn("gridstack.js: Option `"+e+"` is deprecated in "+o+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))}function d(t,e,i,o){var a=t.attr(e);void 0!==a&&(t.attr(i,a),console.warn("gridstack.js: attribute `"+e+"`="+a+" is deprecated on this object in "+o+" and has been replaced with `"+i+"`. It will be **completely** removed in v1.0"))}var f={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){if(!i){var o=t.map(function(t){return t.x+t.width});i=Math.max.apply(Math,o)}return-1===e?f.sortBy(t,function(t){return-(t.x+t.y*i)}):f.sortBy(t,function(t){return t.x+t.y*i})},createStylesheet:function(t,e){var i=document.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute("data-gs-style-id",t),i.styleSheet?i.styleSheet.cssText="":i.appendChild(document.createTextNode("")),(e=e||document.getElementsByTagName("head")[0]).insertBefore(i,e.firstChild),i.sheet},removeStylesheet:function(t){m("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&&f.isIntercepted(t,this.nn)},_didCollide:function(t){return f.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},t)},_isAddNodeIntercepted:function(t){return f.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&&"string"==typeof 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}},without:function(t,e){var i=t.indexOf(e);return-1!==i&&(t=t.slice(0)).splice(i,1),t},sortBy:function(t,a){return t.slice(0).sort(function(t,e){var i=a(t),o=a(e);return o===i?0:o<i?1:-1})},defaults:function(i){return Array.prototype.slice.call(arguments,1).forEach(function(t){for(var e in t)!t.hasOwnProperty(e)||i.hasOwnProperty(e)&&void 0!==i[e]||(i[e]=t[e])}),i},clone:function(t){return m.extend({},t)},throttle:function(t,e){var i=!1;return function(){i||(t.apply(this,arguments),i=!0,setTimeout(function(){i=!1},e))}},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:f.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=f.getScrollParent(t);if(null!==n){var d=n.scrollTop;o.top<0&&i<0?t.offsetHeight>a?n.scrollTop+=i:n.scrollTop+=Math.abs(r)>Math.abs(i)?i:r:0<i&&(t.offsetHeight>a?n.scrollTop+=i:n.scrollTop+=i<s?i:s),e.position.top+=n.scrollTop-d}}}};function h(t){this.grid=t}h.registeredPlugins=[],h.registerPlugin=function(t){h.registeredPlugins.push(t)},h.prototype.resizable=function(t,e){return this},h.prototype.draggable=function(t,e){return this},h.prototype.droppable=function(t,e){return this},h.prototype.isDroppable=function(t){return!1},h.prototype.on=function(t,e,i){return this};function l(t,e,i,o,a){this.column=t||12,this.float=i||!1,this.maxRow=o||0,this.nodes=a||[],this.onchange=e||function(){},this._addedNodes=[],this._removedNodes=[],this._batchMode=!1}var s=0;l.prototype.batchUpdate=function(){this._batchMode||(this._batchMode=!0,this._prevFloat=this.float,this.float=!0)},l.prototype.commit=function(){this._batchMode&&(this._batchMode=!1,this.float=this._prevFloat,delete this._prevFloat,this._packNodes(),this._notify())},l.prototype.getNodeDataByDOMEl=function(e){return this.nodes.find(function(t){return e.get(0)===t.el.get(0)})},l.prototype._fixCollisions=function(t){this._sortNodes(-1);var e=t,i=Boolean(this.nodes.find(function(t){return t.locked}));for(this.float||i||(e={x:0,y:t.y,width:this.column,height:t.height});;){var o=this.nodes.find(f._collisionNodeCheck,{node:t,nn:e});if(!o)return;this.moveNode(o,o.x,t.y+t.height,o.width,o.height,!0)}},l.prototype.isAreaEmpty=function(t,e,i,o){var a={x:t||0,y:e||0,width:i||1,height:o||1};return!this.nodes.find(function(t){return f.isIntercepted(t,a)})},l.prototype._sortNodes=function(t){this.nodes=f.sort(this.nodes,t,this.column)},l.prototype._packNodes=function(){this._sortNodes(),this.float?this.nodes.forEach(function(t,e){if(!t._updating&&void 0!==t._packY&&t.y!==t._packY)for(var i=t.y;i>=t._packY;){this.nodes.slice(0,e).find(f._didCollide,{n:t,newY:i})||(t._dirty=!0,t.y=i),--i}},this):this.nodes.forEach(function(t,e){if(!t.locked)for(;0<t.y;){var i=t.y-1,o=0===e;if(0<e)o=void 0===this.nodes.slice(0,e).find(f._didCollide,{n:t,newY:i});if(!o)break;t._dirty=t.y!==i,t.y=i}},this)},l.prototype._prepareNode=function(t,e){void 0!==(t=t||{}).x&&void 0!==t.y&&null!==t.x&&null!==t.y||(t.autoPosition=!0);var i={width:1,height:1,x:0,y:0};return(t=f.defaults(t,i)).x=parseInt(t.x),t.y=parseInt(t.y),t.width=parseInt(t.width),t.height=parseInt(t.height),t.autoPosition=t.autoPosition||!1,t.noResize=t.noResize||!1,t.noMove=t.noMove||!1,Number.isNaN(t.x)&&(t.x=i.x,t.autoPosition=!0),Number.isNaN(t.y)&&(t.y=i.y,t.autoPosition=!0),Number.isNaN(t.width)&&(t.width=i.width),Number.isNaN(t.height)&&(t.height=i.height),t.width>this.column?t.width=this.column:t.width<1&&(t.width=1),t.height<1&&(t.height=1),t.x<0&&(t.x=0),t.x+t.width>this.column&&(e?t.width=this.column-t.x:t.x=this.column-t.width),t.y<0&&(t.y=0),t},l.prototype._notify=function(){if(!this._batchMode){var t=Array.prototype.slice.call(arguments,0);t[0]=void 0===t[0]?[]:Array.isArray(t[0])?t[0]:[t[0]],t[1]=void 0===t[1]||t[1];var e=t[0].concat(this.getDirtyNodes());this.onchange(e,t[1])}},l.prototype.cleanNodes=function(){this._batchMode||this.nodes.forEach(function(t){delete t._dirty})},l.prototype.getDirtyNodes=function(t){if(t){var e=[];return this.nodes.forEach(function(t){t._dirty&&(t.y===t._origY&&t.x===t._origX&&t.width===t._origW&&t.height===t._origH?delete t._dirty:e.push(t))}),e}return this.nodes.filter(function(t){return t._dirty})},l.prototype.addNode=function(t,e){if(void 0!==(t=this._prepareNode(t)).maxWidth&&(t.width=Math.min(t.width,t.maxWidth)),void 0!==t.maxHeight&&(t.height=Math.min(t.height,t.maxHeight)),void 0!==t.minWidth&&(t.width=Math.max(t.width,t.minWidth)),void 0!==t.minHeight&&(t.height=Math.max(t.height,t.minHeight)),t._id=t._id||++s,t.autoPosition){this._sortNodes();for(var i=0;;++i){var o=i%this.column,a=Math.floor(i/this.column);if(!(o+t.width>this.column)&&!this.nodes.find(f._isAddNodeIntercepted,{x:o,y:a,node:t})){t.x=o,t.y=a,delete t.autoPosition;break}}}return this.nodes.push(t),e&&this._addedNodes.push(t),this._fixCollisions(t),this._packNodes(),this._notify(),t},l.prototype.removeNode=function(t,e){e=void 0===e||e,this._removedNodes.push(t),t._id=null,this.nodes=f.without(this.nodes,t),this._packNodes(),this._notify(t,e)},l.prototype.removeAll=function(t){delete this._layouts,0!==this.nodes.length&&(t=void 0===t||t,this.nodes.forEach(function(t){t._id=null}),this._removedNodes=this.nodes,this.nodes=[],this._notify(this._removedNodes,t))},l.prototype.canMoveNode=function(e,t,i,o,a){if(!this.isNodeChangedPosition(e,t,i,o,a))return!1;var s,r=Boolean(this.nodes.find(function(t){return t.locked}));if(!this.maxRow&&!r)return!0;var n=new l(this.column,null,this.float,0,this.nodes.map(function(t){return t===e?s=m.extend({},t):m.extend({},t)}));if(!s)return!0;n.moveNode(s,t,i,o,a);var d=!0;return r&&(d&=!Boolean(n.nodes.find(function(t){return t!==s&&Boolean(t.locked)&&Boolean(t._dirty)}))),this.maxRow&&(d&=n.getGridHeight()<=this.maxRow),d},l.prototype.canBePlacedWithRespectToHeight=function(t){if(!this.maxRow)return!0;var e=new l(this.column,null,this.float,0,this.nodes.map(function(t){return m.extend({},t)}));return e.addNode(t),e.getGridHeight()<=this.maxRow},l.prototype.isNodeChangedPosition=function(t,e,i,o,a){return"number"!=typeof e&&(e=t.x),"number"!=typeof i&&(i=t.y),"number"!=typeof o&&(o=t.width),"number"!=typeof a&&(a=t.height),void 0!==t.maxWidth&&(o=Math.min(o,t.maxWidth)),void 0!==t.maxHeight&&(a=Math.min(a,t.maxHeight)),void 0!==t.minWidth&&(o=Math.max(o,t.minWidth)),void 0!==t.minHeight&&(a=Math.max(a,t.minHeight)),t.x!==e||t.y!==i||t.width!==o||t.height!==a},l.prototype.moveNode=function(t,e,i,o,a,s){if("number"!=typeof e&&(e=t.x),"number"!=typeof i&&(i=t.y),"number"!=typeof o&&(o=t.width),"number"!=typeof a&&(a=t.height),void 0!==t.maxWidth&&(o=Math.min(o,t.maxWidth)),void 0!==t.maxHeight&&(a=Math.min(a,t.maxHeight)),void 0!==t.minWidth&&(o=Math.max(o,t.minWidth)),void 0!==t.minHeight&&(a=Math.max(a,t.minHeight)),t.x===e&&t.y===i&&t.width===o&&t.height===a)return t;var r=t.width!==o;return t._dirty=!0,t.x=e,t.y=i,t.width=o,t.height=a,t.lastTriedX=e,t.lastTriedY=i,t.lastTriedWidth=o,t.lastTriedHeight=a,t=this._prepareNode(t,r),this._fixCollisions(t),s||(this._packNodes(),this._notify()),t},l.prototype.getGridHeight=function(){return this.nodes.reduce(function(t,e){return Math.max(t,e.y+e.height)},0)},l.prototype.beginUpdate=function(t){t._updating||(t._updating=!0,this.nodes.forEach(function(t){t._packY=t.y}))},l.prototype.endUpdate=function(){var t=this.nodes.find(function(t){return t._updating});t&&(t._updating=!1,this.nodes.forEach(function(t){delete t._packY}))};function i(t,e){var i,c=this;e=e||{},this.container=m(t),n(e,"width","column","v0.5.3"),n(e,"height","maxRow","v0.5.3"),function(t,e,i,o){void 0!==t[e]&&console.warn("gridstack.js: Option `"+e+"` is deprecated in "+i+o)}(e,"oneColumnModeClass","v0.6.3",". Use class `.grid-stack-1` instead"),d(this.container,"data-gs-width","data-gs-column","v0.5.3"),d(this.container,"data-gs-height","data-gs-max-row","v0.5.3"),e.itemClass=e.itemClass||"grid-stack-item";var o=0<this.container.closest("."+e.itemClass).length;if(this.opts=f.defaults(e,{column:parseInt(this.container.attr("data-gs-column"))||12,maxRow:parseInt(this.container.attr("data-gs-max-row"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:f.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:f.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removableOptions:f.defaults(e.removableOptions||{},{accept:"."+e.itemClass}),removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",disableOneColumnMode:e.disableOneColumnMode||!1,oneColumnModeDomSort:e.oneColumnModeDomSort,ddPlugin:null}),!1===this.opts.ddPlugin?this.opts.ddPlugin=h:null===this.opts.ddPlugin&&(this.opts.ddPlugin=h.registeredPlugins[0]||h),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=o,(i="auto"===this.opts.cellHeight)?c.cellHeight(c.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),o&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new l(this.opts.column,function(t,e){e=void 0===e||e;var i=0;this.nodes.forEach(function(t){i=Math.max(i,t.y+t.height)}),t.forEach(function(t){e&&null===t._id?t.el&&t.el.remove():t.el.attr("data-gs-x",t.x).attr("data-gs-y",t.y).attr("data-gs-width",t.width).attr("data-gs-height",t.height)}),c._updateStyles(i+10)},this.opts.float,this.opts.maxRow),this.opts.auto){var a=[],s=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(t,e){e=m(e);var i=parseInt(e.attr("data-gs-x")),o=parseInt(e.attr("data-gs-y"));a.push({el:e,i:(Number.isNaN(i)?1e3:i)+(Number.isNaN(o)?1e3:o)*s.opts.column})}),f.sortBy(a,function(t){return t.i}).forEach(function(t){this._prepareElement(t.el)},this)}if(this.grid._saveInitial(),this.setAnimation(this.opts.animate),this.placeholder=m('<div class="'+this.opts.placeholderClass+" "+this.opts.itemClass+'"><div class="placeholder-content">'+this.opts.placeholderText+"</div></div>").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=f.throttle(function(){c.cellHeight(c.cellWidth(),!1)},100),this.onResizeHandler=function(){if(i&&c._updateHeightsOnResize(),!c.opts.staticGrid)if(!c.opts.disableOneColumnMode&&(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=c.opts.minWidth){if(c.oneColumnMode)return;c.oneColumnMode=!0,c.setColumn(1)}else{if(!c.oneColumnMode)return;c.oneColumnMode=!1,c.setColumn(c._prevColumn)}},m(window).resize(this.onResizeHandler),this.onResizeHandler(),!c.opts.staticGrid&&"string"==typeof c.opts.removable){var r=m(c.opts.removable);this.dd.isDroppable(r)||this.dd.droppable(r,c.opts.removableOptions),this.dd.on(r,"dropover",function(t,e){var i=m(e.draggable),o=i.data("_gridstack_node");o&&o._grid===c&&(i.data("inTrashZone",!0),c._setupRemovingTimeout(i))}).on(r,"dropout",function(t,e){var i=m(e.draggable),o=i.data("_gridstack_node");o&&o._grid===c&&(i.data("inTrashZone",!1),c._clearRemovingTimeout(i))})}if(!c.opts.staticGrid&&c.opts.acceptWidgets){function p(t,e){var i=u,o=i.data("_gridstack_node"),a=c.getCellFromPixel({left:t.pageX,top:t.pageY},!0),s=Math.max(0,a.x),r=Math.max(0,a.y);o._added||(o._added=!0,o.el=i,o.autoPosition=!0,o.x=s,o.y=r,c.grid.cleanNodes(),c.grid.beginUpdate(o),c.grid.addNode(o),c.container.append(c.placeholder),c.placeholder.attr("data-gs-x",o.x).attr("data-gs-y",o.y).attr("data-gs-width",o.width).attr("data-gs-height",o.height).show(),o.el=c.placeholder,o._beforeDragX=o.x,o._beforeDragY=o.y,c._updateContainerHeight()),c.grid.canMoveNode(o,s,r)&&(c.grid.moveNode(o,s,r),c._updateContainerHeight())}var u=null;this.dd.droppable(c.container,{accept:function(t){var e=(t=m(t)).data("_gridstack_node");return(!e||e._grid!==c)&&t.is(!0===c.opts.acceptWidgets?".grid-stack-item":c.opts.acceptWidgets)}}).on(c.container,"dropover",function(t,e){var i,o,a=m(e.draggable),s=a.data("_gridstack_node");if(!s||!s.width||!s.height){var r=parseInt(a.attr("data-gs-width"));0<r&&((s=s||{}).width=r);var n=parseInt(a.attr("data-gs-height"));0<n&&((s=s||{}).height=n)}var d=c.cellWidth(),h=c.cellHeight(),l=c.opts.verticalMargin;i=s&&s.width?s.width:Math.ceil(a.outerWidth()/d),o=s&&s.height?s.height:Math.round((a.outerHeight()+l)/(h+l)),u=a;var g=c.grid._prepareNode({width:i,height:o,_added:!1,_temporary:!0});return g.isOutOfGrid=!0,a.data("_gridstack_node",g),a.data("_gridstack_node_orig",s),a.on("drag",p),!1}).on(c.container,"dropout",function(t,e){var i=m(e.draggable);if(i.data("_gridstack_node")){var o=i.data("_gridstack_node");if(o.isOutOfGrid)return i.unbind("drag",p),o.el=null,c.grid.removeNode(o),c.placeholder.detach(),c._updateContainerHeight(),i.data("_gridstack_node",i.data("_gridstack_node_orig")),!1}}).on(c.container,"drop",function(t,e){c.placeholder.detach();var i=m(e.draggable).data("_gridstack_node");i.isOutOfGrid=!1,i._grid=c;var o=m(e.draggable).clone(!1);o.data("_gridstack_node",i);var a=m(e.draggable).data("_gridstack_node_orig");return void 0!==a&&void 0!==a._grid&&a._grid._triggerRemoveEvent(),m(e.helper).remove(),i.el=o,c.placeholder.hide(),f.removePositioningStyles(o),o.find("div.ui-resizable-handle").remove(),o.attr("data-gs-x",i.x).attr("data-gs-y",i.y).attr("data-gs-width",i.width).attr("data-gs-height",i.height).addClass(c.opts.itemClass).enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),c.container.append(o),c._prepareElementsByNode(o,i),c._updateContainerHeight(),c.grid._addedNodes.push(i),c._triggerAddEvent(),c._triggerChangeEvent(),c.grid.endUpdate(),m(e.draggable).unbind("drag",p),m(e.draggable).removeData("_gridstack_node"),m(e.draggable).removeData("_gridstack_node_orig"),c.container.trigger("dropped",[a,i]),!1})}}var e,o,a,r;function g(){return console.warn("gridstack.js: Function `"+o+"` is deprecated in "+r+" and has been replaced with `"+a+"`. It will be **completely** removed in v1.0"),e.apply(this,arguments)}return i.prototype._triggerChangeEvent=function(){if(!this.grid._batchMode){var t=this.grid.getDirtyNodes(!0);t&&t.length&&(this.grid._layoutsNodesChange(t),this.container.trigger("change",[t])),this.grid._saveInitial()}},i.prototype._triggerAddEvent=function(){this.grid._batchMode||this.grid._addedNodes&&0<this.grid._addedNodes.length&&(this.grid._layoutsNodesChange(this.grid._addedNodes),this.grid._addedNodes.forEach(function(t){delete t._dirty}),this.container.trigger("added",[this.grid._addedNodes]),this.grid._addedNodes=[])},i.prototype._triggerRemoveEvent=function(){this.grid._batchMode||this.grid._removedNodes&&0<this.grid._removedNodes.length&&(this.container.trigger("removed",[this.grid._removedNodes]),this.grid._removedNodes=[])},i.prototype._initStyles=function(){this._stylesId&&f.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=f.createStylesheet(this._stylesId,this.container.get(0).parentNode),null!==this._styles&&(this._styles._max=0)},i.prototype._updateStyles=function(t){if(null!==this._styles&&void 0!==this._styles){var e,i="."+this.opts._class+" ."+this.opts.itemClass,o=this;if(void 0===t&&(t=this._styles._max),this._initStyles(),this._updateContainerHeight(),this.opts.cellHeight&&!(0!==this._styles._max&&t<=this._styles._max)&&(e=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(t,e){return t&&e?"calc("+(o.opts.cellHeight*t+o.opts.cellHeightUnit)+" + "+(o.opts.verticalMargin*e+o.opts.verticalMarginUnit)+")":o.opts.cellHeight*t+o.opts.verticalMargin*e+o.opts.cellHeightUnit}:function(t,e){return o.opts.cellHeight*t+o.opts.verticalMargin*e+o.opts.cellHeightUnit},0===this._styles._max&&f.insertCSSRule(this._styles,i,"min-height: "+e(1,0)+";",0),t>this._styles._max)){for(var a=this._styles._max;a<t;++a)f.insertCSSRule(this._styles,i+'[data-gs-height="'+(a+1)+'"]',"height: "+e(a+1,a)+";",a),f.insertCSSRule(this._styles,i+'[data-gs-min-height="'+(a+1)+'"]',"min-height: "+e(a+1,a)+";",a),f.insertCSSRule(this._styles,i+'[data-gs-max-height="'+(a+1)+'"]',"max-height: "+e(a+1,a)+";",a),f.insertCSSRule(this._styles,i+'[data-gs-y="'+a+'"]',"top: "+e(a,a)+";",a);this._styles._max=t}}},i.prototype._updateContainerHeight=function(){if(!this.grid._batchMode){var t=this.grid.getGridHeight(),e=parseInt(this.container.css("min-height"));if(0<e){var i=this.opts.verticalMargin,o=Math.round((e+i)/(this.cellHeight()+i));t<o&&(t=o)}this.container.attr("data-gs-current-height",t),this.opts.cellHeight&&(this.opts.verticalMargin?this.opts.cellHeightUnit===this.opts.verticalMarginUnit?this.container.css("height",t*(this.opts.cellHeight+this.opts.verticalMargin)-this.opts.verticalMargin+this.opts.cellHeightUnit):this.container.css("height","calc("+(t*this.opts.cellHeight+this.opts.cellHeightUnit)+" + "+(t*(this.opts.verticalMargin-1)+this.opts.verticalMarginUnit)+")"):this.container.css("height",t*this.opts.cellHeight+this.opts.cellHeightUnit))}},i.prototype._setupRemovingTimeout=function(t){var e=m(t).data("_gridstack_node");!e._removeTimeout&&this.opts.removable&&(e._removeTimeout=setTimeout(function(){t.addClass("grid-stack-item-removing"),e._isAboutToRemove=!0},this.opts.removeTimeout))},i.prototype._clearRemovingTimeout=function(t){var e=m(t).data("_gridstack_node");e._removeTimeout&&(clearTimeout(e._removeTimeout),e._removeTimeout=null,t.removeClass("grid-stack-item-removing"),e._isAboutToRemove=!1)},i.prototype._prepareElementsByNode=function(h,l){function t(t,e){var i,o,a=Math.round(e.position.left/g),s=Math.floor((e.position.top+c/2)/c);if("drag"!==t.type&&(i=Math.round(e.size.width/g),o=Math.round(e.size.height/c)),"drag"===t.type){var r=e.position.top-l._prevYPix;if(l._prevYPix=e.position.top,f.updateScrollPosition(h[0],e,r),h.data("inTrashZone")||a<0||a>=p.grid.column||s<0||!p.grid.float&&s>p.grid.getGridHeight()){if(l._temporaryRemoved)return;!0===p.opts.removable&&p._setupRemovingTimeout(h),a=l._beforeDragX,s=l._beforeDragY,p.placeholder.detach(),p.placeholder.hide(),p.grid.removeNode(l),p._updateContainerHeight(),l._temporaryRemoved=!0}else p._clearRemovingTimeout(h),l._temporaryRemoved&&(p.grid.addNode(l),p.placeholder.attr("data-gs-x",a).attr("data-gs-y",s).attr("data-gs-width",i).attr("data-gs-height",o).show(),p.container.append(p.placeholder),l.el=p.placeholder,l._temporaryRemoved=!1)}else if("resize"===t.type&&a<0)return;var n=void 0!==i?i:l.lastTriedWidth,d=void 0!==o?o:l.lastTriedHeight;!p.grid.canMoveNode(l,a,s,i,o)||l.lastTriedX===a&&l.lastTriedY===s&&l.lastTriedWidth===n&&l.lastTriedHeight===d||(l.lastTriedX=a,l.lastTriedY=s,l.lastTriedWidth=i,l.lastTriedHeight=o,p.grid.moveNode(l,a,s,i,o),p._updateContainerHeight(),"resize"===t.type&&m(t.target).trigger("gsresize",l))}function e(t,e){p.container.append(p.placeholder);var i=m(this);p.grid.cleanNodes(),p.grid.beginUpdate(l),g=p.cellWidth();var o=p.cellHeight();c=p.container.height()/parseInt(p.container.attr("data-gs-current-height")),p.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(),l.el=p.placeholder,l._beforeDragX=l.x,l._beforeDragY=l.y,l._prevYPix=e.position.top;var a=l.minHeight||1,s=p.opts.verticalMargin;p.dd.resizable(h,"option","minWidth",g*(l.minWidth||1)),p.dd.resizable(h,"option","minHeight",o*a+(a-1)*s),"resizestart"===t.type&&i.find(".grid-stack-item").trigger("resizestart")}function i(t,e){var i=m(this);if(i.data("_gridstack_node")){if(p.placeholder.detach(),l.el=i,p.placeholder.hide(),l._isAboutToRemove)h.data("_gridstack_node")._grid._triggerRemoveEvent(),h.removeData("_gridstack_node"),h.remove();else p._clearRemovingTimeout(h),l._temporaryRemoved?(f.removePositioningStyles(i),i.attr("data-gs-x",l._beforeDragX).attr("data-gs-y",l._beforeDragY).attr("data-gs-width",l.width).attr("data-gs-height",l.height),l.x=l._beforeDragX,l.y=l._beforeDragY,l._temporaryRemoved=!1,p.grid.addNode(l)):(f.removePositioningStyles(i),i.attr("data-gs-x",l.x).attr("data-gs-y",l.y).attr("data-gs-width",l.width).attr("data-gs-height",l.height));p._updateContainerHeight(),p._triggerChangeEvent(),p.grid.endUpdate();var o=i.find(".grid-stack");o.length&&"resizestop"===t.type&&(o.each(function(t,e){m(e).data("gridstack").onResizeHandler()}),i.find(".grid-stack-item").trigger("resizestop"),i.find(".grid-stack-item").trigger("gsresizestop")),"resizestop"===t.type&&p.container.trigger("gsresizestop",i)}}var g,c,p=this;this.dd.draggable(h,{start:e,stop:i,drag:t}).resizable(h,{start:e,stop:i,resize:t}),(l.noMove||this.opts.disableDrag||this.opts.staticGrid)&&this.dd.draggable(h,"disable"),(l.noResize||this.opts.disableResize||this.opts.staticGrid)&&this.dd.resizable(h,"disable"),this._writeAttr(h,l)},i.prototype._prepareElement=function(t,e){e=void 0!==e&&e;(t=m(t)).addClass(this.opts.itemClass);var i=this._readAttr(t,{el:t,_grid:this});i=this.grid.addNode(i,e),t.data("_gridstack_node",i),this._prepareElementsByNode(t,i)},i.prototype._writeAttr=function(t,e){t=m(t),void 0!==(e=e||{}).x&&t.attr("data-gs-x",e.x),void 0!==e.y&&t.attr("data-gs-y",e.y),void 0!==e.width&&t.attr("data-gs-width",e.width),void 0!==e.height&&t.attr("data-gs-height",e.height),void 0!==e.autoPosition&&t.attr("data-gs-auto-position",!!e.autoPosition||null),void 0!==e.minWidth&&t.attr("data-gs-min-width",e.minWidth),void 0!==e.maxWidth&&t.attr("data-gs-max-width",e.maxWidth),void 0!==e.minHeight&&t.attr("data-gs-min-height",e.minHeight),void 0!==e.maxHeight&&t.attr("data-gs-max-height",e.maxHeight),void 0!==e.noResize&&t.attr("data-gs-no-resize",!!e.noResize||null),void 0!==e.noMove&&t.attr("data-gs-no-move",!!e.noMove||null),void 0!==e.locked&&t.attr("data-gs-locked",!!e.locked||null),void 0!==e.resizeHandles&&t.attr("data-gs-resize-handles",e.resizeHandles),void 0!==e.id&&t.attr("data-gs-id",e.id)},i.prototype._readAttr=function(t,e){return t=m(t),(e=e||{}).x=t.attr("data-gs-x"),e.y=t.attr("data-gs-y"),e.width=t.attr("data-gs-width"),e.height=t.attr("data-gs-height"),e.autoPosition=f.toBool(t.attr("data-gs-auto-position")),e.maxWidth=t.attr("data-gs-max-width"),e.minWidth=t.attr("data-gs-min-width"),e.maxHeight=t.attr("data-gs-max-height"),e.minHeight=t.attr("data-gs-min-height"),e.noResize=f.toBool(t.attr("data-gs-no-resize")),e.noMove=f.toBool(t.attr("data-gs-no-move")),e.locked=f.toBool(t.attr("data-gs-locked")),e.resizeHandles=t.attr("data-gs-resize-handles"),e.id=t.attr("data-gs-id"),e},i.prototype.setAnimation=function(t){t?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},i.prototype.addWidget=function(t,e,i,o,a,s,r,n,d,h,l){return void 0!==e&&"object"!=typeof e?this.addWidget(t,{x:e,y:i,width:o,height:a,autoPosition:s,minWidth:r,maxWidth:n,minHeight:d,maxHeight:h,id:l}):(e=e||{},t=m(t),this._writeAttr(t,e),this.container.append(t),this.makeWidget(t))},i.prototype.makeWidget=function(t){return t=m(t),this._prepareElement(t,!0),this._updateContainerHeight(),this._triggerAddEvent(),this._triggerChangeEvent(!0),t},i.prototype.willItFit=function(t,e,i,o,a){var s={x:t,y:e,width:i,height:o,autoPosition:a};return this.grid.canBePlacedWithRespectToHeight(s)},i.prototype.removeWidget=function(t,e){e=void 0===e||e;var i=(t=m(t)).data("_gridstack_node");i=i||this.grid.getNodeDataByDOMEl(t),t.removeData("_gridstack_node"),this.grid.removeNode(i,e),this._triggerRemoveEvent(),this._triggerChangeEvent(!0)},i.prototype.removeAll=function(t){!1!==t&&this.grid.nodes.forEach(function(t){t.el.removeData("_gridstack_node")}),this.grid.removeAll(t),this._triggerRemoveEvent()},i.prototype.destroy=function(t){m(window).off("resize",this.onResizeHandler),this.disable(),void 0===t||t?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),f.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},i.prototype.resizable=function(t,o){var a=this;return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(i.noResize=!o,i.noResize?a.dd.resizable(e,"disable"):a.dd.resizable(e,"enable"))}),this},i.prototype.movable=function(t,o){var a=this;return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(i.noMove=!o,i.noMove?(a.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(a.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},i.prototype.enableMove=function(t,e){this.movable(this.container.children("."+this.opts.itemClass),t),e&&(this.opts.disableDrag=!t)},i.prototype.enableResize=function(t,e){this.resizable(this.container.children("."+this.opts.itemClass),t),e&&(this.opts.disableResize=!t)},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(t,o){return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(i.locked=o||!1,e.attr("data-gs-locked",i.locked?"yes":null))}),this},i.prototype.maxHeight=function(t,o){return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(isNaN(o)||(i.maxHeight=o||!1,e.attr("data-gs-max-height",o)))}),this},i.prototype.minHeight=function(t,o){return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(isNaN(o)||(i.minHeight=o||!1,e.attr("data-gs-min-height",o)))}),this},i.prototype.maxWidth=function(t,o){return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(isNaN(o)||(i.maxWidth=o||!1,e.attr("data-gs-max-width",o)))}),this},i.prototype.minWidth=function(t,o){return(t=m(t)).each(function(t,e){var i=(e=m(e)).data("_gridstack_node");i&&(isNaN(o)||(i.minWidth=o||!1,e.attr("data-gs-min-width",o)))}),this},i.prototype._updateElement=function(t,e){var i=(t=m(t).first()).data("_gridstack_node");if(i){var o=this;o.grid.cleanNodes(),o.grid.beginUpdate(i),e.call(this,t,i),o._updateContainerHeight(),o._triggerChangeEvent(),o.grid.endUpdate()}},i.prototype.resize=function(t,i,o){this._updateElement(t,function(t,e){i=null!=i?i:e.width,o=null!=o?o:e.height,this.grid.moveNode(e,e.x,e.y,i,o)})},i.prototype.move=function(t,i,o){this._updateElement(t,function(t,e){i=null!=i?i:e.x,o=null!=o?o:e.y,this.grid.moveNode(e,i,o,e.width,e.height)})},i.prototype.update=function(t,i,o,a,s){this._updateElement(t,function(t,e){i=null!=i?i:e.x,o=null!=o?o:e.y,a=null!=a?a:e.width,s=null!=s?s:e.height,this.grid.moveNode(e,i,o,a,s)})},i.prototype.compact=function(){if(0!==this.grid.nodes.length){this.batchUpdate(),this.grid._sortNodes();var t=this.grid.nodes;this.grid.nodes=[],t.forEach(function(t){t.noMove||t.locked||(t.autoPosition=!0),this.grid.addNode(t,!1),t._dirty=!0},this),this.commit()}},i.prototype.verticalMargin=function(t,e){if(void 0===t)return this.opts.verticalMargin;var i=f.parseHeight(t);this.opts.verticalMarginUnit===i.unit&&this.opts.maxRow===i.height||(this.opts.verticalMarginUnit=i.unit,this.opts.verticalMargin=i.height,e||this._updateStyles())},i.prototype.cellHeight=function(t,e){if(void 0===t){if(this.opts.cellHeight&&"auto"!==this.opts.cellHeight)return this.opts.cellHeight;var i=this.container.children("."+this.opts.itemClass).first(),o=i.attr("data-gs-height"),a=this.opts.verticalMargin;return Math.round((i.outerHeight()-(o-1)*a)/o)}var s=f.parseHeight(t);this.opts.cellHeightUnit===s.unit&&this.opts.cellHeight===s.height||(this.opts.cellHeightUnit=s.unit,this.opts.cellHeight=s.height,e||this._updateStyles())},i.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.column)},i.prototype.getCellFromPixel=function(t,e){var i=void 0!==e&&e?this.container.offset():this.container.position(),o=t.left-i.left,a=t.top-i.top,s=Math.floor(this.container.width()/this.opts.column),r=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(o/s),y:Math.floor(a/r)}},i.prototype.batchUpdate=function(){this.grid.batchUpdate()},i.prototype.commit=function(){this.grid.commit(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()},i.prototype.isAreaEmpty=function(t,e,i,o){return this.grid.isAreaEmpty(t,e,i,o)},i.prototype.setStatic=function(t){this.opts.staticGrid=!0===t,this.enableMove(!t),this.enableResize(!t),this._setStaticClass()},i.prototype._setStaticClass=function(){var t="grid-stack-static";!0===this.opts.staticGrid?this.container.addClass(t):this.container.removeClass(t)},l.prototype._layoutsNodesChange=function(t){this._layouts&&!this._ignoreLayoutsNodeChange&&this._layouts.forEach(function(o,a){o&&a!==this.column&&(a<this.column?this._layouts[a]=void 0:t.forEach(function(e){var t=o.find(function(t){return t._id===e._id});if(t){var i=a/this.column;e.y!==e._origY&&(t.y+=e.y-e._origY),e.x!==e._origX&&(t.x=Math.round(e.x*i)),e.width!==e._origW&&(t.width=Math.round(e.width*i))}},this))},this)},l.prototype._updateNodeWidths=function(e,i,o){if(this.nodes.length&&e!==i){var a=[this.nodes.length];if(this.nodes.forEach(function(t,e){a[e]={x:t.x,y:t.y,width:t.width,_id:t._id}}),this._layouts=this._layouts||[],this._layouts[e]=a,1===i&&o&&o.length){var s=0;o.forEach(function(t){t.x=0,t.width=1,t.y=Math.max(t.y,s),s=t.y+t.height})}else o=f.sort(this.nodes,-1,e);var t=this._layouts[i]||[],r=this._layouts.length-1;0===t.length&&e<i&&i<r&&(t=this._layouts[r]||[]).length&&(e=r,t.forEach(function(e){var t=o.findIndex(function(t){return t&&t._id===e._id});-1!==t&&(o[t].x=e.x,o[t].y=e.y,o[t].width=e.width)}),t=[]);var n=[];t.forEach(function(e){var t=o.findIndex(function(t){return t&&t._id===e._id});-1!==t&&(o[t].x=e.x,o[t].y=e.y,o[t].width=e.width,n.push(o[t]),o[t]=null)});var d=i/e;o.forEach(function(t){t&&(t.x=1===i?0:Math.round(t.x*d),t.width=1===i||1===e?1:Math.round(t.width*d)||1,n.push(t))}),n=f.sort(n,-1,i),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(),this.nodes=[],n.forEach(function(t){this.addNode(t,!1),t._dirty=!0},this),this.commit(),delete this._ignoreLayoutsNodeChange}},l.prototype._saveInitial=function(){this.nodes.forEach(function(t){t._origX=t.x,t._origY=t.y,t._origW=t.width,t._origH=t.height,delete t._dirty})},i.prototype.setColumn=function(t,e){if(this.opts.column!==t){var o,i=this.opts.column;if(1===t?this._prevColumn=i:delete this._prevColumn,this.container.removeClass("grid-stack-"+i),this.container.addClass("grid-stack-"+t),this.opts.column=this.grid.column=t,!0!==e)this.opts.oneColumnModeDomSort&&1===t&&(o=[],this.container.children("."+this.opts.itemClass).each(function(t,e){var i=m(e).data("_gridstack_node");i&&o.push(i)}),o.length||(o=void 0)),this.grid._updateNodeWidths(i,t,o),this.grid._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this.grid._ignoreLayoutsNodeChange}},i.prototype.float=function(t){if(void 0===t)return this.opts.float||!1;this.opts.float!==t&&(this.opts.float=this.grid.float=t||!1,t||(this.grid._packNodes(),this.grid._notify(),this._triggerChangeEvent()))},i.prototype.setGridWidth=(o="setGridWidth",a="setColumn",r="v0.5.3",g.prototype=(e=i.prototype.setColumn).prototype,g),t.GridStackUI=i,t.GridStackUI.Utils=f,t.GridStackUI.Engine=l,t.GridStackUI.GridStackDragDropPlugin=h,m.fn.gridstack=function(e){return this.each(function(){var t=m(this);t.data("gridstack")||t.data("gridstack",new i(this,e))})},t.GridStackUI});
//# sourceMappingURL=gridstack.min.map