Skip to main content

Bug Tracker

Side navigation

Ticket #2122: uidroppable-fix_element_comparer_and_accept_fn.patch
File uidroppable-fix_element_comparer_and_accept_fn.patch, 2.8 KB (added by mnichols, January 07, 2008 06:31PM UTC)

This patch fixes element comparisons on droppable in the trunk and also extends the accept function argument

Index: ui.droppable.js
===================================================================
--- ui.droppable.js	(revision 4364)
+++ ui.droppable.js	(working copy)
@@ -66,9 +66,8 @@
 		over: function(e) {
 
 			var draggable = $.ui.ddmanager.current;
-			if (!draggable || draggable.element == this.element) return; // Bail if draggable and droppable are same element
-			
-			if (this.options.accept(draggable.element)) {
+			if (!draggable || $(draggable.element)[0] == $(this.element)[0]) return; // Bail if draggable and droppable are same element			
+			if (this.options.accept(this.ui(draggable))) {
 				$.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);
 				$(this.element).triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);
 			}
@@ -77,9 +76,9 @@
 		out: function(e) {
 
 			var draggable = $.ui.ddmanager.current;
-			if (!draggable || draggable.element == this.element) return; // Bail if draggable and droppable are same element
+			if (!draggable || $(draggable.element)[0] == $(this.element)[0]) return; // Bail if draggable and droppable are same element
 
-			if (this.options.accept(draggable.element)) {
+			if (this.options.accept(this.ui(draggable))) {
 				$.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);
 				$(this.element).triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);
 			}
@@ -88,9 +87,9 @@
 		drop: function(e) {
 
 			var draggable = $.ui.ddmanager.current;
-			if (!draggable || draggable.element == this.element) return; // Bail if draggable and droppable are same element
+			if (!draggable || $(draggable.element)[0] == $(this.element)[0]) return; // Bail if draggable and droppable are same element
 			
-			if(this.options.accept(draggable.element)) {
+			if(this.options.accept(this.ui(draggable))) {
 				$.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);
 				$(this.element).triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);
 			}
@@ -163,7 +162,7 @@
 				if(m[i].item.disabled) continue;
 				m[i].offset = $(m[i].item.element).offset();
 				
-				if (t && m[i].item.options.accept(t.element)) //Activate the droppable if used directly from draggables
+				if (t && m[i].item.options.accept.call(m[i].item,m[i].item.ui(t))) //Activate the droppable if used directly from draggables
 					m[i].item.activate.call(m[i].item, e);
 					
 			}
@@ -175,8 +174,8 @@
 				
 				if (!this.item.disabled && $.ui.intersect(draggable, this, this.item.options.tolerance))
 					this.item.drop.call(this.item, e);
-					
-				if (!this.item.disabled && this.item.options.accept(draggable.element)) {
+                
+				if (!this.item.disabled && this.item.options.accept.call(this.item,this.item.ui(draggable))) {
 					this.out = 1; this.over = 0;
 					this.item.deactivate.call(this.item, e);
 				}

Download in other formats:

Original Format