Allow for an optional drag handle to be specified

When defining the gridster, you can now define a draggable.handle selector:

For example:

    $("#widgets").gridster({
        widget_margins: [10, 10],
        widget_base_dimensions: [565, 400],
		draggable: {
			stop: function(event, ui) {
				console.log('save new columns');
			},
			handle: '.title'
		}
    });

If handle is omitted (or left blank), it works as it did previously. If a value is specified, then dragging only starts if the element which was clicked matches the selector specified.

Added by @vieron:
Closes #29
This commit is contained in:
Philip Manavopoulos
2012-10-09 12:24:12 +02:00
committed by vieron
parent 07b34131bd
commit 552df22e1c

View File

@ -14,7 +14,8 @@
limit: true,
offset_left: 0,
autoscroll: true,
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON']
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'],
handle: null
// ,drag: function(e){},
// start : function(e, ui){},
// stop : function(e){}
@ -329,6 +330,10 @@
};
fn.ignore_drag = function(event) {
if (this.options.handle) {
return !$(event.target).is(this.options.handle);
}
return $.inArray(event.target.nodeName, this.options.ignore_dragging) >= 0;
};