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

📄 zoom.htm

📁 万能配电器原理说明: 图1: 服务器主要具有收集万能配电器的参数值,和修改万能配电器的内部设置的功能.服务器是通过配电集线器分出多组万能配电器来控制和显示万能配电器的参数.而服务器于配电集线器的方
💻 HTM
📖 第 1 页 / 共 2 页
字号:
function PostZoomProcessing (newZoomLevel)
{
	var xOffset = parseInt(zoomRectDiv.style.left) - parseInt(divThumbnail.style.left);
	var yOffset = parseInt(zoomRectDiv.style.top) - parseInt(divThumbnail.style.top);

	var xPercent = xOffset / PNZimg.style.pixelWidth;
	var yPercent = yOffset / PNZimg.style.pixelHeight;

	var viewMgr = parent.parent.viewMgr;
	viewMgr.ChangingView = true;

	if (viewMgr.setView)
	{
		viewMgr.PostSetViewProcessing = PostSetViewProcessing;
		viewMgr.setView (xPercent, yPercent);
	}

	SetCorrectTick (newZoomLevel);

	viewMgr.PostZoomProcessing = null;
}

function SetCorrectTick (newZoomLevel)
{
	var zoomLevels = parent.zoomLevels;
	if (newZoomLevel <= zoomLevels[0])
	{
		parent.changeTick(zoomLevels[0]);
	}
	else if (newZoomLevel >= zoomLevels[zoomLevels.length - 1])
	{
		parent.changeTick(zoomLevels[zoomLevels.length - 1]);
	}
	else
	{
		for (var count = 0; count < zoomLevels.length - 1; count++)
		{
			var deltaDown = newZoomLevel - zoomLevels[count];
			var deltaUp = newZoomLevel - zoomLevels[count + 1];
			if (deltaDown >= 0 && deltaUp <= 0)
			{
				if (Math.abs(deltaDown) < Math.abs(deltaUp))
				{
					parent.changeTick(zoomLevels[count]);
					break;
				}
				else
				{
					parent.changeTick(zoomLevels[count + 1]);
					break;
				}
			}
		}
	}
}

function PostSetViewProcessing ()
{
	parent.parent.viewMgr.ChangingView = false;
	parent.parent.viewMgr.PostSetViewProcessing = null;
}

function startNewZoomRectDrag()
{
	var x = getMouseXcoord();
	var y = getMouseYcoord();
	zoomObj.newZWinStartX = x;
	zoomObj.newZWinStartY = y;
	
	g_newZWinObjRef = document.all("newZoomWindowDiv");
	g_newZWinObjRef.style.display = "";

	startDrag( 'zoomRectDiv', doNewZoomRectDrag, stopNewZoomRectDrag );
}

function doNewZoomRectDrag(dragObj, x, y)
{
	var PNZimg = document.all("ConvertedImage");

	var width	= Math.abs( zoomObj.newZWinStartX - x );
	var height	= Math.abs( zoomObj.newZWinStartY - y );

	var aspectRatio = parent.parent.viewMgr.docDrawing.body.clientWidth / parent.parent.viewMgr.docDrawing.body.clientHeight;

	if( width < (aspectRatio * height))
	{
		width = (aspectRatio) * height;
	}
	else
	{
		height = width / (aspectRatio);
	}

	width = Math.min (width, parseInt(PNZimg.style.pixelWidth));
	height = Math.min (height, parseInt(PNZimg.style.pixelHeight));

	var left = (x > zoomObj.newZWinStartX) ? zoomObj.newZWinStartX : zoomObj.newZWinStartX - width;
	var top  = (y > zoomObj.newZWinStartY) ? zoomObj.newZWinStartY : zoomObj.newZWinStartY - height;

	newZoomWindowDiv.style.top = top;
	newZoomWindowDiv.style.left = left;
	newZoomWindowDiv.style.height = height;
	newZoomWindowDiv.style.width = width;
	newZoomWindowDiv.style.visibility = "visible";

	zoomObj.zoomWinLeft		= left;
	zoomObj.zoomWinWidth	= width;
	zoomObj.zoomWinTop		= top;
	zoomObj.zoomWinHeight	= height;
}

function stopNewZoomRectDrag(dragObj, x, y)
{
	newZoomWindowDiv.style.visibility = "hidden";

	if (parseInt (newZoomWindowDiv.style.width) > 10 && 
		parseInt (newZoomWindowDiv.style.height) > 10)
	{
		zoomRectDiv.style.top = newZoomWindowDiv.style.top;
		zoomRectDiv.style.left = newZoomWindowDiv.style.left;
		zoomRectDiv.style.height = newZoomWindowDiv.style.height;
		zoomRectDiv.style.width = newZoomWindowDiv.style.width;

		stopResizeZoomRectDrag(dragObj,x,y);
		zoomRectDiv.style.display = "inline";
		zoomRectDiv.style.visibility = "visible";
	}
	else
	{
		zoomObj.zoomWinLeft		= parseInt(zoomRectDiv.style.left);
		zoomObj.zoomWinWidth	= parseInt(zoomRectDiv.style.width);
		zoomObj.zoomWinTop		= parseInt(zoomRectDiv.style.top);
		zoomObj.zoomWinHeight	= parseInt(zoomRectDiv.style.height);
	}

	newZoomWindowDiv.style.height = "0px";
	newZoomWindowDiv.style.width = "0px";

	newZoomWindowDiv.style.display = "none";
}

