window.js 2.91 KB
//>>built
define("./_base/lang ./sniff ./_base/window ./dom ./dom-geometry ./dom-style ./dom-construct".split(" "),function(y,l,r,H,n,D,h){l.add("rtl-adjust-position-for-verticalScrollBar",function(b,c){b=r.body(c);c=h.create("div",{style:{overflow:"scroll",overflowX:"visible",direction:"rtl",visibility:"hidden",position:"absolute",left:"0",top:"0",width:"64px",height:"64px"}},b,"last");var e=h.create("div",{style:{overflow:"hidden",direction:"ltr"}},c,"last"),f=0!=n.position(e).x;c.removeChild(e);b.removeChild(c);
return f});l.add("position-fixed-support",function(b,c){b=r.body(c);c=h.create("span",{style:{visibility:"hidden",position:"fixed",left:"1px",top:"1px"}},b,"last");var e=h.create("span",{style:{position:"fixed",left:"0",top:"0"}},c,"last"),f=n.position(e).x!=n.position(c).x;c.removeChild(e);b.removeChild(c);return f});var k={getBox:function(b){b=b||r.doc;var c="BackCompat"==b.compatMode?r.body(b):b.documentElement,e=n.docScroll(b);if(l("touch")){var f=k.get(b);b=f.innerWidth||c.clientWidth;c=f.innerHeight||
c.clientHeight}else b=c.clientWidth,c=c.clientHeight;return{l:e.x,t:e.y,w:b,h:c}},get:function(b){if(l("ie")&&k!==document.parentWindow){b.parentWindow.execScript("document._parentWindow \x3d window;","Javascript");var c=b._parentWindow;b._parentWindow=null;return c}return b.parentWindow||b.defaultView},scrollIntoView:function(b,c){try{b=H.byId(b);var e=b.ownerDocument||r.doc,f=r.body(e),p=e.documentElement||f.parentNode,h=l("ie")||0,k=l("webkit");if(b!=f&&b!=p){var z="BackCompat"==e.compatMode,A=
Math.min(f.clientWidth||p.clientWidth,p.clientWidth||f.clientWidth),B=Math.min(f.clientHeight||p.clientHeight,p.clientHeight||f.clientHeight),e=k||z?f:p,m=c||n.position(b),d=b.parentNode;c=function(a){return 6>=h||7==h&&z?!1:l("position-fixed-support")&&"fixed"==D.get(a,"position").toLowerCase()};var y=this,k=function(a,b,c){"BODY"==a.tagName||"HTML"==a.tagName?y.get(a.ownerDocument).scrollBy(b,c):(b&&(a.scrollLeft+=b),c&&(a.scrollTop+=c))};if(!c(b))for(;d;){d==f&&(d=e);var a=n.position(d),E=c(d),
C="rtl"==D.getComputedStyle(d).direction.toLowerCase();if(d==e)a.w=A,a.h=B,e==p&&h&&C&&(a.x+=e.offsetWidth-a.w),a.x=0,a.y=0;else{var t=n.getPadBorderExtents(d);a.w-=t.w;a.h-=t.h;a.x+=t.l;a.y+=t.t;var q=d.clientWidth,u=a.w-q;0<q&&0<u&&(C&&l("rtl-adjust-position-for-verticalScrollBar")&&(a.x+=u),a.w=q);q=d.clientHeight;u=a.h-q;0<q&&0<u&&(a.h=q)}E&&(0>a.y&&(a.h+=a.y,a.y=0),0>a.x&&(a.w+=a.x,a.x=0),a.y+a.h>B&&(a.h=B-a.y),a.x+a.w>A&&(a.w=A-a.x));var v=m.x-a.x,w=m.y-a.y,F=v+m.w-a.w,G=w+m.h-a.h,g,x;0<F*v&&
(d.scrollLeft||d==e||d.scrollWidth>d.offsetHeight)&&(g=Math[0>v?"max":"min"](v,F),C&&8==h&&!z&&(g=-g),x=d.scrollLeft,k(d,g,0),g=d.scrollLeft-x,m.x-=g);0<G*w&&(d.scrollTop||d==e||d.scrollHeight>d.offsetHeight)&&(g=Math.ceil(Math[0>w?"max":"min"](w,G)),x=d.scrollTop,k(d,0,g),g=d.scrollTop-x,m.y-=g);d=d!=e&&!E&&d.parentNode}}}catch(I){console.error("scrollIntoView: "+I),b.scrollIntoView(!1)}}};y.setObject("dojo.window",k);return k});