Skip to content

Commit 6bcfa6e

Browse files
committed
fix(gridster): custom ignore_dragging overwrites the default value
1 parent 21a294c commit 6bcfa6e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/jquery.draggable.js

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
* the mouse must move before dragging should start.
6363
* @param {Boolean} [options.limit] Constrains dragging to the width of
6464
* the container
65+
* @param {Object|Function} [options.ignore_dragging] Array of node names
66+
* that sould not trigger dragging, by default is `['INPUT', 'TEXTAREA',
67+
* 'SELECT', 'BUTTON']`. If a function is used return true to ignore dragging.
6568
* @param {offset_left} [options.offset_left] Offset added to the item
6669
* that is being dragged.
6770
* @param {Number} [options.drag] Executes a callback when the mouse is

src/jquery.gridster.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
collision: {},
4444
draggable: {
4545
items: '.gs-w',
46-
distance: 4
46+
distance: 4,
47+
ignore_dragging: Draggable.defaults.ignore_dragging.slice(0)
4748
},
4849
resize: {
4950
enabled: false,
@@ -102,8 +103,10 @@
102103
* @param {Object} [options.draggable] An Object with all options for
103104
* Draggable class you want to overwrite. See Draggable docs for more
104105
* info.
105-
* @param {Object} [options.resize] An Object with resize config
106-
* options.
106+
* @param {Object|Function} [options.draggable.ignore_dragging] Note that
107+
* if you use a Function, and resize is enabled, you should ignore the
108+
* resize handlers manually (options.resize.handle_class).
109+
* @param {Object} [options.resize] An Object with resize config options.
107110
* @param {Boolean} [options.resize.enabled] Set to true to enable
108111
* resizing.
109112
* @param {Array} [options.resize.axes] Axes in which widgets can be
@@ -943,8 +946,6 @@
943946
offset_top: this.options.widget_margins[1],
944947
container_width: this.cols * this.min_widget_width,
945948
limit: true,
946-
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON',
947-
'.' + this.options.resize.handle_class],
948949
start: function(event, ui) {
949950
self.$widgets.filter('.player-revert')
950951
.removeClass('player-revert');
@@ -1014,6 +1015,12 @@
10141015
this.resize_handle_tpl = $.map(axes, function(type) {
10151016
return handle_tpl.replace('{type}', type);
10161017
}).join('');
1018+
1019+
if ($.isArray(this.options.draggable.ignore_dragging)) {
1020+
this.options.draggable.ignore_dragging.push(
1021+
'.' + this.resize_handle_class);
1022+
}
1023+
10171024
return this;
10181025
};
10191026

0 commit comments

Comments
 (0)