Skip to content

Commit

Permalink
Release v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vieron committed Feb 14, 2014
1 parent 073fdc4 commit 967984f
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 153 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<a name="v0.5.0"></a>
## v0.5.0 (2014-02-14)


#### Bug Fixes

* **autogrow:** refining autogrow_cols behavior and grid width issues ([835c2df8](http://github.com/ducksboard/gridster.js/commit/835c2df84419a92b1641b687fcf083f3ff102627))
* **resize.stop:** Call resize.stop at the latest possible moment ([e21f63a0](http://github.com/ducksboard/gridster.js/commit/e21f63a05a539f5c611eb49cd6861b1e38b36531))


#### Features

* **draggable:** Add toggle draggable method. ([073fdc40](http://github.com/ducksboard/gridster.js/commit/073fdc40e0a94dd371646fc54cd420e3ddab0254))

<a name="v0.4.4"></a>
### v0.4.4 (2014-02-13)

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.gridster.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! gridster.js - v0.4.4 - 2014-02-13
/*! gridster.js - v0.5.0 - 2014-02-14
* http://gridster.net/
* Copyright (c) 2014 ducksboard; Licensed MIT */

Expand Down
156 changes: 77 additions & 79 deletions dist/jquery.gridster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! gridster.js - v0.4.4 - 2014-02-13
/*! gridster.js - v0.5.0 - 2014-02-14
* http://gridster.net/
* Copyright (c) 2014 ducksboard; Licensed MIT */

Expand Down Expand Up @@ -138,12 +138,7 @@
this.$element = el;
this.last_colliders = [];
this.last_colliders_coords = [];
if (typeof colliders === 'string' || colliders instanceof $) {
this.$colliders = $(colliders,
this.options.colliders_context).not(this.$element);
}else{
this.colliders = $(colliders);
}
this.set_colliders(colliders);

this.init();
}
Expand Down Expand Up @@ -308,6 +303,16 @@
};


fn.set_colliders = function(colliders) {
if (typeof colliders === 'string' || colliders instanceof $) {
this.$colliders = $(colliders,
this.options.colliders_context).not(this.$element);
}else{
this.colliders = $(colliders);
}
};


//jQuery adapter
$.fn.collision = function(collider, options) {
return new Collision( this, collider, options );
Expand Down Expand Up @@ -951,18 +956,6 @@
return this;
};

/**
* Toggle dragging.
*
* @method toggle
* @return {Class} Returns the instance of the Gridster Class.
*/

fn.toggle = function() {
(this.drag_api.disabled) ? this.drag_api.enable() : this.drag_api.disable();
return this;
};



/**
Expand Down Expand Up @@ -1047,7 +1040,7 @@
this.set_dom_grid_width();
this.set_dom_grid_height();

this.drag_api.set_limits(this.container_width);
this.drag_api.set_limits(this.cols * this.min_widget_width);

return $w.fadeIn();
};
Expand Down Expand Up @@ -1602,7 +1595,7 @@
var draggable_options = $.extend(true, {}, this.options.draggable, {
offset_left: this.options.widget_margins[0],
offset_top: this.options.widget_margins[1],
container_width: this.container_width,
container_width: this.cols * this.min_widget_width,
limit: true,
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON',
'.' + this.options.resize.handle_class],
Expand Down Expand Up @@ -1696,14 +1689,15 @@
this.placeholder_grid_data = $.extend({}, this.player_grid_data);

this.set_dom_grid_height(this.$el.height() +
(this.player_grid_data.size_y * this.min_widget_height));
(this.player_grid_data.size_y * this.min_widget_height));

this.set_dom_grid_width(this.highest_col + 1);
this.set_dom_grid_width(this.cols);

// auto grow cols
var pgd_sizex = this.player_grid_data.size_x;
var cols_diff = this.cols - this.highest_col;
if (cols_diff < this.player_grid_data.size_x) {
this.add_faux_cols(this.player_grid_data.size_x - cols_diff);

if (this.options.autogrow_cols && cols_diff <= pgd_sizex) {
this.add_faux_cols(Math.min(pgd_sizex - cols_diff, 1));
}

var colliders = this.faux_grid;
Expand Down Expand Up @@ -1755,31 +1749,30 @@
top: ui.position.top + this.baseY
};

// auto grow cols
if (this.options.autogrow_cols) {
var prcol = this.placeholder_grid_data.col +
this.placeholder_grid_data.size_x - 1;

// "- 1" due to adding at least 1 column in on_start_drag
if (prcol >= 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(
abs_offset);

this.on_overlapped_column_change(
this.on_start_overlapping_column,
this.on_stop_overlapping_column
);
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.on_start_overlapping_row, this.on_stop_overlapping_row);

//auto grow cols
if (this.options.autogrow_cols) {
var prcol = this.placeholder_grid_data.col +
this.placeholder_grid_data.size_x - 1;
if (prcol === this.highest_col) {
if (prcol < this.cols) {
this.set_dom_grid_width(prcol + 1);
}
this.highest_col = prcol + 1;
this.drag_api.set_limits(this.container_width);
}
}

if (this.helper && this.$player) {
this.$player.css({
Expand Down Expand Up @@ -1855,7 +1848,7 @@
this.set_dom_grid_width();

if (this.options.autogrow_cols) {
this.drag_api.set_limits(this.container_width);
this.drag_api.set_limits(this.cols * this.min_widget_width);
}
};

Expand Down Expand Up @@ -1893,6 +1886,8 @@

this.resize_initial_last_col = this.get_highest_occupied_cell().col;

this.set_dom_grid_width(this.cols);

this.resize_dir = {
right: ui.$player.is('.' + this.resize_handle_class + '-x'),
bottom: ui.$player.is('.' + this.resize_handle_class + '-y')
Expand Down Expand Up @@ -1946,19 +1941,19 @@
'min-width': '',
'min-height': ''
});

if (this.options.resize.stop) {
this.options.resize.stop.call(this, event, ui, 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.container_width);
this.drag_api.set_limits(this.cols * this.min_widget_width);
}

if (this.options.resize.stop) {
this.options.resize.stop.call(this, event, ui, this.$resized_widget);
}

this.$el.trigger('gridster:resizestop');
};

/**
Expand All @@ -1973,52 +1968,54 @@
var rel_y = (ui.pointer.diff_top);
var wbd_x = this.options.widget_base_dimensions[0];
var wbd_y = this.options.widget_base_dimensions[1];
var margin_x = this.options.widget_margins[0];
var margin_y = this.options.widget_margins[1];
var max_size_x = this.resize_max_size_x;
var min_size_x = this.resize_min_size_x;
var max_size_y = this.resize_max_size_y;
var min_size_y = this.resize_min_size_y;
var autogrow = this.options.autogrow_cols;
var width;
var max_width = Infinity;
var max_height = Infinity;

var inc_units_x = Math.ceil((rel_x /
(this.options.widget_base_dimensions[0] +
this.options.widget_margins[0] * 2)) - 0.2);

var inc_units_y = Math.ceil((rel_y /
(this.options.widget_base_dimensions[1] +
this.options.widget_margins[1] * 2)) - 0.2);
var inc_units_x = Math.ceil((rel_x / (wbd_x + margin_x * 2)) - 0.2);
var inc_units_y = Math.ceil((rel_y / (wbd_y + margin_y * 2)) - 0.2);

var size_x = Math.max(1, this.resize_initial_sizex + inc_units_x);
var size_y = Math.max(1, this.resize_initial_sizey + inc_units_y);

size_x = Math.max(Math.min(size_x, this.resize_max_size_x), this.resize_min_size_x);
max_width = (this.resize_max_size_x * wbd_x) +
((size_x - 1) * this.options.widget_margins[0] * 2);
min_width = (this.resize_min_size_x * wbd_x) +
((size_x - 1) * this.options.widget_margins[0] * 2);
var max_cols = (this.container_width / this.min_widget_width) -
this.resize_initial_col + 1;
var limit_width = ((max_cols * this.min_widget_width) - margin_x * 2);

size_x = Math.max(Math.min(size_x, max_size_x), min_size_x);
size_x = Math.min(max_cols, size_x);
width = (max_size_x * wbd_x) + ((size_x - 1) * margin_x * 2);
max_width = Math.min(width, limit_width);
min_width = (min_size_x * wbd_x) + ((size_x - 1) * margin_x * 2);

size_y = Math.max(Math.min(size_y, this.resize_max_size_y), this.resize_min_size_y);
max_height = (this.resize_max_size_y * wbd_y) +
((size_y - 1) * this.options.widget_margins[1] * 2);
min_height = (this.resize_min_size_y * wbd_y) +
((size_y - 1) * this.options.widget_margins[1] * 2);
size_y = Math.max(Math.min(size_y, max_size_y), min_size_y);
max_height = (max_size_y * wbd_y) + ((size_y - 1) * margin_y * 2);
min_height = (min_size_y * wbd_y) + ((size_y - 1) * margin_y * 2);

if (this.resize_dir.right) {
size_y = this.resize_initial_sizey;
} else if (this.resize_dir.bottom) {
size_x = this.resize_initial_sizex;
}


if (this.options.autogrow_cols) {
// auto grow cols
if (autogrow) {
var last_widget_col = this.resize_initial_col + size_x - 1;
if (this.options.autogrow_cols && this.resize_initial_last_col <= last_widget_col) {
this.set_dom_grid_width(last_widget_col + 1);
if (autogrow && this.resize_initial_last_col <= last_widget_col) {
this.set_dom_grid_width(Math.max(last_widget_col + 1, this.cols));

if (this.cols < last_widget_col) {
this.add_faux_cols(last_widget_col - this.cols);
}
}
}


var css_props = {};
!this.resize_dir.bottom && (css_props.width = Math.max(Math.min(
this.resize_initial_width + rel_x, max_width), min_width));
Expand All @@ -2031,6 +2028,7 @@
size_y !== this.resize_last_sizey) {

this.resize_widget(this.$resized_widget, size_x, size_y);
this.set_dom_grid_width(this.cols);

this.$resize_preview_holder.css({
'width': '',
Expand Down Expand Up @@ -3496,14 +3494,14 @@
* @return {Object} Returns the instance of the Gridster class.
*/
fn.set_dom_grid_width = function(cols) {
var width;

if (typeof cols === 'undefined') {
cols = this.get_highest_occupied_cell().col;
}

cols = Math.min(this.options.max_cols,
Math.max(cols, this.options.min_cols));
var max_cols = (this.options.autogrow_cols ? this.options.max_cols :
this.cols);

cols = Math.min(max_cols, Math.max(cols, this.options.min_cols));
this.container_width = cols * this.min_widget_width;
this.$el.css('width', this.container_width);
return this;
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.gridster.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/jquery.gridster.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 967984f

Please sign in to comment.