Skip to content

Commit 46e0abe

Browse files
committed
Release v0.4.0
1 parent 1aee438 commit 46e0abe

File tree

8 files changed

+191
-38
lines changed

8 files changed

+191
-38
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
<a name="v0.4.0"></a>
2+
## v0.4.0 (2014-02-07)
3+
4+
5+
#### Bug Fixes
6+
7+
* **gridster:**
8+
* leaking options with multiple Gridster instances ([07c71097](http://github.com/ducksboard/gridster.js/commit/07c7109771094d98be51d68448a20e1d2987b35d))
9+
* resize.axes default option only 'both' ([62988780](http://github.com/ducksboard/gridster.js/commit/6298878077d5db129daa9780939fec5237b82af9))
10+
* **licenses:** add required copyright message for underscore ([b563c094](http://github.com/ducksboard/gridster.js/commit/b563c094cf0f3a5da2288492f95759ae32e8967c))
11+
* **readme:** link title jsfiddle -> jsbin, edit 5) of process steps ([0641aa89](http://github.com/ducksboard/gridster.js/commit/0641aa89833ecf9d167f7d8e89ee8bd5b4304248))
12+
13+
14+
#### Features
15+
16+
* **draggable:**
17+
* method to set drag limits dynamically ([d4482ec1](http://github.com/ducksboard/gridster.js/commit/d4482ec1476f8a0b6fb6cdeb25b7774ef678d81c))
18+
* support horizontal scrolling while dragging ([ae4921b7](http://github.com/ducksboard/gridster.js/commit/ae4921b70798944211267cacf8a89e62d0818369))
19+
* **gridster:** increase grid width when dragging or resizing ([37c4e943](http://github.com/ducksboard/gridster.js/commit/37c4e94358b9392710452b9e7f96454837bf9845))
20+
* **resize:** add option to set min_size of a widget ([ff511872](http://github.com/ducksboard/gridster.js/commit/ff511872e65992ee89bd2a88d862caaf99733f38))
21+
122
<a name="v0.3.0"></a>
223
## v0.3.0 (2013-11-18)
324

dist/jquery.gridster.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*! gridster.js - v0.3.0 - 2013-11-19
1+
/*! gridster.js - v0.4.0 - 2014-02-07
22
* http://gridster.net/
3-
* Copyright (c) 2013 ducksboard; Licensed MIT */
3+
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

55
.gridster {
66
position:relative;

dist/jquery.gridster.js

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*! gridster.js - v0.3.0 - 2013-11-19
1+
/*! gridster.js - v0.4.0 - 2014-02-07
22
* http://gridster.net/
3-
* Copyright (c) 2013 ducksboard; Licensed MIT */
3+
* Copyright (c) 2014 ducksboard; Licensed MIT */
44

55
;(function($, window, document, undefined){
66
/**
@@ -324,8 +324,33 @@
324324
return setTimeout(function(){ return func.apply(null, args); }, wait);
325325
};
326326

327-
328-
/* Debounce and throttle functions taken from underscore.js */
327+
/* Debounce and throttle functions taken from underscore.js
328+
*
329+
* Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and
330+
* Investigative Reporters & Editors
331+
*
332+
* Permission is hereby granted, free of charge, to any person
333+
* obtaining a copy of this software and associated documentation
334+
* files (the "Software"), to deal in the Software without
335+
* restriction, including without limitation the rights to use,
336+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
337+
* copies of the Software, and to permit persons to whom the
338+
* Software is furnished to do so, subject to the following
339+
* conditions:
340+
*
341+
* The above copyright notice and this permission notice shall be
342+
* included in all copies or substantial portions of the Software.
343+
*
344+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
345+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
346+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
347+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
348+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
349+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
350+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
351+
* OTHER DEALINGS IN THE SOFTWARE.
352+
*/
353+
329354
window.debounce = function(func, wait, immediate) {
330355
var timeout;
331356
return function() {
@@ -340,7 +365,6 @@
340365
};
341366
};
342367

343-
344368
window.throttle = function(func, wait) {
345369
var context, args, timeout, throttling, more, result;
346370
var whenDone = debounce(
@@ -787,7 +811,7 @@
787811
},
788812
resize: {
789813
enabled: false,
790-
axes: ['x', 'y', 'both'],
814+
axes: ['both'],
791815
handle_append_to: '',
792816
handle_class: 'gs-resize-handle',
793817
max_size: [Infinity, Infinity]
@@ -852,6 +876,9 @@
852876
* @param {Array} [options.resize.max_size] Limit widget dimensions
853877
* when resizing. Array values should be integers:
854878
* `[max_cols_occupied, max_rows_occupied]`
879+
* @param {Array} [options.resize.min_size] Limit widget dimensions
880+
* when resizing. Array values should be integers:
881+
* `[min_cols_occupied, min_rows_occupied]`
855882
* @param {Function} [options.resize.start] Function executed
856883
* when resizing starts.
857884
* @param {Function} [otions.resize.resize] Function executed
@@ -862,7 +889,7 @@
862889
* @constructor
863890
*/
864891
function Gridster(el, options) {
865-
this.options = $.extend(true, defaults, options);
892+
this.options = $.extend(true, {}, defaults, options);
866893
this.$el = $(el);
867894
this.$wrapper = this.$el.parent();
868895
this.$widgets = this.$el.children(
@@ -962,10 +989,11 @@
962989
* @param {Number} [col] The column the widget should start in.
963990
* @param {Number} [row] The row the widget should start in.
964991
* @param {Array} [max_size] max_size Maximun size (in units) for width and height.
992+
* @param {Array} [min_size] min_size Minimum size (in units) for width and height.
965993
* @return {HTMLElement} Returns the jQuery wrapped HTMLElement representing.
966994
* the widget that was just created.
967995
*/
968-
fn.add_widget = function(html, size_x, size_y, col, row, max_size) {
996+
fn.add_widget = function(html, size_x, size_y, col, row, max_size, min_size) {
969997
var pos;
970998
size_x || (size_x = 1);
971999
size_y || (size_y = 1);
@@ -999,12 +1027,39 @@
9991027
this.set_widget_max_size($w, max_size);
10001028
}
10011029

1030+
if (min_size) {
1031+
this.set_widget_min_size($w, min_size);
1032+
}
1033+
10021034
this.set_dom_grid_height();
10031035

10041036
return $w.fadeIn();
10051037
};
10061038

10071039

1040+
/**
1041+
* Change widget size limits.
1042+
*
1043+
* @method set_widget_min_size
1044+
* @param {HTMLElement|Number} $widget The jQuery wrapped HTMLElement
1045+
* representing the widget or an index representing the desired widget.
1046+
* @param {Array} min_size Minimum size (in units) for width and height.
1047+
* @return {HTMLElement} Returns instance of gridster Class.
1048+
*/
1049+
fn.set_widget_min_size = function($widget, min_size) {
1050+
$widget = typeof $widget === 'number' ?
1051+
this.$widgets.eq($widget) : $widget;
1052+
1053+
if (!$widget.length) { return this; }
1054+
1055+
var wgd = $widget.data('coords').grid;
1056+
wgd.min_size_x = min_size[0];
1057+
wgd.min_size_y = min_size[1];
1058+
1059+
return this;
1060+
};
1061+
1062+
10081063
/**
10091064
* Change widget size limits.
10101065
*
@@ -1432,6 +1487,8 @@
14321487
'size_y': parseInt($el.attr('data-sizey'), 10),
14331488
'max_size_x': parseInt($el.attr('data-max-sizex'), 10) || false,
14341489
'max_size_y': parseInt($el.attr('data-max-sizey'), 10) || false,
1490+
'min_size_x': parseInt($el.attr('data-min-sizex'), 10) || false,
1491+
'min_size_y': parseInt($el.attr('data-min-sizey'), 10) || false,
14351492
'el': $el
14361493
};
14371494

@@ -1812,6 +1869,12 @@
18121869
this.options.max_cols - this.resize_initial_col + 1);
18131870
this.resize_max_size_y = this.resize_wgd.max_size_y ||
18141871
this.options.resize.max_size[1];
1872+
1873+
this.resize_min_size_x = (this.resize_wgd.min_size_x ||
1874+
this.options.resize.min_size[0] || 1);
1875+
this.resize_min_size_y = (this.resize_wgd.min_size_y ||
1876+
this.options.resize.min_size[1] || 1);
1877+
18151878
this.resize_initial_last_col = this.get_highest_occupied_cell().col;
18161879

18171880
this.resize_dir = {
@@ -1904,14 +1967,17 @@
19041967
var size_x = Math.max(1, this.resize_initial_sizex + inc_units_x);
19051968
var size_y = Math.max(1, this.resize_initial_sizey + inc_units_y);
19061969

1907-
size_x = Math.min(size_x, this.resize_max_size_x);
1970+
size_x = Math.max(Math.min(size_x, this.resize_max_size_x), this.resize_min_size_x);
19081971
max_width = (this.resize_max_size_x * wbd_x) +
19091972
((size_x - 1) * this.options.widget_margins[0] * 2);
1973+
min_width = (this.resize_min_size_x * wbd_x) +
1974+
((size_x - 1) * this.options.widget_margins[0] * 2);
19101975

1911-
size_y = Math.min(size_y, this.resize_max_size_y);
1976+
size_y = Math.max(Math.min(size_y, this.resize_max_size_y), this.resize_min_size_y);
19121977
max_height = (this.resize_max_size_y * wbd_y) +
19131978
((size_y - 1) * this.options.widget_margins[1] * 2);
1914-
1979+
min_height = (this.resize_min_size_y * wbd_y) +
1980+
((size_y - 1) * this.options.widget_margins[1] * 2);
19151981

19161982
if (this.resize_dir.right) {
19171983
size_y = this.resize_initial_sizey;
@@ -1934,10 +2000,10 @@
19342000

19352001

19362002
var css_props = {};
1937-
!this.resize_dir.bottom && (css_props.width = Math.min(
1938-
this.resize_initial_width + rel_x, max_width));
1939-
!this.resize_dir.right && (css_props.height = Math.min(
1940-
this.resize_initial_height + rel_y, max_height));
2003+
!this.resize_dir.bottom && (css_props.width = Math.max(Math.min(
2004+
this.resize_initial_width + rel_x, max_width), min_width));
2005+
!this.resize_dir.right && (css_props.height = Math.max(Math.min(
2006+
this.resize_initial_height + rel_y, max_height), min_height));
19412007

19422008
this.$resized_widget.css(css_props);
19432009

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.

0 commit comments

Comments
 (0)