📄 wz_dragdrop.js
字号:
d_p.defy += d_dy; d_p.moveBy(d_dx, d_dy); } } } } else if(d_o.is_image && !dd.n4) { if(dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg)); var d_defx = d_o.defx, d_defy = d_o.defy; if(!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1)) d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy); } }};function WINSZ(d_x){ if(d_x) { if(dd.n4) { dd.iW = innerWidth; dd.iH = innerHeight; } window.onresize = new Function('WINSZ();'); } else if(dd.n4 && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload(); else if(!dd.n4) setTimeout('dd.recalc()', 0xa);}WINSZ(1);function DDObj(d_o, d_i){ this.id = d_o; this.cmd = ''; this.cpy_n = dd.getCmdVal(this, COPY); this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1); this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1); this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1); this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1); var d_j = dd_cursors.length; while(d_j--) if(dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2); this.clone = dd.getCmd(this, CLONE, 1); this.detach = dd.getCmd(this, DETACH_CHILDREN); this.scalable = dd.getCmd(this, SCALABLE, 1); this.horizontal = dd.getCmd(this, HORIZONTAL); this.noalt = dd.getCmd(this, NO_ALT, 1); this.nodrag = dd.getCmd(this, NO_DRAG); this.scroll = dd.getCmd(this, SCROLL, 1); this.resizable = dd.getCmd(this, RESIZABLE, 1); this.re_z = dd.getCmd(this, RESET_Z, 1); this.diaphan = dd.getCmd(this, TRANSPARENT, 1); this.vertical = dd.getCmd(this, VERTICAL); this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1); this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1)); this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1); this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1)); this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = null; this.name = this.id + (d_i || ''); this.oimg = dd.getImg(this, this.id, 1); this.is_image = !!this.oimg; this.copies = new Array(); this.children = new Array(); this.parent = this.original = null; if(this.oimg) { this.id = this.name + 'div'; this.w = dd.getImgW(this.oimg); this.h = dd.getImgH(this.oimg); this.dw = this.dh = 0; this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1; this.defsrc = this.src = this.oimg.src; this.htm = '<img name="' + this.id + 'NImG"'+ ' src="' + this.oimg.src + '" '+ 'width="' + this.w + '" height="' + this.h + '">'; this.t_htm = '<div id="' + this.id + '" style="position:absolute;'+ 'left:' + (this.cssx = this.x = this.defx) + 'px;'+ 'top:' + (this.cssy = this.y = this.defy) + 'px;'+ 'width:' + this.w + 'px;'+ 'height:' + this.h + 'px;">'+ this.htm + '</div>'; } else { if(!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != dd_u) this.css = this.div.style; dd.getWH(this); if(this.div) { this.div.ddObj = this; this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0); } dd.getPageXY(this.div); this.defx = this.x = dd.x; this.defy = this.y = dd.y; dd.getCssXY(this); this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex')); } this.defw = this.w || 0; this.defh = this.h || 0;}DDObj.prototype.setPickFunc = function(d_x){ this.pickFunc = d_x;};DDObj.prototype.setDragFunc = function(d_x){ this.dragFunc = d_x;};DDObj.prototype.setResizeFunc = function(d_x){ this.resizeFunc = d_x;};DDObj.prototype.setDropFunc = function(d_x){ this.dropFunc = d_x;};DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o){ if(!this.div) return; this.x += (d_x = dd.Int(d_x)); this.y += (d_y = dd.Int(d_y)); if(!d_kds || this.is_image || this.parent != this.defparent) { (d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px; d_o.top = (this.cssy += d_y) + dd.px; } var d_i = this.children.length; while(d_i--) { if(!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1); d_o.defx += d_x; d_o.defy += d_y; }};DDObj.prototype.moveTo = function(d_x, d_y){ this.moveBy(dd.Int(d_x)-this.x, dd.Int(d_y)-this.y);};DDObj.prototype.hide = function(d_m, d_o, d_p){ if(this.div && this.visible) { d_p = this.css || this.div; if(d_m && !dd.n4) { this.display = dd.getCssProp(this.div, "display", "display", "display"); if(this.oimg) { this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display"); this.oimg.style.display = "none"; } d_p.display = "none"; dd.recalc(); } else d_p.visibility = "hidden"; } this.visible = false; var d_i = this.children.length; while(d_i--) if(!(d_o = this.children[d_i]).detached) d_o.hide(d_m);};DDObj.prototype.show = function(d_o, d_p){ if(this.div) { d_p = this.css || this.div; if(d_p.display && d_p.display == "none") { d_p.display = this.display || "block"; if(this.oimg) this.oimg.style.display = this.oimg.display || "inline"; dd.recalc(); } else d_p.visibility = "visible"; } this.visible = true; var d_i = this.children.length; while(d_i--) if(!(d_o = this.children[d_i]).detached) d_o.show();};DDObj.prototype.resizeTo = function(d_w, d_h, d_o){ if(!this.div) return; d_w = (this.w = dd.Int(d_w))-this.dw; d_h = (this.h = dd.Int(d_h))-this.dh; if(dd.n4) { this.div.resizeTo(d_w, d_h); if(this.is_image) { this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">'); (this.nimg = this.div.document.images[0]).src = this.src; } } else if(typeof this.css.pixelWidth != dd_u) { this.css.pixelWidth = d_w; this.css.pixelHeight = d_h; if(this.is_image) { (d_o = this.nimg.style).pixelWidth = d_w; d_o.pixelHeight = d_h; } } else { this.css.width = d_w + dd.px; this.css.height = d_h + dd.px; if(this.is_image) { (d_o = this.nimg).width = d_w; d_o.height = d_h; if(!d_o.complete) d_o.src = this.src; } }};DDObj.prototype.resizeBy = function(d_dw, d_dh){ this.resizeTo(this.w+dd.Int(d_dw), this.h+dd.Int(d_dh));};DDObj.prototype.swapImage = function(d_x, d_cp){ if(!this.nimg) return; this.nimg.src = d_x; this.src = this.nimg.src; if(d_cp) { var d_i = this.copies.length; while(d_i--) this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src; }};DDObj.prototype.setBgColor = function(d_x){ if(dd.n4 && this.div) this.div.bgColor = d_x; else if(this.css) this.css.background = d_x; this.bgColor = d_x;};DDObj.prototype.write = function(d_x, d_o){ this.text = d_x; if(!this.div) return; if(dd.n4) { (d_o = this.div.document).open(); d_o.write(d_x); d_o.close(); dd.getWH(this); } else { this.css.height = 'auto'; this.div.innerHTML = d_x; if(!dd.ie4) dd.recalc(); if(dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0); // n6.0: recalc twice }};DDObj.prototype.copy = function(d_n, d_p, d_b){ if(!this.oimg) return; d_b = (dd.ie && document.all.tags('body'))? document.all.tags('body')[0] : document.getElementsByTagName? (document.getElementsByTagName('body')[0] || dd.db) : dd.db; d_n = d_n || 1; while(d_n--) { var d_l = this.copies.length, d_o = new DDObj(this.name+this.cmd, d_l+1); if(dd.n4) { d_o.id = (d_p = new Layer(d_o.w)).name; d_p.clip.height = d_o.h; d_p.visibility = 'show'; (d_p = d_p.document).open(); d_p.write(d_o.htm); d_p.close(); } else if(d_b && d_b.insertAdjacentHTML) d_b.insertAdjacentHTML("AfterBegin", d_o.t_htm); else if(document.createElement && d_b && d_b.appendChild) { d_b.appendChild(d_p = document.createElement('div')); d_p.innerHTML = d_o.htm; d_p.id = d_o.id; d_p.style.position = 'absolute'; d_p.style.width = d_o.w + 'px'; d_p.style.height = d_o.h + 'px'; } else if(d_b && d_b.innerHTML) d_b.innerHTML += d_o.t_htm; d_o.defz = this.defz+1+d_l; dd.addProps(d_o); d_o.original = this; dd.addElt(d_o, this); if(this.parent) { this.parent.addChild(d_o, this.detached); d_o.defparent = this.defparent; } d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy); if(dd.n4) d_o.defsrc = d_o.src = this.defsrc; d_o.swapImage(this.src); }};DDObj.prototype.addChild = function(d_kd, detach, defp){ if(typeof d_kd != "object") d_kd = dd.elements[d_kd]; if(d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return; this.children[this.children.length] = this.children[d_kd.name] = d_kd; d_kd.detached = detach || 0; if(defp) d_kd.defparent = this; else if(this == d_kd.defparent && d_kd.is_image) dd.getImg(this, d_kd.oimg.name, 1); if(!d_kd.defparent || this != d_kd.defparent) { d_kd.defx = d_kd.x; d_kd.defy = d_kd.y; } if(!detach) { d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1); d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1); } if(d_kd.parent) d_kd.parent._removeChild(d_kd, 1); d_kd.parent = this;};DDObj.prototype._removeChild = function(d_kd, d_newp){ if(typeof d_kd != "object") d_kd = this.children[d_kd]; var d_oc = this.children, d_nc = new Array(); for(var d_i = 0; d_i < d_oc.length; d_i++) if(d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i]; this.children = d_nc; d_kd.parent = null; if(!d_newp) { d_kd.detached = d_kd.defp = 0; if(d_kd.is_image) dd.getImg(d_kd, d_kd.oimg.name, 1); }};DDObj.prototype.attachChild = function(d_kd){ (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0; d_kd.setZ(d_kd.defz + this.z-this.defz, 1);};DDObj.prototype.detachChild = function(d_kd){ (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;};DDObj.prototype.setZ = function(d_x, d_kds, d_o){ if(d_kds) { var d_dz = d_x-this.z, d_i = this.children.length; while(d_i--) if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1); } dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);};DDObj.prototype.maximizeZ = function(){ this.setZ(dd.z+1, 1);};DDObj.prototype._resetZ = function(d_o){ if(this.re_z || dd.re_z) { this.setZ(this.defz); var d_i = this.children.length; while(d_i--) if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz); }};DDObj.prototype.setOpacity = function(d_x){ this.opacity = d_x; this._setOpaRel(1.0, 1);};DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o){ if(this.diaphan || d_kd) { d_y = this.opacity*d_x; if(dd.n6) this.css.MozOpacity = d_y; else if(dd.ie && !dd.iemac) { if(this.css) this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")"; } else if(this.css) this.css.opacity = d_y; var d_i = this.children.length; while(d_i--) if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1); }};DDObj.prototype.setCursor = function(d_x){ this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);};DDObj.prototype._setCrs = function(d_x){ if(this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x;};DDObj.prototype.setDraggable = function(d_x){ this.nodrag = !d_x*1; this._setCrs(d_x? this.cursor : 'auto');};DDObj.prototype.setResizable = function(d_x){ this.resizable = d_x*1; if(d_x) this.scalable = 0;};DDObj.prototype.setScalable = function(d_x){ this.scalable = d_x*1; if(d_x) this.resizable = 0;};DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y){ var d_o, d_cmp = -1, d_i = dd.elements.length; while(d_i--) { d_o = dd.elements[d_i]; d_x = d_o.x-this.w/2; d_y = d_o.y-this.h/2; if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h) { if(d_o.z > d_cmp) { d_cmp = d_o.z; d_ret = d_o; } } } return d_ret;};DDObj.prototype.del = function(d_os, d_o){ var d_i; if(this.parent && this.parent._removeChild) this.parent._removeChild(this); if(this.original) { this.hide(); if(this.original.copies) { d_os = new Array(); for(d_i = 0; d_i < this.original.copies.length; d_i++) if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o; this.original.copies = d_os; } } else if(this.is_image) { this.hide(); if(this.oimg) { if(dd.n4) this.oimg.src = this.defsrc; else this.oimg.style.visibility = 'visible'; } } else if(this.moveTo) { if(this.css) this.css.cursor = 'default'; this.moveTo(this.defx, this.defy); this.resizeTo(this.defw, this.defh); } d_os = new Array(); for(d_i = 0; d_i < dd.elements.length; d_i++) { if((d_o = dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o; else d_o._free(); } dd.elements = d_os; if(!dd.n4) dd.recalc();};DDObj.prototype._free = function(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -