<commit_before>/*
 * angular-gridster
 * http://manifestwebdesign.github.io/angular-gridster
 *
 * @version: 0.9.8
 * @license: MIT
 */
"use strict";angular.module("gridster",[]).constant("gridsterConfig",{columns:6,width:"auto",colWidth:"auto",rowHeight:"match",margins:[10,10],isMobile:!1,minColumns:1,minRows:1,maxRows:100,defaultSizeX:2,defaultSizeY:1,mobileBreakPoint:600,resizable:{enabled:!0},draggable:{enabled:!0}}).controller("GridsterCtrl",["gridsterConfig",function(a){this.options=angular.extend({},a),this.grid=[],this.$preview=null,this.$element=null,this.init=function(a,b){this.$element=a,this.$preview=b},this.destroy=function(){this.options=this.options.margins=this.grid=this.$element=this.$preview=null},this.setOptions=function(a){angular.extend(this.options,a),this.options.curWidth="auto"===this.options.width?this.$element.width():this.options.width,this.options.curColWidth="auto"===this.options.colWidth?(this.options.curWidth-this.options.margins[1])/this.options.columns:this.options.colWidth,this.options.curRowHeight="match"===this.options.rowHeight?this.options.curColWidth:this.options.rowHeight},this.redraw=function(){this.setOptions(),this.options.isMobile=this.options.curWidth<=this.options.mobileBreakPoint;for(var a=0,b=this.grid.length;b>a;++a){var c=this.grid[a];if(c)for(var d=0,e=c.length;e>d;++d)if(c[d]){var f=c[d],g=f.$element;this.setElementPosition(g,f.row,f.col),this.setElementSizeY(g,f.sizeY),this.setElementSizeX(g,f.sizeX)}}},this.canItemOccupy=function(a,b,c){return b>-1&&c>-1&&a.sizeX+c<=this.options.columns},this.autoSetItemPosition=function(a){for(var b=0;b<this.options.maxRows;++b)for(var c=0;c<this.options.columns;++c)if(!this.getItem(b,c)&&this.canItemOccupy(a,b,c))return this.putItem(a,b,c),void 0;throw new Error("Unable to place item!")},this.getItems=function(a,b,c,d,e){var f=[];c&&d||(c=d=1),!e||e instanceof Array||(e=[e]);for(var g=0;d>g;++g)for(var h=0;c>h;++h){var i=this.getItem(a+g,b+h,e);!i||e&&-1!==e.indexOf(i)||-1!==f.indexOf(i)||f.push(i)}return f},this.removeItem=function(a){for(var b=0,c=this.grid.length;c>b;++b){var d=this.grid[b];if(d){var e=d.indexOf(a);if(-1!==e){d[e]=null;break}}}this.floatItemsUp(),this.updateHeight()},this.getItem=function(a,b,c){!c||c instanceof Array||(c=[c]);for(var d=1;a>-1;){for(var e=1,f=b;f>-1;){var g=this.grid[a];if(g){var h=g[f];if(h&&(!c||-1===c.indexOf(h))&&h.sizeX>=e&&h.sizeY>=d)return h}++e,--f}--a,++d}return null},this.putItems=function(a){for(var b=0,c=a.length;c>b;++b)this.putItem(a[b])},this.putItem=function(a,b,c){if(("undefined"==typeof b||null===b)&&(b=a.row,c=a.col,"undefined"==typeof b||null===b))return this.autoSetItemPosition(a),void 0;if(this.canItemOccupy(a,b,c)||(c=Math.min(this.options.columns-a.sizeX,Math.max(0,c)),b=Math.max(0,b)),a&&null!==a.oldRow&&"undefined"!=typeof a.oldRow){if(a.oldRow===b&&a.oldColumn===c)return a.row=b,a.col=c,void 0;var d=this.grid[a.oldRow];d&&d[a.oldColumn]===a&&delete d[a.oldColumn]}a.oldRow=a.row=b,a.oldColumn=a.col=c,this.moveOverlappingItems(a),this.grid[b]||(this.grid[b]=[]),this.grid[b][c]=a},this.moveOverlappingItems=function(a){var b=this.getItems(a.row,a.col,a.sizeX,a.sizeY,a);this.moveItemsDown(b,a.row+a.sizeY)},this.moveItemsDown=function(a,b){if(a&&0!==a.length){var c,d,e,f={};for(d=0,e=a.length;e>d;++d){c=a[d];var g=f[c.col];("undefined"==typeof g||c.row<g)&&(f[c.col]=c.row)}for(d=0,e=a.length;e>d;++d){c=a[d];var h=b-f[c.col];this.putItem(c,c.row+h,c.col)}}},this.floatItemsUp=function(){for(var a=0,b=this.grid.length;b>a;++a){var c=this.grid[a];if(c)for(var d=0,e=c.length;e>d;++d)c[d]&&this.floatItemUp(c[d])}},this.floatItemUp=function(a){for(var b=a.col,c=a.sizeY,d=a.sizeX,e=null,f=null,g=a.row-1;g>-1;){var h=this.getItems(g,b,d,c,a);if(0!==h.length)break;e=g,f=b,--g}null!==e&&this.putItem(a,e,f)},this.updateHeight=function(a){var b=this.options.minRows;a||(a=0);for(var c=this.grid.length;c>=0;--c){var d=this.grid[c];if(d)for(var e=0,f=d.length;f>e;++e)d[e]&&(b=Math.max(b,c+a+d[e].sizeY))}this.options.gridHeight=Math.min(this.options.maxRows,b)},this.pixelsToRows=function(a,b){return b===!0?Math.ceil(a/this.options.curRowHeight):b===!1?Math.floor(a/this.options.curRowHeight):Math.round(a/this.options.curRowHeight)},this.pixelsToColumns=function(a,b){return b===!0?Math.ceil(a/this.options.curColWidth):b===!1?Math.floor(a/this.options.curColWidth):Math.round(a/this.options.curColWidth)},this.setElementPosition=function(a,b,c){this.options.isMobile?a.css({margin:this.options.margins[0]+"px",top:"auto",left:"auto"}):a.css({margin:0,top:b*this.options.curRowHeight+this.options.margins[0],left:c*this.options.curColWidth+this.options.margins[1]})},this.setElementSizeY=function(a,b){this.options.isMobile?a.css("height","auto"):a.css("height",b*this.options.curRowHeight-this.options.margins[0]+"px")},this.setElementSizeX=function(a,b){this.options.isMobile?a.css("width","auto"):a.css("width",b*this.options.curColWidth-this.options.margins[1]+"px")}}]).directive("gridster",["$timeout","$rootScope","$window",function(a,b,c){return{restrict:"EAC",transclude:!0,replace:!0,template:"<div ng-transclude></div>",controller:"GridsterCtrl",scope:{config:"=?gridster"},compile:function(d){return d.addClass("gridster"),function(d,e,f,g){function h(){var a=e.width();a===l||e.find(".gridster-item-moving").length>0||(l=a,e.removeClass("gridster-loaded"),g.redraw(),k(),"undefined"!=typeof g.options.resizable&&g.options.resizable.enabled&&d.$broadcast("gridster-resized",[a,e.height()]),e.addClass("gridster-loaded"))}function i(){h(),d.$apply()}e.removeClass("gridster-loaded");var j=angular.element('<div class="gridster-item gridster-preview-holder"></div>').appendTo(e);d.config=d.config||{},d.$watch("config",function(a,c){a&&a!==c&&(g.setOptions(a),"undefined"!=typeof a.draggable&&a.draggable.enabled&&b.$broadcast("draggable-changed"),"undefined"!=typeof a.resizable&&a.resizable.enabled&&b.$broadcast("resizable-changed"),g.redraw(),k())},!0);var k=function(){g.$element.css("height",g.options.gridHeight*g.options.curRowHeight+g.options.margins[0]+"px")};d.$watch(function(){return g.options.gridHeight},k),d.$watch(function(){return g.options.isMobile},function(a){a?g.$element.addClass("gridster-mobile"):g.$element.removeClass("gridster-mobile")});var l=e.width();"function"==typeof e.resize&&e.resize(i);var m=angular.element(c);m.on("resize",i),d.$watch(function(){return e.width()},h),d.$on("$destroy",function(){this.$preview.remove(),g.destroy(),m.off("resize",i)}),g.init(e,j),g.setOptions(d.config),g.redraw(),a(function(){g.floatItemsUp(),e.addClass("gridster-loaded")},100)}}}}]).controller("GridsterItemCtrl",function(){this.$element=null,this.gridster=null,this.dragging=!1,this.resizing=!1,this.row=null,this.col=null,this.sizeX=null,this.sizeY=null,this.init=function(a,b){this.$element=a,this.gridster=b,this.sizeX=b.options.defaultSizeX,this.sizeY=b.options.defaultSizeY},this.destroy=function(){this.gridster=null,this.$element=null},this.toJSON=function(){return{row:this.row,col:this.col,sizeY:this.sizeY,sizeX:this.sizeX}},this.setPosition=function(a,b){this.gridster.putItem(this,a,b),this.gridster.floatItemsUp(),this.gridster.updateHeight(this.dragging?this.sizeY:0),this.dragging?this.gridster.setElementPosition(this.gridster.$preview,this.row,this.col):this.gridster.setElementPosition(this.$element,this.row,this.col)},this.setSize=function(a,b){a=a.toUpperCase();var c="size"+a,d="Size"+a;if(""!==b){b=parseInt(b,10),(isNaN(b)||0===b)&&(b=this.gridster.options["default"+d]);var e=!(this[c]===b&&this["old"+d]&&this["old"+d]===b);this["old"+d]=this[c]=b,this.resizing?(this.gridster.setElementPosition(this.gridster.$preview,this.row,this.col),this.gridster["setElement"+d](this.gridster.$preview,b)):this.gridster["setElement"+d](this.$element,b),e&&(this.gridster.moveOverlappingItems(this),this.gridster.floatItemsUp(),this.gridster.updateHeight(this.dragging?this.sizeY:0))}},this.setSizeY=function(a){this.setSize("y",a)},this.setSizeX=function(a){this.setSize("x",a)}}).directive("gridsterItem",["$parse","$controller","$timeout",function(a,b,c){return{restrict:"EAC",require:"^gridster",link:function(d,e,f,g){function h(){if(o)if("undefined"!=typeof g.options.draggable&&g.options.draggable.enabled)e.draggable({handle:g.options.draggable&&g.options.draggable.handle?g.options.draggable.handle:null,refreshPositions:!0,start:function(a,b){e.addClass("gridster-item-moving"),n.dragging=!0,g.$preview.show(),g.setElementSizeX(g.$preview,n.sizeX),g.setElementSizeY(g.$preview,n.sizeY),g.setElementPosition(g.$preview,n.row,n.col),g.updateHeight(n.sizeY),d.$apply(function(){g.options.draggable&&g.options.draggable.start&&g.options.draggable.start(a,b,e)})},drag:function(a,b){n.row=g.pixelsToRows(b.position.top),n.col=g.pixelsToColumns(b.position.left),d.$apply(function(){g.options.draggable&&g.options.draggable.drag&&g.options.draggable.drag(a,b,e)})},stop:function(a,b){e.removeClass("gridster-item-moving"),n.row=g.pixelsToRows(b.position.top),n.col=g.pixelsToColumns(b.position.left),n.dragging=!1,g.$preview.hide(),n.setPosition(n.row,n.col),g.updateHeight(),d.$apply(function(){g.options.draggable&&g.options.draggable.stop&&g.options.draggable.stop(a,b,e)})}});else try{e.draggable("destroy")}catch(a){}}function i(a){p&&a&&(e.resizable("option","minHeight",g.options.minRows*g.options.curRowHeight-g.options.margins[0]),e.resizable("option","maxHeight",g.options.maxRows*g.options.curRowHeight-g.options.margins[0]),e.resizable("option","minWidth",g.options.minColumns*g.options.curColWidth-g.options.margins[1]),e.resizable("option","maxWidth",g.options.columns*g.options.curColWidth-g.options.margins[1]))}function j(){if(p)if("undefined"!=typeof g.options.resizable&&g.options.resizable.enabled)e.resizable({autoHide:!0,handles:"n, e, s, w, ne, se, sw, nw",minHeight:g.options.minRows*g.options.curRowHeight-g.options.margins[0],maxHeight:g.options.maxRows*g.options.curRowHeight-g.options.margins[0],minWidth:g.options.minColumns*g.options.curColWidth-g.options.margins[1],maxWidth:g.options.columns*g.options.curColWidth-g.options.margins[1],start:function(a,b){e.addClass("gridster-item-moving"),n.resizing=!0,n.dragging=!0,g.$preview.fadeIn(300),g.setElementSizeX(g.$preview,n.sizeX),g.setElementSizeY(g.$preview,n.sizeY),d.$apply(function(){g.options.resizable&&g.options.resizable.start&&g.options.resizable.start(a,b,e)})},resize:function(a,b){n.row=g.pixelsToRows(b.position.top,!1),n.col=g.pixelsToColumns(b.position.left,!1),n.sizeX=g.pixelsToColumns(b.size.width,!0),n.sizeY=g.pixelsToRows(b.size.height,!0),d.$apply(function(){g.options.resizable&&g.options.resizable.resize&&g.options.resizable.resize(a,b,e)})},stop:function(a,b){e.removeClass("gridster-item-moving"),n.row=g.pixelsToRows(b.position.top,!1),n.col=g.pixelsToColumns(b.position.left,!1),n.sizeX=g.pixelsToColumns(b.size.width,!0),n.sizeY=g.pixelsToRows(b.size.height,!0),n.resizing=!1,n.dragging=!1,g.$preview.fadeOut(300),n.setPosition(n.row,n.col),n.setSizeY(n.sizeY),n.setSizeX(n.sizeX),d.$apply(function(){g.options.resizable&&g.options.resizable.stop&&g.options.resizable.stop(a,b,e)})}});else try{e.resizable("destroy")}catch(a){}}function k(){n.setPosition(n.row,n.col),s.row&&s.row.assign&&s.row.assign(d,n.row),s.col&&s.col.assign&&s.col.assign(d,n.col)}var l,m=f.gridsterItem,n=b("GridsterItemCtrl"),o="function"==typeof e.draggable,p="function"==typeof e.resizable;if(m){var q=a(m);l=q(d)||{},!l&&q.assign&&(l={row:n.row,col:n.col,sizeX:n.sizeX,sizeY:n.sizeY},q.assign(d,l))}else l=f;n.init(e,g),e.addClass("gridster-item"),e.addClass("gridster-item-moving");for(var r=["sizeX","sizeY","row","col"],s={},t=function(b){var c;if("string"==typeof l[b])c=l[b];else if("string"==typeof l[b.toLowerCase()])c=l[b.toLowerCase()];else{if(!m)return;c=a(m+"."+b)}s[b]=a(c),d.$watch(c,function(a){a=parseInt(a,10),isNaN(a)||(n[b]=a)});var e=s[b](d);"number"==typeof e&&(n[b]=e)},u=0,v=r.length;v>u;++u)t(r[u]);return d.$watch(function(){return n.row},k),d.$watch(function(){return n.col},k),d.$on("draggable-changed",h),d.$on("resizable-changed",j),d.$on("gridster-resized",i),h(),j(),d.$watch(function(){return n.sizeY},function(a){n.setSizeY(a),s.sizeY&&s.sizeY.assign&&s.sizeY.assign(d,n.sizeY)}),d.$watch(function(){return n.sizeX},function(a){n.setSizeX(a),s.sizeX&&s.sizeX.assign&&s.sizeX.assign(d,n.sizeX)}),c(function(){e.removeClass("gridster-item-moving")},100),d.$on("$destroy",function(){try{g.removeItem(n)}catch(a){}try{n.destroy()}catch(a){}try{e.draggable("destroy")}catch(a){}try{e.resizable("destroy")}catch(a){}})}}}]);<commit_msg>new build<commit_after>/*
 * angular-gridster
 * http://manifestwebdesign.github.io/angular-gridster
 *
 * @version: 0.9.8
 * @license: MIT
 */
