Skip to main content

Search and Top Navigation

Ticket #3175: draggable-revert.patch


File draggable-revert.patch, 2.3 KB (added by kevingessner, August 12, 2008 10:11AM UTC)

Patch for ui.draggable adding callback capability to revert: (with test)

Index: tests/draggable-revert.html
===================================================================
--- tests/draggable-revert.html	(revision 0)
+++ tests/draggable-revert.html	(revision 0)
@@ -0,0 +1,30 @@
+
+
+	
+		
+		jQuery UI Draggable Revert-Function Test
+		
+		
+		
+		
+		
+
+		
+	
+	
+		

jQuery UI Draggable Revert-Function Test

+

+
Drag me!
+ + \ No newline at end of file Index: tests/draggable-revert.js =================================================================== --- tests/draggable-revert.js (revision 0) +++ tests/draggable-revert.js (revision 0) @@ -0,0 +1,7 @@ +$(function () { + $('#draggable').draggable({ + revert: function () { + return !!($('#revert').val()); + } + }); +}); \ No newline at end of file Index: ui/ui.draggable.js =================================================================== --- ui/ui.draggable.js (revision 536) +++ ui/ui.draggable.js (working copy) @@ -229,7 +229,7 @@ if ($.ui.ddmanager && !this.options.dropBehaviour) var dropped = $.ui.ddmanager.drop(this, e); - if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) { + if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || (typeof(this.options.revert) == 'function' && this.options.revert())) { var self = this; $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() { self.propagate("stop", e);

Download in other formats:

Original Format