Acerca de js arrastrar y soltar

var dragable ={

oldObj: nulo,

obj: nulo,

moveObjName: nulo,

isBoxDragable:false, p>

tx:0,

ty:0,

tx1:0,

ty1:0,

arrayTemplateLayout: nulo,

arrayTemplateStyle: nulo,

mapTemplateObject: nuevo mapa(),

contextId: "context1",

objectId: "",

ifremeObj: nulo,

dragbox: nulo,

dragboxId: "dragbox",

ocupación: " ocupación",

isImageObject: false,

getDragBox: function(){

if(!this.dragbox){

this .dragbox = hs.createElement( oculto;posición: absoluta;izquierda:192px;arriba:330px;fondo:#ffffffff;ancho:55px; altura:31px" >

' ;

documento. cuerpo appendChild(this.dragbox);

}

return this.dragbox.firstChild

},

loadTemplateInfo: función () {

this.arrayTemplateLayout = new Array();

this.arrayTemplateStyle = new Array();

this.searchObjectTag(document.getElementById( this.contextId));

},

makeRateBoxBarHandler: function(){

try{

var e = dragable.makeRateBoxBarHandler. .arguments [0];

var obj = dragable.makeRateBoxBarHandler.arguments[1];

var tmpobj = obj

while(tmpobj.id. indexOf( "_fordrag") == -1 && amp !this.isBoxDragable )

}else if(e.type == 'mouseup' ){

if(this. isBoxDragable)

this.rateBoxBarMouseUp(e);

else

hs.removeEventListener(document, "mousemove",this.rateBoxBarMouseMoveH

andler);

}

e= 'mouseup';

}else if(e.type == 'mouseup' ){

if(this.

e=e||window.event;

if (e. preventDefault == null){

e.preventDefault = función () { this.returnValue = false };

}

if (e.preventDefault();

Event.stop( e);

},

rateBoxBarMouseMoveHandler: función(e){

if(dragable.isBoxDragable){

dragable.getDragBox ().style.cursor="move";

dragable.getDragBox().style.left = (dragable.tx- dragable.tx1+pointeurX(e))+"px"; >

dragable.getDragBox().style.top = (dragable.ty- dragable.ty1+pointeurY(e))+"px"

var x = parseInt(dragable.getDragBox(); .style.left);//pointeurX(e);

var y = parseInt( dragable.getDragBox().style.top);//pointeurY(e);

if(dragable.getDragBox().style.top = (dragable.ty- dragable.ty1+pointeurY(e));

if (dragable.isTemplateObject){

var nodos = dragable.oldObj.parentNode.childNodes;

for(var a = 0; a < nodes.length; a++){

if(nodes[a].tagName!=" DIV") continuar;

if(nodos[a] == dragable.oldObj.parentNode.childNodes;

for(var a = 0; a < nodes.length; a++) {

if(nodos[a].tagName! luego continuar;

var p = hs.position(nodos[a]);

if(x >p.x && y > p.y && x < (p.x+nodos[a].offsetWidth) && y < (p.y + nodos[a].offsetHeight)){

nodos[a].estilo. ancho = nodos[a].firstChild.offsetWidth + "px";

nodos[a].style.height = nodos[a].firstChild.offsetHeig

ht + "px";

dragable.oldObj.style.height = dragable.oldObj.firstChild.offsetHeight + "px";

Node[a].innerHTML = "?"

Nodo[a].style.border = "1px sólido #000000";

//if(nodes[a].attributes.oldObj.attributes.getNamedItem("index) ").nodeValue;

// nodos[a].attributes.getNamedItem("index").nodeValue = t;

//}

p > dragable.oldObj = nodos[a];

}

}

}

}

} else{

dragable.rateBoxBarInit_123456(e);

}

e=e|| ventana.event;

if(e .preventDefault ==null){

e.preventDefault = function () { this.returnValue = false };

}

if(e. stopPropagation ==null){

e.mapTemplateObject.getKeyList();

for(var i = 0 ; i< list.length ; i++){

if( lista[i].valor.compareObject(obj) != -1)

devolver lista[i].valor;

}

devolver - 1 ;

},

rateBoxBarMouseUp : función(e){

//var ele = document.getElementsByName("objeto");

var x = parseInt(dragable.getDragBox().style.getDragBox().style.left);//pointeurX(e);

var y = parseInt(dragable. getDragBox(). style.top);//pointeurY(e);

var ele = this.arrayTemplateLayout;

if(ele == null){

arrastrable. x + this.ifremeObj.offsetWidth) && y < (p.y + this.ifremeObj.offsetHeight)){

bus_design.isInsertImage(null, dragable.getDragBox().firstChild.src);

dragable.getDragBox().innerHTML = " ?"

dragable.isBoxDragable = false

hs.removeEventListener(documento;

ment, "mousemove",this.rateBoxBarMouseMoveHandler);

dragable.getDragBox().style.visibility="hidden";

return

}

}

for(var i = ele.length -1; i >= 0; i--){

// if(ele[i] .attributes.getNamedItem("objects").nodeValue==dragable.occupation)

// continuar

if(ele[i] == null) continuar

var p = hs.position(ele[i]);

//document.getElementById("memo").innerHTML = x+"/"+y+"/"/"+p .x+"/"/"+ p.y+"/"+(p.x+ele[i].offsetWidth )+"/"+ (p.y + ele[i].offsetHeight);

if(x>p.x && y > p.y && x < (p.x+ele[i].offsetWidth) && y < (p.y + ele [i].offsetHeight)){

//ele[ i].innerHTML="arrastrar a OK..." ;

prueba{

if(ele[i].firstChild.attributes.getNamedItem("name").nodeValue. indexOf("HtmlEdit") ! = -1){

if(ele[i].firstChild.tagName == "IFRAME" ){

if(dragable.isImageObject)

bus_design.isInsertImage(ele[i], dragable.getDragBox().firstChild.src

}else if(!dragable.isImageObject)

if (window.confirm('Las ventanas están en una habitación con una casa abierta.Valuable.mappingTemplateObject.get( dragable.objectId)){

dragable.mapTemplateObject.get(dragable.objectId).init(ele [i]);

}

}

}else if((ele[i]. firstChild.tagName=="IMG"){

if(window.confirm('las ventanas de inicio están en la sala de la jornada de puertas abiertas.confirm('página de inicio 僃僋valiantly 僃僋believe 僃僆僃僃僋valiantly 偐丠')==1){

dragable.destroyObject(ele[i]);

if(dragable.mapT

emplateObject.get(dragable.objectId)){

arrastrable.

}

}

}

}

}catch(e){

if(dragable. mapTemplateObject.get(dragable.objectId)){

dragable.mapTemplateObject.get(dragable. objectId).init(ele[i]);

}

}

}

} p>

romper ;

}

}

if(this.oldObj.style.height = dragable.oldObj.firstChild.offsetHeight + "px";

dragable.isTemplateObject = false

bus_stack.isBoxDragable = false

hs.removeEventListener(documento, "mousemove",this.rateBoxBarMouseMoveHandler

intente{

this.isImageObject = false

this.isTemplateObject = false

if(this. obj.id.indexOf("img_") ! = -1)

this.isImageObject = true

else if(this.obj.id.indexOf("template_") ! = -1)

this.isTemplateObject = true

this.getDragBox().className = this.obj.className

this.getDragBox( ).innerHTML = this.obj.innerHTML;

this.getDragBox().style.width = this.obj.offsetWidth +"true" }

};

var BoxUtils = {

obj: nulo,

tx: 0,

ty: 0,

tx1: 0 ,

ty1 : 0 ,

makeRateBoxHandler .function(e,obj){

if(obj.style.cursor ! = "move")

return ;

intentar{

while(obj.id.indexOf("_formove") == -1 && obj.name ! = "closeImage")

obj = obj.parentNode;

}catch(e){

devuelve falso

}

if(obj.name == "closeImage") devuelve falso;

this.o

bj = obj

//this.mapkey = root.attributes.getNamedItem("nombre").nodeValue

if (e.type == 'mousedown') {

var p = hs.position(obj);

this.tx = p.x

this.ty = p.y

this.tx = this.tx?this.tx : 0 ;

this..tx1 = pointeurX(e);

this.ty1 = pointeurY(e); > hs.addEventListener(document, 'mousemove', this.boxMouseMoveHandler);

} else if(e.type == 'mouseup' ){

hs.removeEventListener(document, "mousemove", this.boxMouseMoveHandler)

}

e=e||window.returnValue = false };

}

e.preventDefault();

},

boxMouseMoveHandler: function(e){

//document.getElementById(RateUtils.moveObjName).style. cursor="move";

BoxUtils.obj.style.left = (BoxUtils.tx- BoxUtils.tx1+pointeurX(e))+ "px";

BoxUtils.obj .style.top = (BoxUtils.ty- BoxUtils.ty1+pointeurY(e))+ "px";

//BoxUtils.obj.style.zIndex = 88888;

//if(hs.ie)

//setBackiframe(parseInt(BoxUtils.obj.style.left),parseInt( BoxUtils.obj.style.top),

// BoxUtils.obj.firstChild.offsetWidth,BoxUtils.obj.firstChild.returnValue = false };

}

e.preventDefault()

}

};

función createDiv(html,key,visible){

if(document.getElementById('dragDiv_'+key)) return ;

var div = hs.createElement(

'div',

{

id: 'dragDiv_'+clave

},

null

);

div.innerHTML = html;

document.body.appendChild(div);

devolver div;

}

Este es un código de arrastrar y soltar de un proyecto real. Es bastante complejo, la idea general es que después de crear el div, lo selecciones en una posición determinada. En cuanto a si se puede guardar, es porque cierta información se guarda en las cookies.