Click here to Skip to main content
15,885,875 members
Articles / Web Development / ASP.NET

ASP.NET Google Site Map Provider

Rate me:
Please Sign up or sign in to vote.
2.40/5 (4 votes)
10 Oct 2006CPOL9 min read 94.2K   2.7K   43  
Using the ASP.NET Provider model to generate a dynamic Google Sitemap.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

<style type="text/css">
	 v\:* { behavior: url(#default#VML); }
</style>

<script type="text/jscript" language="jscript">

var BUFFER = 1;

function zoomObject()
{
	this.PZImgRatio			= null;
	
	this.zoomWinHeight		= null;
	this.zoomWinWidth		= null;
	this.zoomWinTop			= null;
	this.zoomWinLeft		= null;
	
	this.scaleFactor		= null;
	
	this.updateContent		= zObj_updateContent;
	this.doOnBodyResize		= zObj_doOnBodyResize;
	this.clipZoomRect		= zObj_clipZoomRect;
}

var g_thumbHeight = window.clientHeight;
var g_thumbWidth = window.clientWidth;
zoomObj = new zoomObject();


function showObject( divObject, divID ) 
{
	if( divObject == null )
		divObject = getObj( divID );
	
	if( divObject != null ) 
	{
		divObject.style.visibility = "visible"
	}
	return divObject;
}

function hideObject( divObject, divID ) 
{
	if( divObject == null )
		divObject = getObj( divID );
	
	if( divObject != null ) 
	{
		divObject.style.visibility = "hidden";
	}
	return divObject;
}

function zObj_updateContent( win_width, win_height, VMLDiv_left, VMLDiv_top, VMLDiv_width, VMLDiv_height )
{
	this.mainWinWidth		= win_width;
	this.mainWinHeight		= win_height;

	this.mainImgRatio = VMLDiv_height / VMLDiv_width;
	this.doOnBodyResize();
}

function zObj_doOnBodyResize()
{
	return;
}

function zObj_clipZoomRect( objectToClip )
{
	if( objectToClip == null )
	{
		objectToClip = zoomRectObj;
	}
	
	var clipTop		= ( objectToClip.style.posTop < (g_thumbTop) )	? (g_thumbTop - objectToClip.style.posTop)	: 0;
	var clipLeft	= ( objectToClip.style.posLeft < (g_thumbLeft) )	? (g_thumbLeft - objectToClip.style.posLeft)	: 0;
	var clipBottom	= ( (objectToClip.style.posHeight - clipTop) > (g_thumbTop + g_thumbHeight + 2 * BUFFER) ) ? (g_thumbHeight + clipTop + BUFFER) : objectToClip.style.posHeight;
	var clipRight	= 0;
	if( (this.zoomWinWidth - clipLeft) > (g_thumbLeft + g_thumbWidth) )
	{
		if( clipLeft == 0 )
		{
			clipRight = g_thumbWidth - objectToClip.style.posLeft + 2 * BUFFER;
		}
		else
		{
			clipRight = (g_thumbWidth + clipLeft + BUFFER);
		}
	}
	else
	{
		clipRight = objectToClip.style.posWidth;
	}
	clipTo( objectToClip, clipTop, clipRight, clipBottom, clipLeft);
}

function findContent()
{
	zoomRectDiv.style.display = "none";
	newZoomWindowDiv.style.display = "none";

	if (parent.parent.frmDrawing && parent.parent.viewMgr)
	{
		var viewMgr = parent.parent.viewMgr;

		var getPNZ = parent.parent.viewMgr.getPNZ;
		if (getPNZ)
		{
			var tmp = parent.parent.frmDrawing;

			divThumb = document.all("divThumbnail");

			if (divThumb.innerHTML.length == 0)
			{
				divThumb.innerHTML = getPNZ();
			}
			else
			{
				var pnzInfo = getPNZ();
				var idIndex = pnzInfo.indexOf("ConvertedImage");
				if (idIndex >= 0)
				{
					var test = pnzInfo;
					pnzInfo = test.substring (0, idIndex);
					pnzInfo += "Temp";
					pnzInfo += test.substring (idIndex, test.length);

					divTempThumbnail.innerHTML = pnzInfo;

					var vmlGroup = divThumbnail.childNodes(0);
					var vmlTempGroup = divTempThumbnail.childNodes(0);
					CopyVMLAttrs(vmlGroup, vmlTempGroup);
					
					var vmlShape = vmlGroup.childNodes(1);
					var vmlTempShape = vmlTempGroup.childNodes(1);
					CopyVMLAttrs(vmlShape, vmlTempShape);

					CopyVMLAttrs(vmlGroup.childNodes(0), vmlTempGroup.childNodes(0));
					
					var vmlImageData = vmlShape.childNodes(0);
					var vmlTempImageData = vmlTempShape.childNodes(0);
					CopyVMLImageData(vmlImageData, vmlTempImageData);
				}
			}

			zoomRectObj = document.all("zoomRectDiv");
			showObject( zoomRectObj );

			PNZimg = document.all("ConvertedImage");
			if (PNZimg)
			{
				PNZimg.style.left = 0;
				PNZimg.style.top = 0;

				if (PNZimg.style.pixelWidth > PNZimg.style.pixelHeight)
				{
					var oldWidth = PNZimg.style.pixelWidth;
					PNZimg.style.width = document.body.clientWidth;
					PNZimg.style.height = (document.body.clientWidth / oldWidth) * PNZimg.style.pixelHeight;

					divThumb.style.top = (document.body.clientHeight - parseInt(PNZimg.style.height)) / 2;
					divThumb.style.left = 0;
				}
				else
				{
					var oldHeight = PNZimg.style.pixelHeight;
					PNZimg.style.height = document.body.clientHeight;
					PNZimg.style.width = (document.body.clientHeight / oldHeight) * PNZimg.style.pixelWidth;

					divThumb.style.left = (document.body.clientWidth - parseInt(PNZimg.style.width)) / 2;
					divThumb.style.top = 0;
				}

				PNZimg.style.visibility = "visible";

				var strOutput = divThumb.innerHTML;
				if (strOutput.length > 0)
				{
					var tmp2 = document.all['ConvertedImage'];
					zoomObj.updateContent( tmp.document.body.clientWidth, tmp.document.body.clientHeight, parseInt(tmp2.style.left), parseInt(tmp2.style.top), parseInt(tmp2.clientWidth), parseInt(tmp2.clientHeight) );

					viewMgr.viewChanged = PageViewChanged;
				}
			}
		}
	}
}

function CopyVMLAttrs(vmlObjDst, vmlObjSrc)
{
	if (vmlObjDst != null && vmlObjSrc != null)
	{
		vmlObjDst.style.cssText = vmlObjSrc.style.cssText;
	}
}

function CopyVMLImageData(vmlImageDataDst, vmlImageDataSrc)
{
	if (vmlImageDataDst != null && vmlImageDataSrc != null)
	{
		vmlImageDataDst.src = vmlImageDataSrc.src;
	}
}

function setZoomRectCursor()
{
	var x = getMouseXcoord() - zoomObj.zoomWinLeft;
	var y = getMouseYcoord() - zoomObj.zoomWinTop;

	var rbw = 5;

	var newCursor	= "";
	if( y > (zoomObj.zoomWinHeight - rbw) )
		newCursor = "s"
	else if( y < rbw )
		newCursor = "n";
		
	if( x < rbw )
		newCursor += "w";
	else if( x > (zoomObj.zoomWinWidth - rbw) )
		newCursor += "e";

	if( newCursor != "" )
		zoomRectObj.style.cursor = newCursor + "-resize";
	else
		zoomRectObj.style.cursor = "move";
}

function startZoomRectDrag()
{
	var currentCursor = zoomRectObj.style.cursor;

	if( currentCursor.indexOf( '-' ) != -1 )
	{
		g_resizeDirection = currentCursor.split( '-' )[0];
		startDrag( 'zoomRectDiv', doResizeZoomRectDrag, stopResizeZoomRectDrag );
	}
	else
	{
		startDrag( 'zoomRectDiv', doZoomRectDrag, stopZoomRectDrag );
	}
}

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

	var rectLeft = parseInt(dragObj.divObject.style.left);
	var rectTop = parseInt(dragObj.divObject.style.top);
	var rectWidth = parseInt(dragObj.divObject.style.width);
	var rectHeight = parseInt(dragObj.divObject.style.height);

	var xOffset = 0;
	var yOffset = 0;

	var xPercent = 0;
	var yPercent = 0;

	var pnzImgLeft = parseInt(divThumbnail.style.left);
	var pnzImgTop = parseInt(divThumbnail.style.top);
	var pnzImgWidth = parseInt(PNZimg.style.pixelWidth);
	var pnzImgHeight = parseInt(PNZimg.style.pixelHeight);
		
	xOffset = x + dragObj.xOffset - pnzImgLeft;
	xPercent = xOffset / pnzImgWidth;

	yOffset = y + dragObj.yOffset - pnzImgTop;
	yPercent = yOffset / pnzImgHeight;

	if (xOffset < 0)
	{
		xPercent = 0;
		xOffset = pnzImgLeft - BUFFER;
	}
	else if (xOffset + rectWidth > pnzImgWidth)
	{
		xPercent = 1;
		xOffset = pnzImgLeft + pnzImgWidth - rectWidth + BUFFER;
	}
	else
	{
		xOffset = x + dragObj.xOffset;
	}

	if (yOffset < 0)
	{
		yPercent = 0;
		yOffset = pnzImgTop - BUFFER;
	}
	else if (yOffset + rectHeight > pnzImgHeight)
	{
		yPercent = 1;
		yOffset = pnzImgTop + pnzImgHeight - rectHeight + BUFFER;
	}
	else
	{
		yOffset = y + dragObj.yOffset;
	}

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

	setZWinSize (null, null, xOffset, yOffset);
}

function stopZoomRectDrag(dragObj, x, y)
{
	var el = window.event.srcElement;
	g_newLeft = parseInt(el.style.left);
	g_newTop = parseInt(el.style.top);
}

function setZWinSize( newWidth, newHeight, newLeft, newTop )
{
	if( newWidth != null && newWidth >= 0 ) 
	{
		zoomObj.zoomWinWidth = newWidth;
		zoomRectObj.style.width = newWidth;
	}

	if( newHeight != null && newHeight >= 0 ) 
	{
		zoomObj.zoomWinHeight = newHeight;
		zoomRectObj.style.height = newHeight;
	}

	if( newLeft != null && newLeft >= 0 )
	{
		zoomObj.zoomWinLeft = newLeft;
		zoomRectObj.style.left = newLeft;
	}

	if( newTop != null && newTop >= 0 )
	{
		zoomObj.zoomWinTop = newTop;
		zoomRectObj.style.top= newTop;
	}
}

function doResizeZoomRectDrag(dragObj, x, y)
{
	var newWidth	= null;
	var newHeight	= null;
	var newLeft		= null;
	var newTop		= null;
		
	var tmp = parent.parent.frmDrawing;
	if (tmp)
	{
		zoomObj.mainWinWidth		= tmp.document.body.clientWidth;
		zoomObj.mainWinHeight		= tmp.document.body.clientHeight;
	}

	var widthHeightRatio = zoomObj.mainWinWidth / zoomObj.mainWinHeight;
	
	var minimumSize = 10;
	if( g_resizeDirection == 'e' )
	{
		newWidth	= Math.max( minimumSize, x - zoomObj.zoomWinLeft);
		newHeight	= newWidth / widthHeightRatio;
		newTop		= zoomObj.zoomWinTop - (newWidth - zoomObj.zoomWinWidth)/4;
		setZWinSize( newWidth, newHeight, newLeft, newTop );
		return;
	}

	if( g_resizeDirection == 'w' )
	{
		newWidth	= zoomObj.zoomWinWidth + zoomObj.zoomWinLeft - x;
		if( newWidth > minimumSize )
		{
			newHeight	= newWidth / widthHeightRatio;
			newTop		= zoomObj.zoomWinTop - (newWidth - zoomObj.zoomWinWidth)/4;
			newLeft		= x;
			setZWinSize( newWidth, newHeight, newLeft, newTop );
		}
		return;
	}

	if( g_resizeDirection == 'se' )
	{
		newWidth	= Math.max( minimumSize, x - zoomObj.zoomWinLeft);
		newHeight	= newWidth / widthHeightRatio;
		setZWinSize( newWidth, newHeight, newLeft, newTop );
		return;
	}

	if( g_resizeDirection == 's' )
	{
		newHeight	= Math.max( minimumSize, y - zoomObj.zoomWinTop);
		newWidth	= newHeight * widthHeightRatio;
		newLeft		= zoomObj.zoomWinLeft - (newHeight - zoomObj.zoomWinHeight)/2;
		setZWinSize( newWidth, newHeight, newLeft, newTop );
		return;
	}

	if( g_resizeDirection == 'sw' )
	{
		newHeight	= Math.max( minimumSize, y - zoomObj.zoomWinTop);
		newWidth	= newHeight * widthHeightRatio;
		newLeft		= zoomObj.zoomWinLeft - ((newHeight - zoomObj.zoomWinHeight) * zoomObj.zoomWinWidth / zoomObj.zoomWinHeight);
		setZWinSize( newWidth, newHeight, newLeft, newTop );
		return;
	}
	
	if( g_resizeDirection == 'n' )
	{
		newHeight	= zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight;
		if( newHeight > minimumSize )
		{
			newWidth	= newHeight * widthHeightRatio;
			newTop		= y;
			newLeft		= zoomObj.zoomWinLeft - (newHeight - zoomObj.zoomWinHeight)/2;
			setZWinSize( newWidth, newHeight, newLeft, newTop );
		}
		return;
	}
	
	if( g_resizeDirection == 'ne' )
	{
		newHeight	= zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight;
		if( newHeight > minimumSize )
		{
			newWidth	= newHeight * widthHeightRatio;
			newTop		= y;
			setZWinSize( newWidth, newHeight, newLeft, newTop );
		}
		return;
	}
	
	if( g_resizeDirection == 'nw' )
	{
		newHeight	= zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight;
		if( newHeight > minimumSize )
		{
			newWidth	= newHeight * widthHeightRatio;
			newTop		= y;
			newLeft		= zoomObj.zoomWinLeft - ((newHeight - zoomObj.zoomWinHeight) * zoomObj.zoomWinWidth / zoomObj.zoomWinHeight);
			setZWinSize( newWidth, newHeight, newLeft, newTop );
		}
		return;
	}
}

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

	var xWidthPercent = parseInt(zoomRectDiv.style.width) / PNZimg.style.pixelWidth;
	var yHeightPercent = parseInt(zoomRectDiv.style.height) / PNZimg.style.pixelHeight;

	var newZoomLevel = GetZoomLevel (xWidthPercent, yHeightPercent);

	if (parent.parent.viewMgr.Zoom)
	{
		var viewMgr = parent.parent.viewMgr;
		viewMgr.PostZoomProcessing = PostZoomProcessing;
		viewMgr.ChangingView = true;
		viewMgr.Zoom (newZoomLevel);
	}

	g_width = parseInt(zoomRectDiv.style.pixelWidth);
	g_height = parseInt(zoomRectDiv.style.pixelHeight);
	g_newLeft = parseInt(zoomRectDiv.style.left);
	g_newTop = parseInt(zoomRectDiv.style.top);
}

function GetZoomLevel (xWidthPercent, yHeightPercent)
{
	var newZoomLevel;
	if (xWidthPercent < yHeightPercent)
	{
		newZoomLevel = 100 / xWidthPercent;
	}
	else
	{
		newZoomLevel = 100 / yHeightPercent;
	}

	return newZoomLevel;
}

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="Visible Area. Use mouse or arrow keys to move." onkeydown="keydown()" onkeyup="keyup()" style="display:none;position: absolute; border: solid red thin; z-index: 3;" onmousedown="startZoomRectDrag();" onmouseover="setZoomRectCursor();" onmousemove="setZoomRectCursor();"></div>
<div id="newZoomWindowDiv" style="position: absolute; border: solid blue thin; z-index: 4; visibility: hidden;"></div>

</body>
</html>






By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager DNN Corp
Australia Australia
Bruce Chapman is the Product Manager for Cloud Services at DNN. He’s been an active member of the DNN Community since 2006 as a contributor, vendor and now employee of DNN Corp.

You can read his blog at http://dnnsoftware.com/blog or follow him on Twitter @brucerchapman

Comments and Discussions