1 | <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="http://www.w3.org/TR/REC-html40"> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
---|
4 | |
---|
5 | <style type="text/css"> |
---|
6 | v\:* { behavior: url(#default#VML); } |
---|
7 | </style> |
---|
8 | |
---|
9 | <script type="text/jscript" language="jscript"> |
---|
10 | |
---|
11 | var BUFFER = 1; |
---|
12 | |
---|
13 | function zoomObject() |
---|
14 | { |
---|
15 | this.PZImgRatio = null; |
---|
16 | |
---|
17 | this.zoomWinHeight = null; |
---|
18 | this.zoomWinWidth = null; |
---|
19 | this.zoomWinTop = null; |
---|
20 | this.zoomWinLeft = null; |
---|
21 | |
---|
22 | this.scaleFactor = null; |
---|
23 | |
---|
24 | this.updateContent = zObj_updateContent; |
---|
25 | this.doOnBodyResize = zObj_doOnBodyResize; |
---|
26 | this.clipZoomRect = zObj_clipZoomRect; |
---|
27 | } |
---|
28 | |
---|
29 | var g_thumbHeight = window.clientHeight; |
---|
30 | var g_thumbWidth = window.clientWidth; |
---|
31 | zoomObj = new zoomObject(); |
---|
32 | |
---|
33 | |
---|
34 | function showObject( divObject, divID ) |
---|
35 | { |
---|
36 | if( divObject == null ) |
---|
37 | divObject = getObj( divID ); |
---|
38 | |
---|
39 | if( divObject != null ) |
---|
40 | { |
---|
41 | divObject.style.visibility = "visible" |
---|
42 | } |
---|
43 | return divObject; |
---|
44 | } |
---|
45 | |
---|
46 | function hideObject( divObject, divID ) |
---|
47 | { |
---|
48 | if( divObject == null ) |
---|
49 | divObject = getObj( divID ); |
---|
50 | |
---|
51 | if( divObject != null ) |
---|
52 | { |
---|
53 | divObject.style.visibility = "hidden"; |
---|
54 | } |
---|
55 | return divObject; |
---|
56 | } |
---|
57 | |
---|
58 | function zObj_updateContent( win_width, win_height, VMLDiv_left, VMLDiv_top, VMLDiv_width, VMLDiv_height ) |
---|
59 | { |
---|
60 | this.mainWinWidth = win_width; |
---|
61 | this.mainWinHeight = win_height; |
---|
62 | |
---|
63 | this.mainImgRatio = VMLDiv_height / VMLDiv_width; |
---|
64 | this.doOnBodyResize(); |
---|
65 | } |
---|
66 | |
---|
67 | function zObj_doOnBodyResize() |
---|
68 | { |
---|
69 | return; |
---|
70 | } |
---|
71 | |
---|
72 | function zObj_clipZoomRect( objectToClip ) |
---|
73 | { |
---|
74 | if( objectToClip == null ) |
---|
75 | { |
---|
76 | objectToClip = zoomRectObj; |
---|
77 | } |
---|
78 | |
---|
79 | var clipTop = ( objectToClip.style.posTop < (g_thumbTop) ) ? (g_thumbTop - objectToClip.style.posTop) : 0; |
---|
80 | var clipLeft = ( objectToClip.style.posLeft < (g_thumbLeft) ) ? (g_thumbLeft - objectToClip.style.posLeft) : 0; |
---|
81 | var clipBottom = ( (objectToClip.style.posHeight - clipTop) > (g_thumbTop + g_thumbHeight + 2 * BUFFER) ) ? (g_thumbHeight + clipTop + BUFFER) : objectToClip.style.posHeight; |
---|
82 | var clipRight = 0; |
---|
83 | if( (this.zoomWinWidth - clipLeft) > (g_thumbLeft + g_thumbWidth) ) |
---|
84 | { |
---|
85 | if( clipLeft == 0 ) |
---|
86 | { |
---|
87 | clipRight = g_thumbWidth - objectToClip.style.posLeft + 2 * BUFFER; |
---|
88 | } |
---|
89 | else |
---|
90 | { |
---|
91 | clipRight = (g_thumbWidth + clipLeft + BUFFER); |
---|
92 | } |
---|
93 | } |
---|
94 | else |
---|
95 | { |
---|
96 | clipRight = objectToClip.style.posWidth; |
---|
97 | } |
---|
98 | clipTo( objectToClip, clipTop, clipRight, clipBottom, clipLeft); |
---|
99 | } |
---|
100 | |
---|
101 | function findContent() |
---|
102 | { |
---|
103 | zoomRectDiv.style.display = "none"; |
---|
104 | newZoomWindowDiv.style.display = "none"; |
---|
105 | |
---|
106 | if (parent.parent.frmDrawing && parent.parent.viewMgr) |
---|
107 | { |
---|
108 | var viewMgr = parent.parent.viewMgr; |
---|
109 | |
---|
110 | var getPNZ = parent.parent.viewMgr.getPNZ; |
---|
111 | if (getPNZ) |
---|
112 | { |
---|
113 | var tmp = parent.parent.frmDrawing; |
---|
114 | |
---|
115 | divThumb = document.all("divThumbnail"); |
---|
116 | |
---|
117 | if (divThumb.innerHTML.length == 0) |
---|
118 | { |
---|
119 | divThumb.innerHTML = getPNZ(); |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | var pnzInfo = getPNZ(); |
---|
124 | var idIndex = pnzInfo.indexOf("ConvertedImage"); |
---|
125 | if (idIndex >= 0) |
---|
126 | { |
---|
127 | var test = pnzInfo; |
---|
128 | pnzInfo = test.substring (0, idIndex); |
---|
129 | pnzInfo += "Temp"; |
---|
130 | pnzInfo += test.substring (idIndex, test.length); |
---|
131 | |
---|
132 | divTempThumbnail.innerHTML = pnzInfo; |
---|
133 | |
---|
134 | var vmlGroup = divThumbnail.childNodes(0); |
---|
135 | var vmlTempGroup = divTempThumbnail.childNodes(0); |
---|
136 | CopyVMLAttrs(vmlGroup, vmlTempGroup); |
---|
137 | |
---|
138 | var vmlShape = vmlGroup.childNodes(1); |
---|
139 | var vmlTempShape = vmlTempGroup.childNodes(1); |
---|
140 | CopyVMLAttrs(vmlShape, vmlTempShape); |
---|
141 | |
---|
142 | CopyVMLAttrs(vmlGroup.childNodes(0), vmlTempGroup.childNodes(0)); |
---|
143 | |
---|
144 | var vmlImageData = vmlShape.childNodes(0); |
---|
145 | var vmlTempImageData = vmlTempShape.childNodes(0); |
---|
146 | CopyVMLImageData(vmlImageData, vmlTempImageData); |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | zoomRectObj = document.all("zoomRectDiv"); |
---|
151 | showObject( zoomRectObj ); |
---|
152 | |
---|
153 | PNZimg = document.all("ConvertedImage"); |
---|
154 | if (PNZimg) |
---|
155 | { |
---|
156 | PNZimg.style.left = 0; |
---|
157 | PNZimg.style.top = 0; |
---|
158 | |
---|
159 | if (PNZimg.style.pixelWidth > PNZimg.style.pixelHeight) |
---|
160 | { |
---|
161 | var oldWidth = PNZimg.style.pixelWidth; |
---|
162 | PNZimg.style.width = document.body.clientWidth; |
---|
163 | PNZimg.style.height = (document.body.clientWidth / oldWidth) * PNZimg.style.pixelHeight; |
---|
164 | |
---|
165 | divThumb.style.top = (document.body.clientHeight - parseInt(PNZimg.style.height)) / 2; |
---|
166 | divThumb.style.left = 0; |
---|
167 | } |
---|
168 | else |
---|
169 | { |
---|
170 | var oldHeight = PNZimg.style.pixelHeight; |
---|
171 | PNZimg.style.height = document.body.clientHeight; |
---|
172 | PNZimg.style.width = (document.body.clientHeight / oldHeight) * PNZimg.style.pixelWidth; |
---|
173 | |
---|
174 | divThumb.style.left = (document.body.clientWidth - parseInt(PNZimg.style.width)) / 2; |
---|
175 | divThumb.style.top = 0; |
---|
176 | } |
---|
177 | |
---|
178 | PNZimg.style.visibility = "visible"; |
---|
179 | |
---|
180 | var strOutput = divThumb.innerHTML; |
---|
181 | if (strOutput.length > 0) |
---|
182 | { |
---|
183 | var tmp2 = document.all['ConvertedImage']; |
---|
184 | zoomObj.updateContent( tmp.document.body.clientWidth, tmp.document.body.clientHeight, parseInt(tmp2.style.left), parseInt(tmp2.style.top), parseInt(tmp2.clientWidth), parseInt(tmp2.clientHeight) ); |
---|
185 | |
---|
186 | viewMgr.viewChanged = PageViewChanged; |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | } |
---|
192 | |
---|
193 | function CopyVMLAttrs(vmlObjDst, vmlObjSrc) |
---|
194 | { |
---|
195 | if (vmlObjDst != null && vmlObjSrc != null) |
---|
196 | { |
---|
197 | vmlObjDst.style.cssText = vmlObjSrc.style.cssText; |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | function CopyVMLImageData(vmlImageDataDst, vmlImageDataSrc) |
---|
202 | { |
---|
203 | if (vmlImageDataDst != null && vmlImageDataSrc != null) |
---|
204 | { |
---|
205 | vmlImageDataDst.src = vmlImageDataSrc.src; |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | function setZoomRectCursor() |
---|
210 | { |
---|
211 | var x = getMouseXcoord() - zoomObj.zoomWinLeft; |
---|
212 | var y = getMouseYcoord() - zoomObj.zoomWinTop; |
---|
213 | |
---|
214 | var rbw = 5; |
---|
215 | |
---|
216 | var newCursor = ""; |
---|
217 | if( y > (zoomObj.zoomWinHeight - rbw) ) |
---|
218 | newCursor = "s" |
---|
219 | else if( y < rbw ) |
---|
220 | newCursor = "n"; |
---|
221 | |
---|
222 | if( x < rbw ) |
---|
223 | newCursor += "w"; |
---|
224 | else if( x > (zoomObj.zoomWinWidth - rbw) ) |
---|
225 | newCursor += "e"; |
---|
226 | |
---|
227 | if( newCursor != "" ) |
---|
228 | zoomRectObj.style.cursor = newCursor + "-resize"; |
---|
229 | else |
---|
230 | zoomRectObj.style.cursor = "move"; |
---|
231 | } |
---|
232 | |
---|
233 | function startZoomRectDrag() |
---|
234 | { |
---|
235 | var currentCursor = zoomRectObj.style.cursor; |
---|
236 | |
---|
237 | if( currentCursor.indexOf( '-' ) != -1 ) |
---|
238 | { |
---|
239 | g_resizeDirection = currentCursor.split( '-' )[0]; |
---|
240 | startDrag( 'zoomRectDiv', doResizeZoomRectDrag, stopResizeZoomRectDrag ); |
---|
241 | } |
---|
242 | else |
---|
243 | { |
---|
244 | startDrag( 'zoomRectDiv', doZoomRectDrag, stopZoomRectDrag ); |
---|
245 | } |
---|
246 | } |
---|
247 | |
---|
248 | function doZoomRectDrag(dragObj, x, y) |
---|
249 | { |
---|
250 | var PNZimg = document.all("ConvertedImage"); |
---|
251 | |
---|
252 | var rectLeft = parseInt(dragObj.divObject.style.left); |
---|
253 | var rectTop = parseInt(dragObj.divObject.style.top); |
---|
254 | var rectWidth = parseInt(dragObj.divObject.style.width); |
---|
255 | var rectHeight = parseInt(dragObj.divObject.style.height); |
---|
256 | |
---|
257 | var xOffset = 0; |
---|
258 | var yOffset = 0; |
---|
259 | |
---|
260 | var xPercent = 0; |
---|
261 | var yPercent = 0; |
---|
262 | |
---|
263 | var pnzImgLeft = parseInt(divThumbnail.style.left); |
---|
264 | var pnzImgTop = parseInt(divThumbnail.style.top); |
---|
265 | var pnzImgWidth = parseInt(PNZimg.style.pixelWidth); |
---|
266 | var pnzImgHeight = parseInt(PNZimg.style.pixelHeight); |
---|
267 | |
---|
268 | xOffset = x + dragObj.xOffset - pnzImgLeft; |
---|
269 | xPercent = xOffset / pnzImgWidth; |
---|
270 | |
---|
271 | yOffset = y + dragObj.yOffset - pnzImgTop; |
---|
272 | yPercent = yOffset / pnzImgHeight; |
---|
273 | |
---|
274 | if (xOffset < 0) |
---|
275 | { |
---|
276 | xPercent = 0; |
---|
277 | xOffset = pnzImgLeft - BUFFER; |
---|
278 | } |
---|
279 | else if (xOffset + rectWidth > pnzImgWidth) |
---|
280 | { |
---|
281 | xPercent = 1; |
---|
282 | xOffset = pnzImgLeft + pnzImgWidth - rectWidth + BUFFER; |
---|
283 | } |
---|
284 | else |
---|
285 | { |
---|
286 | xOffset = x + dragObj.xOffset; |
---|
287 | } |
---|
288 | |
---|
289 | if (yOffset < 0) |
---|
290 | { |
---|
291 | yPercent = 0; |
---|
292 | yOffset = pnzImgTop - BUFFER; |
---|
293 | } |
---|
294 | else if (yOffset + rectHeight > pnzImgHeight) |
---|
295 | { |
---|
296 | yPercent = 1; |
---|
297 | yOffset = pnzImgTop + pnzImgHeight - rectHeight + BUFFER; |
---|
298 | } |
---|
299 | else |
---|
300 | { |
---|
301 | yOffset = y + dragObj.yOffset; |
---|
302 | } |
---|
303 | |
---|
304 | if (parent.parent.viewMgr.setView) |
---|
305 | { |
---|
306 | var viewMgr = parent.parent.viewMgr; |
---|
307 | viewMgr.PostSetViewProcessing = PostSetViewProcessing; |
---|
308 | viewMgr.ChangingView = true; |
---|
309 | viewMgr.setView (xPercent, yPercent); |
---|
310 | } |
---|
311 | |
---|
312 | setZWinSize (null, null, xOffset, yOffset); |
---|
313 | } |
---|
314 | |
---|
315 | function stopZoomRectDrag(dragObj, x, y) |
---|
316 | { |
---|
317 | var el = window.event.srcElement; |
---|
318 | g_newLeft = parseInt(el.style.left); |
---|
319 | g_newTop = parseInt(el.style.top); |
---|
320 | } |
---|
321 | |
---|
322 | function setZWinSize( newWidth, newHeight, newLeft, newTop ) |
---|
323 | { |
---|
324 | if( newWidth != null && newWidth >= 0 ) |
---|
325 | { |
---|
326 | zoomObj.zoomWinWidth = newWidth; |
---|
327 | zoomRectObj.style.width = newWidth; |
---|
328 | } |
---|
329 | |
---|
330 | if( newHeight != null && newHeight >= 0 ) |
---|
331 | { |
---|
332 | zoomObj.zoomWinHeight = newHeight; |
---|
333 | zoomRectObj.style.height = newHeight; |
---|
334 | } |
---|
335 | |
---|
336 | if( newLeft != null && newLeft >= 0 ) |
---|
337 | { |
---|
338 | zoomObj.zoomWinLeft = newLeft; |
---|
339 | zoomRectObj.style.left = newLeft; |
---|
340 | } |
---|
341 | |
---|
342 | if( newTop != null && newTop >= 0 ) |
---|
343 | { |
---|
344 | zoomObj.zoomWinTop = newTop; |
---|
345 | zoomRectObj.style.top= newTop; |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | function doResizeZoomRectDrag(dragObj, x, y) |
---|
350 | { |
---|
351 | var newWidth = null; |
---|
352 | var newHeight = null; |
---|
353 | var newLeft = null; |
---|
354 | var newTop = null; |
---|
355 | |
---|
356 | var tmp = parent.parent.frmDrawing; |
---|
357 | if (tmp) |
---|
358 | { |
---|
359 | zoomObj.mainWinWidth = tmp.document.body.clientWidth; |
---|
360 | zoomObj.mainWinHeight = tmp.document.body.clientHeight; |
---|
361 | } |
---|
362 | |
---|
363 | var widthHeightRatio = zoomObj.mainWinWidth / zoomObj.mainWinHeight; |
---|
364 | |
---|
365 | var minimumSize = 10; |
---|
366 | if( g_resizeDirection == 'e' ) |
---|
367 | { |
---|
368 | newWidth = Math.max( minimumSize, x - zoomObj.zoomWinLeft); |
---|
369 | newHeight = newWidth / widthHeightRatio; |
---|
370 | newTop = zoomObj.zoomWinTop - (newWidth - zoomObj.zoomWinWidth)/4; |
---|
371 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
372 | return; |
---|
373 | } |
---|
374 | |
---|
375 | if( g_resizeDirection == 'w' ) |
---|
376 | { |
---|
377 | newWidth = zoomObj.zoomWinWidth + zoomObj.zoomWinLeft - x; |
---|
378 | if( newWidth > minimumSize ) |
---|
379 | { |
---|
380 | newHeight = newWidth / widthHeightRatio; |
---|
381 | newTop = zoomObj.zoomWinTop - (newWidth - zoomObj.zoomWinWidth)/4; |
---|
382 | newLeft = x; |
---|
383 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
384 | } |
---|
385 | return; |
---|
386 | } |
---|
387 | |
---|
388 | if( g_resizeDirection == 'se' ) |
---|
389 | { |
---|
390 | newWidth = Math.max( minimumSize, x - zoomObj.zoomWinLeft); |
---|
391 | newHeight = newWidth / widthHeightRatio; |
---|
392 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
393 | return; |
---|
394 | } |
---|
395 | |
---|
396 | if( g_resizeDirection == 's' ) |
---|
397 | { |
---|
398 | newHeight = Math.max( minimumSize, y - zoomObj.zoomWinTop); |
---|
399 | newWidth = newHeight * widthHeightRatio; |
---|
400 | newLeft = zoomObj.zoomWinLeft - (newHeight - zoomObj.zoomWinHeight)/2; |
---|
401 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
402 | return; |
---|
403 | } |
---|
404 | |
---|
405 | if( g_resizeDirection == 'sw' ) |
---|
406 | { |
---|
407 | newHeight = Math.max( minimumSize, y - zoomObj.zoomWinTop); |
---|
408 | newWidth = newHeight * widthHeightRatio; |
---|
409 | newLeft = zoomObj.zoomWinLeft - ((newHeight - zoomObj.zoomWinHeight) * zoomObj.zoomWinWidth / zoomObj.zoomWinHeight); |
---|
410 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
411 | return; |
---|
412 | } |
---|
413 | |
---|
414 | if( g_resizeDirection == 'n' ) |
---|
415 | { |
---|
416 | newHeight = zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight; |
---|
417 | if( newHeight > minimumSize ) |
---|
418 | { |
---|
419 | newWidth = newHeight * widthHeightRatio; |
---|
420 | newTop = y; |
---|
421 | newLeft = zoomObj.zoomWinLeft - (newHeight - zoomObj.zoomWinHeight)/2; |
---|
422 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
423 | } |
---|
424 | return; |
---|
425 | } |
---|
426 | |
---|
427 | if( g_resizeDirection == 'ne' ) |
---|
428 | { |
---|
429 | newHeight = zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight; |
---|
430 | if( newHeight > minimumSize ) |
---|
431 | { |
---|
432 | newWidth = newHeight * widthHeightRatio; |
---|
433 | newTop = y; |
---|
434 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
435 | } |
---|
436 | return; |
---|
437 | } |
---|
438 | |
---|
439 | if( g_resizeDirection == 'nw' ) |
---|
440 | { |
---|
441 | newHeight = zoomObj.zoomWinTop - y + zoomObj.zoomWinHeight; |
---|
442 | if( newHeight > minimumSize ) |
---|
443 | { |
---|
444 | newWidth = newHeight * widthHeightRatio; |
---|
445 | newTop = y; |
---|
446 | newLeft = zoomObj.zoomWinLeft - ((newHeight - zoomObj.zoomWinHeight) * zoomObj.zoomWinWidth / zoomObj.zoomWinHeight); |
---|
447 | setZWinSize( newWidth, newHeight, newLeft, newTop ); |
---|
448 | } |
---|
449 | return; |
---|
450 | } |
---|
451 | } |
---|
452 | |
---|
453 | function stopResizeZoomRectDrag(dragObj, x, y) |
---|
454 | { |
---|
455 | PNZimg = document.all("ConvertedImage"); |
---|
456 | |
---|
457 | var xWidthPercent = parseInt(zoomRectDiv.style.width) / PNZimg.style.pixelWidth; |
---|
458 | var yHeightPercent = parseInt(zoomRectDiv.style.height) / PNZimg.style.pixelHeight; |
---|
459 | |
---|
460 | var newZoomLevel = GetZoomLevel (xWidthPercent, yHeightPercent); |
---|
461 | |
---|
462 | if (parent.parent.viewMgr.Zoom) |
---|
463 | { |
---|
464 | var viewMgr = parent.parent.viewMgr; |
---|
465 | viewMgr.PostZoomProcessing = PostZoomProcessing; |
---|
466 | viewMgr.ChangingView = true; |
---|
467 | viewMgr.Zoom (newZoomLevel); |
---|
468 | } |
---|
469 | |
---|
470 | g_width = parseInt(zoomRectDiv.style.pixelWidth); |
---|
471 | g_height = parseInt(zoomRectDiv.style.pixelHeight); |
---|
472 | g_newLeft = parseInt(zoomRectDiv.style.left); |
---|
473 | g_newTop = parseInt(zoomRectDiv.style.top); |
---|
474 | } |
---|
475 | |
---|
476 | function GetZoomLevel (xWidthPercent, yHeightPercent) |
---|
477 | { |
---|
478 | var newZoomLevel; |
---|
479 | if (xWidthPercent < yHeightPercent) |
---|
480 | { |
---|
481 | newZoomLevel = 100 / xWidthPercent; |
---|
482 | } |
---|
483 | else |
---|
484 | { |
---|
485 | newZoomLevel = 100 / yHeightPercent; |
---|
486 | } |
---|
487 | |
---|
488 | return newZoomLevel; |
---|
489 | } |
---|
490 | |
---|
491 | function PostZoomProcessing (newZoomLevel) |
---|
492 | { |
---|
493 | var xOffset = parseInt(zoomRectDiv.style.left) - parseInt(divThumbnail.style.left); |
---|
494 | var yOffset = parseInt(zoomRectDiv.style.top) - parseInt(divThumbnail.style.top); |
---|
495 | |
---|
496 | var xPercent = xOffset / PNZimg.style.pixelWidth; |
---|
497 | var yPercent = yOffset / PNZimg.style.pixelHeight; |
---|
498 | |
---|
499 | var viewMgr = parent.parent.viewMgr; |
---|
500 | viewMgr.ChangingView = true; |
---|
501 | |
---|
502 | if (viewMgr.setView) |
---|
503 | { |
---|
504 | viewMgr.PostSetViewProcessing = PostSetViewProcessing; |
---|
505 | viewMgr.setView (xPercent, yPercent); |
---|
506 | } |
---|
507 | |
---|
508 | SetCorrectTick (newZoomLevel); |
---|
509 | |
---|
510 | viewMgr.PostZoomProcessing = null; |
---|
511 | } |
---|
512 | |
---|
513 | function SetCorrectTick (newZoomLevel) |
---|
514 | { |
---|
515 | var zoomLevels = parent.zoomLevels; |
---|
516 | if (newZoomLevel <= zoomLevels[0]) |
---|
517 | { |
---|
518 | parent.changeTick(zoomLevels[0]); |
---|
519 | } |
---|
520 | else if (newZoomLevel >= zoomLevels[zoomLevels.length - 1]) |
---|
521 | { |
---|
522 | parent.changeTick(zoomLevels[zoomLevels.length - 1]); |
---|
523 | } |
---|
524 | else |
---|
525 | { |
---|
526 | for (var count = 0; count < zoomLevels.length - 1; count++) |
---|
527 | { |
---|
528 | var deltaDown = newZoomLevel - zoomLevels[count]; |
---|
529 | var deltaUp = newZoomLevel - zoomLevels[count + 1]; |
---|
530 | if (deltaDown >= 0 && deltaUp <= 0) |
---|
531 | { |
---|
532 | if (Math.abs(deltaDown) < Math.abs(deltaUp)) |
---|
533 | { |
---|
534 | parent.changeTick(zoomLevels[count]); |
---|
535 | break; |
---|
536 | } |
---|
537 | else |
---|
538 | { |
---|
539 | parent.changeTick(zoomLevels[count + 1]); |
---|
540 | break; |
---|
541 | } |
---|
542 | } |
---|
543 | } |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | function PostSetViewProcessing () |
---|
548 | { |
---|
549 | parent.parent.viewMgr.ChangingView = false; |
---|
550 | parent.parent.viewMgr.PostSetViewProcessing = null; |
---|
551 | } |
---|
552 | |
---|
553 | function startNewZoomRectDrag() |
---|
554 | { |
---|
555 | var x = getMouseXcoord(); |
---|
556 | var y = getMouseYcoord(); |
---|
557 | zoomObj.newZWinStartX = x; |
---|
558 | zoomObj.newZWinStartY = y; |
---|
559 | |
---|
560 | g_newZWinObjRef = document.all("newZoomWindowDiv"); |
---|
561 | g_newZWinObjRef.style.display = ""; |
---|
562 | |
---|
563 | startDrag( 'zoomRectDiv', doNewZoomRectDrag, stopNewZoomRectDrag ); |
---|
564 | } |
---|
565 | |
---|
566 | function doNewZoomRectDrag(dragObj, x, y) |
---|
567 | { |
---|
568 | var PNZimg = document.all("ConvertedImage"); |
---|
569 | |
---|
570 | var width = Math.abs( zoomObj.newZWinStartX - x ); |
---|
571 | var height = Math.abs( zoomObj.newZWinStartY - y ); |
---|
572 | |
---|
573 | var aspectRatio = parent.parent.viewMgr.docDrawing.body.clientWidth / parent.parent.viewMgr.docDrawing.body.clientHeight; |
---|
574 | |
---|
575 | if( width < (aspectRatio * height)) |
---|
576 | { |
---|
577 | width = (aspectRatio) * height; |
---|
578 | } |
---|
579 | else |
---|
580 | { |
---|
581 | height = width / (aspectRatio); |
---|
582 | } |
---|
583 | |
---|
584 | width = Math.min (width, parseInt(PNZimg.style.pixelWidth)); |
---|
585 | height = Math.min (height, parseInt(PNZimg.style.pixelHeight)); |
---|
586 | |
---|
587 | var left = (x > zoomObj.newZWinStartX) ? zoomObj.newZWinStartX : zoomObj.newZWinStartX - width; |
---|
588 | var top = (y > zoomObj.newZWinStartY) ? zoomObj.newZWinStartY : zoomObj.newZWinStartY - height; |
---|
589 | |
---|
590 | newZoomWindowDiv.style.top = top; |
---|
591 | newZoomWindowDiv.style.left = left; |
---|
592 | newZoomWindowDiv.style.height = height; |
---|
593 | newZoomWindowDiv.style.width = width; |
---|
594 | newZoomWindowDiv.style.visibility = "visible"; |
---|
595 | |
---|
596 | zoomObj.zoomWinLeft = left; |
---|
597 | zoomObj.zoomWinWidth = width; |
---|
598 | zoomObj.zoomWinTop = top; |
---|
599 | zoomObj.zoomWinHeight = height; |
---|
600 | } |
---|
601 | |
---|
602 | function stopNewZoomRectDrag(dragObj, x, y) |
---|
603 | { |
---|
604 | newZoomWindowDiv.style.visibility = "hidden"; |
---|
605 | |
---|
606 | if (parseInt (newZoomWindowDiv.style.width) > 10 && |
---|
607 | parseInt (newZoomWindowDiv.style.height) > 10) |
---|
608 | { |
---|
609 | zoomRectDiv.style.top = newZoomWindowDiv.style.top; |
---|
610 | zoomRectDiv.style.left = newZoomWindowDiv.style.left; |
---|
611 | zoomRectDiv.style.height = newZoomWindowDiv.style.height; |
---|
612 | zoomRectDiv.style.width = newZoomWindowDiv.style.width; |
---|
613 | |
---|
614 | stopResizeZoomRectDrag(dragObj,x,y); |
---|
615 | zoomRectDiv.style.display = "inline"; |
---|
616 | zoomRectDiv.style.visibility = "visible"; |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | zoomObj.zoomWinLeft = parseInt(zoomRectDiv.style.left); |
---|
621 | zoomObj.zoomWinWidth = parseInt(zoomRectDiv.style.width); |
---|
622 | zoomObj.zoomWinTop = parseInt(zoomRectDiv.style.top); |
---|
623 | zoomObj.zoomWinHeight = parseInt(zoomRectDiv.style.height); |
---|
624 | } |
---|
625 | |
---|
626 | newZoomWindowDiv.style.height = "0px"; |
---|
627 | newZoomWindowDiv.style.width = "0px"; |
---|
628 | |
---|
629 | newZoomWindowDiv.style.display = "none"; |
---|
630 | } |
---|
631 | |
---|
632 | var g_lastX = 0; |
---|
633 | var g_lastY = 0; |
---|
634 | |
---|
635 | document.onmousedown = mouseDown; |
---|
636 | document.onmousemove = mouseMove; |
---|
637 | document.onmouseup = mouseUp; |
---|
638 | document.onmouseout = mouseOut; |
---|
639 | |
---|
640 | function mouseDown() |
---|
641 | { |
---|
642 | return true; |
---|
643 | } |
---|
644 | |
---|
645 | function mouseMove() |
---|
646 | { |
---|
647 | var x = event.clientX + document.body.scrollLeft; |
---|
648 | var y = event.clientY + document.body.scrollTop; |
---|
649 | |
---|
650 | g_lastX = x; |
---|
651 | g_lastY = y; |
---|
652 | |
---|
653 | doDrag( x, y ); |
---|
654 | return true; |
---|
655 | } |
---|
656 | |
---|
657 | function mouseUp() |
---|
658 | { |
---|
659 | var x = event.x + document.body.scrollLeft; |
---|
660 | var y = event.y + document.body.scrollTop; |
---|
661 | |
---|
662 | stopDrag(null,x,y); |
---|
663 | return true; |
---|
664 | } |
---|
665 | |
---|
666 | function mouseOut() |
---|
667 | { |
---|
668 | var x = event.x + document.body.scrollLeft; |
---|
669 | var y = event.y + document.body.scrollTop; |
---|
670 | |
---|
671 | if( x < 0 ) x = -1; |
---|
672 | if( x >= document.body.clientWidth ) x = -1; |
---|
673 | |
---|
674 | if( y < 0 ) y = -1; |
---|
675 | if( y >= document.body.clientHeight ) y = -1; |
---|
676 | |
---|
677 | if( x == -1 || y == -1 ) |
---|
678 | { |
---|
679 | x = -1; |
---|
680 | y = -1; |
---|
681 | } |
---|
682 | |
---|
683 | |
---|
684 | if( x == -1 ) |
---|
685 | stopDrag( null, x, y ); |
---|
686 | return true; |
---|
687 | } |
---|
688 | |
---|
689 | function getMouseXcoord() |
---|
690 | { |
---|
691 | return event.x + document.body.scrollLeft; |
---|
692 | } |
---|
693 | |
---|
694 | function getMouseYcoord() |
---|
695 | { |
---|
696 | return event.y + document.body.scrollTop; |
---|
697 | } |
---|
698 | |
---|
699 | var g_width = -1; |
---|
700 | var g_height = -1; |
---|
701 | var g_newLeft = -1; |
---|
702 | var g_newTop = -1; |
---|
703 | |
---|
704 | var g_pnzImgWidth = -1; |
---|
705 | var g_pnzImgHeight = -1; |
---|
706 | var g_pnzImgLeft = -1; |
---|
707 | var g_pnzImgTop = -1; |
---|
708 | |
---|
709 | function keydown() |
---|
710 | { |
---|
711 | var key = window.event.keyCode; |
---|
712 | var el = window.event.srcElement; |
---|
713 | |
---|
714 | if(key == 37 || key == 38 || key == 39 || key == 40) |
---|
715 | { |
---|
716 | if(g_width == -1) |
---|
717 | g_width = parseInt(el.style.pixelWidth); |
---|
718 | |
---|
719 | if(g_height == -1) |
---|
720 | g_height = parseInt(el.style.pixelHeight); |
---|
721 | |
---|
722 | if(g_newLeft == -1) |
---|
723 | g_newLeft = parseInt(el.style.left); |
---|
724 | |
---|
725 | if(g_newTop == -1) |
---|
726 | g_newTop = parseInt(el.style.top); |
---|
727 | |
---|
728 | if(g_pnzImgWidth == -1) |
---|
729 | g_pnzImgWidth = parseInt(PNZimg.style.pixelWidth); |
---|
730 | |
---|
731 | if(g_pnzImgHeight == -1) |
---|
732 | g_pnzImgHeight = parseInt(PNZimg.style.pixelHeight); |
---|
733 | |
---|
734 | if(g_pnzImgLeft == -1) |
---|
735 | g_pnzImgLeft = parseInt(divThumbnail.style.left); |
---|
736 | |
---|
737 | if(g_pnzImgTop == -1) |
---|
738 | g_pnzImgTop = parseInt(divThumbnail.style.top); |
---|
739 | |
---|
740 | |
---|
741 | if(key == 37) |
---|
742 | { |
---|
743 | g_newLeft -= 1; |
---|
744 | if(g_newLeft < g_pnzImgLeft) |
---|
745 | { |
---|
746 | g_newLeft = g_pnzImgLeft; |
---|
747 | } |
---|
748 | } |
---|
749 | else if(key == 38) |
---|
750 | { |
---|
751 | g_newTop -= 1; |
---|
752 | if(g_newTop < g_pnzImgTop) |
---|
753 | { |
---|
754 | g_newTop = g_pnzImgTop; |
---|
755 | } |
---|
756 | } |
---|
757 | else if(key == 39) |
---|
758 | { |
---|
759 | g_newLeft += 1; |
---|
760 | if(g_newLeft + g_width > g_pnzImgLeft + g_pnzImgWidth) |
---|
761 | { |
---|
762 | g_newLeft = g_pnzImgLeft + g_pnzImgWidth - g_width; |
---|
763 | } |
---|
764 | } |
---|
765 | |
---|
766 | else if(key == 40) |
---|
767 | { |
---|
768 | g_newTop += 1; |
---|
769 | if(g_newTop + g_height > g_pnzImgTop + g_pnzImgHeight) |
---|
770 | { |
---|
771 | g_newTop = g_pnzImgTop + g_pnzImgHeight - g_height; |
---|
772 | } |
---|
773 | } |
---|
774 | |
---|
775 | setZoomRectCursor(); |
---|
776 | |
---|
777 | var xOffset = g_newLeft - g_pnzImgLeft; |
---|
778 | var yOffset = g_newTop - g_pnzImgTop; |
---|
779 | |
---|
780 | var xPercent = xPercent = xOffset / g_pnzImgWidth; |
---|
781 | var yPercent = yPercent = yOffset / g_pnzImgHeight; |
---|
782 | |
---|
783 | if (xOffset < 0) |
---|
784 | { |
---|
785 | xPercent = 0; |
---|
786 | xOffset = g_pnzImgLeft; |
---|
787 | } |
---|
788 | else if (xOffset + g_width > g_pnzImgWidth) |
---|
789 | { |
---|
790 | xPercent = 1; |
---|
791 | xOffset = g_pnzImgLeft + g_pnzImgWidth - g_width; |
---|
792 | } |
---|
793 | |
---|
794 | if (yOffset < 0) |
---|
795 | { |
---|
796 | yPercent = 0; |
---|
797 | yOffset = g_pnzImgTop; |
---|
798 | } |
---|
799 | else if (yOffset + g_height > g_pnzImgHeight) |
---|
800 | { |
---|
801 | yPercent = 1; |
---|
802 | yOffset = g_pnzImgTop + g_pnzImgHeight - g_height; |
---|
803 | } |
---|
804 | |
---|
805 | if (parent.parent.viewMgr.setView) |
---|
806 | { |
---|
807 | var viewMgr = parent.parent.viewMgr; |
---|
808 | viewMgr.PostSetViewProcessing = PostSetViewProcessing; |
---|
809 | viewMgr.ChangingView = true; |
---|
810 | viewMgr.setView (xPercent, yPercent); |
---|
811 | } |
---|
812 | setZWinSize (null, null, g_newLeft, g_newTop); |
---|
813 | } |
---|
814 | } |
---|
815 | |
---|
816 | function keyup() |
---|
817 | { |
---|
818 | var key = window.event.keyCode; |
---|
819 | if(key == 37 || key == 38 || key == 39 || key == 40) |
---|
820 | { |
---|
821 | el = window.event.srcElement; |
---|
822 | } |
---|
823 | } |
---|
824 | |
---|
825 | function dragObject( divID, divObject, xOffset, yOffset, dragFunctionPointer, dragStopFunctionPointer ) |
---|
826 | { |
---|
827 | this.divID = divID; |
---|
828 | this.divObject = divObject; |
---|
829 | this.xOffset = xOffset; |
---|
830 | this.yOffset = yOffset; |
---|
831 | this.dragFPtr = dragFunctionPointer; |
---|
832 | this.dragStopFPtr = dragStopFunctionPointer; |
---|
833 | } |
---|
834 | |
---|
835 | var dragList = new Array(); |
---|
836 | |
---|
837 | |
---|
838 | function startDrag( divID, dragFunctionPtr, dragStopFunctionPointer, xOffset, yOffset ) |
---|
839 | { |
---|
840 | var divObject = document.all(divID); |
---|
841 | if( divObject != null ) |
---|
842 | { |
---|
843 | document.selection.empty(); |
---|
844 | |
---|
845 | if( xOffset == null ) |
---|
846 | { |
---|
847 | xOffset = parseInt(divObject.style.left) - g_lastX; |
---|
848 | } |
---|
849 | |
---|
850 | if( yOffset == null ) |
---|
851 | { |
---|
852 | yOffset = parseInt(divObject.style.top) - g_lastY; |
---|
853 | } |
---|
854 | |
---|
855 | dragList[ dragList.length ] = new dragObject( divID, divObject, xOffset, yOffset, dragFunctionPtr, dragStopFunctionPointer ); |
---|
856 | return true; |
---|
857 | } |
---|
858 | else |
---|
859 | { |
---|
860 | return false; |
---|
861 | } |
---|
862 | } |
---|
863 | |
---|
864 | function doDrag( x, y ) |
---|
865 | { |
---|
866 | for( var i=0; i < dragList.length; i++ ) |
---|
867 | { |
---|
868 | if( dragList[i].dragFPtr != null ) |
---|
869 | dragList[i].dragFPtr( dragList[i], x, y ); |
---|
870 | } |
---|
871 | if( dragList.length ) |
---|
872 | { |
---|
873 | document.selection.empty(); |
---|
874 | } |
---|
875 | } |
---|
876 | |
---|
877 | function stopDrag( divID, x, y ) |
---|
878 | { |
---|
879 | var tmpDragObject; |
---|
880 | for( var i=0; i < dragList.length; i++ ) |
---|
881 | { |
---|
882 | if( dragList[i].divID == divID || divID == null ) |
---|
883 | { |
---|
884 | tmpDragObject = dragList[i]; |
---|
885 | |
---|
886 | dragList[i] = dragList[ dragList.length - 1 ]; |
---|
887 | dragList.length = dragList.length - 1; |
---|
888 | |
---|
889 | if( tmpDragObject.dragStopFPtr != null ) |
---|
890 | { |
---|
891 | tmpDragObject.dragStopFPtr( tmpDragObject, x, y ); |
---|
892 | } |
---|
893 | |
---|
894 | } |
---|
895 | } |
---|
896 | } |
---|
897 | |
---|
898 | function PageViewChanged(newLeftPercent, newTopPercent, newWidthPercent, newHeightPercent) |
---|
899 | { |
---|
900 | if (dragList.length == 0 && !parent.parent.viewMgr.ChangingView) |
---|
901 | { |
---|
902 | var newLeft = null; |
---|
903 | var newTop = null; |
---|
904 | var newWidth = null; |
---|
905 | var newHeight = null; |
---|
906 | |
---|
907 | var PNZimg = document.all("ConvertedImage"); |
---|
908 | |
---|
909 | if (newLeftPercent != null) |
---|
910 | { |
---|
911 | newLeft = (newLeftPercent * PNZimg.style.pixelWidth) + parseInt(divThumbnail.style.left); |
---|
912 | } |
---|
913 | |
---|
914 | if (newTopPercent != null) |
---|
915 | { |
---|
916 | newTop = (newTopPercent * PNZimg.style.pixelHeight) + parseInt(divThumbnail.style.top); |
---|
917 | } |
---|
918 | |
---|
919 | if (newWidthPercent != null) |
---|
920 | { |
---|
921 | newWidth = newWidthPercent * PNZimg.style.pixelWidth; |
---|
922 | } |
---|
923 | |
---|
924 | if (newHeightPercent != null) |
---|
925 | { |
---|
926 | newHeight = newHeightPercent * PNZimg.style.pixelHeight; |
---|
927 | } |
---|
928 | |
---|
929 | setZWinSize (newWidth, newHeight, newLeft, newTop); |
---|
930 | |
---|
931 | if (newLeftPercent <= 0 && newTopPercent <= 0 && newWidthPercent >= 1 && newHeightPercent >= 1) |
---|
932 | { |
---|
933 | zoomRectDiv.style.display = "none"; |
---|
934 | zoomRectDiv.style.visibility = "hidden"; |
---|
935 | } |
---|
936 | else |
---|
937 | { |
---|
938 | zoomRectDiv.style.display = "inline"; |
---|
939 | zoomRectDiv.style.visibility = "visible"; |
---|
940 | } |
---|
941 | |
---|
942 | if (newWidthPercent != null && newHeightPercent != null) |
---|
943 | { |
---|
944 | var newZoomLevel = GetZoomLevel (newWidthPercent, newHeightPercent); |
---|
945 | SetCorrectTick (newZoomLevel); |
---|
946 | } |
---|
947 | } |
---|
948 | } |
---|
949 | |
---|
950 | function load() |
---|
951 | { |
---|
952 | parent.parent.g_ZoomLoaded = true; |
---|
953 | |
---|
954 | if (parent.parent.g_LoadingWidgets) |
---|
955 | { |
---|
956 | parent.parent.g_LoadingWidgets = false; |
---|
957 | parent.parent.location.reload(); |
---|
958 | } |
---|
959 | } |
---|
960 | |
---|
961 | function unload() |
---|
962 | { |
---|
963 | if (parent.parent.viewMgr) |
---|
964 | { |
---|
965 | parent.parent.viewMgr.viewChanged = null; |
---|
966 | } |
---|
967 | |
---|
968 | parent.parent.g_LoadingWidgets = true; |
---|
969 | } |
---|
970 | |
---|
971 | |
---|
972 | </script> |
---|
973 | </head> |
---|
974 | <body onload="load();" onunload="unload();"> |
---|
975 | <div id="divPZWindow" style="width: 100%; height: 100%;" > |
---|
976 | <div id="divThumbnail" style="position: absolute; " onmousedown="startNewZoomRectDrag();"></div> |
---|
977 | </div> |
---|
978 | <div id="divTempThumbnail" style="position: absolute; visibility:hidden; display:none;" ></div> |
---|
979 | |
---|
980 | <div id="zoomRectDiv" tabindex="1" title="可見的區域。使用滑鼠或方向鍵來移動。" onkeydown="keydown()" onkeyup="keyup()" style="display:none;position: absolute; border: solid red thin; z-index: 3;" onmousedown="startZoomRectDrag();" onmouseover="setZoomRectCursor();" onmousemove="setZoomRectCursor();"></div> |
---|
981 | <div id="newZoomWindowDiv" style="position: absolute; border: solid blue thin; z-index: 4; visibility: hidden;"></div> |
---|
982 | |
---|
983 | </body> |
---|
984 | </html> |
---|
985 | |
---|
986 | |
---|
987 | |
---|
988 | |
---|
989 | |
---|
990 | |
---|