aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui.droppable.js
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2008-07-28 18:34:01 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2008-07-28 18:34:01 +0000
commit841751a0d5ce21bae6e2318f2d3d16b9a4748014 (patch)
tree1732e770b9444f3454c6aa199e7396a4e2110e20 /ui/ui.droppable.js
parent609699d9e987ae06f10b636ff7ee0c6ac8a582ff (diff)
downloadjquery-ui-841751a0d5ce21bae6e2318f2d3d16b9a4748014.tar.gz
jquery-ui-841751a0d5ce21bae6e2318f2d3d16b9a4748014.zip
1.8: initial version of tree component, dependant upon sortables and droppables
1.6: droppables can now operate in a seperate scope, droppables and sortables in the current dragged item are filtered out at start, preventing node hierarchy issues
Diffstat (limited to 'ui/ui.droppable.js')
-rw-r--r--ui/ui.droppable.js29
1 files changed, 18 insertions, 11 deletions
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);