var g_lastX = 0;
var g_lastY = 0;

document.onmousedown = mouseDown;
document.onmousemove = mouseMove;
document.onmouseup = mouseUp;
document.onmouseout = mouseOut;

function mouseDown()
{
	return true;
}

function mouseMove()
{
	var x = event.clientX + document.body.scrollLeft;
	var y = event.clientY + document.body.scrollTop;

	g_lastX = x;
	g_lastY = y;
	
	doDrag( x, y );
	return true;
}

function mouseUp() 
{
	var x = event.x + document.body.scrollLeft;
	var y = event.y + document.body.scrollTop;
	
	stopDrag(null,x,y);
	return true;
}

function mouseOut() 
{
	var x = event.x + document.body.scrollLeft;
	var y = event.y + document.body.scrollTop;

	if( x < 0 ) x = -1;
	if( x >= document.body.clientWidth ) x = -1;
		
	if( y < 0 ) y = -1;
	if( y >= document.body.clientHeight ) y = -1;

	if( x == -1 || y == -1 )
	{
		x = -1;
		y = -1;
	}
	

	if( x == -1 )
		stopDrag( null, x, y );
	return true;
}

function getMouseXcoord()
{
	return event.x + document.body.scrollLeft;
}

function getMouseYcoord()
{
	return event.y + document.body.scrollTop;
}

var g_width		= -1;
var g_height	= -1;
var g_newLeft	= -1;	
var g_newTop	= -1;
		
var g_pnzImgWidth = -1;
var g_pnzImgHeight = -1;
var g_pnzImgLeft = -1;
var g_pnzImgTop = -1;

function keydown()
{
	var key = window.event.keyCode;
	var el = window.event.srcElement;

	if(key == 37 || key == 38 || key == 39 || key == 40)
	{
		if(g_width == -1)
			g_width		= parseInt(el.style.pixelWidth);
			
		if(g_height == -1)
			g_height		= parseInt(el.style.pixelHeight);
			
		if(g_newLeft == -1)
			g_newLeft		= parseInt(el.style.left);	
		
		if(g_newTop == -1)
			g_newTop		= parseInt(el.style.top);
		
		if(g_pnzImgWidth == -1)
			g_pnzImgWidth = parseInt(PNZimg.style.pixelWidth);
			
		if(g_pnzImgHeight == -1)
			g_pnzImgHeight = parseInt(PNZimg.style.pixelHeight);
			
		if(g_pnzImgLeft == -1)
			g_pnzImgLeft = parseInt(divThumbnail.style.left);
			
		if(g_pnzImgTop == -1)
			g_pnzImgTop = parseInt(divThumbnail.style.top);
	

		if(key == 37)	
		{
			g_newLeft -= 1;
			if(g_newLeft < g_pnzImgLeft)
			{
				g_newLeft = g_pnzImgLeft;
			}	
		}
		else if(key == 38)	
		{
			g_newTop -= 1;
			if(g_newTop < g_pnzImgTop)
			{
				g_newTop = g_pnzImgTop;
			}	
		}
		else if(key == 39)	
		{
			g_newLeft += 1;
			if(g_newLeft + g_width > g_pnzImgLeft + g_pnzImgWidth)
			{
				g_newLeft = g_pnzImgLeft + g_pnzImgWidth - g_width;		
			}
		}
		
		else if(key == 40)	
		{
			g_newTop += 1;
			if(g_newTop + g_height > g_pnzImgTop + g_pnzImgHeight)
			{
				g_newTop = g_pnzImgTop + g_pnzImgHeight - g_height;		
			}
		}
		
		setZoomRectCursor();

		var xOffset = g_newLeft - g_pnzImgLeft;
		var yOffset = g_newTop - g_pnzImgTop;
		
		var xPercent = xPercent = xOffset / g_pnzImgWidth;
		var yPercent = yPercent = yOffset / g_pnzImgHeight;

		if (xOffset < 0)
		{
			xPercent = 0;
			xOffset = g_pnzImgLeft;
		}
		else if (xOffset + g_width > g_pnzImgWidth)
		{
			xPercent = 1;
			xOffset = g_pnzImgLeft + g_pnzImgWidth - g_width;
		}

		if (yOffset < 0)
		{
			yPercent = 0;
			yOffset = g_pnzImgTop;
		}
		else if (yOffset + g_height > g_pnzImgHeight)
		{
			yPercent = 1;
			yOffset = g_pnzImgTop + g_pnzImgHeight - g_height;
		}

		if (parent.parent.viewMgr.setView)
		{
			var viewMgr = parent.parent.viewMgr;
			viewMgr.PostSetViewProcessing = PostSetViewProcessing;
			viewMgr.ChangingView = true;
			viewMgr.setView (xPercent, yPercent);
		}	
		setZWinSize (null, null, g_newLeft, g_newTop);
	}
}

