Bug Tracker

Ticket #2571: greedy.patch

File greedy.patch, 1.8 kB (added by scott.gonzalez, 10 months ago)
  • ui.droppable.js

     
    112112            if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element 
    113113             
    114114            var childrenIntersection = false; 
    115             this.element.children(".ui-droppable").each(function() { 
     115            this.element.find(".ui-droppable").each(function() { 
    116116                var inst = $.data(this, 'droppable'); 
    117117                if(inst.options.greedy && $.ui.intersect(draggable, { item: inst, offset: inst.element.offset() }, inst.options.tolerance)) childrenIntersection = true; 
    118118            }); 
     
    220220            //Run through all droppables and check their positions based on specific tolerance options 
    221221            $.each($.ui.ddmanager.droppables, function() { 
    222222 
    223                 if(this.item.disabled) return;  
     223                if(this.item.disabled || this.greedyChild) return;  
    224224                var intersects = $.ui.intersect(draggable, this, this.item.options.tolerance); 
    225225 
    226226                var c = !intersects && this.over == 1 ? 'out' : (intersects && this.over == 0 ? 'over' : null); 
    227227                if(!c) return; 
    228                      
     228                 
     229                var instance = $.data(this.item.element[0], 'droppable'); 
     230                if (instance.options.greedy) { 
     231                    this.item.element.parents('.ui-droppable').each(function() { 
     232                        var parent = this; 
     233                        $.each($.ui.ddmanager.droppables, function() { 
     234                            if (this.item.element[0] != parent) return; 
     235                            this[c] = 0; 
     236                            this[c == 'out' ? 'over' : 'out'] = 1; 
     237                            this.greedyChild = (c == 'over' ? 1 : 0); 
     238                            this.item[c == 'out' ? 'over' : 'out'].call(this.item, e); 
     239                            return false; 
     240                        }); 
     241                    }); 
     242                } 
     243                 
    229244                this[c] = 1; this[c == 'out' ? 'over' : 'out'] = 0; 
    230245                this.item[c].call(this.item, e); 
    231246