Bug Tracker

Ticket #2571: greedy.2.patch

File greedy.2.patch, 2.0 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'); 
    117                 if(inst.options.greedy && $.ui.intersect(draggable, { item: inst, offset: inst.element.offset() }, inst.options.tolerance)) childrenIntersection = true; 
     117                if(inst.options.greedy && $.ui.intersect(draggable, { item: inst, offset: inst.element.offset() }, inst.options.tolerance)) { 
     118                    childrenIntersection = true; 
     119                    return false; 
     120                } 
    118121            }); 
    119122            if(childrenIntersection) return; 
    120123             
     
    220223            //Run through all droppables and check their positions based on specific tolerance options 
    221224            $.each($.ui.ddmanager.droppables, function() { 
    222225 
    223                 if(this.item.disabled) return;  
     226                if(this.item.disabled || this.greedyChild) return;  
    224227                var intersects = $.ui.intersect(draggable, this, this.item.options.tolerance); 
    225228 
    226229                var c = !intersects && this.over == 1 ? 'out' : (intersects && this.over == 0 ? 'over' : null); 
    227230                if(!c) return; 
    228                      
     231                 
     232                var instance = $.data(this.item.element[0], 'droppable'); 
     233                if (instance.options.greedy) { 
     234                    this.item.element.parents('.ui-droppable').each(function() { 
     235                        var parent = this; 
     236                        $.each($.ui.ddmanager.droppables, function() { 
     237                            if (this.item.element[0] != parent) return; 
     238                            this[c] = 0; 
     239                            this[c == 'out' ? 'over' : 'out'] = 1; 
     240                            this.greedyChild = (c == 'over' ? 1 : 0); 
     241                            this.item[c == 'out' ? 'over' : 'out'].call(this.item, e); 
     242                            return false; 
     243                        }); 
     244                    }); 
     245                } 
     246                 
    229247                this[c] = 1; this[c == 'out' ? 'over' : 'out'] = 0; 
    230248                this.item[c].call(this.item, e); 
    231249