function keyup()
{
	var key = window.event.keyCode;
	if(key == 37 || key == 38 || key == 39 || key == 40)
	{		
		el = window.event.srcElement;
	}
}

function dragObject( divID, divObject, xOffset, yOffset, dragFunctionPointer, dragStopFunctionPointer )
{
	this.divID			= divID;
	this.divObject		= divObject;
	this.xOffset		= xOffset;
	this.yOffset		= yOffset;
	this.dragFPtr		= dragFunctionPointer;
	this.dragStopFPtr	= dragStopFunctionPointer;
}

var dragList = new Array();


function startDrag( divID, dragFunctionPtr, dragStopFunctionPointer, xOffset, yOffset ) 
{
	var divObject = document.all(divID);
	if( divObject != null ) 
	{
		document.selection.empty();
		
		if( xOffset == null )
		{
			xOffset = parseInt(divObject.style.left) - g_lastX;
		}
		
		if( yOffset == null )
		{
			yOffset = parseInt(divObject.style.top)  - g_lastY;
		}

		dragList[ dragList.length ] = new dragObject( divID, divObject, xOffset, yOffset, dragFunctionPtr, dragStopFunctionPointer );
		return true;
	} 
	else 
	{
		return false;
	}
}

function doDrag( x, y ) 
{
	for( var i=0; i < dragList.length; i++ ) 
	{
		if( dragList[i].dragFPtr != null )
			dragList[i].dragFPtr( dragList[i], x, y );
	}
	if( dragList.length )
	{
		document.selection.empty();
	}
}

function stopDrag( divID, x, y ) 
{ 
	var tmpDragObject;
	for( var i=0; i < dragList.length; i++ ) 
	{
		if( dragList[i].divID == divID || divID == null ) 
		{
			tmpDragObject = dragList[i];
			
			dragList[i] = dragList[ dragList.length - 1 ];
			dragList.length = dragList.length - 1;
			
			if( tmpDragObject.dragStopFPtr != null )
			{
				tmpDragObject.dragStopFPtr( tmpDragObject, x, y );
			}
			
		}
	}
}

function PageViewChanged(newLeftPercent, newTopPercent, newWidthPercent, newHeightPercent)
{
	if (dragList.length == 0 && !parent.parent.viewMgr.ChangingView)
	{
		var newLeft		= null;
		var newTop		= null;
		var newWidth	= null;
		var newHeight	= null;

		var PNZimg = document.all("ConvertedImage");

		if (newLeftPercent != null)
		{
			newLeft = (newLeftPercent * PNZimg.style.pixelWidth) + parseInt(divThumbnail.style.left);
		}
		
		if (newTopPercent != null)
		{
			newTop = (newTopPercent * PNZimg.style.pixelHeight) + parseInt(divThumbnail.style.top);
		}
		
		if (newWidthPercent != null)
		{
			newWidth = newWidthPercent * PNZimg.style.pixelWidth;
		}
		
		if (newHeightPercent != null)
		{
			newHeight = newHeightPercent * PNZimg.style.pixelHeight;
		}

		setZWinSize (newWidth, newHeight, newLeft, newTop);

		if (newLeftPercent <= 0 && newTopPercent <= 0 && newWidthPercent >= 1 && newHeightPercent >= 1)
		{
			zoomRectDiv.style.display = "none";
			zoomRectDiv.style.visibility = "hidden";
		}
		else
		{
			zoomRectDiv.style.display = "inline";
			zoomRectDiv.style.visibility = "visible";
		}

		if (newWidthPercent != null && newHeightPercent != null)
		{
			var newZoomLevel = GetZoomLevel (newWidthPercent, newHeightPercent);
			SetCorrectTick (newZoomLevel);
		}
	}
}

function load()
{
	parent.parent.g_ZoomLoaded = true;

	if (parent.parent.g_LoadingWidgets)
	{
		parent.parent.g_LoadingWidgets = false;
		parent.parent.location.reload();
	}
}

function unload()
{
	if (parent.parent.viewMgr)
	{
		parent.parent.viewMgr.viewChanged = null;
	}

	parent.parent.g_LoadingWidgets = true;
}


</script>
</head>
<body onload="load();" onunload="unload();">
<div id="divPZWindow" style="width: 100%; height: 100%;" >
	<div id="divThumbnail" style="position: absolute; " onmousedown="startNewZoomRectDrag();"></div>
</div>
<div id="divTempThumbnail" style="position: absolute; visibility:hidden; display:none;" ></div>

<div id="zoomRectDiv" tabindex="1" title="鍙

⌨️ 快捷键说明

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