2 /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
5 * @class a YAHOO.util.DDProxy implementation. During the drag over event, the
6 * dragged element is inserted before the dragged-over element.
8 * @extends YAHOO.util.DDProxy
10 * @param {String} id the id of the linked element
11 * @param {String} sGroup the group of related DragDrop objects
13 function ygDDList(id, sGroup) {
16 this.init(id, sGroup);
20 var s = this.getDragEl().style;
21 s.borderColor = "transparent";
22 s.backgroundColor = "#f6f5e5";
24 s.filter = "alpha(opacity=76)";
27 ygDDList.prototype = new YAHOO.util.DDProxy();
29 ygDDList.prototype.borderDiv = null;
30 ygDDList.prototype.originalDisplayProperties = Array();
32 ygDDList.prototype.startDrag = function(x, y) {
33 //this.logger.debug(this.id + " startDrag");
35 var dragEl = this.getDragEl();
36 var clickEl = this.getEl();
38 dragEl.innerHTML = clickEl.innerHTML;
39 dragElObjects = dragEl.getElementsByTagName('object');
42 dragEl.className = clickEl.className;
43 dragEl.style.color = clickEl.style.color;
44 dragEl.style.border = "1px solid #aaa";
46 // save the style of the object
47 clickElRegion = YAHOO.util.Dom.getRegion(clickEl);
49 this.borderDiv = document.createElement('div'); // create a div to display border
50 this.borderDiv.style.height = (clickElRegion.bottom - clickElRegion.top) + 'px';
51 this.borderDiv.style.border = '2px dashed #cccccc';
53 for(i in clickEl.childNodes) { // hide contents of the target elements contents
54 if(typeof clickEl.childNodes[i].style != 'undefined') {
55 this.originalDisplayProperties[i] = clickEl.childNodes[i].style.display;
56 clickEl.childNodes[i].style.display = 'none';
60 clickEl.appendChild(this.borderDiv);
63 ygDDList.prototype.endDrag = function(e) {
64 // disable moving the linked element
65 var clickEl = this.getEl();
67 clickEl.removeChild(this.borderDiv); // remove border div
69 for(i in clickEl.childNodes) { // show target elements contents
70 if(typeof clickEl.childNodes[i].style != 'undefined') {
71 clickEl.childNodes[i].style.display = this.originalDisplayProperties[i];
76 clickEl.style.height = this.clickHeight;
78 clickEl.style.height = '';
81 clickEl.style.border = this.clickBorder;
83 clickEl.style.border = '';
85 dragEl = this.getDragEl();
86 dragEl.innerHTML = '';
91 ygDDList.prototype.afterEndDrag = function(e) {
95 ygDDList.prototype.onDrag = function(e, id) {
99 ygDDList.prototype.onDragOver = function(e, id) {
100 // this.logger.debug(this.id.toString() + " onDragOver " + id);
103 if ("string" == typeof id) {
104 el = YAHOO.util.DDM.getElement(id);
106 el = YAHOO.util.DDM.getBestMatch(id).getEl();
109 dragEl = this.getDragEl();
110 elRegion = YAHOO.util.Dom.getRegion(el);
112 // this.logger.debug('id: ' + el.id);
113 // this.logger.debug('size: ' + (elRegion.bottom - elRegion.top));
114 // this.logger.debug('getPosY: ' + YAHOO.util.DDM.getPosY(el));
115 var mid = YAHOO.util.DDM.getPosY(el) + (Math.floor((elRegion.bottom - elRegion.top) / 2));
116 // this.logger.debug('mid: ' + mid);
118 // this.logger.debug(YAHOO.util.DDM.getPosY(dragEl) + " < " + mid);
119 // this.logger.debug("Y: " + YAHOO.util.Event.getPageY(e));
121 if (YAHOO.util.DDM.getPosY(dragEl) < mid ) { // insert on top triggering item
122 var el2 = this.getEl();
123 var p = el.parentNode;
124 p.insertBefore(el2, el);
126 if (YAHOO.util.DDM.getPosY(dragEl) >= mid ) { // insert below triggered item
127 var el2 = this.getEl();
128 var p = el.parentNode;
129 p.insertBefore(el2, el.nextSibling);
133 ygDDList.prototype.onDragEnter = function(e, id) {
134 // this.logger.debug(this.id.toString() + " onDragEnter " + id);
135 // this.getDragEl().style.border = "1px solid #449629";
138 ygDDList.prototype.onDragOut = function(e, id) {
139 // I need to know when we are over nothing
140 // this.getDragEl().style.border = "1px solid #964428";
143 /////////////////////////////////////////////////////////////////////////////
145 function ygDDListBoundary(id, sGroup) {
147 this.init(id, sGroup);
148 //this.logger = new ygLogger("ygDDListBoundary");
149 this.isBoundary = true;
153 ygDDListBoundary.prototype = new YAHOO.util.DDTarget();