diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.draggable.js | 3 | ||||
-rw-r--r-- | ui/ui.droppable.js | 29 | ||||
-rw-r--r-- | ui/ui.sortable.js | 23 |
3 files changed, 40 insertions, 15 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index 80024a4d6..d72e24685 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -267,7 +267,8 @@ $.extend($.ui.draggable, { cancel: ":input", delay: 0, distance: 1, - helper: "original" + helper: "original", + scope: "default" } }); diff --git a/ui/ui.droppable.js b/ui/ui.droppable.js index 6833c4dfd..3e5d2999e 100644 --- a/ui/ui.droppable.js +++ b/ui/ui.droppable.js @@ -27,7 +27,8 @@ $.widget("ui.droppable", { this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; // Add the reference and positions to the manager - $.ui.ddmanager.droppables.push(this); + $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || []; + $.ui.ddmanager.droppables[this.options.scope].push(this); }, plugins: {}, @@ -42,7 +43,7 @@ $.widget("ui.droppable", { }; }, destroy: function() { - var drop = $.ui.ddmanager.droppables; + var drop = $.ui.ddmanager.droppables[this.options.scope]; for ( var i = 0; i < drop.length; i++ ) if ( drop[i] == this ) drop.splice(i, 1); @@ -116,7 +117,8 @@ $.widget("ui.droppable", { $.extend($.ui.droppable, { defaults: { disabled: false, - tolerance: 'intersect' + tolerance: 'intersect', + scope: 'default' } }); @@ -167,26 +169,31 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) { */ $.ui.ddmanager = { current: null, - droppables: [], + droppables: { scope: [] }, prepareOffsets: function(t, e) { - var m = $.ui.ddmanager.droppables; + var m = $.ui.ddmanager.droppables[t.options.scope]; var type = e ? e.type : null; // workaround for #2317 + var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); - for (var i = 0; i < m.length; i++) { - if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue; - m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue + droppablesLoop: for (var i = 0; i < m.length; i++) { + + if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue; //No disabled and non-accepted + for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item + m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue + m[i].offset = m[i].element.offset(); m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; - if(type == "dragstart" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables + if(type == "dragstart" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables + } }, drop: function(draggable, e) { var dropped = false; - $.each($.ui.ddmanager.droppables, function() { + $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { if(!this.options) return; if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) @@ -208,7 +215,7 @@ $.ui.ddmanager = { //Run through all droppables and check their positions based on specific tolerance options - $.each($.ui.ddmanager.droppables, function() { + $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { if(this.options.disabled || this.greedyChild || !this.visible) return; var intersects = $.ui.intersect(draggable, this, this.options.tolerance); diff --git a/ui/ui.sortable.js b/ui/ui.sortable.js index 803531f43..24c934852 100644 --- a/ui/ui.sortable.js +++ b/ui/ui.sortable.js @@ -127,7 +127,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { if ((x1 + dxClick) > l && (x1 + dxClick) < l + item.width/2) return 2; if ((x1 + dxClick) > l + item.width/2 && (x1 + dxClick) < r) return 1; } else { - var height = item.height, helperHeight = this.helperProportions.height; + var height = item.height; var direction = y1 - this.updateOriginalPosition.top < 0 ? 2 : 1; // 2 = up if (direction == 1 && (y1 + dyClick) < t + height/2) { return 2; } // up @@ -188,6 +188,21 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { }, + removeCurrentsFromItems: function() { + + var list = this.currentItem.find(":data(sortable-item)"); + + for (var i=0; i < this.items.length; i++) { + + for (var j=0; j < list.length; j++) { + if(list[j] == this.items[i].item[0]) + this.items.splice(i,1); + }; + + }; + + }, + refreshItems: function() { this.items = []; @@ -371,6 +386,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { } this.currentItem = currentItem; + this.removeCurrentsFromItems(); return true; }, @@ -437,7 +453,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, { //Call plugins and callbacks this.propagate("start", e); - this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size + if(!this._preserveHelperProportions) this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size if(o.cursorAt) { if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left; @@ -705,7 +721,8 @@ $.extend($.ui.sortable, { zIndex: 1000, dropOnEmpty: true, appendTo: "parent", - sortIndicator: $.ui.sortable.prototype.rearrange + sortIndicator: $.ui.sortable.prototype.rearrange, + scope: "default" } }); |