⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wz_dragdrop.js

📁 java版源代码,里面包含很多源代码,大家可以看看.
💻 JS
📖 第 1 页 / 共 3 页
字号:
/* This notice must be untouched at all times.wz_dragdrop.js	v. 4.83The latest version is available athttp://www.walterzorn.comor http://www.devira.comor http://www.walterzorn.deCopyright (c) 2002-2003 Walter Zorn. All rights reserved.Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )Last modified: 9. 12. 2005This DHTML & Drag&Drop Library adds Drag&Drop functionalityto the following types of html-elements:- images, even if not positioned via layers,  nor via stylesheets or any other kind of "hard-coding"- relatively and absolutely positioned layers (DIV elements).Moreover, it provides extended DHTML abilities.LICENSE: LGPLThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense (LGPL) as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.For more details on the GNU Lesser General Public License,see http://www.gnu.org/copyleft/lesser.html*/// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)var spacer = 'transparentpixel.gif';//window.onerror = new Function('return true;');// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)var CLONE			= 'C10nE';   // i  img	  clone imagevar COPY			 = 'C0pY';	// i  img	  create copiesvar DETACH_CHILDREN  = 'd37aCH';  // i  lyr	  detach imagesvar HORIZONTAL	   = 'H0r1Z';   // i  img,lyr  horizontally draggable onlyvar MAXHEIGHT		= 'm7x8I';   // i  img,lyr  maximum height limit, "var MAXOFFBOTTOM	 = 'm7xd0wN'; // i  img,lyr  downward offset limitvar MAXOFFLEFT	   = 'm7x23Ft'; // i  img,lyr  leftward offset limitvar MAXOFFRIGHT	  = 'm7x0Ff8'; // i  img,lyr  rightward offset limitvar MAXOFFTOP		= 'm7xu9';   // i  img,lyr  upward offset limitvar MAXWIDTH		 = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalablevar MINWIDTH		 = 'm1nw1';   // i  img,lyr  minimum width limit, "var MINHEIGHT		= 'm1n8I';   // i  img,lyr  minimum height limit, "var NO_ALT		   = 'no81T';   // gi img	  disable alt and title attributesvar NO_DRAG		  = 'N0d4Ag';  // i  img,lyr  disable draggabilityvar RESET_Z		  = 'r35E7z';  // gi img,lyr  reset z-index when droppedvar RESIZABLE		= 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressedvar SCALABLE		 = 'SCLbl';   // gi img,lyr  scalable		   "var SCROLL		   = 'sC8lL';   // gi img,lyr  enable auto scroll functionalityvar TRANSPARENT	  = 'dIApHAn'; // gi img,lyr  translucent while draggedvar VERTICAL		 = 'V3Rt1C';  // i  img,lyr  vertically draggable onlyvar dd_cursors = new Array(	'c:default',	'c:crosshair',	'c:e-resize',	'c:hand',	'c:help',	'c:move',	'c:n-resize',	'c:ne-resize',	'c:nw-resize',	'c:s-resize',	'c:se-resize',	'c:sw-resize',	'c:text',	'c:w-resize',	'c:wait');var dd_i = dd_cursors.length; while(dd_i--)	eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";');var dd_u = "undefined";function WZDD(){	this.elements = new Array(0);	this.obj = null;	this.n = navigator.userAgent.toLowerCase();	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?		document.documentElement		: (document.body || null);	this.op = !!(window.opera && document.getElementById);	if(this.op) document.onmousedown = new Function('e',		'if(((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;');	this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op);	this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);	this.ie4 = !!(this.ie && !document.getElementById);	this.n4 = !!(document.layers && typeof document.classes != dd_u);	this.n6 = !!(typeof window.getComputedStyle != dd_u && typeof document.createRange != dd_u);	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);	this.ce = !!(document.captureEvents && document.releaseEvents);	this.px = this.n4? '' : 'px';	this.tiv = this.w3c? 40 : 10;}var dd = new WZDD();dd.Int = function(d_x, d_y){	return isNaN(d_y = parseInt(d_x))? 0 : d_y;};dd.getWndW = function(){	return dd.Int(		(dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth		: (window.innerWidth || 0)	);};dd.getWndH = function(){	return dd.Int(		(dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight		: (window.innerHeight || 0)	);};dd.getScrollX = function(){	return dd.Int(window.pageXOffset || (dd.db? dd.db.scrollLeft : 0));};dd.getScrollY = function(){	return dd.Int(window.pageYOffset || (dd.db? dd.db.scrollTop : 0));};dd.getPageXY = function(d_o){	if(dd.n4 && d_o)	{		dd.x = d_o.pageX || 0;		dd.y = d_o.pageY || 0;	}	else	{		dd.x = dd.y = 0; //global helper vars		while(d_o)		{			dd.x += dd.Int(d_o.offsetLeft);			dd.y += dd.Int(d_o.offsetTop);			d_o = d_o.offsetParent || null;		}	}};dd.getCssXY = function(d_o){	if(d_o.div)	{		if(dd.n4)		{			d_o.cssx = d_o.div.x;			d_o.cssy = d_o.div.y;		}		else if(dd.ie4)		{			d_o.cssx = d_o.css.pixelLeft;			d_o.cssy = d_o.css.pixelTop;		}		else		{			d_o.css.left = d_o.css.top = 0 + dd.px;			dd.getPageXY(d_o.div);			d_o.cssx = d_o.x - dd.x;			d_o.cssy = d_o.y - dd.y;			d_o.css.left = d_o.cssx + dd.px;			d_o.css.top = d_o.cssy + dd.px;		}	}	else	{		d_o.cssx = 0;		d_o.cssy = 0;	}};dd.getImgW = function(d_o){	return d_o? dd.Int(d_o.width) : 0;};dd.getImgH = function(d_o){	return d_o? dd.Int(d_o.height) : 0;};dd.getDivW = function(d_o){	return dd.Int(		dd.n4? (d_o.div? d_o.div.clip.width : 0)		: d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)		: 0	);};dd.getDivH = function(d_o){	return dd.Int(		dd.n4? (d_o.div? d_o.div.clip.height : 0)		: d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)		: 0	);};dd.getWH = function(d_o){	d_o.w = dd.getDivW(d_o);	d_o.h = dd.getDivH(d_o);	if(d_o.css)	{		d_o.css.width = d_o.w + dd.px;		d_o.css.height = d_o.h + dd.px;		d_o.dw = dd.getDivW(d_o)-d_o.w;		d_o.dh = dd.getDivH(d_o)-d_o.h;		d_o.css.width = (d_o.w-d_o.dw) + dd.px;		d_o.css.height = (d_o.h-d_o.dh) + dd.px;	}	else d_o.dw = d_o.dh = 0;};dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4){	if(d_o && dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6);	if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);	if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);	if(d_o && dd.n4) return ''+eval('d_o.'+d_pn4);	return '';};dd.getDiv = function(d_x, d_d){	d_d = d_d || document;	if(dd.n4)	{		if(d_d.layers[d_x]) return d_d.layers[d_x];		for(var d_i = d_d.layers.length; d_i--;)		{			var d_y = dd.getDiv(d_x, d_d.layers[d_i].document);			if(d_y) return d_y;		}	}	if(dd.ie) return d_d.all[d_x] || null;	if(d_d.getElementById) return d_d.getElementById(d_x) || null;	return null;};dd.getImg = function(d_o, d_nm, d_xy, d_w){	d_w = d_w || window;	var d_img;	if(document.images && (d_img = d_w.document.images[d_nm]))	{		if(d_xy)		{			if(dd.n4)			{				dd.getPageXY(d_w);				d_o.defx = d_img.x + dd.x;				d_o.defy = d_img.y + dd.y;			}			else			{				dd.getPageXY(d_img);				d_o.defx = dd.x;				d_o.defy = dd.y;			}		}		return d_img;	}	if(dd.n4) for(var d_i = d_w.document.layers.length; d_i--;)	{		var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]);		if(d_y) return d_y;	}	return null;};dd.getParent = function(d_o, d_p){	if(dd.n4)	{		for(d_p, d_i = dd.elements.length; d_i--;)		{			if(!((d_p = dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name]))				d_p.addChild(d_o, d_p.detach, 1);		}	}	else	{		d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);		while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))		{			if(d_p.ddObj)			{				d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);				break;			}		}	}};dd.getCmd = function(d_o, d_cmd, d_cmdStr){	var d_i = d_o.id.indexOf(d_cmd), d_j,	d_y = (d_i >= 0)*1;	if(d_y)	{		d_j = d_i+d_cmd.length;		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);	}	return d_y;};dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0){	var d_i = d_o.id.indexOf(d_cmd), d_j,	d_y = (d_o.id.indexOf(d_cmd) >= 0)? dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0;	if(!int0 && d_y || int0 && d_y >= 0)	{		d_j = d_i+d_cmd.length+(""+d_y).length;		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);	}	return d_y;};dd.addElt = function(d_o, d_p){	dd.elements[d_o.name] = dd.elements[d_o.index = dd.elements.length] = d_o;	if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;};dd.mkWzDom = function(){	var d_o, d_i = dd.elements.length; while(d_i--) dd.getParent(dd.elements[d_i]);	d_i = dd.elements.length; while(d_i--)	{		d_o = dd.elements[d_i];		if(d_o.children && !d_o.parent)		{			var d_j = d_o.children.length; while(d_j--)				d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);		}	}};dd.addProps = function(d_o){	var d_i, d_c;	if(d_o.is_image)	{		d_o.div = dd.getDiv(d_o.id);		d_o.css = (d_o.div && typeof d_o.div.style != dd_u)? d_o.div.style : null;		d_o.nimg = (dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+'NImG'] || null);		if(!d_o.noalt && !dd.noalt && d_o.nimg && d_o.oimg)		{			d_o.nimg.alt = d_o.oimg.alt || '';			if(d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;		}		d_o.bgColor = '';	}	else	{		d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();		if(dd.n6 && d_o.div)		{			if((d_c = d_o.bgColor).indexOf('rgb') >= 0)			{				d_c = d_c.substring(4, d_c.length-1).split(',');				d_o.bgColor = '#';				for(d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);			}			else d_o.bgColor = d_c;		}	}	if(dd.scalable) d_o.scalable = d_o.resizable^1;	else if(dd.resizable) d_o.resizable = d_o.scalable^1;	d_o.setZ(d_o.defz);	d_o.cursor = d_o.cursor || dd.cursor || 'auto';	d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);	d_o.diaphan = d_o.diaphan || dd.diaphan || 0;	d_o.opacity = 1.0;	if(dd.ie && !dd.iemac && d_o.div && d_o.div.style)		d_o.div.style.filter = "Alpha(opacity=100)";	d_o.visible = true;};dd.initz = function(){	if(!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return;	else if(dd.n6 || dd.ie || dd.op || dd.w3c) dd.recalc(1);	var d_drag = (document.onmousemove == DRAG),	d_resize = (document.onmousemove == RESIZE);	if(dd.loadFunc) dd.loadFunc();	if(d_drag) dd.setMovHdl(DRAG);	else if(d_resize) dd.setMovHdl(RESIZE);	if(d_drag || d_resize) dd.setUpHdl(DROP);	dd.setDwnHdl(PICK);};dd.finlz = function(){	if(dd.ie && dd.elements)	{		var d_i = dd.elements.length; while(d_i--)			dd.elements[d_i].del();	}	if(dd.uloadFunc) dd.uloadFunc();};dd.setCe = function(d_e, d_fnc){	d_fnc? document.captureEvents(d_e) : document.releaseEvents(d_e);};dd.setDwnHdl = function(d_x){	if(document.onmousedown != d_x)	{		dd.downFunc = document.onmousedown;		document.onmousedown = d_x;		if(dd.ce) dd.setCe(Event.MOUSEDOWN, d_x);	}};dd.setMovHdl = function(d_x){	if(document.onmousemove != d_x)	{		dd.moveFunc = document.onmousemove;		document.onmousemove = d_x;		if(dd.ce) dd.setCe(Event.MOUSEMOVE, d_x);	}};dd.setUpHdl = function(d_x){	if(document.onmouseup != d_x)	{		dd.upFunc = document.onmouseup;		document.onmouseup = d_x;		if(dd.ce) dd.setCe(Event.MOUSEUP, d_x);	}};dd.evt = function(d_e){	this.but = (this.e = d_e || window.event).which || this.e.button || 0;	this.button = (this.e.type == 'mousedown')? this.but		: (dd.e && dd.e.button)? dd.e.button		: 0;	this.src = this.e.target || this.e.srcElement || null;	this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();	this.x = dd.Int(this.e.pageX || this.e.clientX || 0);	this.y = dd.Int(this.e.pageY || this.e.clientY || 0);	if(dd.ie)	{		this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1;		this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1;	}	this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);};dd.recalc = function(d_x){	var d_o, d_i = dd.elements.length; while(d_i--)	{		if(!(d_o = dd.elements[d_i]).is_image && d_o.div)		{			dd.getWH(d_o);			if(d_o.div.pos_rel)			{				dd.getPageXY(d_o.div);				var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y;				d_o.defx += d_dx;				d_o.x += d_dx;				d_o.defy += d_dy;				d_o.y += d_dy;				var d_p, d_j = d_o.children.length; while(d_j--)				{					if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1))))					{						d_p.defx += d_dx;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -