overlib_anchor_mini.js
上传用户:stephen_wu
上传日期:2008-07-05
资源大小:1757k
文件大小:6k
源码类别:

网络

开发平台:

Unix_Linux

  1. ///////
  2. //  overLIB Anchor Plugin
  3. //  This file requires overLIB 4.10 or later.
  4. //
  5. //  overLIB 4.10 - You may not remove or change this notice.
  6. //  Copyright Erik Bosrup 1998-2004. All rights reserved.
  7. //  Contributors are listed on the homepage.
  8. //  See http://www.bosrup.com/web/overlib/ for details.
  9. ///////
  10. //  THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL!
  11. if(typeof olInfo=='undefined'||typeof olInfo.meets=='undefined'||!olInfo.meets(4.10))alert('overLIB 4.10 or later is required for the Anchor Plugin.');else{registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign');
  12. if(typeof ol_anchor=='undefined')var ol_anchor='';if(typeof ol_anchorx=='undefined')var ol_anchorx=0;if(typeof ol_anchory=='undefined')var ol_anchory=0;if(typeof ol_noanchorwarn=='undefined')var ol_noanchorwarn=1;if(typeof ol_anchoralign=='undefined')var ol_anchoralign='UL';
  13. var o3_anchor="",o3_anchorx=0,o3_anchory=0,o3_noanchorwarn=1,o3_anchoralign='UL',mrkObj,rmrkPosition;
  14. function setAnchorVariables(){o3_anchor=ol_anchor;o3_anchorx=ol_anchorx;o3_anchory=ol_anchory;o3_noanchorwarn=ol_noanchorwarn;o3_anchoralign=ol_anchoralign;mrkObj=null}
  15. function parseAnchorExtras(pf,i,ar){var v,k=i;
  16. if(k<ar.length){if(ar[k]==ANCHOR){eval(pf+"anchor='"+escSglQuote(ar[++k])+"'");return k;}
  17. if(ar[k]==ANCHORX){eval(pf+'anchorx='+ar[++k]);return k;}
  18. if(ar[k]==ANCHORY){eval(pf+'anchory='+ar[++k]);return k;}
  19. if(ar[k]==NOANCHORWARN){eval(pf+'noanchorwarn=('+pf+'noanchorwarn==1)?0:1');return k;}
  20. if(ar[k]==ANCHORALIGN){k=opt_MULTIPLEARGS(++k,ar,(pf+'anchoralign')); return k;}}
  21. return-1}
  22. function checkAnchorObject(){var w=o3_anchor;
  23. if(w){if(!(mrkObj=getAnchorObjectRef(w))){if(o3_noanchorwarn){alert('WARNING!  Reference mark "'+w+'" not found.');return false;}else w=''}}
  24. return true}
  25. function anchorHorizontal(browserWidth,horizontalScrollAmount,widthFix){var hasAnchor=(typeof o3_anchor!='undefined'&&o3_anchor);if(!hasAnchor)return void(0);
  26. if(typeof o3_followscroll!='undefined'&&o3_followscroll&&o3_sticky)o3_relx=rmrkPosition[0];
  27. return rmrkPosition[0]}
  28. function anchorVertical(browserHeight,verticalScrollAmount){var hasAnchor=(typeof o3_anchor!='undefined'&&o3_anchor);if(!hasAnchor)return void(0);
  29. if(typeof o3_followscroll!='undefined'&&o3_followscroll&&o3_sticky)o3_rely=rmrkPosition[1];
  30. return rmrkPosition[1]}
  31. function anchorPreface(){if(!mrkObj)return;rmrkPosition=getAnchorLocation(mrkObj)}
  32. function getAnchorObjectRef(aObj){return getRefById(aObj,o3_frame.document)||getRefByName(aObj,o3_frame.document)}
  33. function getAnchorLocation(objRef){var mkObj,of,offsets,mlyr
  34. mkObj=mlyr=objRef
  35. offsets=[o3_anchorx,o3_anchory]
  36. if(document.layers){if(typeof mlyr.length!='undefined'&& mlyr.length>1){mkObj=mlyr[0]
  37. offsets[0]+=mlyr[0].x+mlyr[1].pageX
  38. offsets[1]+=mlyr[0].y+mlyr[1].pageY
  39. }else{if(mlyr.toString().indexOf('Image')!=-1||mlyr.toString().indexOf('Anchor')!=-1){offsets[0]+=mlyr.x
  40. offsets[1]+=mlyr.y
  41. }else{offsets[0]+=mlyr.pageX
  42. offsets[1]+=mlyr.pageY}}
  43. }else{offsets[0]+=pageLocation(mlyr,'Left')
  44. offsets[1]+=pageLocation(mlyr,'Top')}
  45. of=getAnchorOffsets(mkObj)
  46. if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgLeft=offsets[0];olImgTop=offsets[1]}
  47. offsets[0]+=of[0]
  48. offsets[1]+=of[1]
  49. if(typeof o3_dragimg!='undefined'&& o3_dragimg){olImgRight=offsets[0];olImgBottom=offsets[1];return}
  50. return offsets}
  51. function getAnchorOffsets(mkObj){var fx=fy=0, mp,puc,mkAry,sx=sy=0,w=o3_anchoralign
  52. var mW=mH=pW=pH=0
  53. var off=[0,0]
  54. mkAry=w.split(',');
  55. if(mkAry.length<3){mp=mkAry[0].toUpperCase();puc=(mkAry.length==1)?mp:mkAry[1].toUpperCase();}else if(mkAry.length==3){if(!isNaN(mkAry[0])){mp=mkAry.slice(0,2);puc=mkAry[2].toUpperCase();}else{mp=mkAry[0].toUpperCase();puc=mkAry.slice(1)}
  56. }else{mp=mkAry.slice(0,2);puc=mkAry.slice(2)}
  57. var shdwPresent=typeof o3_shadow!='undefined'&& o3_shadow
  58. if(shdwPresent){sx=Math.abs(o3_shadowx);sy=Math.abs(o3_shadowy)}
  59. pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth))
  60. pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight))
  61. if(olOp&& o3_wrap){pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth))
  62. pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight))}
  63. if(!olOp&& mkObj.toString().indexOf('Image')!=-1){mW=mkObj.width
  64. mH=mkObj.height
  65. }else if(!olOp&& mkObj.toString().indexOf('Anchor')!=-1){mp='UL'
  66. }else{mW=(olNs4)?mkObj.clip.width:mkObj.offsetWidth
  67. mH=(olNs4)?mkObj.clip.height:mkObj.offsetHeight}
  68. if(!isNaN(mp)||typeof mp=='object'){if(typeof mp=='object'){fx=parseFloat(mp[0]);fy=parseFloat(mp[1]);}else
  69. fx=fy=parseFloat(mp);off=[Math.round(fx*mW),Math.round(fy*mH)];}else{if(mp=='UR')off=[mW,0]
  70. else if(mp=='LL')off=[0,mH]
  71. else if(mp=='LR')off=[mW,mH]}
  72. if(typeof o3_dragimg!='undefined'&& o3_dragimg)return off;else{if(!isNaN(puc)||typeof puc=='object' ){if(typeof puc=='object'){fx=parseFloat(puc[0]);fy=parseFloat(puc[1]);}else
  73. fx=fy=parseFloat(puc);off[0]-=Math.round(fx*(pW-sx));off[1]-=Math.round(fy*(pH-sy));}else{if(puc=='UR'){off[0]-=(pW-sx);off[1]-=sy
  74. }else if(puc=='LL'){off[0]-=sx;off[1]-=(pH-sy)
  75. }else if(puc=='LR'){off[0]-=(pW-sx);off[1]-=(pH-sy)}}
  76. return off}}
  77. function pageLocation(o,t){var x=0
  78. while(o.offsetParent){x+=o['offset'+t]
  79. o=o.offsetParent}
  80. x+=o['offset'+t]
  81. return x}
  82. function getRefById(l,d){var r="",j
  83. d=(d||document)
  84. if(d.all)return d.all[l]
  85. else if(d.getElementById)return d.getElementById(l)
  86. else if(d.layers&& d.layers.length>0){if(d.layers[l])return d.layers[l]
  87. for(j=0;j<d.layers.length;j++){r=getRefById(l,d.layers[j].document)
  88. if(r)return r}}
  89. return false}
  90. function getRefByName(l,d){var r=null,j
  91. d=(d||document)
  92. if(d.images[l])return d.images[l]
  93. else if(d.anchors[l])return d.anchors[l];else if(d.layers&& d.layers.length>0){for(j=0;j<d.layers.length;j++){r=getRefByName(l,d.layers[j].document)
  94. if(r&& r.length>0)return r
  95. else if(r)return [r,d.layers[j]]}}
  96. return null}
  97. registerRunTimeFunction(setAnchorVariables);registerCmdLineFunction(parseAnchorExtras);registerPostParseFunction(checkAnchorObject);registerHook("createPopup",anchorPreface,FAFTER);registerHook("horizontalPlacement",anchorHorizontal,FCHAIN);registerHook("verticalPlacement",anchorVertical,FCHAIN);if(olInfo.meets(4.10))registerNoParameterCommands('noanchorwarn');
  98. }