Skip to content

Commit

Permalink
fix(gridster): custom ignore_dragging overwrites the default value
Browse files Browse the repository at this point in the history
  • Loading branch information
vieron committed Jun 25, 2014
1 parent 21a294c commit 6bcfa6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/jquery.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
* the mouse must move before dragging should start.
* @param {Boolean} [options.limit] Constrains dragging to the width of
* the container
* @param {Object|Function} [options.ignore_dragging] Array of node names
* that sould not trigger dragging, by default is `['INPUT', 'TEXTAREA',
* 'SELECT', 'BUTTON']`. If a function is used return true to ignore dragging.
* @param {offset_left} [options.offset_left] Offset added to the item
* that is being dragged.
* @param {Number} [options.drag] Executes a callback when the mouse is
Expand Down
17 changes: 12 additions & 5 deletions src/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
collision: {},
draggable: {
items: '.gs-w',
distance: 4
distance: 4,
ignore_dragging: Draggable.defaults.ignore_dragging.slice(0)
},
resize: {
enabled: false,
Expand Down Expand Up @@ -102,8 +103,10 @@
* @param {Object} [options.draggable] An Object with all options for
* Draggable class you want to overwrite. See Draggable docs for more
* info.
* @param {Object} [options.resize] An Object with resize config
* options.
* @param {Object|Function} [options.draggable.ignore_dragging] Note that
* if you use a Function, and resize is enabled, you should ignore the
* resize handlers manually (options.resize.handle_class).
* @param {Object} [options.resize] An Object with resize config options.
* @param {Boolean} [options.resize.enabled] Set to true to enable
* resizing.
* @param {Array} [options.resize.axes] Axes in which widgets can be
Expand Down Expand Up @@ -943,8 +946,6 @@
offset_top: this.options.widget_margins[1],
container_width: this.cols * this.min_widget_width,
limit: true,
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON',
'.' + this.options.resize.handle_class],
start: function(event, ui) {
self.$widgets.filter('.player-revert')
.removeClass('player-revert');
Expand Down Expand Up @@ -1014,6 +1015,12 @@
this.resize_handle_tpl = $.map(axes, function(type) {
return handle_tpl.replace('{type}', type);
}).join('');

if ($.isArray(this.options.draggable.ignore_dragging)) {
this.options.draggable.ignore_dragging.push(
'.' + this.resize_handle_class);
}

return this;
};

Expand Down

0 comments on commit 6bcfa6e

Please sign in to comment.