From 93c46ff45ebe59f3658b7f32f05b67109aa87311 Mon Sep 17 00:00:00 2001 From: David Small Date: Thu, 10 Apr 2014 16:22:43 -0400 Subject: [PATCH] fix(gridster): Removing previously added style tags before adding new one. Hopefully fixes #211 and #294. --- dist/jquery.gridster.js | 2 ++ dist/jquery.gridster.min.js | 3 +-- src/jquery.gridster.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/jquery.gridster.js diff --git a/dist/jquery.gridster.js b/dist/jquery.gridster.js index 30d7fbb7..461133f8 100644 --- a/dist/jquery.gridster.js +++ b/dist/jquery.gridster.js @@ -3592,6 +3592,8 @@ (x * opts.widget_base_dimensions[0] + (x - 1) * (opts.widget_margins[0] * 2)) + 'px; }\n'); } + + this.remove_style_tags(); return this.add_style_tag(styles); }; diff --git a/dist/jquery.gridster.min.js b/dist/jquery.gridster.min.js index a2d19627..710d9b38 100644 --- a/dist/jquery.gridster.min.js +++ b/dist/jquery.gridster.min.js @@ -1,2 +1 @@ -/*! gridster.js - v0.5.1 - 2014-03-26 - * http://gridster.net/ - Copyright (c) 2014 ducksboard; Licensed MIT */ (function(t){function i(i){return i[0]&&t.isPlainObject(i[0])?this.data=i[0]:this.el=i,this.isCoords=!0,this.coords={},this.init(),this}var e=i.prototype;e.init=function(){this.set(),this.original_coords=this.get()},e.set=function(t,i){var e=this.el;if(e&&!t&&(this.data=e.offset(),this.data.width=e.width(),this.data.height=e.height()),e&&t&&!i){var s=e.offset();this.data.top=s.top,this.data.left=s.left}var r=this.data;return r.left===undefined&&(r.left=r.x1),r.top===undefined&&(r.top=r.y1),this.coords.x1=r.left,this.coords.y1=r.top,this.coords.x2=r.left+r.width,this.coords.y2=r.top+r.height,this.coords.cx=r.left+r.width/2,this.coords.cy=r.top+r.height/2,this.coords.width=r.width,this.coords.height=r.height,this.coords.el=e||!1,this},e.update=function(i){if(!i&&!this.el)return this;if(i){var e=t.extend({},this.data,i);return this.data=e,this.set(!0,!0)}return this.set(!0),this},e.get=function(){return this.coords},e.destroy=function(){this.el.removeData("coords"),delete this.el},t.fn.coords=function(){if(this.data("coords"))return this.data("coords");var t=new i(this,arguments[0]);return this.data("coords",t),t}})(jQuery,window,document),function(t,i,e){function s(i,e,s){this.options=t.extend(r,s),this.$element=i,this.last_colliders=[],this.last_colliders_coords=[],this.set_colliders(e),this.init()}var r={colliders_context:e.body,overlapping_region:"C"},o=s.prototype;o.init=function(){this.find_collisions()},o.overlaps=function(t,i){var e=!1,s=!1;return(i.x1>=t.x1&&i.x1<=t.x2||i.x2>=t.x1&&i.x2<=t.x2||t.x1>=i.x1&&t.x2<=i.x2)&&(e=!0),(i.y1>=t.y1&&i.y1<=t.y2||i.y2>=t.y1&&i.y2<=t.y2||t.y1>=i.y1&&t.y2<=i.y2)&&(s=!0),e&&s},o.detect_overlapping_region=function(t,i){var e="",s="";return t.y1>i.cy&&t.y1i.y1&&t.y2i.cx&&t.x1i.x1&&t.x2o;o++)-1===t.inArray(r[o],i)&&e.call(this,r[o]);for(var h=0,n=i.length;n>h;h++)-1===t.inArray(i[h],r)&&s.call(this,i[h])},o.find_collisions=function(i){for(var e=this,s=this.options.overlapping_region,r=[],o=[],a=this.colliders||this.$colliders,h=a.length,n=e.$element.coords().update(i||!1).get();h--;){var _=e.$colliders?t(a[h]):a[h],d=_.isCoords?_:_.coords(),l=d.get(),c=e.overlaps(n,l);if(c){var p=e.detect_overlapping_region(n,l);if(p===s||"all"===s){var g=e.calculate_overlapped_area_coords(n,l),u=e.calculate_overlapped_area(g),f={area:u,area_coords:g,region:p,coords:l,player_coords:n,el:_};e.options.on_overlap&&e.options.on_overlap.call(this,f),r.push(d),o.push(f)}}}return(e.options.on_overlap_stop||e.options.on_overlap_start)&&this.manage_colliders_start_stop(r,e.options.on_overlap_start,e.options.on_overlap_stop),this.last_colliders_coords=r,o},o.get_closest_colliders=function(t){var i=this.find_collisions(t);return i.sort(function(t,i){return"C"===t.region&&"C"===i.region?t.coords.y1this.player_max_left?r=this.player_max_left:this.player_min_left>r&&(r=this.player_min_left)),{position:{left:r,top:o},pointer:{left:i.left,top:i.top,diff_left:e+this.scroll_offset_x,diff_top:s+this.scroll_offset_y}}},d.get_drag_data=function(t){var i=this.get_offset(t);return i.$player=this.$player,i.$helper=this.helper?this.$helper:this.$player,i},d.set_limits=function(t){return t||(t=this.$container.width()),this.player_max_left=t-this.player_width+-this.options.offset_left,this.options.container_width=t,this},d.scroll_in=function(i,s){var r,h=a[i],n=50,d=30,l="x"===i,c=l?this.window_width:this.window_height,p=l?t(e).width():t(e).height(),g=l?this.$player.width():this.$player.height(),u=o["scroll"+_(h)](),f=u,w=f+c,m=w-n,y=f+n,v=f+s.pointer[h],z=p-c+g;return v>=m&&(r=u+d,z>r&&(o["scroll"+_(h)](r),this["scroll_offset_"+i]+=d)),y>=v&&(r=u-d,r>0&&(o["scroll"+_(h)](r),this["scroll_offset_"+i]-=d)),this},d.manage_scroll=function(t){this.scroll_in("x",t),this.scroll_in("y",t)},d.calculate_dimensions=function(){this.window_height=o.height(),this.window_width=o.width()},d.drag_handler=function(i){if(i.target.nodeName,!this.disabled&&(1===i.which||h)&&!this.ignore_drag(i)){var e=this,s=!0;return this.$player=t(i.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(i),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$body.on(n.move,function(t){var i=e.get_mouse_pos(t),r=Math.abs(i.left-e.mouse_init_pos.left),o=Math.abs(i.top-e.mouse_init_pos.top);return r>e.options.distance||o>e.options.distance?s?(s=!1,e.on_dragstart.call(e,t),!1):(e.is_dragging===!0&&e.on_dragmove.call(e,t),!1):!1}),h?undefined:!1}},d.on_dragstart=function(t){if(t.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var i=this.$container.offset();return this.baseX=Math.round(i.left),this.baseY=Math.round(i.top),this.initial_container_width=this.options.container_width||this.$container.width(),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_offset_y=0,this.scroll_offset_x=0,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_height=this.$player.height(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,t,this.get_drag_data(t)),!1},d.on_dragmove=function(t){var i=this.get_drag_data(t);this.options.autoscroll&&this.manage_scroll(i),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:i.position.left,top:i.position.top});var e=this.last_position||i.position;return i.prev_position=e,this.options.drag&&this.options.drag.call(this.$player,t,i),this.last_position=i.position,!1},d.on_dragstop=function(t){var i=this.get_drag_data(t);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,t,i),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},d.on_select_start=function(t){return this.disabled||this.ignore_drag(t)?undefined:!1},d.enable=function(){this.disabled=!1},d.disable=function(){this.disabled=!0},d.destroy=function(){this.disable(),this.$container.off(".gridster-draggable"),this.$body.off(".gridster-draggable"),t(i).off(".gridster-draggable"),t.removeData(this.$container,"drag")},d.ignore_drag=function(i){return this.options.handle?!t(i.target).is(this.options.handle):t.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(i):t(i.target).is(this.options.ignore_dragging.join(", "))},t.fn.drag=function(t){return new s(this,t)}}(jQuery,window,document),function(t,i,e){function s(i,e){this.options=t.extend(!0,{},r,e),this.$el=t(i),this.$wrapper=this.$el.parent(),this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w"),this.widgets=[],this.$changed=t([]),this.wrapper_width=this.$wrapper.width(),this.min_widget_width=2*this.options.widget_margins[0]+this.options.widget_base_dimensions[0],this.min_widget_height=2*this.options.widget_margins[1]+this.options.widget_base_dimensions[1],this.generated_stylesheets=[],this.$style_tags=t([]),this.init()}var r={namespace:"",widget_selector:"li",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:1/0,min_rows:15,max_size_x:!1,autogrow_cols:!1,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,serialize_params:function(t,i){return{col:i.col,row:i.row,size_x:i.size_x,size_y:i.size_y}},collision:{},draggable:{items:".gs-w",distance:4},resize:{enabled:!1,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[1/0,1/0],min_size:[1,1]}};s.generated_stylesheets=[];var o=s.prototype;o.init=function(){this.options.resize.enabled&&this.setup_resize(),this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.set_dom_grid_width(),this.$wrapper.addClass("ready"),this.draggable(),this.options.resize.enabled&&this.resizable(),t(i).bind("resize.gridster",throttle(t.proxy(this.recalculate_faux_grid,this),200))},o.disable=function(){return this.$wrapper.find(".player-revert").removeClass("player-revert"),this.drag_api.disable(),this},o.enable=function(){return this.drag_api.enable(),this},o.disable_resize=function(){return this.$el.addClass("gs-resize-disabled"),this.resize_api.disable(),this},o.enable_resize=function(){return this.$el.removeClass("gs-resize-disabled"),this.resize_api.enable(),this},o.add_widget=function(i,e,s,r,o,a,h){var n;e||(e=1),s||(s=1),!r&!o?n=this.next_position(e,s):(n={col:r,row:o},this.empty_cells(r,o,e,s));var _=t(i).attr({"data-col":n.col,"data-row":n.row,"data-sizex":e,"data-sizey":s}).addClass("gs-w").appendTo(this.$el).hide();return this.$widgets=this.$widgets.add(_),this.register_widget(_),this.add_faux_rows(n.size_y),a&&this.set_widget_max_size(_,a),h&&this.set_widget_min_size(_,h),this.set_dom_grid_width(),this.set_dom_grid_height(),this.drag_api.set_limits(this.cols*this.min_widget_width),_.fadeIn()},o.set_widget_min_size=function(t,i){if(t="number"==typeof t?this.$widgets.eq(t):t,!t.length)return this;var e=t.data("coords").grid;return e.min_size_x=i[0],e.min_size_y=i[1],this},o.set_widget_max_size=function(t,i){if(t="number"==typeof t?this.$widgets.eq(t):t,!t.length)return this;var e=t.data("coords").grid;return e.max_size_x=i[0],e.max_size_y=i[1],this},o.add_resize_handle=function(i){var e=this.options.resize.handle_append_to;return t(this.resize_handle_tpl).appendTo(e?t(e,i):i),this},o.resize_widget=function(t,i,e,s){var r=t.coords().grid,o=r.col,a=this.options.max_cols,h=r.size_y,n=r.col,_=n;i||(i=r.size_x),e||(e=r.size_y),1/0!==a&&(i=Math.min(i,a-o+1)),e>h&&this.add_faux_rows(Math.max(e-h,0));var d=o+i-1;d>this.cols&&this.add_faux_cols(d-this.cols);var l={col:_,row:r.row,size_x:i,size_y:e};return this.mutate_widget_in_gridmap(t,r,l),this.set_dom_grid_height(),this.set_dom_grid_width(),s&&s.call(this,l.size_x,l.size_y),t},o.mutate_widget_in_gridmap=function(i,e,s){e.size_x;var r=e.size_y,o=this.get_cells_occupied(e),a=this.get_cells_occupied(s),h=[];t.each(o.cols,function(i,e){-1===t.inArray(e,a.cols)&&h.push(e)});var n=[];t.each(a.cols,function(i,e){-1===t.inArray(e,o.cols)&&n.push(e)});var _=[];t.each(o.rows,function(i,e){-1===t.inArray(e,a.rows)&&_.push(e)});var d=[];if(t.each(a.rows,function(i,e){-1===t.inArray(e,o.rows)&&d.push(e)}),this.remove_from_gridmap(e),n.length){var l=[s.col,s.row,s.size_x,Math.min(r,s.size_y),i];this.empty_cells.apply(this,l)}if(d.length){var c=[s.col,s.row,s.size_x,s.size_y,i];this.empty_cells.apply(this,c)}if(e.col=s.col,e.row=s.row,e.size_x=s.size_x,e.size_y=s.size_y,this.add_to_gridmap(s,i),i.removeClass("player-revert"),i.data("coords").update({width:s.size_x*this.options.widget_base_dimensions[0]+2*(s.size_x-1)*this.options.widget_margins[0],height:s.size_y*this.options.widget_base_dimensions[1]+2*(s.size_y-1)*this.options.widget_margins[1]}),i.attr({"data-col":s.col,"data-row":s.row,"data-sizex":s.size_x,"data-sizey":s.size_y}),h.length){var p=[h[0],s.row,h.length,Math.min(r,s.size_y),i];this.remove_empty_cells.apply(this,p)}if(_.length){var g=[s.col,s.row,s.size_x,s.size_y,i];this.remove_empty_cells.apply(this,g)}return this.move_widget_up(i),this},o.empty_cells=function(i,e,s,r,o){var a=this.widgets_below({col:i,row:e-r,size_x:s,size_y:r});return a.not(o).each(t.proxy(function(i,s){var o=t(s).coords().grid;if(e+r-1>=o.row){var a=e+r-o.row;this.move_widget_down(t(s),a)}},this)),this.set_dom_grid_height(),this},o.remove_empty_cells=function(i,e,s,r,o){var a=this.widgets_below({col:i,row:e,size_x:s,size_y:r});return a.not(o).each(t.proxy(function(i,e){this.move_widget_up(t(e),r)},this)),this.set_dom_grid_height(),this},o.next_position=function(t,i){t||(t=1),i||(i=1);for(var e,s=this.gridmap,r=s.length,o=[],a=1;r>a;a++){e=s[a].length;for(var h=1;e>=h;h++){var n=this.can_move_to({size_x:t,size_y:i},a,h);n&&o.push({col:a,row:h,size_y:i,size_x:t})}}return o.length?this.sort_by_row_and_col_asc(o)[0]:!1},o.remove_widget=function(i,e,s){var r=i instanceof t?i:t(i),o=r.coords().grid;t.isFunction(e)&&(s=e,e=!1),this.cells_occupied_by_placeholder={},this.$widgets=this.$widgets.not(r);var a=this.widgets_below(r);return this.remove_from_gridmap(o),r.fadeOut(t.proxy(function(){r.remove(),e||a.each(t.proxy(function(i,e){this.move_widget_up(t(e),o.size_y)},this)),this.set_dom_grid_height(),s&&s.call(this,i)},this)),this},o.remove_all_widgets=function(i){return this.$widgets.each(t.proxy(function(t,e){this.remove_widget(e,!0,i)},this)),this},o.serialize=function(i){i||(i=this.$widgets);var e=[];return i.each(t.proxy(function(i,s){e.push(this.options.serialize_params(t(s),t(s).coords().grid))},this)),e},o.serialize_changed=function(){return this.serialize(this.$changed)},o.register_widget=function(i){var e={col:parseInt(i.attr("data-col"),10),row:parseInt(i.attr("data-row"),10),size_x:parseInt(i.attr("data-sizex"),10),size_y:parseInt(i.attr("data-sizey"),10),max_size_x:parseInt(i.attr("data-max-sizex"),10)||!1,max_size_y:parseInt(i.attr("data-max-sizey"),10)||!1,min_size_x:parseInt(i.attr("data-min-sizex"),10)||!1,min_size_y:parseInt(i.attr("data-min-sizey"),10)||!1,el:i};return this.options.avoid_overlapped_widgets&&!this.can_move_to({size_x:e.size_x,size_y:e.size_y},e.col,e.row)&&(t.extend(e,this.next_position(e.size_x,e.size_y)),i.attr({"data-col":e.col,"data-row":e.row,"data-sizex":e.size_x,"data-sizey":e.size_y})),i.data("coords",i.coords()),i.data("coords").grid=e,this.add_to_gridmap(e,i),this.options.resize.enabled&&this.add_resize_handle(i),this},o.update_widget_position=function(t,i){return this.for_each_cell_occupied(t,function(t,e){return this.gridmap[t]?(this.gridmap[t][e]=i,undefined):this}),this},o.remove_from_gridmap=function(t){return this.update_widget_position(t,!1)},o.add_to_gridmap=function(i,e){if(this.update_widget_position(i,e||i.el),i.el){var s=this.widgets_below(i.el);s.each(t.proxy(function(i,e){this.move_widget_up(t(e))},this))}},o.draggable=function(){var i=this,e=t.extend(!0,{},this.options.draggable,{offset_left:this.options.widget_margins[0],offset_top:this.options.widget_margins[1],container_width:this.cols*this.min_widget_width,limit:!0,ignore_dragging:["INPUT","TEXTAREA","SELECT","BUTTON","."+this.options.resize.handle_class],start:function(e,s){i.$widgets.filter(".player-revert").removeClass("player-revert"),i.$player=t(this),i.$helper=t(s.$helper),i.helper=!i.$helper.is(i.$player),i.on_start_drag.call(i,e,s),i.$el.trigger("gridster:dragstart")},stop:function(t,e){i.on_stop_drag.call(i,t,e),i.$el.trigger("gridster:dragstop")},drag:throttle(function(t,e){i.on_drag.call(i,t,e),i.$el.trigger("gridster:drag")},60)});return this.drag_api=this.$el.drag(e),this},o.resizable=function(){return this.resize_api=this.$el.drag({items:"."+this.options.resize.handle_class,offset_left:this.options.widget_margins[0],container_width:this.container_width,move_element:!1,resize:!0,limit:this.options.autogrow_cols?!1:!0,start:t.proxy(this.on_start_resize,this),stop:t.proxy(function(i,e){delay(t.proxy(function(){this.on_stop_resize(i,e)},this),120)},this),drag:throttle(t.proxy(this.on_resize,this),60)}),this},o.setup_resize=function(){this.resize_handle_class=this.options.resize.handle_class;var i=this.options.resize.axes,e='';return this.resize_handle_tpl=t.map(i,function(t){return e.replace("{type}",t)}).join(""),this},o.on_start_drag=function(i,e){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging"),this.highest_col=this.get_highest_occupied_cell().col,this.$player.addClass("player"),this.player_grid_data=this.$player.coords().grid,this.placeholder_grid_data=t.extend({},this.player_grid_data),this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height),this.set_dom_grid_width(this.cols);var s=this.player_grid_data.size_x,r=this.cols-this.highest_col;this.options.autogrow_cols&&s>=r&&this.add_faux_cols(Math.min(s-r,1));var o=this.faux_grid,a=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data),this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.last_cols=[],this.last_rows=[],this.collision_api=this.$helper.collision(o,this.options.collision),this.$preview_holder=t("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:a.width,height:a.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,i,e)},o.on_drag=function(t,i){if(null===this.$player)return!1;var e={left:i.position.left+this.baseX,top:i.position.top+this.baseY};if(this.options.autogrow_cols){var s=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;s>=this.cols-1&&this.options.max_cols>=this.cols+1&&(this.add_faux_cols(1),this.set_dom_grid_width(this.cols+1),this.drag_api.set_limits(this.container_width)),this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(e),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.helper&&this.$player&&this.$player.css({left:i.position.left,top:i.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,t,i)},o.on_stop_drag=function(t,i){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),i.position.left=i.position.left+this.baseX,i.position.top=i.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(i.position),this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column),this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row),this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""}),this.$changed=this.$changed.add(this.$player),this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data),this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row),this.$player.coords().grid.row=this.placeholder_grid_data.row,this.$player.coords().grid.col=this.placeholder_grid_data.col,this.options.draggable.stop&&this.options.draggable.stop.call(this,t,i),this.$preview_holder.remove(),this.$player=null,this.$helper=null,this.placeholder_grid_data={},this.player_grid_data={},this.cells_occupied_by_placeholder={},this.cells_occupied_by_player={},this.set_dom_grid_height(),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},o.on_start_resize=function(i,e){this.$resized_widget=e.$player.closest(".gs-w"),this.resize_coords=this.$resized_widget.coords(),this.resize_wgd=this.resize_coords.grid,this.resize_initial_width=this.resize_coords.coords.width,this.resize_initial_height=this.resize_coords.coords.height,this.resize_initial_sizex=this.resize_coords.grid.size_x,this.resize_initial_sizey=this.resize_coords.grid.size_y,this.resize_initial_col=this.resize_coords.grid.col,this.resize_last_sizex=this.resize_initial_sizex,this.resize_last_sizey=this.resize_initial_sizey,this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1),this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1],this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1,this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1,this.resize_initial_last_col=this.get_highest_occupied_cell().col,this.set_dom_grid_width(this.cols),this.resize_dir={right:e.$player.is("."+this.resize_handle_class+"-x"),bottom:e.$player.is("."+this.resize_handle_class+"-y")},this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var s=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=t("<"+s+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el),this.$resized_widget.addClass("resizing"),this.options.resize.start&&this.options.resize.start.call(this,i,e,this.$resized_widget),this.$el.trigger("gridster:resizestart")},o.on_stop_resize=function(i,e){this.$resized_widget.removeClass("resizing").css({width:"",height:""}),delay(t.proxy(function(){this.$resize_preview_holder.remove().css({"min-width":"","min-height":""}),this.options.resize.stop&&this.options.resize.stop.call(this,i,e,this.$resized_widget),this.$el.trigger("gridster:resizestop")},this),300),this.set_dom_grid_width(),this.options.autogrow_cols&&this.drag_api.set_limits(this.cols*this.min_widget_width)},o.on_resize=function(t,i){var e,s=i.pointer.diff_left,r=i.pointer.diff_top,o=this.options.widget_base_dimensions[0],a=this.options.widget_base_dimensions[1],h=this.options.widget_margins[0],n=this.options.widget_margins[1],_=this.resize_max_size_x,d=this.resize_min_size_x,l=this.resize_max_size_y,c=this.resize_min_size_y,p=this.options.autogrow_cols,g=1/0,u=1/0,f=Math.ceil(s/(o+2*h)-.2),w=Math.ceil(r/(a+2*n)-.2),m=Math.max(1,this.resize_initial_sizex+f),y=Math.max(1,this.resize_initial_sizey+w),v=this.container_width/this.min_widget_width-this.resize_initial_col+1,z=v*this.min_widget_width-2*h;if(m=Math.max(Math.min(m,_),d),m=Math.min(v,m),e=_*o+2*(m-1)*h,g=Math.min(e,z),min_width=d*o+2*(m-1)*h,y=Math.max(Math.min(y,l),c),u=l*a+2*(y-1)*n,min_height=c*a+2*(y-1)*n,this.resize_dir.right?y=this.resize_initial_sizey:this.resize_dir.bottom&&(m=this.resize_initial_sizex),p){var x=this.resize_initial_col+m-1;p&&x>=this.resize_initial_last_col&&(this.set_dom_grid_width(Math.max(x+1,this.cols)),x>this.cols&&this.add_faux_cols(x-this.cols))}var $={};!this.resize_dir.bottom&&($.width=Math.max(Math.min(this.resize_initial_width+s,g),min_width)),!this.resize_dir.right&&($.height=Math.max(Math.min(this.resize_initial_height+r,u),min_height)),this.$resized_widget.css($),(m!==this.resize_last_sizex||y!==this.resize_last_sizey)&&(this.resize_widget(this.$resized_widget,m,y),this.set_dom_grid_width(this.cols),this.$resize_preview_holder.css({width:"",height:""}).attr({"data-row":this.$resized_widget.attr("data-row"),"data-sizex":m,"data-sizey":y})),this.options.resize.resize&&this.options.resize.resize.call(this,t,i,this.$resized_widget),this.$el.trigger("gridster:resize"),this.resize_last_sizex=m,this.resize_last_sizey=y},o.on_overlapped_column_change=function(i,e){if(!this.colliders_data.length)return this;var s,r=this.get_targeted_columns(this.colliders_data[0].el.data.col),o=this.last_cols.length,a=r.length;for(s=0;a>s;s++)-1===t.inArray(r[s],this.last_cols)&&(i||t.noop).call(this,r[s]);for(s=0;o>s;s++)-1===t.inArray(this.last_cols[s],r)&&(e||t.noop).call(this,this.last_cols[s]);return this.last_cols=r,this},o.on_overlapped_row_change=function(i,e){if(!this.colliders_data.length)return this;var s,r=this.get_targeted_rows(this.colliders_data[0].el.data.row),o=this.last_rows.length,a=r.length;for(s=0;a>s;s++)-1===t.inArray(r[s],this.last_rows)&&(i||t.noop).call(this,r[s]);for(s=0;o>s;s++)-1===t.inArray(this.last_rows[s],r)&&(e||t.noop).call(this,this.last_rows[s]);this.last_rows=r},o.set_player=function(t,i,e){var s=this;e||this.empty_cells_player_occupies();var r=e?{col:t}:s.colliders_data[0].el.data,o=r.col,a=i||r.row;this.player_grid_data={col:o,row:a,size_y:this.player_grid_data.size_y,size_x:this.player_grid_data.size_x},this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data);var h=this.get_widgets_overlapped(this.player_grid_data),n=this.widgets_constraints(h);if(this.manage_movements(n.can_go_up,o,a),this.manage_movements(n.can_not_go_up,o,a),!h.length){var _=this.can_go_player_up(this.player_grid_data);_!==!1&&(a=_),this.set_placeholder(o,a)}return{col:o,row:a}},o.widgets_constraints=function(i){var e,s=t([]),r=[],o=[];return i.each(t.proxy(function(i,e){var a=t(e),h=a.coords().grid;this.can_go_widget_up(h)?(s=s.add(a),r.push(h)):o.push(h)},this)),e=i.not(s),{can_go_up:this.sort_by_row_asc(r),can_not_go_up:this.sort_by_row_desc(o)}},o.sort_by_row_asc=function(i){return i=i.sort(function(i,e){return i.row||(i=t(i).coords().grid,e=t(e).coords().grid),i.row>e.row?1:-1})},o.sort_by_row_and_col_asc=function(t){return t=t.sort(function(t,i){return t.row>i.row||t.row===i.row&&t.col>i.col?1:-1})},o.sort_by_col_asc=function(t){return t=t.sort(function(t,i){return t.col>i.col?1:-1})},o.sort_by_row_desc=function(t){return t=t.sort(function(t,i){return t.row+t.size_y=0&&t.inArray(e,s.rows)>=0},o.is_placeholder_in=function(i,e){var s=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(i)&&t.inArray(e,s.rows)>=0},o.is_placeholder_in_col=function(i){var e=this.cells_occupied_by_placeholder||[];return t.inArray(i,e.cols)>=0},o.is_empty=function(t,i){return this.gridmap[t]!==undefined?this.gridmap[t][i]!==undefined&&this.gridmap[t][i]===!1?!0:!1:!0},o.is_occupied=function(t,i){return this.gridmap[t]?this.gridmap[t][i]?!0:!1:!1},o.is_widget=function(t,i){var e=this.gridmap[t];return e?(e=e[i],e?e:!1):!1},o.is_widget_under_player=function(t,i){return this.is_widget(t,i)?this.is_player_in(t,i):!1},o.get_widgets_under_player=function(i){i||(i=this.cells_occupied_by_player||{cols:[],rows:[]});var e=t([]);return t.each(i.cols,t.proxy(function(s,r){t.each(i.rows,t.proxy(function(t,i){this.is_widget(r,i)&&(e=e.add(this.gridmap[r][i]))},this))},this)),e},o.set_placeholder=function(i,e){var s=t.extend({},this.placeholder_grid_data),r=this.widgets_below({col:s.col,row:s.row,size_y:s.size_y,size_x:s.size_x}),o=i+s.size_x-1;o>this.cols&&(i-=o-i);var a=e>this.placeholder_grid_data.row,h=this.placeholder_grid_data.col!==i;this.placeholder_grid_data.col=i,this.placeholder_grid_data.row=e,this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data),this.$preview_holder.attr({"data-row":e,"data-col":i}),(a||h)&&r.each(t.proxy(function(e,r){this.move_widget_up(t(r),this.placeholder_grid_data.col-i+s.size_y)},this));var n=this.get_widgets_under_player(this.cells_occupied_by_placeholder);n.length&&n.each(t.proxy(function(i,r){var o=t(r);this.move_widget_down(o,e+s.size_y-o.data("coords").grid.row)},this))},o.can_go_player_up=function(t){var i=t.row+t.size_y-1,e=!0,s=[],r=1e4,o=this.get_widgets_under_player();return this.for_each_column_occupied(t,function(t){var a=this.gridmap[t],h=i+1;for(s[t]=[];--h>0&&(this.is_empty(t,h)||this.is_player(t,h)||this.is_widget(t,h)&&a[h].is(o));)s[t].push(h),r=r>h?h:r;return 0===s[t].length?(e=!1,!0):(s[t].sort(function(t,i){return t-i}),undefined)}),e?this.get_valid_rows(t,s,r):!1},o.can_go_widget_up=function(t){var i=t.row+t.size_y-1,e=!0,s=[],r=1e4;return this.for_each_column_occupied(t,function(o){var a=this.gridmap[o];s[o]=[];for(var h=i+1;--h>0&&(!this.is_widget(o,h)||this.is_player_in(o,h)||a[h].is(t.el));)this.is_player(o,h)||this.is_placeholder_in(o,h)||this.is_player_in(o,h)||s[o].push(h),r>h&&(r=h);return 0===s[o].length?(e=!1,!0):(s[o].sort(function(t,i){return t-i}),undefined)}),e?this.get_valid_rows(t,s,r):!1},o.get_valid_rows=function(i,e,s){for(var r=i.row,o=i.row+i.size_y-1,a=i.size_y,h=s-1,n=[];o>=++h;){var _=!0;if(t.each(e,function(i,e){t.isArray(e)&&-1===t.inArray(h,e)&&(_=!1)}),_===!0&&(n.push(h),n.length===a))break}var d=!1;return 1===a?n[0]!==r&&(d=n[0]||!1):n[0]!==r&&(d=this.get_consecutive_numbers_index(n,a)),d},o.get_consecutive_numbers_index=function(t,i){for(var e=t.length,s=[],r=!0,o=-1,a=0;e>a;a++){if(r||t[a]===o+1){if(s.push(a),s.length===i)break;r=!1}else s=[],r=!0;o=t[a]}return s.length>=i?t[s[0]]:!1},o.get_widgets_overlapped=function(){var i=t([]),e=[],s=this.cells_occupied_by_player.rows.slice(0);return s.reverse(),t.each(this.cells_occupied_by_player.cols,t.proxy(function(r,o){t.each(s,t.proxy(function(s,r){if(!this.gridmap[o])return!0;var a=this.gridmap[o][r];this.is_occupied(o,r)&&!this.is_player(a)&&-1===t.inArray(a,e)&&(i=i.add(a),e.push(a)) -},this))},this)),i},o.on_start_overlapping_column=function(t){this.set_player(t,!1)},o.on_start_overlapping_row=function(t){this.set_player(!1,t)},o.on_stop_overlapping_column=function(t){this.set_player(t,!1);var i=this;this.for_each_widget_below(t,this.cells_occupied_by_player.rows[0],function(){i.move_widget_up(this,i.player_grid_data.size_y)})},o.on_stop_overlapping_row=function(t){this.set_player(!1,t);for(var i=this,e=this.cells_occupied_by_player.cols,s=0,r=e.length;r>s;s++)this.for_each_widget_below(e[s],t,function(){i.move_widget_up(this,i.player_grid_data.size_y)})},o.move_widget_to=function(i,e){var s=this,r=i.coords().grid;e-r.row;var o=this.widgets_below(i),a=this.can_move_to(r,r.col,e,i);return a===!1?!1:(this.remove_from_gridmap(r),r.row=e,this.add_to_gridmap(r),i.attr("data-row",e),this.$changed=this.$changed.add(i),o.each(function(i,e){var r=t(e),o=r.coords().grid,a=s.can_go_widget_up(o);a&&a!==o.row&&s.move_widget_to(r,a)}),this)},o.move_widget_up=function(i,e){var s=i.coords().grid,r=s.row,o=[];return e||(e=1),this.can_go_up(i)?(this.for_each_column_occupied(s,function(s){if(-1===t.inArray(i,o)){var a=i.coords().grid,h=r-e;if(h=this.can_go_up_to_row(a,s,h),!h)return!0;var n=this.widgets_below(i);this.remove_from_gridmap(a),a.row=h,this.add_to_gridmap(a),i.attr("data-row",a.row),this.$changed=this.$changed.add(i),o.push(i),n.each(t.proxy(function(i,s){this.move_widget_up(t(s),e)},this))}}),undefined):!1},o.move_widget_down=function(i,e){var s,r,o,a;if(0>=e)return!1;if(s=i.coords().grid,r=s.row,o=[],a=e,!i)return!1;if(-1===t.inArray(i,o)){var h=i.coords().grid,n=r+e,_=this.widgets_below(i);this.remove_from_gridmap(h),_.each(t.proxy(function(i,e){var s=t(e),r=s.coords().grid,o=this.displacement_diff(r,h,a);o>0&&this.move_widget_down(s,o)},this)),h.row=n,this.update_widget_position(h,i),i.attr("data-row",h.row),this.$changed=this.$changed.add(i),o.push(i)}},o.can_go_up_to_row=function(i,e,s){var r,o=this.gridmap,a=!0,h=[],n=i.row;if(this.for_each_column_occupied(i,function(t){for(o[t],h[t]=[],r=n;r--&&this.is_empty(t,r)&&!this.is_placeholder_in(t,r);)h[t].push(r);return h[t].length?undefined:(a=!1,!0)}),!a)return!1;for(r=s,r=1;n>r;r++){for(var _=!0,d=0,l=h.length;l>d;d++)h[d]&&-1===t.inArray(r,h[d])&&(_=!1);if(_===!0){a=r;break}}return a},o.displacement_diff=function(t,i,e){var s=t.row,r=[],o=i.row+i.size_y;this.for_each_column_occupied(t,function(t){for(var i=0,e=o;s>e;e++)this.is_empty(t,e)&&(i+=1);r.push(i)});var a=Math.max.apply(Math,r);return e-=a,e>0?e:0},o.widgets_below=function(i){var e=t.isPlainObject(i)?i:i.coords().grid,s=this;this.gridmap;var r=e.row+e.size_y-1,o=t([]);return this.for_each_column_occupied(e,function(i){s.for_each_widget_below(i,r,function(){return s.is_player(this)||-1!==t.inArray(this,o)?undefined:(o=o.add(this),!0)})}),this.sort_by_row_asc(o)},o.set_cells_player_occupies=function(t,i){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=t,this.placeholder_grid_data.row=i,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},o.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},o.can_go_up=function(t){var i=t.coords().grid,e=i.row,s=e-1;this.gridmap;var r=!0;return 1===e?!1:(this.for_each_column_occupied(i,function(t){return this.is_widget(t,s),this.is_occupied(t,s)||this.is_player(t,s)||this.is_placeholder_in(t,s)||this.is_player_in(t,s)?(r=!1,!0):undefined}),r)},o.can_move_to=function(t,i,e,s){this.gridmap;var r=t.el,o={size_y:t.size_y,size_x:t.size_x,col:i,row:e},a=!0,h=i+t.size_x-1;return h>this.cols?!1:s&&e+t.size_y-1>s?!1:(this.for_each_cell_occupied(o,function(i,e){var s=this.is_widget(i,e);!s||t.el&&!s.is(r)||(a=!1)}),a)},o.get_targeted_columns=function(t){for(var i=(t||this.player_grid_data.col)+(this.player_grid_data.size_x-1),e=[],s=t;i>=s;s++)e.push(s);return e},o.get_targeted_rows=function(t){for(var i=(t||this.player_grid_data.row)+(this.player_grid_data.size_y-1),e=[],s=t;i>=s;s++)e.push(s);return e},o.get_cells_occupied=function(i){var e,s={cols:[],rows:[]};for(arguments[1]instanceof t&&(i=arguments[1].coords().grid),e=0;i.size_x>e;e++){var r=i.col+e;s.cols.push(r)}for(e=0;i.size_y>e;e++){var o=i.row+e;s.rows.push(o)}return s},o.for_each_cell_occupied=function(t,i){return this.for_each_column_occupied(t,function(e){this.for_each_row_occupied(t,function(t){i.call(this,e,t)})}),this},o.for_each_column_occupied=function(t,i){for(var e=0;t.size_x>e;e++){var s=t.col+e;i.call(this,s,t)}},o.for_each_row_occupied=function(t,i){for(var e=0;t.size_y>e;e++){var s=t.row+e;i.call(this,s,t)}},o._traversing_widgets=function(i,e,s,r,o){var a=this.gridmap;if(a[s]){var h,n,_=i+"/"+e;if(arguments[2]instanceof t){var d=arguments[2].coords().grid;s=d.col,r=d.row,o=arguments[3]}var l=[],c=r,p={"for_each/above":function(){for(;c--&&!(c>0&&this.is_widget(s,c)&&-1===t.inArray(a[s][c],l)&&(h=o.call(a[s][c],s,c),l.push(a[s][c]),h)););},"for_each/below":function(){for(c=r+1,n=a[s].length;n>c&&(!this.is_widget(s,c)||-1!==t.inArray(a[s][c],l)||(h=o.call(a[s][c],s,c),l.push(a[s][c]),!h));c++);}};p[_]&&p[_].call(this)}},o.for_each_widget_above=function(t,i,e){return this._traversing_widgets("for_each","above",t,i,e),this},o.for_each_widget_below=function(t,i,e){return this._traversing_widgets("for_each","below",t,i,e),this},o.get_highest_occupied_cell=function(){for(var t,i=this.gridmap,e=i[1].length,s=[],r=[],o=i.length-1;o>=1;o--)for(t=e-1;t>=1;t--)if(this.is_widget(o,t)){s.push(t),r.push(o);break}return{col:Math.max.apply(Math,r),row:Math.max.apply(Math,s)}},o.get_widgets_from=function(i,e){this.gridmap;var s=t();return i&&(s=s.add(this.$widgets.filter(function(){var e=t(this).attr("data-col");return e===i||e>i}))),e&&(s=s.add(this.$widgets.filter(function(){var i=t(this).attr("data-row");return i===e||i>e}))),s},o.set_dom_grid_height=function(t){if(t===undefined){var i=this.get_highest_occupied_cell().row;t=i*this.min_widget_height}return this.container_height=t,this.$el.css("height",this.container_height),this},o.set_dom_grid_width=function(t){t===undefined&&(t=this.get_highest_occupied_cell().col);var i=this.options.autogrow_cols?this.options.max_cols:this.cols;return t=Math.min(i,Math.max(t,this.options.min_cols)),this.container_width=t*this.min_widget_width,this.$el.css("width",this.container_width),this},o.generate_stylesheet=function(i){var e,r="",o=this.options.max_size_x||this.cols;i||(i={}),i.cols||(i.cols=this.cols),i.rows||(i.rows=this.rows),i.namespace||(i.namespace=this.options.namespace),i.widget_base_dimensions||(i.widget_base_dimensions=this.options.widget_base_dimensions),i.widget_margins||(i.widget_margins=this.options.widget_margins),i.min_widget_width=2*i.widget_margins[0]+i.widget_base_dimensions[0],i.min_widget_height=2*i.widget_margins[1]+i.widget_base_dimensions[1];var a=t.param(i);if(t.inArray(a,s.generated_stylesheets)>=0)return!1;for(this.generated_stylesheets.push(a),s.generated_stylesheets.push(a),e=i.cols;e>=0;e--)r+=i.namespace+' [data-col="'+(e+1)+'"] { left:'+(e*i.widget_base_dimensions[0]+e*i.widget_margins[0]+(e+1)*i.widget_margins[0])+"px; }\n";for(e=i.rows;e>=0;e--)r+=i.namespace+' [data-row="'+(e+1)+'"] { top:'+(e*i.widget_base_dimensions[1]+e*i.widget_margins[1]+(e+1)*i.widget_margins[1])+"px; }\n";for(var h=1;i.rows>=h;h++)r+=i.namespace+' [data-sizey="'+h+'"] { height:'+(h*i.widget_base_dimensions[1]+(h-1)*2*i.widget_margins[1])+"px; }\n";for(var n=1;o>=n;n++)r+=i.namespace+' [data-sizex="'+n+'"] { width:'+(n*i.widget_base_dimensions[0]+(n-1)*2*i.widget_margins[0])+"px; }\n";return this.add_style_tag(r)},o.add_style_tag=function(t){var i=e,s=i.createElement("style");return i.getElementsByTagName("head")[0].appendChild(s),s.setAttribute("type","text/css"),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(e.createTextNode(t)),this.$style_tags=this.$style_tags.add(s),this},o.remove_style_tags=function(){var i=s.generated_stylesheets,e=this.generated_stylesheets;this.$style_tags.remove(),s.generated_stylesheets=t.map(i,function(i){return-1===t.inArray(i,e)?i:undefined})},o.generate_faux_grid=function(t,i){this.faux_grid=[],this.gridmap=[];var e,s;for(e=i;e>0;e--)for(this.gridmap[e]=[],s=t;s>0;s--)this.add_faux_cell(s,e);return this},o.add_faux_cell=function(i,e){var s=t({left:this.baseX+(e-1)*this.min_widget_width,top:this.baseY+(i-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:e,row:i,original_col:e,original_row:i}).coords();return t.isArray(this.gridmap[e])||(this.gridmap[e]=[]),this.gridmap[e][i]=!1,this.faux_grid.push(s),this},o.add_faux_rows=function(t){for(var i=this.rows,e=i+(t||1),s=e;s>i;s--)for(var r=this.cols;r>=1;r--)this.add_faux_cell(s,r);return this.rows=e,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},o.add_faux_cols=function(t){var i=this.cols,e=i+(t||1);e=Math.min(e,this.options.max_cols);for(var s=i+1;e>=s;s++)for(var r=this.rows;r>=1;r--)this.add_faux_cell(r,s);return this.cols=e,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this},o.recalculate_faux_grid=function(){var e=this.$wrapper.width();return this.baseX=(t(i).width()-e)/2,this.baseY=this.$wrapper.offset().top,t.each(this.faux_grid,t.proxy(function(t,i){this.faux_grid[t]=i.update({left:this.baseX+(i.data.col-1)*this.min_widget_width,top:this.baseY+(i.data.row-1)*this.min_widget_height})},this)),this},o.get_widgets_from_DOM=function(){return this.$widgets.each(t.proxy(function(i,e){this.register_widget(t(e))},this)),this},o.generate_grid_and_stylesheet=function(){var e=this.$wrapper.width(),s=this.options.max_cols,r=Math.floor(e/this.min_widget_width)+this.options.extra_cols,o=this.$widgets.map(function(){return t(this).attr("data-col")}).get();o.length||(o=[0]);var a=Math.max.apply(Math,o);this.cols=Math.max(a,r,this.options.min_cols),1/0!==s&&s>=a&&this.cols>s&&(this.cols=s);var h=this.options.extra_rows;return this.$widgets.each(function(i,e){h+=+t(e).attr("data-sizey")}),this.rows=Math.max(h,this.options.min_rows),this.baseX=(t(i).width()-e)/2,this.baseY=this.$wrapper.offset().top,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this.generate_faux_grid(this.rows,this.cols)},o.destroy=function(e){return this.$el.removeData("gridster"),t(i).unbind(".gridster"),this.drag_api&&this.drag_api.destroy(),this.remove_style_tags(),e&&this.$el.remove(),this},t.fn.gridster=function(i){return this.each(function(){t(this).data("gridster")||t(this).data("gridster",new s(this,i))})},t.Gridster=o}(jQuery,window,document); \ No newline at end of file +(function(e,t,n,r){function s(t,n){this.options=e.extend(true,{},i,n);this.$el=e(t);this.$wrapper=this.$el.parent();this.$widgets=this.$el.children(this.options.widget_selector).addClass("gs-w");this.widgets=[];this.$changed=e([]);this.wrapper_width=this.$wrapper.width();this.min_widget_width=this.options.widget_margins[0]*2+this.options.widget_base_dimensions[0];this.min_widget_height=this.options.widget_margins[1]*2+this.options.widget_base_dimensions[1];this.generated_stylesheets=[];this.$style_tags=e([]);this.init()}var i={namespace:"",widget_selector:"li",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,max_cols:Infinity,min_rows:15,max_size_x:false,autogrow_cols:false,autogenerate_stylesheet:true,avoid_overlapped_widgets:true,serialize_params:function(e,t){return{col:t.col,row:t.row,size_x:t.size_x,size_y:t.size_y}},collision:{},draggable:{items:".gs-w",distance:4},resize:{enabled:false,axes:["both"],handle_append_to:"",handle_class:"gs-resize-handle",max_size:[Infinity,Infinity],min_size:[1,1]}};s.generated_stylesheets=[];var o=s.prototype;o.init=function(){this.options.resize.enabled&&this.setup_resize();this.generate_grid_and_stylesheet();this.get_widgets_from_DOM();this.set_dom_grid_height();this.set_dom_grid_width();this.$wrapper.addClass("ready");this.draggable();this.options.resize.enabled&&this.resizable();e(t).bind("resize.gridster",throttle(e.proxy(this.recalculate_faux_grid,this),200))};o.disable=function(){this.$wrapper.find(".player-revert").removeClass("player-revert");this.drag_api.disable();return this};o.enable=function(){this.drag_api.enable();return this};o.disable_resize=function(){this.$el.addClass("gs-resize-disabled");this.resize_api.disable();return this};o.enable_resize=function(){this.$el.removeClass("gs-resize-disabled");this.resize_api.enable();return this};o.add_widget=function(t,n,r,i,s,o,u){var a;n||(n=1);r||(r=1);if(!i&!s){a=this.next_position(n,r)}else{a={col:i,row:s};this.empty_cells(i,s,n,r)}var f=e(t).attr({"data-col":a.col,"data-row":a.row,"data-sizex":n,"data-sizey":r}).addClass("gs-w").appendTo(this.$el).hide();this.$widgets=this.$widgets.add(f);this.register_widget(f);this.add_faux_rows(a.size_y);if(o){this.set_widget_max_size(f,o)}if(u){this.set_widget_min_size(f,u)}this.set_dom_grid_width();this.set_dom_grid_height();this.drag_api.set_limits(this.cols*this.min_widget_width);return f.fadeIn()};o.set_widget_min_size=function(e,t){e=typeof e==="number"?this.$widgets.eq(e):e;if(!e.length){return this}var n=e.data("coords").grid;n.min_size_x=t[0];n.min_size_y=t[1];return this};o.set_widget_max_size=function(e,t){e=typeof e==="number"?this.$widgets.eq(e):e;if(!e.length){return this}var n=e.data("coords").grid;n.max_size_x=t[0];n.max_size_y=t[1];return this};o.add_resize_handle=function(t){var n=this.options.resize.handle_append_to;e(this.resize_handle_tpl).appendTo(n?e(n,t):t);return this};o.resize_widget=function(e,t,n,r){var i=e.coords().grid;var s=i.col;var o=this.options.max_cols;var u=i.size_y;var a=i.col;var f=a;t||(t=i.size_x);n||(n=i.size_y);if(o!==Infinity){t=Math.min(t,o-s+1)}if(n>u){this.add_faux_rows(Math.max(n-u,0))}var l=s+t-1;if(l>this.cols){this.add_faux_cols(l-this.cols)}var c={col:f,row:i.row,size_x:t,size_y:n};this.mutate_widget_in_gridmap(e,i,c);this.set_dom_grid_height();this.set_dom_grid_width();if(r){r.call(this,c.size_x,c.size_y)}return e};o.mutate_widget_in_gridmap=function(t,n,r){var i=n.size_x;var s=n.size_y;var o=this.get_cells_occupied(n);var u=this.get_cells_occupied(r);var a=[];e.each(o.cols,function(t,n){if(e.inArray(n,u.cols)===-1){a.push(n)}});var f=[];e.each(u.cols,function(t,n){if(e.inArray(n,o.cols)===-1){f.push(n)}});var l=[];e.each(o.rows,function(t,n){if(e.inArray(n,u.rows)===-1){l.push(n)}});var c=[];e.each(u.rows,function(t,n){if(e.inArray(n,o.rows)===-1){c.push(n)}});this.remove_from_gridmap(n);if(f.length){var h=[r.col,r.row,r.size_x,Math.min(s,r.size_y),t];this.empty_cells.apply(this,h)}if(c.length){var p=[r.col,r.row,r.size_x,r.size_y,t];this.empty_cells.apply(this,p)}n.col=r.col;n.row=r.row;n.size_x=r.size_x;n.size_y=r.size_y;this.add_to_gridmap(r,t);t.removeClass("player-revert");t.data("coords").update({width:r.size_x*this.options.widget_base_dimensions[0]+(r.size_x-1)*this.options.widget_margins[0]*2,height:r.size_y*this.options.widget_base_dimensions[1]+(r.size_y-1)*this.options.widget_margins[1]*2});t.attr({"data-col":r.col,"data-row":r.row,"data-sizex":r.size_x,"data-sizey":r.size_y});if(a.length){var d=[a[0],r.row,a.length,Math.min(s,r.size_y),t];this.remove_empty_cells.apply(this,d)}if(l.length){var v=[r.col,r.row,r.size_x,r.size_y,t];this.remove_empty_cells.apply(this,v)}this.move_widget_up(t);return this};o.empty_cells=function(t,n,r,i,s){var o=this.widgets_below({col:t,row:n-i,size_x:r,size_y:i});o.not(s).each(e.proxy(function(t,r){var s=e(r).coords().grid;if(!(s.row<=n+i-1)){return}var o=n+i-s.row;this.move_widget_down(e(r),o)},this));this.set_dom_grid_height();return this};o.remove_empty_cells=function(t,n,r,i,s){var o=this.widgets_below({col:t,row:n,size_x:r,size_y:i});o.not(s).each(e.proxy(function(t,n){this.move_widget_up(e(n),i)},this));this.set_dom_grid_height();return this};o.next_position=function(e,t){e||(e=1);t||(t=1);var n=this.gridmap;var r=n.length;var i=[];var s;for(var o=1;o';this.resize_handle_tpl=e.map(t,function(e){return n.replace("{type}",e)}).join("");return this};o.on_start_drag=function(t,n){this.$helper.add(this.$player).add(this.$wrapper).addClass("dragging");this.highest_col=this.get_highest_occupied_cell().col;this.$player.addClass("player");this.player_grid_data=this.$player.coords().grid;this.placeholder_grid_data=e.extend({},this.player_grid_data);this.set_dom_grid_height(this.$el.height()+this.player_grid_data.size_y*this.min_widget_height);this.set_dom_grid_width(this.cols);var r=this.player_grid_data.size_x;var i=this.cols-this.highest_col;if(this.options.autogrow_cols&&i<=r){this.add_faux_cols(Math.min(r-i,1))}var s=this.faux_grid;var o=this.$player.data("coords").coords;this.cells_occupied_by_player=this.get_cells_occupied(this.player_grid_data);this.cells_occupied_by_placeholder=this.get_cells_occupied(this.placeholder_grid_data);this.last_cols=[];this.last_rows=[];this.collision_api=this.$helper.collision(s,this.options.collision);this.$preview_holder=e("<"+this.$player.get(0).tagName+" />",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:o.width,height:o.height}}).appendTo(this.$el);if(this.options.draggable.start){this.options.draggable.start.call(this,t,n)}};o.on_drag=function(e,t){if(this.$player===null){return false}var n={left:t.position.left+this.baseX,top:t.position.top+this.baseY};if(this.options.autogrow_cols){var r=this.placeholder_grid_data.col+this.placeholder_grid_data.size_x-1;if(r>=this.cols-1&&this.options.max_cols>=this.cols+1){this.add_faux_cols(1);this.set_dom_grid_width(this.cols+1);this.drag_api.set_limits(this.container_width)}this.collision_api.set_colliders(this.faux_grid)}this.colliders_data=this.collision_api.get_closest_colliders(n);this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column);this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row);if(this.helper&&this.$player){this.$player.css({left:t.position.left,top:t.position.top})}if(this.options.draggable.drag){this.options.draggable.drag.call(this,e,t)}};o.on_stop_drag=function(e,t){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging");t.position.left=t.position.left+this.baseX;t.position.top=t.position.top+this.baseY;this.colliders_data=this.collision_api.get_closest_colliders(t.position);this.on_overlapped_column_change(this.on_start_overlapping_column,this.on_stop_overlapping_column);this.on_overlapped_row_change(this.on_start_overlapping_row,this.on_stop_overlapping_row);this.$player.addClass("player-revert").removeClass("player").attr({"data-col":this.placeholder_grid_data.col,"data-row":this.placeholder_grid_data.row}).css({left:"",top:""});this.$changed=this.$changed.add(this.$player);this.cells_occupied_by_player=this.get_cells_occupied(this.placeholder_grid_data);this.set_cells_player_occupies(this.placeholder_grid_data.col,this.placeholder_grid_data.row);this.$player.coords().grid.row=this.placeholder_grid_data.row;this.$player.coords().grid.col=this.placeholder_grid_data.col;if(this.options.draggable.stop){this.options.draggable.stop.call(this,e,t)}this.$preview_holder.remove();this.$player=null;this.$helper=null;this.placeholder_grid_data={};this.player_grid_data={};this.cells_occupied_by_placeholder={};this.cells_occupied_by_player={};this.set_dom_grid_height();this.set_dom_grid_width();if(this.options.autogrow_cols){this.drag_api.set_limits(this.cols*this.min_widget_width)}};o.on_start_resize=function(t,n){this.$resized_widget=n.$player.closest(".gs-w");this.resize_coords=this.$resized_widget.coords();this.resize_wgd=this.resize_coords.grid;this.resize_initial_width=this.resize_coords.coords.width;this.resize_initial_height=this.resize_coords.coords.height;this.resize_initial_sizex=this.resize_coords.grid.size_x;this.resize_initial_sizey=this.resize_coords.grid.size_y;this.resize_initial_col=this.resize_coords.grid.col;this.resize_last_sizex=this.resize_initial_sizex;this.resize_last_sizey=this.resize_initial_sizey;this.resize_max_size_x=Math.min(this.resize_wgd.max_size_x||this.options.resize.max_size[0],this.options.max_cols-this.resize_initial_col+1);this.resize_max_size_y=this.resize_wgd.max_size_y||this.options.resize.max_size[1];this.resize_min_size_x=this.resize_wgd.min_size_x||this.options.resize.min_size[0]||1;this.resize_min_size_y=this.resize_wgd.min_size_y||this.options.resize.min_size[1]||1;this.resize_initial_last_col=this.get_highest_occupied_cell().col;this.set_dom_grid_width(this.cols);this.resize_dir={right:n.$player.is("."+this.resize_handle_class+"-x"),bottom:n.$player.is("."+this.resize_handle_class+"-y")};this.$resized_widget.css({"min-width":this.options.widget_base_dimensions[0],"min-height":this.options.widget_base_dimensions[1]});var r=this.$resized_widget.get(0).tagName;this.$resize_preview_holder=e("<"+r+" />",{"class":"preview-holder resize-preview-holder","data-row":this.$resized_widget.attr("data-row"),"data-col":this.$resized_widget.attr("data-col"),css:{width:this.resize_initial_width,height:this.resize_initial_height}}).appendTo(this.$el);this.$resized_widget.addClass("resizing");if(this.options.resize.start){this.options.resize.start.call(this,t,n,this.$resized_widget)}this.$el.trigger("gridster:resizestart")};o.on_stop_resize=function(t,n){this.$resized_widget.removeClass("resizing").css({width:"",height:""});delay(e.proxy(function(){this.$resize_preview_holder.remove().css({"min-width":"","min-height":""});if(this.options.resize.stop){this.options.resize.stop.call(this,t,n,this.$resized_widget)}this.$el.trigger("gridster:resizestop")},this),300);this.set_dom_grid_width();if(this.options.autogrow_cols){this.drag_api.set_limits(this.cols*this.min_widget_width)}};o.on_resize=function(e,t){var n=t.pointer.diff_left;var r=t.pointer.diff_top;var i=this.options.widget_base_dimensions[0];var s=this.options.widget_base_dimensions[1];var o=this.options.widget_margins[0];var u=this.options.widget_margins[1];var a=this.resize_max_size_x;var f=this.resize_min_size_x;var l=this.resize_max_size_y;var c=this.resize_min_size_y;var h=this.options.autogrow_cols;var p;var d=Infinity;var v=Infinity;var m=Math.ceil(n/(i+o*2)-.2);var g=Math.ceil(r/(s+u*2)-.2);var y=Math.max(1,this.resize_initial_sizex+m);var b=Math.max(1,this.resize_initial_sizey+g);var w=this.container_width/this.min_widget_width-this.resize_initial_col+1;var E=w*this.min_widget_width-o*2;y=Math.max(Math.min(y,a),f);y=Math.min(w,y);p=a*i+(y-1)*o*2;d=Math.min(p,E);min_width=f*i+(y-1)*o*2;b=Math.max(Math.min(b,l),c);v=l*s+(b-1)*u*2;min_height=c*s+(b-1)*u*2;if(this.resize_dir.right){b=this.resize_initial_sizey}else if(this.resize_dir.bottom){y=this.resize_initial_sizex}if(h){var S=this.resize_initial_col+y-1;if(h&&this.resize_initial_last_col<=S){this.set_dom_grid_width(Math.max(S+1,this.cols));if(this.colsn.row){return 1}return-1});return t};o.sort_by_row_and_col_asc=function(e){e=e.sort(function(e,t){if(e.row>t.row||e.row===t.row&&e.col>t.col){return 1}return-1});return e};o.sort_by_col_asc=function(e){e=e.sort(function(e,t){if(e.col>t.col){return 1}return-1});return e};o.sort_by_row_desc=function(e){e=e.sort(function(e,t){if(e.row+e.size_y=0&&e.inArray(n,r.rows)>=0};o.is_placeholder_in=function(t,n){var r=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(t)&&e.inArray(n,r.rows)>=0};o.is_placeholder_in_col=function(t){var n=this.cells_occupied_by_placeholder||[];return e.inArray(t,n.cols)>=0};o.is_empty=function(e,t){if(typeof this.gridmap[e]!=="undefined"){if(typeof this.gridmap[e][t]!=="undefined"&&this.gridmap[e][t]===false){return true}return false}return true};o.is_occupied=function(e,t){if(!this.gridmap[e]){return false}if(this.gridmap[e][t]){return true}return false};o.is_widget=function(e,t){var n=this.gridmap[e];if(!n){return false}n=n[t];if(n){return n}return false};o.is_widget_under_player=function(e,t){if(this.is_widget(e,t)){return this.is_player_in(e,t)}return false};o.get_widgets_under_player=function(t){t||(t=this.cells_occupied_by_player||{cols:[],rows:[]});var n=e([]);e.each(t.cols,e.proxy(function(r,i){e.each(t.rows,e.proxy(function(e,t){if(this.is_widget(i,t)){n=n.add(this.gridmap[i][t])}},this))},this));return n};o.set_placeholder=function(t,n){var r=e.extend({},this.placeholder_grid_data);var i=this.widgets_below({col:r.col,row:r.row,size_y:r.size_y,size_x:r.size_x});var s=t+r.size_x-1;if(s>this.cols){t=t-(s-t)}var o=this.placeholder_grid_data.row0){if(this.is_empty(e,u)||this.is_player(e,u)||this.is_widget(e,u)&&o[u].is(s)){r[e].push(u);i=u0){if(this.is_widget(s,u)&&!this.is_player_in(s,u)){if(!o[u].is(e.el)){break}}if(!this.is_player(s,u)&&!this.is_placeholder_in(s,u)&&!this.is_player_in(s,u)){r[s].push(u)}if(u=t?e[r[0]]:false};o.get_widgets_overlapped=function(){var t;var n=e([]);var r=[];var i=this.cells_occupied_by_player.rows.slice(0);i.reverse();e.each(this.cells_occupied_by_player.cols,e.proxy(function(t,s){e.each(i,e.proxy(function(t,i){if(!this.gridmap[s]){return true}var o=this.gridmap[s][i];if(this.is_occupied(s,i)&&!this.is_player(o)&&e.inArray(o,r)===-1){n=n.add(o);r.push(o)}},this))},this));return n};o.on_start_overlapping_column=function(e){this.set_player(e,false)};o.on_start_overlapping_row=function(e){this.set_player(false,e)};o.on_stop_overlapping_column=function(e){this.set_player(e,false);var t=this;this.for_each_widget_below(e,this.cells_occupied_by_player.rows[0],function(e,n){t.move_widget_up(this,t.player_grid_data.size_y)})};o.on_stop_overlapping_row=function(e){this.set_player(false,e);var t=this;var n=this.cells_occupied_by_player.cols;for(var r=0,i=n.length;r0){this.move_widget_down(r,s)}},this));u.row=a;this.update_widget_position(u,t);t.attr("data-row",u.row);this.$changed=this.$changed.add(t);s.push(t)}};o.can_go_up_to_row=function(t,n,r){var i=this.gridmap;var s=true;var o=[];var u=t.row;var a;this.for_each_column_occupied(t,function(e){var t=i[e];o[e]=[];a=u;while(a--){if(this.is_empty(e,a)&&!this.is_placeholder_in(e,a)){o[e].push(a)}else{break}}if(!o[e].length){s=false;return true}});if(!s){return false}a=r;for(a=1;a0?n:0};o.widgets_below=function(t){var n=e.isPlainObject(t)?t:t.coords().grid;var r=this;var i=this.gridmap;var s=n.row+n.size_y-1;var o=e([]);this.for_each_column_occupied(n,function(t){r.for_each_widget_below(t,s,function(t,n){if(!r.is_player(this)&&e.inArray(this,o)===-1){o=o.add(this);return true}})});return this.sort_by_row_asc(o)};o.set_cells_player_occupies=function(e,t){this.remove_from_gridmap(this.placeholder_grid_data);this.placeholder_grid_data.col=e;this.placeholder_grid_data.row=t;this.add_to_gridmap(this.placeholder_grid_data,this.$player);return this};o.empty_cells_player_occupies=function(){this.remove_from_gridmap(this.placeholder_grid_data);return this};o.can_go_up=function(e){var t=e.coords().grid;var n=t.row;var r=n-1;var i=this.gridmap;var s=[];var o=true;if(n===1){return false}this.for_each_column_occupied(t,function(e){var t=this.is_widget(e,r);if(this.is_occupied(e,r)||this.is_player(e,r)||this.is_placeholder_in(e,r)||this.is_player_in(e,r)){o=false;return true}});return o};o.can_move_to=function(e,t,n,r){var i=this.gridmap;var s=e.el;var o={size_y:e.size_y,size_x:e.size_x,col:t,row:n};var u=true;var a=t+e.size_x-1;if(a>this.cols){return false}if(r&&r0&&this.is_widget(r,h)&&e.inArray(o[r][h],c)===-1){u=s.call(o[r][h],r,h);c.push(o[r][h]);if(u){break}}}},"for_each/below":function(){for(h=i+1,a=o[r].length;h=1;o--){for(e=n-1;e>=1;e--){if(this.is_widget(o,e)){r.push(e);i.push(o);break}}}return{col:Math.max.apply(Math,i),row:Math.max.apply(Math,r)}};o.get_widgets_from=function(t,n){var r=this.gridmap;var i=e();if(t){i=i.add(this.$widgets.filter(function(){var n=e(this).attr("data-col");return n===t||n>t}))}if(n){i=i.add(this.$widgets.filter(function(){var t=e(this).attr("data-row");return t===n||t>n}))}return i};o.set_dom_grid_height=function(e){if(typeof e==="undefined"){var t=this.get_highest_occupied_cell().row;e=t*this.min_widget_height}this.container_height=e;this.$el.css("height",this.container_height);return this};o.set_dom_grid_width=function(e){if(typeof e==="undefined"){e=this.get_highest_occupied_cell().col}var t=this.options.autogrow_cols?this.options.max_cols:this.cols;e=Math.min(t,Math.max(e,this.options.min_cols));this.container_width=e*this.min_widget_width;this.$el.css("width",this.container_width);return this};o.generate_stylesheet=function(t){var n="";var r=this.options.max_size_x||this.cols;var i=0;var o=0;var u;var a;t||(t={});t.cols||(t.cols=this.cols);t.rows||(t.rows=this.rows);t.namespace||(t.namespace=this.options.namespace);t.widget_base_dimensions||(t.widget_base_dimensions=this.options.widget_base_dimensions);t.widget_margins||(t.widget_margins=this.options.widget_margins);t.min_widget_width=t.widget_margins[0]*2+t.widget_base_dimensions[0];t.min_widget_height=t.widget_margins[1]*2+t.widget_base_dimensions[1];var f=e.param(t);if(e.inArray(f,s.generated_stylesheets)>=0){return false}this.generated_stylesheets.push(f);s.generated_stylesheets.push(f);for(u=t.cols;u>=0;u--){n+=t.namespace+' [data-col="'+(u+1)+'"] { left:'+(u*t.widget_base_dimensions[0]+u*t.widget_margins[0]+(u+1)*t.widget_margins[0])+"px; }\n"}for(u=t.rows;u>=0;u--){n+=t.namespace+' [data-row="'+(u+1)+'"] { top:'+(u*t.widget_base_dimensions[1]+u*t.widget_margins[1]+(u+1)*t.widget_margins[1])+"px; }\n"}for(var l=1;l<=t.rows;l++){n+=t.namespace+' [data-sizey="'+l+'"] { height:'+(l*t.widget_base_dimensions[1]+(l-1)*t.widget_margins[1]*2)+"px; }\n"}for(var c=1;c<=r;c++){n+=t.namespace+' [data-sizex="'+c+'"] { width:'+(c*t.widget_base_dimensions[0]+(c-1)*t.widget_margins[0]*2)+"px; }\n"}this.remove_style_tags();return this.add_style_tag(n)};o.add_style_tag=function(e){var t=n;var r=t.createElement("style");t.getElementsByTagName("head")[0].appendChild(r);r.setAttribute("type","text/css");if(r.styleSheet){r.styleSheet.cssText=e}else{r.appendChild(n.createTextNode(e))}this.$style_tags=this.$style_tags.add(r);return this};o.remove_style_tags=function(){var t=s.generated_stylesheets;var n=this.generated_stylesheets;this.$style_tags.remove();s.generated_stylesheets=e.map(t,function(t){if(e.inArray(t,n)===-1){return t}})};o.generate_faux_grid=function(e,t){this.faux_grid=[];this.gridmap=[];var n;var r;for(n=t;n>0;n--){this.gridmap[n]=[];for(r=e;r>0;r--){this.add_faux_cell(r,n)}}return this};o.add_faux_cell=function(t,n){var r=e({left:this.baseX+(n-1)*this.min_widget_width,top:this.baseY+(t-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:n,row:t,original_col:n,original_row:t}).coords();if(!e.isArray(this.gridmap[n])){this.gridmap[n]=[]}this.gridmap[n][t]=false;this.faux_grid.push(r);return this};o.add_faux_rows=function(e){var t=this.rows;var n=t+(e||1);for(var r=n;r>t;r--){for(var i=this.cols;i>=1;i--){this.add_faux_cell(r,i)}}this.rows=n;if(this.options.autogenerate_stylesheet){this.generate_stylesheet()}return this};o.add_faux_cols=function(e){var t=this.cols;var n=t+(e||1);n=Math.min(n,this.options.max_cols);for(var r=t+1;r<=n;r++){for(var i=this.rows;i>=1;i--){this.add_faux_cell(i,r)}}this.cols=n;if(this.options.autogenerate_stylesheet){this.generate_stylesheet()}return this};o.recalculate_faux_grid=function(){var n=this.$wrapper.width();this.baseX=(e(t).width()-n)/2;this.baseY=this.$wrapper.offset().top;e.each(this.faux_grid,e.proxy(function(e,t){this.faux_grid[e]=t.update({left:this.baseX+(t.data.col-1)*this.min_widget_width,top:this.baseY+(t.data.row-1)*this.min_widget_height})},this));return this};o.get_widgets_from_DOM=function(){this.$widgets.each(e.proxy(function(t,n){this.register_widget(e(n))},this));return this};o.generate_grid_and_stylesheet=function(){var n=this.$wrapper.width();var r=this.options.max_cols;var i=Math.floor(n/this.min_widget_width)+this.options.extra_cols;var s=this.$widgets.map(function(){return e(this).attr("data-col")}).get();s.length||(s=[0]);var o=Math.max.apply(Math,s);this.cols=Math.max(o,i,this.options.min_cols);if(r!==Infinity&&r>=o&&r