diff --git a/dist/jquery.gridster.css b/dist/jquery.gridster.css
index 986c69f573..c77088046a 100644
--- a/dist/jquery.gridster.css
+++ b/dist/jquery.gridster.css
@@ -1,4 +1,4 @@
-/*! gridster.js - v0.1.0 - 2012-07-23
+/*! gridster.js - v0.1.0 - 2012-07-24
* https://github.com/ducksboard/gridster.js
* Copyright (c) 2012 ducksboard; Licensed MIT, GPL */
diff --git a/dist/jquery.gridster.js b/dist/jquery.gridster.js
index 769ba2b41d..bda06f8871 100644
--- a/dist/jquery.gridster.js
+++ b/dist/jquery.gridster.js
@@ -1,4 +1,4 @@
-/*! gridster.js - v0.1.0 - 2012-07-23
+/*! gridster.js - v0.1.0 - 2012-07-24
* https://github.com/ducksboard/gridster.js
* Copyright (c) 2012 ducksboard; Licensed MIT, GPL */
@@ -42,10 +42,10 @@
var el = this.el;
if (el && !update) {
- this.data = {} || el.offset();
+ this.data = el.offset();
this.data.width = el.width();
this.data.height = el.height();
- };
+ }
if (el && update && !not_update_offsets) {
var offset = el.offset();
@@ -320,7 +320,7 @@
}(jQuery, window, document));
-(function(window, undefined) {
+;(function(window, undefined) {
/* Debounce and throttle functions taken from underscore.js */
window.debounce = function(func, wait, immediate) {
var timeout;
@@ -360,7 +360,7 @@
};
};
-})(window)
+})(window);
;(function($, window, document, undefined){
@@ -411,7 +411,7 @@
this.player_min_left = 0 + this.options.offset_left;
this.init();
- };
+ }
var fn = Draggable.prototype;
@@ -438,7 +438,7 @@
fn.drag_handler = function(e) {
if (e.which !== 1) {
return false;
- };
+ }
var self = this;
var first = true;
@@ -464,7 +464,7 @@
if (self.is_dragging == true) {
throttle(self.on_dragmove.call(self, mme), 130);
- };
+ }
return false;
@@ -492,7 +492,7 @@
this.options.start.call(this.$player, e, {
helper: this.helper ? this.$helper : this.$player
});
- };
+ }
return false;
};
@@ -512,12 +512,12 @@
}else if(left < this.player_min_left) {
left = this.player_min_left;
}
- };
+ }
return {
left: left,
top: top
- }
+ };
};
@@ -554,7 +554,7 @@
'left': offset.left,
'top': offset.top
}
- }
+ };
if (this.options.stop) {
this.options.stop.call(this.$player, e, ui);
@@ -714,7 +714,7 @@
this.$wrapper.find('.player-revert').removeClass('player-revert');
this.drag_api.disable();
return this;
- }
+ };
/**
@@ -726,7 +726,7 @@
fn.enable = function() {
this.drag_api.enable();
return this;
- }
+ };
/**
@@ -828,7 +828,7 @@
if (callback) {
callback.apply(this, el);
- };
+ }
}, this));
};
@@ -897,7 +897,7 @@
'data-sizex': wgd.size_x,
'data-sizey': wgd.size_y
});
- };
+ }
// attach Coord object to player data-coord attribute
$el.data('coords', $el.coords());
@@ -1068,7 +1068,7 @@
var abs_offset = {
left: ui.position.left + this.baseX,
top: ui.position.top + this.baseY
- }
+ };
this.colliders_data = this.collision_api.get_closest_colliders(
abs_offset);
@@ -1340,7 +1340,7 @@
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) placing first the empty cells upper left.
*
- * @method sort_by_row_asc
+ * @method sort_by_row_and_col_asc
* @param {Array} widgets Array of grid coords objects
* @return {Array} Returns the array sorted.
*/
@@ -1360,7 +1360,7 @@
* Sorts an Array of grid coords objects by column (representing the grid
* coords of each widget) in ascending way.
*
- * @method sort_by_row_asc
+ * @method sort_by_col_asc
* @param {Array} widgets Array of grid coords objects
* @return {Array} Returns the array sorted.
*/
@@ -1626,7 +1626,7 @@
var right_col = (col + phgd.size_x - 1);
if (right_col > this.cols) {
col = col - (right_col - col);
- };
+ }
var moved_down = this.placeholder_grid_data.row < row;
var changed_column = this.placeholder_grid_data.col !== col;
@@ -2525,19 +2525,19 @@
$widgets = $widgets.add(
this.$widgets.filter(function() {
var tcol = $(this).attr('data-col');
- return (tcol == col || tcol > col);
+ return (tcol === col || tcol > col);
})
);
- };
+ }
if (row) {
$widgets = $widgets.add(
this.$widgets.filter(function() {
var trow = $(this).attr('data-row');
- return (trow == row || trow > row);
+ return (trow === row || trow > row);
})
);
- };
+ }
return $widgets;
}
@@ -2589,7 +2589,7 @@
// don't duplicate stylesheets for the same configuration
if ($.inArray(serialized_opts, Gridster.generated_stylesheets) >= 0) {
return false;
- };
+ }
Gridster.generated_stylesheets.push(serialized_opts);
diff --git a/dist/jquery.gridster.min.css b/dist/jquery.gridster.min.css
index 3cce5bc9d1..195434aebd 100644
--- a/dist/jquery.gridster.min.css
+++ b/dist/jquery.gridster.min.css
@@ -1,3 +1,3 @@
-/*! gridster.js - v0.1.0 - 2012-07-23
+/*! gridster.js - v0.1.0 - 2012-07-24
* https://github.com/ducksboard/gridster.js
* Copyright (c) 2012 ducksboard; Licensed MIT, GPL */.gridster{position:relative}.gridster>*{margin:0 auto;-webkit-transition:height .4s;-moz-transition:height .4s;-o-transition:height .4s;-ms-transition:height .4s;transition:height .4s}.gridster .gs_w{z-index:2;position:absolute}.ready .gs_w:not(.preview-holder){-webkit-transition:opacity .3s,left .3s,top .3s;-moz-transition:opacity .3s,left .3s,top .3s;-o-transition:opacity .3s,left .3s,top .3s;transition:opacity .3s,left .3s,top .3s}.gridster .preview-holder{z-index:1;position:absolute;background-color:#fff;border-color:#fff;opacity:.3}.gridster .player-revert{z-index:10!important;-webkit-transition:left .3s,top .3s!important;-moz-transition:left .3s,top .3s!important;-o-transition:left .3s,top .3s!important;transition:left .3s,top .3s!important}.gridster .dragging{z-index:10!important;-webkit-transition:all 0s!important;-moz-transition:all 0s!important;-o-transition:all 0s!important;transition:all 0s!important}
\ No newline at end of file
diff --git a/dist/jquery.gridster.min.js b/dist/jquery.gridster.min.js
index 9be252218e..5b21058a4c 100644
--- a/dist/jquery.gridster.min.js
+++ b/dist/jquery.gridster.min.js
@@ -1,4 +1,4 @@
-/*! gridster.js - v0.1.0 - 2012-07-23
+/*! gridster.js - v0.1.0 - 2012-07-24
* https://github.com/ducksboard/gridster.js
* Copyright (c) 2012 ducksboard; Licensed MIT, GPL */
-(function(a,b,c,d){function e(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var f=e.prototype;f.init=function(){this.set(),this.original_coords=this.get()},f.set=function(a,b){var c=this.el;c&&!a&&(this.data={}||c.offset(),this.data.width=c.width(),this.data.height=c.height());if(c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return this.coords.x1=e.left,this.coords.y1=e.top,this.coords.x2=e.left+e.width,this.coords.y2=e.top+e.height,this.coords.cx=e.left+e.width/2,this.coords.cy=e.top+e.height/2,this.coords.width=e.width,this.coords.height=e.height,this.coords.el=c||!1,this},f.update=function(b){if(!b&&!this.el)return this;if(b){var c=a.extend({},this.data,b);return this.data=c,this.set(!0,!0)}return this.set(!0),this},f.get=function(){return this.coords},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new e(this,arguments[0]);return this.data("coords",a),a}})(jQuery,window,document),function(a,b,c,d){function f(b,c,d){this.options=a.extend(e,d),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],typeof c=="string"||c instanceof jQuery?this.$colliders=a(c,this.options.colliders_context).not(this.$element):this.colliders=a(c),this.init()}var e={colliders_context:c.body},g=f.prototype;g.init=function(){this.find_collisions()},g.overlaps=function(a,b){var c=!1,d=!1;if(b.x1>=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)c=!0;if(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)d=!0;return c&&d},g.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging==!0&&throttle(c.on_dragmove.call(c,a),130),!1):!1}),!1},h.on_dragstart=function(a){return a.preventDefault(),this.drag_start=!0,this.is_dragging=!0,this.$container_offset=this.$container.offset(),this.options.helper==="clone"?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_max_left=this.$container.width()-this.player_width+this.options.offset_left,this.options.start&&this.options.start.call(this.$player,a,{helper:this.helper?this.$helper:this.$player}),!1},h.get_offset=function(a){a.preventDefault();var b=this.get_mouse_pos(a),c=b.left-this.mouse_init_pos.left,d=b.top-this.mouse_init_pos.top,e=this.el_init_offset.left+c-this.$container_offset.left,f=this.el_init_offset.top+d-this.$container_offset.top;return this.options.limit&&(e>this.player_max_left?e=this.player_max_left:e li",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,min_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,serialize_params:function(a,b){return{col:b.col,row:b.row}},collision:{},draggable:{distance:4}};f.generated_stylesheets=[];var g=f.prototype;g.init=function(){this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.$wrapper.addClass("ready"),this.draggable(),a(b).bind("resize",throttle(a.proxy(this.recalculate_faux_grid,this),200))},g.disable=function(){return this.$wrapper.find(".player-revert").removeClass("player-revert"),this.drag_api.disable(),this},g.enable=function(){return this.drag_api.enable(),this},g.add_widget=function(b,c,d){var e=this.next_position(c,d),f=a(b).attr({"data-col":e.col,"data-row":e.row,"data-sizex":e.size_x,"data-sizey":e.size_y}).addClass("gs_w").appendTo(this.$el).hide();return this.$widgets=this.$widgets.add(f),this.register_widget(f),this.set_dom_grid_height(),f.fadeIn()},g.next_position=function(a,b){a||(a=1),b||(b=1);var c=this.gridmap,d=c.length,e=[];for(var f=1;f",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:e.width,height:e.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},g.on_drag=function(a,b){var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};this.colliders_data=this.collision_api.get_closest_colliders(c),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:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},g.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.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.$player=null,this.$preview_holder.remove(),this.set_dom_grid_height(),this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b)},g.on_overlapped_column_change=function(b,c){if(!this.colliders_data.length)return;var d=this.get_targeted_columns(this.colliders_data[0].el.data.col),e=this.last_cols.length,f=d.length,g;for(g=0;gb.row?1:-1}),a},g.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a.row>b.row||a.row==b.row&&a.col>b.col?1:-1}),a},g.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a.col>b.col?1:-1}),a},g.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a.row+a.size_y=0&&a.inArray(c,d.rows)>=0},g.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},g.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},g.is_empty=function(a,b){return typeof this.gridmap[a]!="undefined"&&typeof this.gridmap[a][b]!="undefined"&&this.gridmap[a][b]===!1?!0:!1},g.is_occupied=function(a,b){return this.gridmap[a]?this.gridmap[a][b]?!0:!1:!1},g.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},g.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},g.get_widgets_under_player=function(){var b=this.cells_occupied_by_player,c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},g.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b=b-(f-b));var g=this.placeholder_grid_data.row0)if(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f))d[a].push(h),e=h0){if(this.is_occupied(a,g)&&!this.is_player(a,g))break;!this.is_player(a,g)&&!this.is_placeholder_in(a,g)&&d[a].push(g),g=b?a[d[0]]:!1},g.get_widgets_overlapped=function(){var b,c=a([]),d=[],e=this.cells_occupied_by_player.rows.slice(0);return e.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(b,f){a.each(e,a.proxy(function(b,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&a.inArray(g,d)===-1&&(c=c.add(g),d.push(g))},this))},this)),c},g.on_start_overlapping_column=function(a){this.set_player(a,!1)},g.on_start_overlapping_row=function(a){this.set_player(!1,a)},g.on_stop_overlapping_column=function(a){this.set_player();var b=this;this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},g.on_stop_overlapping_row=function(a){this.set_player();var b=this,c=this.cells_occupied_by_player.cols;for(var d=0,e=c.length;d0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},g.can_go_up_to_row=function(b,c,d){var e=this.gridmap,f=!0,g=[],h=b.row,i;this.for_each_column_occupied(b,function(a){var b=e[a];g[a]=[],i=h;while(i--)if(this.is_empty(a,i)&&!this.is_placeholder_in(a,i))g[a].push(i);else break;if(!g[a].length)return f=!1,!0});if(!f)return!1;i=d;for(i=1;i0?c:0},g.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,d=this,e=this.gridmap,f=c.row+c.size_y-1,g=a([]);return this.for_each_column_occupied(c,function(b){d.for_each_widget_below(b,f,function(b,c){if(!d.is_player(this)&&a.inArray(this,g)===-1)return g=g.add(this),!0})}),this.sort_by_row_asc(g)},g.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},g.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},g.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=this.gridmap,f=[],g=!0;return c===1?!1:(this.for_each_column_occupied(b,function(a){var b=this.is_widget(a,d);if(this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d))return g=!1,!0}),g)},g.can_move_to=function(a,b,c){var d=this.gridmap,e=a.el,f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:(this.for_each_cell_occupied(f,function(b,c){var d=this.is_widget(b,c);d&&(!a.el||d.is(e))&&(g=!1)}),g)},g.get_targeted_columns=function(a){var b=(a||this.player_grid_data.col)+(this.player_grid_data.size_x-1),c=[];for(var d=a;d<=b;d++)c.push(d);return c},g.get_targeted_rows=function(a){var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[];for(var d=a;d<=b;d++)c.push(d);return c},g.get_cells_occupied=function(a){var b={cols:[],rows:[]},c;arguments[1]instanceof jQuery&&(a=arguments[1].coords().grid);for(c=0;c0&&this.is_widget(d,m)&&a.inArray(g[d][m],l)===-1){h=f.call(g[d][m],d,m),l.push(g[d][m]);if(h)break}},"for_each/below":function(){for(m=e+1,i=g[d].length;m=1;e--)for(a=b[e].length-1;a>=1;a--)if(this.is_widget(e,a)){c.push(a),d[a]=e;break}var f=Math.max.apply(null,c);return this.highest_occupied_cell={col:d[f],row:f},this.highest_occupied_cell},g.get_widgets_from=function(b,c){var d=this.gridmap,e=a();return b&&(e=e.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c==b||c>b}))),c&&(e=e.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b==c||b>c}))),e},g.set_dom_grid_height=function(){var a=this.get_highest_occupied_cell().row;return this.$el.css("height",a*this.min_widget_height),this},g.generate_stylesheet=function(b){var c="",d=10,e=6,g=6,h,i;b||(b={}),b.cols||(b.cols=this.cols),b.rows||(b.rows=this.rows),b.namespace||(b.namespace=""),b.widget_base_dimensions||(b.widget_base_dimensions=this.options.widget_base_dimensions),b.widget_margins||(b.widget_margins=this.options.widget_margins),b.min_widget_width=b.widget_margins[0]*2+b.widget_base_dimensions[0],b.min_widget_height=b.widget_margins[1]*2+b.widget_base_dimensions[1];var j=a.param(b);if(a.inArray(j,f.generated_stylesheets)>=0)return!1;f.generated_stylesheets.push(j);for(h=b.cols+d;h>=0;h--)c+=b.namespace+' [data-col="'+(h+1)+'"] { left:'+(h*b.widget_base_dimensions[0]+h*b.widget_margins[0]+(h+1)*b.widget_margins[0])+"px;} ";for(h=b.rows+d;h>=0;h--)c+=b.namespace+' [data-row="'+(h+1)+'"] { top:'+(h*b.widget_base_dimensions[1]+h*b.widget_margins[1]+(h+1)*b.widget_margins[1])+"px;} ";for(var k=1;k0;d--){this.gridmap[d]=[];for(e=b;e>0;e--){var f=a({left:this.baseX+(d-1)*this.min_widget_width,top:this.baseY+(e-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:d,row:e,original_col:d,original_row:e}).coords();this.gridmap[d][e]=!1,this.faux_grid.push(f)}}return this},g.recalculate_faux_grid=function(){var c=this.$wrapper.width();return this.baseX=(a(b).width()-c)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this},g.get_widgets_from_DOM=function(){return this.$widgets.each(a.proxy(function(b,c){this.register_widget(a(c))},this)),this},g.generate_grid_and_stylesheet=function(){var c=this.$wrapper.width(),d=this.$wrapper.height(),e=Math.floor(c/this.min_widget_width)+this.options.extra_cols,f=Math.floor(d/this.min_widget_height)+this.options.extra_rows,g=this.$widgets.map(function(){return a(this).attr("data-col")}),h=this.$widgets.map(function(){return a(this).attr("data-row")}),i=Math.max.apply(null,g),j=Math.max.apply(null,h);return this.cols=Math.max(i,e,this.options.min_cols),this.rows=Math.max(j,f,this.options.min_rows),this.baseX=(a(b).width()-c)/2,this.baseY=this.$wrapper.offset().top,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this.generate_faux_grid(this.rows,this.cols)},a.fn.gridster=function(b){return this.each(function(){a(this).data("gridster")||a(this).data("gridster",new f(this,b))})}}(jQuery,window,document);
\ No newline at end of file
+(function(a,b,c,d){function e(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var f=e.prototype;f.init=function(){this.set(),this.original_coords=this.get()},f.set=function(a,b){var c=this.el;c&&!a&&(this.data=c.offset(),this.data.width=c.width(),this.data.height=c.height());if(c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return this.coords.x1=e.left,this.coords.y1=e.top,this.coords.x2=e.left+e.width,this.coords.y2=e.top+e.height,this.coords.cx=e.left+e.width/2,this.coords.cy=e.top+e.height/2,this.coords.width=e.width,this.coords.height=e.height,this.coords.el=c||!1,this},f.update=function(b){if(!b&&!this.el)return this;if(b){var c=a.extend({},this.data,b);return this.data=c,this.set(!0,!0)}return this.set(!0),this},f.get=function(){return this.coords},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new e(this,arguments[0]);return this.data("coords",a),a}})(jQuery,window,document),function(a,b,c,d){function f(b,c,d){this.options=a.extend(e,d),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],typeof c=="string"||c instanceof jQuery?this.$colliders=a(c,this.options.colliders_context).not(this.$element):this.colliders=a(c),this.init()}var e={colliders_context:c.body},g=f.prototype;g.init=function(){this.find_collisions()},g.overlaps=function(a,b){var c=!1,d=!1;if(b.x1>=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)c=!0;if(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)d=!0;return c&&d},g.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1b.y1&&a.y2b.cx&&a.x1b.x1&&a.x2c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging==!0&&throttle(c.on_dragmove.call(c,a),130),!1):!1}),!1},h.on_dragstart=function(a){return a.preventDefault(),this.drag_start=!0,this.is_dragging=!0,this.$container_offset=this.$container.offset(),this.options.helper==="clone"?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_max_left=this.$container.width()-this.player_width+this.options.offset_left,this.options.start&&this.options.start.call(this.$player,a,{helper:this.helper?this.$helper:this.$player}),!1},h.get_offset=function(a){a.preventDefault();var b=this.get_mouse_pos(a),c=b.left-this.mouse_init_pos.left,d=b.top-this.mouse_init_pos.top,e=this.el_init_offset.left+c-this.$container_offset.left,f=this.el_init_offset.top+d-this.$container_offset.top;return this.options.limit&&(e>this.player_max_left?e=this.player_max_left:e li",widget_margins:[10,10],widget_base_dimensions:[400,225],extra_rows:0,extra_cols:0,min_cols:1,min_rows:15,autogenerate_stylesheet:!0,avoid_overlapped_widgets:!0,serialize_params:function(a,b){return{col:b.col,row:b.row}},collision:{},draggable:{distance:4}};f.generated_stylesheets=[];var g=f.prototype;g.init=function(){this.generate_grid_and_stylesheet(),this.get_widgets_from_DOM(),this.set_dom_grid_height(),this.$wrapper.addClass("ready"),this.draggable(),a(b).bind("resize",throttle(a.proxy(this.recalculate_faux_grid,this),200))},g.disable=function(){return this.$wrapper.find(".player-revert").removeClass("player-revert"),this.drag_api.disable(),this},g.enable=function(){return this.drag_api.enable(),this},g.add_widget=function(b,c,d){var e=this.next_position(c,d),f=a(b).attr({"data-col":e.col,"data-row":e.row,"data-sizex":e.size_x,"data-sizey":e.size_y}).addClass("gs_w").appendTo(this.$el).hide();return this.$widgets=this.$widgets.add(f),this.register_widget(f),this.set_dom_grid_height(),f.fadeIn()},g.next_position=function(a,b){a||(a=1),b||(b=1);var c=this.gridmap,d=c.length,e=[];for(var f=1;f",{"class":"preview-holder","data-row":this.$player.attr("data-row"),"data-col":this.$player.attr("data-col"),css:{width:e.width,height:e.height}}).appendTo(this.$el),this.options.draggable.start&&this.options.draggable.start.call(this,b,c)},g.on_drag=function(a,b){var c={left:b.position.left+this.baseX,top:b.position.top+this.baseY};this.colliders_data=this.collision_api.get_closest_colliders(c),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:b.position.left,top:b.position.top}),this.options.draggable.drag&&this.options.draggable.drag.call(this,a,b)},g.on_stop_drag=function(a,b){this.$helper.add(this.$player).add(this.$wrapper).removeClass("dragging"),b.position.left=b.position.left+this.baseX,b.position.top=b.position.top+this.baseY,this.colliders_data=this.collision_api.get_closest_colliders(b.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.$player=null,this.$preview_holder.remove(),this.set_dom_grid_height(),this.options.draggable.stop&&this.options.draggable.stop.call(this,a,b)},g.on_overlapped_column_change=function(b,c){if(!this.colliders_data.length)return;var d=this.get_targeted_columns(this.colliders_data[0].el.data.col),e=this.last_cols.length,f=d.length,g;for(g=0;gb.row?1:-1}),a},g.sort_by_row_and_col_asc=function(a){return a=a.sort(function(a,b){return a.row>b.row||a.row==b.row&&a.col>b.col?1:-1}),a},g.sort_by_col_asc=function(a){return a=a.sort(function(a,b){return a.col>b.col?1:-1}),a},g.sort_by_row_desc=function(a){return a=a.sort(function(a,b){return a.row+a.size_y=0&&a.inArray(c,d.rows)>=0},g.is_placeholder_in=function(b,c){var d=this.cells_occupied_by_placeholder||{};return this.is_placeholder_in_col(b)&&a.inArray(c,d.rows)>=0},g.is_placeholder_in_col=function(b){var c=this.cells_occupied_by_placeholder||[];return a.inArray(b,c.cols)>=0},g.is_empty=function(a,b){return typeof this.gridmap[a]!="undefined"&&typeof this.gridmap[a][b]!="undefined"&&this.gridmap[a][b]===!1?!0:!1},g.is_occupied=function(a,b){return this.gridmap[a]?this.gridmap[a][b]?!0:!1:!1},g.is_widget=function(a,b){var c=this.gridmap[a];return c?(c=c[b],c?c:!1):!1},g.is_widget_under_player=function(a,b){return this.is_widget(a,b)?this.is_player_in(a,b):!1},g.get_widgets_under_player=function(){var b=this.cells_occupied_by_player,c=a([]);return a.each(b.cols,a.proxy(function(d,e){a.each(b.rows,a.proxy(function(a,b){this.is_widget(e,b)&&(c=c.add(this.gridmap[e][b]))},this))},this)),c},g.set_placeholder=function(b,c){var d=a.extend({},this.placeholder_grid_data),e=this.widgets_below({col:d.col,row:d.row,size_y:d.size_y,size_x:d.size_x}),f=b+d.size_x-1;f>this.cols&&(b=b-(f-b));var g=this.placeholder_grid_data.row0)if(this.is_empty(a,h)||this.is_player(a,h)||this.is_widget(a,h)&&g[h].is(f))d[a].push(h),e=h0){if(this.is_occupied(a,g)&&!this.is_player(a,g))break;!this.is_player(a,g)&&!this.is_placeholder_in(a,g)&&d[a].push(g),g=b?a[d[0]]:!1},g.get_widgets_overlapped=function(){var b,c=a([]),d=[],e=this.cells_occupied_by_player.rows.slice(0);return e.reverse(),a.each(this.cells_occupied_by_player.cols,a.proxy(function(b,f){a.each(e,a.proxy(function(b,e){if(!this.gridmap[f])return!0;var g=this.gridmap[f][e];this.is_occupied(f,e)&&!this.is_player(g)&&a.inArray(g,d)===-1&&(c=c.add(g),d.push(g))},this))},this)),c},g.on_start_overlapping_column=function(a){this.set_player(a,!1)},g.on_start_overlapping_row=function(a){this.set_player(!1,a)},g.on_stop_overlapping_column=function(a){this.set_player();var b=this;this.for_each_widget_below(a,this.cells_occupied_by_player.rows[0],function(a,c){b.move_widget_up(this,b.player_grid_data.size_y)})},g.on_stop_overlapping_row=function(a){this.set_player();var b=this,c=this.cells_occupied_by_player.cols;for(var d=0,e=c.length;d0&&this.move_widget_down(d,f)},this)),h.row=i,this.update_widget_position(h,b),b.attr("data-row",h.row),this.$changed=this.$changed.add(b),f.push(b)}},g.can_go_up_to_row=function(b,c,d){var e=this.gridmap,f=!0,g=[],h=b.row,i;this.for_each_column_occupied(b,function(a){var b=e[a];g[a]=[],i=h;while(i--)if(this.is_empty(a,i)&&!this.is_placeholder_in(a,i))g[a].push(i);else break;if(!g[a].length)return f=!1,!0});if(!f)return!1;i=d;for(i=1;i0?c:0},g.widgets_below=function(b){var c=a.isPlainObject(b)?b:b.coords().grid,d=this,e=this.gridmap,f=c.row+c.size_y-1,g=a([]);return this.for_each_column_occupied(c,function(b){d.for_each_widget_below(b,f,function(b,c){if(!d.is_player(this)&&a.inArray(this,g)===-1)return g=g.add(this),!0})}),this.sort_by_row_asc(g)},g.set_cells_player_occupies=function(a,b){return this.remove_from_gridmap(this.placeholder_grid_data),this.placeholder_grid_data.col=a,this.placeholder_grid_data.row=b,this.add_to_gridmap(this.placeholder_grid_data,this.$player),this},g.empty_cells_player_occupies=function(){return this.remove_from_gridmap(this.placeholder_grid_data),this},g.can_go_up=function(a){var b=a.coords().grid,c=b.row,d=c-1,e=this.gridmap,f=[],g=!0;return c===1?!1:(this.for_each_column_occupied(b,function(a){var b=this.is_widget(a,d);if(this.is_occupied(a,d)||this.is_player(a,d)||this.is_placeholder_in(a,d))return g=!1,!0}),g)},g.can_move_to=function(a,b,c){var d=this.gridmap,e=a.el,f={size_y:a.size_y,size_x:a.size_x,col:b,row:c},g=!0,h=b+a.size_x-1;return h>this.cols?!1:(this.for_each_cell_occupied(f,function(b,c){var d=this.is_widget(b,c);d&&(!a.el||d.is(e))&&(g=!1)}),g)},g.get_targeted_columns=function(a){var b=(a||this.player_grid_data.col)+(this.player_grid_data.size_x-1),c=[];for(var d=a;d<=b;d++)c.push(d);return c},g.get_targeted_rows=function(a){var b=(a||this.player_grid_data.row)+(this.player_grid_data.size_y-1),c=[];for(var d=a;d<=b;d++)c.push(d);return c},g.get_cells_occupied=function(a){var b={cols:[],rows:[]},c;arguments[1]instanceof jQuery&&(a=arguments[1].coords().grid);for(c=0;c0&&this.is_widget(d,m)&&a.inArray(g[d][m],l)===-1){h=f.call(g[d][m],d,m),l.push(g[d][m]);if(h)break}},"for_each/below":function(){for(m=e+1,i=g[d].length;m=1;e--)for(a=b[e].length-1;a>=1;a--)if(this.is_widget(e,a)){c.push(a),d[a]=e;break}var f=Math.max.apply(null,c);return this.highest_occupied_cell={col:d[f],row:f},this.highest_occupied_cell},g.get_widgets_from=function(b,c){var d=this.gridmap,e=a();return b&&(e=e.add(this.$widgets.filter(function(){var c=a(this).attr("data-col");return c===b||c>b}))),c&&(e=e.add(this.$widgets.filter(function(){var b=a(this).attr("data-row");return b===c||b>c}))),e},g.set_dom_grid_height=function(){var a=this.get_highest_occupied_cell().row;return this.$el.css("height",a*this.min_widget_height),this},g.generate_stylesheet=function(b){var c="",d=10,e=6,g=6,h,i;b||(b={}),b.cols||(b.cols=this.cols),b.rows||(b.rows=this.rows),b.namespace||(b.namespace=""),b.widget_base_dimensions||(b.widget_base_dimensions=this.options.widget_base_dimensions),b.widget_margins||(b.widget_margins=this.options.widget_margins),b.min_widget_width=b.widget_margins[0]*2+b.widget_base_dimensions[0],b.min_widget_height=b.widget_margins[1]*2+b.widget_base_dimensions[1];var j=a.param(b);if(a.inArray(j,f.generated_stylesheets)>=0)return!1;f.generated_stylesheets.push(j);for(h=b.cols+d;h>=0;h--)c+=b.namespace+' [data-col="'+(h+1)+'"] { left:'+(h*b.widget_base_dimensions[0]+h*b.widget_margins[0]+(h+1)*b.widget_margins[0])+"px;} ";for(h=b.rows+d;h>=0;h--)c+=b.namespace+' [data-row="'+(h+1)+'"] { top:'+(h*b.widget_base_dimensions[1]+h*b.widget_margins[1]+(h+1)*b.widget_margins[1])+"px;} ";for(var k=1;k0;d--){this.gridmap[d]=[];for(e=b;e>0;e--){var f=a({left:this.baseX+(d-1)*this.min_widget_width,top:this.baseY+(e-1)*this.min_widget_height,width:this.min_widget_width,height:this.min_widget_height,col:d,row:e,original_col:d,original_row:e}).coords();this.gridmap[d][e]=!1,this.faux_grid.push(f)}}return this},g.recalculate_faux_grid=function(){var c=this.$wrapper.width();return this.baseX=(a(b).width()-c)/2,this.baseY=this.$wrapper.offset().top,a.each(this.faux_grid,a.proxy(function(a,b){this.faux_grid[a]=b.update({left:this.baseX+(b.data.col-1)*this.min_widget_width,top:this.baseY+(b.data.row-1)*this.min_widget_height})},this)),this},g.get_widgets_from_DOM=function(){return this.$widgets.each(a.proxy(function(b,c){this.register_widget(a(c))},this)),this},g.generate_grid_and_stylesheet=function(){var c=this.$wrapper.width(),d=this.$wrapper.height(),e=Math.floor(c/this.min_widget_width)+this.options.extra_cols,f=Math.floor(d/this.min_widget_height)+this.options.extra_rows,g=this.$widgets.map(function(){return a(this).attr("data-col")}),h=this.$widgets.map(function(){return a(this).attr("data-row")}),i=Math.max.apply(null,g),j=Math.max.apply(null,h);return this.cols=Math.max(i,e,this.options.min_cols),this.rows=Math.max(j,f,this.options.min_rows),this.baseX=(a(b).width()-c)/2,this.baseY=this.$wrapper.offset().top,this.options.autogenerate_stylesheet&&this.generate_stylesheet(),this.generate_faux_grid(this.rows,this.cols)},a.fn.gridster=function(b){return this.each(function(){a(this).data("gridster")||a(this).data("gridster",new f(this,b))})}}(jQuery,window,document);
\ No newline at end of file
diff --git a/docs/classes/Gridster.html b/docs/classes/Gridster.html
index 351ad30790..51266028a4 100644
--- a/docs/classes/Gridster.html
+++ b/docs/classes/Gridster.html
@@ -868,14 +868,14 @@
- sort_by_row_asc
+ sort_by_col_asc
- sort_by_row_asc
+ sort_by_row_and_col_asc
@@ -7454,113 +7454,8 @@ mapped array of positions.
-
-
sort_by_row_asc
-
-
-
-
-
-
-
- Array
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Sorts an Array of grid coords objects (representing the grid coords of
-each widget) in ascending way.
-
-
-
-
-
Parameters:
-
-
-
- -
-
-
widgets
- Array
-
-
-
-
-
-
Array of grid coords objects
-
-
-
-
-
-
-
-
-
-
-
-
Returns:
-
-
-
-
- Array:
-
- Returns the array sorted.
-
-
-
-
-
-
-
-
-
-
-
sort_by_row_asc
+
+
sort_by_col_asc
@@ -7664,8 +7559,8 @@ coords of each widget) in ascending way.
-
-
sort_by_row_asc
+
+
sort_by_row_and_col_asc
@@ -7766,6 +7661,111 @@ each widget) placing first the empty cells upper left.
+
+
+
+
+
sort_by_row_asc
+
+
+
+
+
+
+
+ Array
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Sorts an Array of grid coords objects (representing the grid coords of
+each widget) in ascending way.
+
+
+
+
+
Parameters:
+
+
+
+ -
+
+
widgets
+ Array
+
+
+
+
+
+
Array of grid coords objects
+
+
+
+
+
+
+
+
+
+
+
+
Returns:
+
+
+
+
+ Array:
+
+ Returns the array sorted.
+
+
+
+
+
+
diff --git a/docs/data.json b/docs/data.json
index 59202ebe88..80b2721731 100644
--- a/docs/data.json
+++ b/docs/data.json
@@ -704,7 +704,7 @@
"line": 740,
"description": "Sorts an Array of grid coords objects (representing the grid coords of\neach widget) placing first the empty cells upper left.",
"itemtype": "method",
- "name": "sort_by_row_asc",
+ "name": "sort_by_row_and_col_asc",
"params": [
{
"name": "widgets",
@@ -723,7 +723,7 @@
"line": 760,
"description": "Sorts an Array of grid coords objects by column (representing the grid\ncoords of each widget) in ascending way.",
"itemtype": "method",
- "name": "sort_by_row_asc",
+ "name": "sort_by_col_asc",
"params": [
{
"name": "widgets",
diff --git a/docs/files/src_jquery.coords.js.html b/docs/files/src_jquery.coords.js.html
index ef71a741f0..d9957d937e 100644
--- a/docs/files/src_jquery.coords.js.html
+++ b/docs/files/src_jquery.coords.js.html
@@ -141,10 +141,10 @@
var el = this.el;
if (el && !update) {
- this.data = {} || el.offset();
+ this.data = el.offset();
this.data.width = el.width();
this.data.height = el.height();
- };
+ }
if (el && update && !not_update_offsets) {
var offset = el.offset();
diff --git a/docs/files/src_jquery.draggable.js.html b/docs/files/src_jquery.draggable.js.html
index ada2dff3fb..c43dc5817e 100644
--- a/docs/files/src_jquery.draggable.js.html
+++ b/docs/files/src_jquery.draggable.js.html
@@ -150,7 +150,7 @@
this.player_min_left = 0 + this.options.offset_left;
this.init();
- };
+ }
var fn = Draggable.prototype;
@@ -177,7 +177,7 @@
fn.drag_handler = function(e) {
if (e.which !== 1) {
return false;
- };
+ }
var self = this;
var first = true;
@@ -203,7 +203,7 @@
if (self.is_dragging == true) {
throttle(self.on_dragmove.call(self, mme), 130);
- };
+ }
return false;
@@ -231,7 +231,7 @@
this.options.start.call(this.$player, e, {
helper: this.helper ? this.$helper : this.$player
});
- };
+ }
return false;
};
@@ -251,12 +251,12 @@
}else if(left < this.player_min_left) {
left = this.player_min_left;
}
- };
+ }
return {
left: left,
top: top
- }
+ };
};
@@ -293,7 +293,7 @@
'left': offset.left,
'top': offset.top
}
- }
+ };
if (this.options.stop) {
this.options.stop.call(this.$player, e, ui);
diff --git a/docs/files/src_jquery.gridster.js.html b/docs/files/src_jquery.gridster.js.html
index 4f6b54bcd0..3001318942 100644
--- a/docs/files/src_jquery.gridster.js.html
+++ b/docs/files/src_jquery.gridster.js.html
@@ -210,7 +210,7 @@
this.$wrapper.find('.player-revert').removeClass('player-revert');
this.drag_api.disable();
return this;
- }
+ };
/**
@@ -222,7 +222,7 @@
fn.enable = function() {
this.drag_api.enable();
return this;
- }
+ };
/**
@@ -324,7 +324,7 @@
if (callback) {
callback.apply(this, el);
- };
+ }
}, this));
};
@@ -393,7 +393,7 @@
'data-sizex': wgd.size_x,
'data-sizey': wgd.size_y
});
- };
+ }
// attach Coord object to player data-coord attribute
$el.data('coords', $el.coords());
@@ -564,7 +564,7 @@
var abs_offset = {
left: ui.position.left + this.baseX,
top: ui.position.top + this.baseY
- }
+ };
this.colliders_data = this.collision_api.get_closest_colliders(
abs_offset);
@@ -836,7 +836,7 @@
* Sorts an Array of grid coords objects (representing the grid coords of
* each widget) placing first the empty cells upper left.
*
- * @method sort_by_row_asc
+ * @method sort_by_row_and_col_asc
* @param {Array} widgets Array of grid coords objects
* @return {Array} Returns the array sorted.
*/
@@ -856,7 +856,7 @@
* Sorts an Array of grid coords objects by column (representing the grid
* coords of each widget) in ascending way.
*
- * @method sort_by_row_asc
+ * @method sort_by_col_asc
* @param {Array} widgets Array of grid coords objects
* @return {Array} Returns the array sorted.
*/
@@ -1122,7 +1122,7 @@
var right_col = (col + phgd.size_x - 1);
if (right_col > this.cols) {
col = col - (right_col - col);
- };
+ }
var moved_down = this.placeholder_grid_data.row < row;
var changed_column = this.placeholder_grid_data.col !== col;
@@ -2021,19 +2021,19 @@
$widgets = $widgets.add(
this.$widgets.filter(function() {
var tcol = $(this).attr('data-col');
- return (tcol == col || tcol > col);
+ return (tcol === col || tcol > col);
})
);
- };
+ }
if (row) {
$widgets = $widgets.add(
this.$widgets.filter(function() {
var trow = $(this).attr('data-row');
- return (trow == row || trow > row);
+ return (trow === row || trow > row);
})
);
- };
+ }
return $widgets;
}
@@ -2085,7 +2085,7 @@
// don't duplicate stylesheets for the same configuration
if ($.inArray(serialized_opts, Gridster.generated_stylesheets) >= 0) {
return false;
- };
+ }
Gridster.generated_stylesheets.push(serialized_opts);