Skip to content

Commit 58b8f8a

Browse files
David S MorseDavid S Morse
authored andcommitted
Prep release of 0.7.0
1 parent e7d7b55 commit 58b8f8a

File tree

9 files changed

+119
-116
lines changed

9 files changed

+119
-116
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name="v0.7.0"></a>
2+
## v0.7.0 (2016-02-26)
3+
4+
5+
#### Bug Fixes
6+
7+
* Apply fix from #22 to vertical positioning ([dfc64916](http://github.com/dsmorse/gridster.js/commit/dfc649168c5b6a2a230b90a47e19621a6937fc7c))
8+
* convert from JQury to DOM ([4936ef82](http://github.com/dsmorse/gridster.js/commit/4936ef82c04690fde118c3d54b798ceaf7c376e6))
9+
* **fn.generate_stylesheet:** only return new stylesheet if colWidth and this.$wrapper.width() are > 0 ([f513793a](http://github.com/dsmorse/gridster.js/commit/f513793a8c0ec63509f6296325a8a7a6e34179f5))
10+
* **gridster:** Add additiona error checking on widgets removal ([2b0f9963](http://github.com/dsmorse/gridster.js/commit/2b0f9963ef80c9acc6f66545eb53597836e2ebec))
11+
112
<a name="v0.6.10"></a>
213
### v0.6.10 (2015-05-31)
314
* Add Ruby on Rails support

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gridster",
33
"homepage": "dsmorse.github.io/gridster.js/",
4-
"version": "0.6.10",
4+
"version": "0.7.0",
55
"dependencies": {
66
"jquery": "^2.1.3"
77
},

dist/jquery.gridster.js

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.6.10 - 2016-01-21
1+
/*! gridster.js - v0.7.0 - 2016-02-26
22
* https://dsmorse.github.io/gridster.js/
33
* Copyright (c) 2016 ducksboard; Licensed MIT */
44

@@ -938,6 +938,7 @@
938938
responsive_breakpoint: false,
939939
scroll_container: window,
940940
shift_larger_widgets_down: true,
941+
move_widgets_down_only: false,
941942
shift_widgets_up: true,
942943
show_element: function($el, callback) {
943944
if (callback) {
@@ -1692,45 +1693,6 @@
16921693
};
16931694

16941695

1695-
/**
1696-
* Change the dimensions of widgets.
1697-
*
1698-
* @method resize_widget_dimensions
1699-
* @param {Object} [options] An Object with all options you want to
1700-
* overwrite:
1701-
* @param {Array} [options.widget_margins] Margin between widgets.
1702-
* The first index for the horizontal margin (left, right) and
1703-
* the second for the vertical margin (top, bottom).
1704-
* @param {Array} [options.widget_base_dimensions] Base widget dimensions
1705-
* in pixels. The first index for the width and the second for the
1706-
* height.
1707-
* @return {Class} Returns the instance of the Gridster Class.
1708-
*/
1709-
fn.resize_widget_dimensions = function (options) {
1710-
if (options.widget_margins) {
1711-
this.options.widget_margins = options.widget_margins;
1712-
}
1713-
1714-
if (options.widget_base_dimensions) {
1715-
this.options.widget_base_dimensions = options.widget_base_dimensions;
1716-
}
1717-
1718-
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
1719-
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
1720-
1721-
this.$widgets.each($.proxy(function (i, widget) {
1722-
var $widget = $(widget);
1723-
this.resize_widget($widget);
1724-
}, this));
1725-
1726-
this.generate_grid_and_stylesheet();
1727-
this.get_widgets_from_DOM();
1728-
this.set_dom_grid_height();
1729-
1730-
return this;
1731-
};
1732-
1733-
17341696
/**
17351697
* Mutate widget dimensions and position in the grid map.
17361698
*
@@ -1864,7 +1826,7 @@
18641826
}, this));
18651827

18661828
if (!this.is_resizing) {
1867-
this.set_dom_grid_height();
1829+
this.set_dom_grid_height();
18681830
}
18691831

18701832
return this;
@@ -2472,13 +2434,23 @@
24722434

24732435
this.$changed = this.$changed.add(this.$player);
24742436

2475-
// move the cells down if there is an overlap and we are in static mode
2476-
if (this.options.collision.wait_for_mouseup) {
2477-
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
2478-
if (this.is_widget(tcol, trow)) {
2479-
this.move_widget_down(this.is_widget(tcol, trow), this.placeholder_grid_data.size_y);
2480-
}
2481-
});
2437+
//If widget has new position, clean previous grid
2438+
if (this.placeholder_grid_data.el.coords().grid.col !== this.placeholder_grid_data.col ||
2439+
this.placeholder_grid_data.el.coords().grid.row !== this.placeholder_grid_data.row) {
2440+
this.update_widget_position(this.placeholder_grid_data.el.coords().grid, false);
2441+
2442+
// move the cells down if there is an overlap and we are in static mode
2443+
if (this.options.collision.wait_for_mouseup) {
2444+
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
2445+
if (this.is_widget(tcol, trow)) {
2446+
// get number of cells to move
2447+
var destinyRow = this.placeholder_grid_data.row + this.placeholder_grid_data.size_y;
2448+
var currentOverlappedRow = parseInt(this.gridmap[tcol][trow][0].getAttribute('data-row'));
2449+
var cellsToMove = destinyRow - currentOverlappedRow;
2450+
this.move_widget_down(this.is_widget(tcol, trow), cellsToMove);
2451+
}
2452+
});
2453+
}
24822454
}
24832455

24842456
this.cells_occupied_by_player = this.get_cells_occupied(this.placeholder_grid_data);
@@ -2808,9 +2780,6 @@
28082780
fn.set_player = function (col, row, no_player) {
28092781
var self = this;
28102782
var swap = false;
2811-
if (!no_player) {
2812-
this.empty_cells_player_occupies();
2813-
}
28142783
var cell = !no_player ? self.colliders_data[0].el.data : {col: col};
28152784
var to_col = cell.col;
28162785
var to_row = cell.row || row;
@@ -2861,7 +2830,19 @@
28612830
});
28622831
} else if (wgd.size_x <= player_size_x && wgd.size_y <= player_size_y) {
28632832
if (!$gr.is_swap_occupied(placeholder_cells.cols[0], wgd.row, wgd.size_x, wgd.size_y) && !$gr.is_player_in(placeholder_cells.cols[0], wgd.row) && !$gr.is_in_queue(placeholder_cells.cols[0], wgd.row, $w)) {
2864-
swap = $gr.queue_widget(placeholder_cells.cols[0], wgd.row, $w);
2833+
if($gr.options.move_widgets_down_only){
2834+
$overlapped_widgets.each($.proxy(function (i, w) {
2835+
var $w = $(w);
2836+
2837+
if ($gr.can_go_down($w) && $w.coords().grid.row === $gr.player_grid_data.row && !$gr.is_in_queue($w.coords().grid.col, wgd.row, $w)) {
2838+
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
2839+
$gr.set_placeholder(to_col, to_row);
2840+
}
2841+
}));
2842+
}
2843+
else{
2844+
swap = $gr.queue_widget(placeholder_cells.cols[0], wgd.row, $w);
2845+
}
28652846
}
28662847
else if (!$gr.is_swap_occupied(outside_col, wgd.row, wgd.size_x, wgd.size_y) && !$gr.is_player_in(outside_col, wgd.row) && !$gr.is_in_queue(outside_col, wgd.row, $w)) {
28672848
swap = $gr.queue_widget(outside_col, wgd.row, $w);
@@ -2873,7 +2854,19 @@
28732854
swap = $gr.queue_widget(wgd.col, outside_row, $w);
28742855
}
28752856
else if (!$gr.is_swap_occupied(placeholder_cells.cols[0], placeholder_cells.rows[0], wgd.size_x, wgd.size_y) && !$gr.is_player_in(placeholder_cells.cols[0], placeholder_cells.rows[0]) && !$gr.is_in_queue(placeholder_cells.cols[0], placeholder_cells.rows[0], $w)) {
2876-
swap = $gr.queue_widget(placeholder_cells.cols[0], placeholder_cells.rows[0], $w);
2857+
if($gr.options.move_widgets_down_only){
2858+
$overlapped_widgets.each($.proxy(function (i, w) {
2859+
var $w = $(w);
2860+
2861+
if ($gr.can_go_down($w) && $w.coords().grid.row === $gr.player_grid_data.row && !$gr.is_in_queue(outside_col, wgd.row, $w)) {
2862+
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
2863+
$gr.set_placeholder(to_col, to_row);
2864+
}
2865+
}));
2866+
}
2867+
else{
2868+
swap = $gr.queue_widget(placeholder_cells.cols[0], placeholder_cells.rows[0], $w);
2869+
}
28772870
} else {
28782871
//in one last attempt we check for any other empty spaces
28792872
for (var c = 0; c < player_size_x; c++) {
@@ -4940,6 +4933,9 @@
49404933
this.options.widget_base_dimensions = options.widget_base_dimensions;
49414934
}
49424935

4936+
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
4937+
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
4938+
49434939
this.$widgets.each($.proxy(function (i, widget) {
49444940
var $widget = $(widget);
49454941
this.resize_widget($widget);

dist/jquery.gridster.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.gridster.with-extras.js

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! gridster.js - v0.6.10 - 2016-01-21
1+
/*! gridster.js - v0.7.0 - 2016-02-26
22
* https://dsmorse.github.io/gridster.js/
33
* Copyright (c) 2016 ducksboard; Licensed MIT */
44

@@ -938,6 +938,7 @@
938938
responsive_breakpoint: false,
939939
scroll_container: window,
940940
shift_larger_widgets_down: true,
941+
move_widgets_down_only: false,
941942
shift_widgets_up: true,
942943
show_element: function($el, callback) {
943944
if (callback) {
@@ -1692,45 +1693,6 @@
16921693
};
16931694

16941695

1695-
/**
1696-
* Change the dimensions of widgets.
1697-
*
1698-
* @method resize_widget_dimensions
1699-
* @param {Object} [options] An Object with all options you want to
1700-
* overwrite:
1701-
* @param {Array} [options.widget_margins] Margin between widgets.
1702-
* The first index for the horizontal margin (left, right) and
1703-
* the second for the vertical margin (top, bottom).
1704-
* @param {Array} [options.widget_base_dimensions] Base widget dimensions
1705-
* in pixels. The first index for the width and the second for the
1706-
* height.
1707-
* @return {Class} Returns the instance of the Gridster Class.
1708-
*/
1709-
fn.resize_widget_dimensions = function (options) {
1710-
if (options.widget_margins) {
1711-
this.options.widget_margins = options.widget_margins;
1712-
}
1713-
1714-
if (options.widget_base_dimensions) {
1715-
this.options.widget_base_dimensions = options.widget_base_dimensions;
1716-
}
1717-
1718-
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
1719-
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
1720-
1721-
this.$widgets.each($.proxy(function (i, widget) {
1722-
var $widget = $(widget);
1723-
this.resize_widget($widget);
1724-
}, this));
1725-
1726-
this.generate_grid_and_stylesheet();
1727-
this.get_widgets_from_DOM();
1728-
this.set_dom_grid_height();
1729-
1730-
return this;
1731-
};
1732-
1733-
17341696
/**
17351697
* Mutate widget dimensions and position in the grid map.
17361698
*
@@ -1864,7 +1826,7 @@
18641826
}, this));
18651827

18661828
if (!this.is_resizing) {
1867-
this.set_dom_grid_height();
1829+
this.set_dom_grid_height();
18681830
}
18691831

18701832
return this;
@@ -2472,13 +2434,23 @@
24722434

24732435
this.$changed = this.$changed.add(this.$player);
24742436

2475-
// move the cells down if there is an overlap and we are in static mode
2476-
if (this.options.collision.wait_for_mouseup) {
2477-
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
2478-
if (this.is_widget(tcol, trow)) {
2479-
this.move_widget_down(this.is_widget(tcol, trow), this.placeholder_grid_data.size_y);
2480-
}
2481-
});
2437+
//If widget has new position, clean previous grid
2438+
if (this.placeholder_grid_data.el.coords().grid.col !== this.placeholder_grid_data.col ||
2439+
this.placeholder_grid_data.el.coords().grid.row !== this.placeholder_grid_data.row) {
2440+
this.update_widget_position(this.placeholder_grid_data.el.coords().grid, false);
2441+
2442+
// move the cells down if there is an overlap and we are in static mode
2443+
if (this.options.collision.wait_for_mouseup) {
2444+
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
2445+
if (this.is_widget(tcol, trow)) {
2446+
// get number of cells to move
2447+
var destinyRow = this.placeholder_grid_data.row + this.placeholder_grid_data.size_y;
2448+
var currentOverlappedRow = parseInt(this.gridmap[tcol][trow][0].getAttribute('data-row'));
2449+
var cellsToMove = destinyRow - currentOverlappedRow;
2450+
this.move_widget_down(this.is_widget(tcol, trow), cellsToMove);
2451+
}
2452+
});
2453+
}
24822454
}
24832455

24842456
this.cells_occupied_by_player = this.get_cells_occupied(this.placeholder_grid_data);
@@ -2808,9 +2780,6 @@
28082780
fn.set_player = function (col, row, no_player) {
28092781
var self = this;
28102782
var swap = false;
2811-
if (!no_player) {
2812-
this.empty_cells_player_occupies();
2813-
}
28142783
var cell = !no_player ? self.colliders_data[0].el.data : {col: col};
28152784
var to_col = cell.col;
28162785
var to_row = cell.row || row;
@@ -2861,7 +2830,19 @@
28612830
});
28622831
} else if (wgd.size_x <= player_size_x && wgd.size_y <= player_size_y) {
28632832
if (!$gr.is_swap_occupied(placeholder_cells.cols[0], wgd.row, wgd.size_x, wgd.size_y) && !$gr.is_player_in(placeholder_cells.cols[0], wgd.row) && !$gr.is_in_queue(placeholder_cells.cols[0], wgd.row, $w)) {
2864-
swap = $gr.queue_widget(placeholder_cells.cols[0], wgd.row, $w);
2833+
if($gr.options.move_widgets_down_only){
2834+
$overlapped_widgets.each($.proxy(function (i, w) {
2835+
var $w = $(w);
2836+
2837+
if ($gr.can_go_down($w) && $w.coords().grid.row === $gr.player_grid_data.row && !$gr.is_in_queue($w.coords().grid.col, wgd.row, $w)) {
2838+
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
2839+
$gr.set_placeholder(to_col, to_row);
2840+
}
2841+
}));
2842+
}
2843+
else{
2844+
swap = $gr.queue_widget(placeholder_cells.cols[0], wgd.row, $w);
2845+
}
28652846
}
28662847
else if (!$gr.is_swap_occupied(outside_col, wgd.row, wgd.size_x, wgd.size_y) && !$gr.is_player_in(outside_col, wgd.row) && !$gr.is_in_queue(outside_col, wgd.row, $w)) {
28672848
swap = $gr.queue_widget(outside_col, wgd.row, $w);
@@ -2873,7 +2854,19 @@
28732854
swap = $gr.queue_widget(wgd.col, outside_row, $w);
28742855
}
28752856
else if (!$gr.is_swap_occupied(placeholder_cells.cols[0], placeholder_cells.rows[0], wgd.size_x, wgd.size_y) && !$gr.is_player_in(placeholder_cells.cols[0], placeholder_cells.rows[0]) && !$gr.is_in_queue(placeholder_cells.cols[0], placeholder_cells.rows[0], $w)) {
2876-
swap = $gr.queue_widget(placeholder_cells.cols[0], placeholder_cells.rows[0], $w);
2857+
if($gr.options.move_widgets_down_only){
2858+
$overlapped_widgets.each($.proxy(function (i, w) {
2859+
var $w = $(w);
2860+
2861+
if ($gr.can_go_down($w) && $w.coords().grid.row === $gr.player_grid_data.row && !$gr.is_in_queue(outside_col, wgd.row, $w)) {
2862+
$gr.move_widget_down($w, $gr.player_grid_data.size_y);
2863+
$gr.set_placeholder(to_col, to_row);
2864+
}
2865+
}));
2866+
}
2867+
else{
2868+
swap = $gr.queue_widget(placeholder_cells.cols[0], placeholder_cells.rows[0], $w);
2869+
}
28772870
} else {
28782871
//in one last attempt we check for any other empty spaces
28792872
for (var c = 0; c < player_size_x; c++) {
@@ -4940,6 +4933,9 @@
49404933
this.options.widget_base_dimensions = options.widget_base_dimensions;
49414934
}
49424935

4936+
this.min_widget_width = (this.options.widget_margins[0] * 2) + this.options.widget_base_dimensions[0];
4937+
this.min_widget_height = (this.options.widget_margins[1] * 2) + this.options.widget_base_dimensions[1];
4938+
49434939
this.$widgets.each($.proxy(function (i, widget) {
49444940
var $widget = $(widget);
49454941
this.resize_widget($widget);

dist/jquery.gridster.with-extras.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/gridster.js-rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Gridster
22
module Rails
3-
VERSION = "0.6.10"
3+
VERSION = "0.7.0"
44
end
55
end

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gridster",
33
"title": "gridster.js",
44
"description": "a drag-and-drop multi-column jQuery grid plugin",
5-
"version": "0.6.10",
5+
"version": "0.7.0",
66
"homepage": "https://dsmorse.github.io/gridster.js/",
77
"author": {
88
"name": "ducksboard"
@@ -23,15 +23,15 @@
2323
],
2424
"keywords": [],
2525
"devDependencies": {
26-
"bower": "~0.9.2",
26+
"bower": "~1.7.7",
2727
"grunt": "~0.4.5",
2828
"grunt-bump": "0.0.11",
2929
"grunt-contrib-clean": "^0.6.0",
3030
"grunt-contrib-concat": "^0.5.0",
3131
"grunt-contrib-copy": "^0.8.0",
3232
"grunt-contrib-cssmin": "~0.10.0",
3333
"grunt-contrib-jshint": "~0.10.0",
34-
"grunt-contrib-less": "^1.0.1",
34+
"grunt-contrib-less": "^1.2.0",
3535
"grunt-contrib-qunit": "^0.7.0",
3636
"grunt-contrib-uglify": "~0.6.0",
3737
"grunt-contrib-watch": "~0.6.1",

0 commit comments

Comments
 (0)