"use strict";angular.module("gridster",[]).constant("gridsterConfig",{columns:6,width:"auto",colWidth:"auto",rowHeight:"match",margins:[10,10],isMobile:!1,minColumns:1,minRows:1,maxRows:100,defaultSizeX:2,defaultSizeY:1,mobileBreakPoint:600,resizable:{enabled:!0},draggable:{enabled:!0}}).controller("GridsterCtrl",["gridsterConfig",function(a){this.options=angular.extend({},a),this.grid=[],this.$preview=null,this.$element=null,this.init=function(a,b){this.$element=a,this.$preview=b},this.destroy=function(){this.options=this.options.margins=this.grid=this.$element=this.$preview=null},this.setOptions=function(a){angular.extend(this.options,a),this.options.curWidth="auto"===this.options.width?this.$element.width():this.options.width,this.options.curColWidth="auto"===this.options.colWidth?(this.options.curWidth-this.options.margins[1])/this.options.columns:this.options.colWidth,this.options.curRowHeight="match"===this.options.rowHeight?this.options.curColWidth:this.options.rowHeight},this.redraw=function(){this.setOptions(),this.options.isMobile=this.options.curWidth<=this.options.mobileBreakPoint;for(var a=0,b=this.grid.length;b>a;++a){var c=this.grid[a];if(c)for(var d=0,e=c.length;e>d;++d)if(c[d]){var f=c[d],g=f.$element;this.setElementPosition(g,f.row,f.col),this.setElementSizeY(g,f.sizeY),this.setElementSizeX(g,f.sizeX)}}},this.canItemOccupy=function(a,b,c){return b>-1&&c>-1&&a.sizeX+c<=this.options.columns},this.autoSetItemPosition=function(a){for(var b=0;b<this.options.maxRows;++b)for(var c=0;c<this.options.columns;++c)if(!this.getItem(b,c)&&this.canItemOccupy(a,b,c))return this.putItem(a,b,c),void 0;throw new Error("Unable to place item!")},this.getItems=function(a,b,c,d,e){var f=[];c&&d||(c=d=1),!e||e instanceof Array||(e=[e]);for(var g=0;d>g;++g)for(var h=0;c>h;++h){var i=this.getItem(a+g,b+h,e);!i||e&&-1!==e.indexOf(i)||-1!==f.indexOf(i)||f.push(i)}return f},this.removeItem=function(a){for(var b=0,c=this.grid.length;c>b;++b){var d=this.grid[b];if(d){var e=d.indexOf(a);if(-1!==e){d[e]=null;break}}}this.floatItemsUp(),this.updateHeight()},this.getItem=function(a,b,c){!c||c instanceof Array||(c=[c]);for(var d=1;a>-1;){for(var e=1,f=b;f>-1;){var g=this.grid[a];if(g){var h=g[f];if(h&&(!c||-1===c.indexOf(h))&&h.sizeX>=e&&h.sizeY>=d)return h}++e,--f}--a,++d}return null},this.putItems=function(a){for(var b=0,c=a.length;c>b;++b)this.putItem(a[b])},this.putItem=function(a,b,c){if(("undefined"==typeof b||null===b)&&(b=a.row,c=a.col,"undefined"==typeof b||null===b))return this.autoSetItemPosition(a),void 0;if(this.canItemOccupy(a,b,c)||(c=Math.min(this.options.columns-a.sizeX,Math.max(0,c)),b=Math.max(0,b)),a&&null!==a.oldRow&&"undefined"!=typeof a.oldRow){if(a.oldRow===b&&a.oldColumn===c)return a.row=b,a.col=c,void 0;var d=this.grid[a.oldRow];d&&d[a.oldColumn]===a&&delete d[a.oldColumn]}a.oldRow=a.row=b,a.oldColumn=a.col=c,this.moveOverlappingItems(a),this.grid[b]||(this.grid[b]=[]),this.grid[b][c]=a},this.moveOverlappingItems=function(a){var b=this.getItems(a.row,a.col,a.sizeX,a.sizeY,a);this.moveItemsDown(b,a.row+a.sizeY)},this.moveItemsDown=function(a,b){if(a&&0!==a.length){var c,d,e,f={};for(d=0,e=a.length;e>d;++d){c=a[d];var g=f[c.col];("undefined"==typeof g||c.row<g)&&(f[c.col]=c.row)}for(d=0,e=a.length;e>d;++d){c=a[d];var h=b-f[c.col];this.putItem(c,c.row+h,c.col)}}},this.floatItemsUp=function(){for(var a=0,b=this.grid.length;b>a;++a){var c=this.grid[a];if(c)for(var d=0,e=c.length;e>d;++d)c[d]&&this.floatItemUp(c[d])}},this.floatItemUp=function(a){for(var b=a.col,c=a.sizeY,d=a.sizeX,e=null,f=null,g=a.row-1;g>-1;){var h=this.getItems(g,b,d,c,a);if(0!==h.length)break;e=g,f=b,--g}null!==e&&this.putItem(a,e,f)},this.updateHeight=function(a){var b=this.options.minRows;a||(a=0);for(var c=this.grid.length;c>=0;--c){var d=this.grid[c];if(d)for(var e=0,f=d.length;f>e;++e)d[e]&&(b=Math.max(b,c+a+d[e].sizeY))}this.options.gridHeight=Math.min(this.options.maxRows,b)},this.pixelsToRows=function(a,b){return b===!0?Math.ceil(a/this.options.curRowHeight):b===!1?Math.floor(a/this.options.curRowHeight):Math.round(a/this.options.curRowHeight)},this.pixelsToColumns=function(a,b){return b===!0?Math.ceil(a/this.options.curColWidth):b===!1?Math.floor(a/this.options.curColWidth):Math.round(a/this.options.curColWidth)},this.setElementPosition=function(a,b,c){this.options.isMobile?a.css({margin:this.options.margins[0]+"px",top:"auto",left:"auto"}):a.css({margin:0,top:b*this.options.curRowHeight+this.options.margins[0],left:c*this.options.curColWidth+this.options.margins[1]})},this.setElementSizeY=function(a,b){this.options.isMobile?a.css("height","auto"):a.css("height",b*this.options.curRowHeight-this.options.margins[0]+"px")},this.setElementSizeX=function(a,b){this.options.isMobile?a.css("width","auto"):a.css("width",b*this.options.curColWidth-this.options.margins[1]+"px")}}]).directive("gridster",["$timeout","$rootScope","$window",function(a,b,c){return{restrict:"EAC",transclude:!0,replace:!0,template:"<div ng-transclude></div>",controller:"GridsterCtrl",scope:{config:"=?gridster"},compile:function(d){return d.addClass("gridster"),function(d,e,f,g){function h(){var a=e.width();a===l||e.find(".gridster-item-moving").length>0||(l=a,e.removeClass("gridster-loaded"),g.redraw(),k(),"undefined"!=typeof g.options.resizable&&g.options.resizable.enabled&&d.$broadcast("gridster-resized",[a,e.height()]),e.addClass("gridster-loaded"))}function i(){h(),d.$apply()}e.removeClass("gridster-loaded");var j=angular.element('<div class="gridster-item gridster-preview-holder"></div>').appendTo(e);d.config=d.config||{},d.$watch("config",function(a,b){a&&a!==b&&(g.setOptions(a),g.redraw(),k())},!0),d.$watch("config.draggable",function(){b.$broadcast("draggable-changed")},!0),d.$watch("config.resizable",function(){b.$broadcast("resizable-changed")},!0);var k=function(){g.$element.css("height",g.options.gridHeight*g.options.curRowHeight+g.options.margins[0]+"px")};d.$watch(function(){return g.options.gridHeight},k),d.$watch(function(){return g.options.isMobile},function(a){a?g.$element.addClass("gridster-mobile"):g.$element.removeClass("gridster-mobile")});var l=e.width();"function"==typeof e.resize&&e.resize(i);var m=angular.element(c);m.on("resize",i),d.$watch(function(){return e.width()},h),d.$on("$destroy",function(){this.$preview.remove(),g.destroy(),m.off("resize",i)}),g.init(e,j),g.setOptions(d.config),g.redraw(),a(function(){g.floatItemsUp(),e.addClass("gridster-loaded")},100)}}}}]).controller("GridsterItemCtrl",function(){this.$element=null,this.gridster=null,this.dragging=!1,this.resizing=!1,this.row=null,this.col=null,this.sizeX=null,this.sizeY=null,this.init=function(a,b){this.$element=a,this.gridster=b,this.sizeX=b.options.defaultSizeX,this.sizeY=b.options.defaultSizeY},this.destroy=function(){this.gridster=null,this.$element=null},this.toJSON=function(){return{row:this.row,col:this.col,sizeY:this.sizeY,sizeX:this.sizeX}},this.setPosition=function(a,b){this.gridster.putItem(this,a,b),this.gridster.$element.hasClass("gridster-loaded")&&this.gridster.floatItemsUp(),this.gridster.updateHeight(this.dragging?this.sizeY:0),this.dragging?this.gridster.setElementPosition(this.gridster.$preview,this.row,this.col):this.gridster.setElementPosition(this.$element,this.row,this.col)},this.setSize=function(a,b){a=a.toUpperCase();var c="size"+a,d="Size"+a;if(""!==b){b=parseInt(b,10),(isNaN(b)||0===b)&&(b=this.gridster.options["default"+d]);var e=!(this[c]===b&&this["old"+d]&&this["old"+d]===b);this["old"+d]=this[c]=b,this.resizing?(this.gridster.setElementPosition(this.gridster.$preview,this.row,this.col),this.gridster["setElement"+d](this.gridster.$preview,b)):this.gridster["setElement"+d](this.$element,b),e&&(this.gridster.moveOverlappingItems(this),this.gridster.floatItemsUp(),this.gridster.updateHeight(this.dragging?this.sizeY:0))}},this.setSizeY=function(a){this.setSize("y",a)},this.setSizeX=function(a){this.setSize("x",a)}}).directive("gridsterItem",["$parse","$controller","$timeout",function(a,b,c){return{restrict:"EAC",require:"^gridster",link:function(d,e,f,g){function h(){if(o)if("undefined"!=typeof g.options.draggable&&g.options.draggable.enabled)e.draggable({handle:g.options.draggable&&g.options.draggable.handle?g.options.draggable.handle:null,refreshPositions:!0,start:function(a,b){e.addClass("gridster-item-moving"),n.dragging=!0,g.$preview.show(),g.setElementSizeX(g.$preview,n.sizeX),g.setElementSizeY(g.$preview,n.sizeY),g.setElementPosition(g.$preview,n.row,n.col),g.updateHeight(n.sizeY),d.$apply(function(){g.options.draggable&&g.options.draggable.start&&g.options.draggable.start(a,b,e)})},drag:function(a,b){n.row=g.pixelsToRows(b.position.top),n.col=g.pixelsToColumns(b.position.left),d.$apply(function(){g.options.draggable&&g.options.draggable.drag&&g.options.draggable.drag(a,b,e)})},stop:function(a,b){e.removeClass("gridster-item-moving"),n.row=g.pixelsToRows(b.position.top),n.col=g.pixelsToColumns(b.position.left),n.dragging=!1,g.$preview.hide(),n.setPosition(n.row,n.col),g.updateHeight(),d.$apply(function(){g.options.draggable&&g.options.draggable.stop&&g.options.draggable.stop(a,b,e)})}});else try{e.draggable("destroy")}catch(a){}}function i(a){p&&a&&(e.resizable("option","minHeight",g.options.minRows*g.options.curRowHeight-g.options.margins[0]),e.resizable("option","maxHeight",g.options.maxRows*g.options.curRowHeight-g.options.margins[0]),e.resizable("option","minWidth",g.options.minColumns*g.options.curColWidth-g.options.margins[1]),e.resizable("option","maxWidth",g.options.columns*g.options.curColWidth-g.options.margins[1]))}function j(){if(p)if("undefined"!=typeof g.options.resizable&&g.options.resizable.enabled)e.resizable({autoHide:!0,handles:"n, e, s, w, ne, se, sw, nw",minHeight:g.options.minRows*g.options.curRowHeight-g.options.margins[0],maxHeight:g.options.maxRows*g.options.curRowHeight-g.options.margins[0],minWidth:g.options.minColumns*g.options.curColWidth-g.options.margins[1],maxWidth:g.options.columns*g.options.curColWidth-g.options.margins[1],start:function(a,b){e.addClass("gridster-item-moving"),n.resizing=!0,n.dragging=!0,g.$preview.fadeIn(300),g.setElementSizeX(g.$preview,n.sizeX),g.setElementSizeY(g.$preview,n.sizeY),d.$apply(function(){g.options.resizable&&g.options.resizable.start&&g.options.resizable.start(a,b,e)})},resize:function(a,b){n.row=g.pixelsToRows(b.position.top,!1),n.col=g.pixelsToColumns(b.position.left,!1),n.sizeX=g.pixelsToColumns(b.size.width,!0),n.sizeY=g.pixelsToRows(b.size.height,!0),d.$apply(function(){g.options.resizable&&g.options.resizable.resize&&g.options.resizable.resize(a,b,e)})},stop:function(a,b){e.removeClass("gridster-item-moving"),n.row=g.pixelsToRows(b.position.top,!1),n.col=g.pixelsToColumns(b.position.left,!1),n.sizeX=g.pixelsToColumns(b.size.width,!0),n.sizeY=g.pixelsToRows(b.size.height,!0),n.resizing=!1,n.dragging=!1,g.$preview.fadeOut(300),n.setPosition(n.row,n.col),n.setSizeY(n.sizeY),n.setSizeX(n.sizeX),d.$apply(function(){g.options.resizable&&g.options.resizable.stop&&g.options.resizable.stop(a,b,e)})}});else try{e.resizable("destroy")}catch(a){}}function k(){n.setPosition(n.row,n.col),s.row&&s.row.assign&&s.row.assign(d,n.row),s.col&&s.col.assign&&s.col.assign(d,n.col)}var l,m=f.gridsterItem,n=b("GridsterItemCtrl"),o="function"==typeof e.draggable,p="function"==typeof e.resizable;if(m){var q=a(m);l=q(d)||{},!l&&q.assign&&(l={row:n.row,col:n.col,sizeX:n.sizeX,sizeY:n.sizeY},q.assign(d,l))}else l=f;n.init(e,g),e.addClass("gridster-item"),e.addClass("gridster-item-moving");for(var r=["sizeX","sizeY","row","col"],s={},t=function(b){var c;if("string"==typeof l[b])c=l[b];else if("string"==typeof l[b.toLowerCase()])c=l[b.toLowerCase()];else{if(!m)return;c=a(m+"."+b)}s[b]=a(c),d.$watch(c,function(a){a=parseInt(a,10),isNaN(a)||(n[b]=a)});var e=s[b](d);"number"==typeof e&&(n[b]=e)},u=0,v=r.length;v>u;++u)t(r[u]);return d.$watch(function(){return n.row},k),d.$watch(function(){return n.col},k),d.$on("draggable-changed",h),d.$on("resizable-changed",j),d.$on("gridster-resized",i),h(),j(),d.$watch(function(){return n.sizeY},function(a){n.setSizeY(a),s.sizeY&&s.sizeY.assign&&s.sizeY.assign(d,n.sizeY)}),d.$watch(function(){return n.sizeX},function(a){n.setSizeX(a),s.sizeX&&s.sizeX.assign&&s.sizeX.assign(d,n.sizeX)}),c(function(){e.removeClass("gridster-item-moving")},100),d.$on("$destroy",function(){try{g.removeItem(n)}catch(a){}try{n.destroy()}catch(a){}try{e.draggable("destroy")}catch(a){}try{e.resizable("destroy")}catch(a){}})}}}]);
{'fraction_non_alphanumeric': 0.26204246553636507, 'fraction_numerical': 0.009427982887022658, 'mean_word_length': 13.409246575342467, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5143641', 'n_tokens_mistral': 10421, 'n_tokens_neox': 10370, 'n_words': 236}