Add option to set a parent element for the dragger.
authorJan Schneider <jan@horde.org>
Mon, 16 Mar 2009 17:19:11 +0000 (18:19 +0100)
committerJan Schneider <jan@horde.org>
Mon, 16 Mar 2009 17:19:11 +0000 (18:19 +0100)
imp/js/src/dragdrop.js

index 2839bc7..8d392d0 100644 (file)
@@ -177,6 +177,7 @@ Drag = Class.create({
         this.options = Object.extend({
             caption: '',
             classname: 'drag',
+            parentElement: null,
             constraint: null,
             ghosting: false,
             scroll: null,
@@ -240,7 +241,11 @@ Drag = Class.create({
                 oleft = this.element.offsetLeft;
                 otop = this.element.offsetTop;
                 this.ghost = $(this.element.cloneNode(true)).writeAttribute('id', null).setOpacity(0.7).clonePosition(this.element, { setLeft: false, setTop: false }).setStyle({ left: oleft + 'px', position: 'absolute', top: otop + 'px', zIndex: parseInt(this.element.getStyle('zIndex')) + 1 });
-                this.element.insert({ before: this.ghost });
+                if (this.options.parentElement) {
+                    this.options.parentElement().insert(this.ghost);
+                } else {
+                    this.element.insert({ before: this.ghost });
+                }
                 vo = this.ghost.cumulativeOffset();
                 this.ghostOffset = [ vo[0] - oleft, vo[1] - otop ];
             }