1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
(function()
{
var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var DDM = YAHOO.util.DragDropMgr;
YAHOO.example.DDApp =
{
init: function()
{
var rows, i;
rows="$res";
new YAHOO.util.DDTarget("form");
for (i=1;i<rows+1;i=i+1)
{
new YAHOO.example.DDList("bb" + i);
}
},
};
YAHOO.example.DDList = function(id, sGroup, config)
{
YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);
this.logger = this.logger || YAHOO;
var el = this.getDragEl();
Dom.setStyle(el, "opacity", 0.67);
this.goingUp = false;
this.lastY = 0;
};
YAHOO.extend(YAHOO.example.DDList, YAHOO.util.DDProxy,
{
startDrag: function(x, y)
{
this.logger.log(this.id + " startDrag");
var dragEl = this.getDragEl();
var clickEl = this.getEl();
Dom.setStyle(clickEl, "visibility", "hidden");
dragEl.innerHTML = clickEl.innerHTML;
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
Dom.setStyle(dragEl, "border", "2px solid gray");
},
endDrag: function(e)
{
var srcEl = this.getEl();
var proxy = this.getDragEl();
Dom.setStyle(proxy, "visibility", "");
var a = new YAHOO.util.Motion(
proxy,
{
points:
{
to: Dom.getXY(srcEl)
}
},
0.2,
YAHOO.util.Easing.easeOut
)
var proxyid = proxy.id;
var thisid = this.id;
a.onComplete.subscribe(function()
{
Dom.setStyle(proxyid, "visibility", "hidden");
Dom.setStyle(thisid, "visibility", "");
});
a.animate();
getDivOrdre();
},
onDragDrop: function(e, id)
{
if (DDM.interactionInfo.drop.length === 1)
{
var pt = DDM.interactionInfo.point;
var region = DDM.interactionInfo.sourceRegion;
if (!region.intersect(pt))
{
var destEl = Dom.get(id);
var destDD = DDM.getDDById(id);
destEl.appendChild(this.getEl());
destDD.isEmpty = false;
DDM.refreshCache();
}
}
},
onDrag: function(e)
{
var y = Event.getPageY(e);
if (y < this.lastY)
{
this.goingUp = true;
}
else if (y > this.lastY)
{
this.goingUp = false;
}
this.lastY = y;
},
onDragOver: function(e, id)
{
var srcEl = this.getEl();
var destEl = Dom.get(id);
if (destEl.nodeName.toLowerCase() == "div")
{
var orig_p = srcEl.parentNode;
var p = destEl.parentNode;
if (this.goingUp)
{
p.insertBefore(srcEl, destEl);
}
else
{
p.insertBefore(srcEl, destEl.nextSibling);
}
DDM.refreshCache();
}
}
});
Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);
})(); |