4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
13 getViewWidth : function(full) {
14 return full ? this.getDocumentWidth() : this.getViewportWidth();
17 getViewHeight : function(full) {
18 return full ? this.getDocumentHeight() : this.getViewportHeight();
21 getDocumentHeight: function() {
22 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
23 return Math.max(scrollHeight, this.getViewportHeight());
26 getDocumentWidth: function() {
27 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
28 return Math.max(scrollWidth, this.getViewportWidth());
31 getViewportHeight: function() {
32 var height = self.innerHeight;
33 var mode = document.compatMode;
35 if ((mode || Roo.isIE) && !Roo.isOpera) {
36 height = (mode == "CSS1Compat") ?
37 document.documentElement.clientHeight :
38 document.body.clientHeight;
44 getViewportWidth: function() {
45 var width = self.innerWidth;
46 var mode = document.compatMode;
48 if (mode || Roo.isIE) {
49 width = (mode == "CSS1Compat") ?
50 document.documentElement.clientWidth :
51 document.body.clientWidth;
56 isAncestor : function(p, c) {
63 if (p.contains && !Roo.isSafari) {
65 } else if (p.compareDocumentPosition) {
66 return !!(p.compareDocumentPosition(c) & 16);
68 var parent = c.parentNode;
73 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
76 parent = parent.parentNode;
82 getRegion : function(el) {
83 return Roo.lib.Region.getRegion(el);
87 return this.getXY(el)[1];
91 return this.getXY(el)[0];
94 getXY : function(el) {
95 var p, pe, b, scroll, bd = document.body;
97 var fly = Roo.lib.AnimBase.fly;
98 if (el.getBoundingClientRect) {
99 b = el.getBoundingClientRect();
100 scroll = fly(document).getScroll();
101 return [b.left + scroll.left, b.top + scroll.top];
107 var hasAbsolute = fly(el).getStyle("position") == "absolute";
114 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
121 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
122 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
129 if (p != el && pe.getStyle('overflow') != 'visible') {
137 if (Roo.isSafari && hasAbsolute) {
142 if (Roo.isGecko && !hasAbsolute) {
144 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
145 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
149 while (p && p != bd) {
150 if (!Roo.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
162 setXY : function(el, xy) {
163 el = Roo.fly(el, '_setXY');
165 var pts = el.translatePoints(xy);
166 if (xy[0] !== false) {
167 el.dom.style.left = pts.left + "px";
169 if (xy[1] !== false) {
170 el.dom.style.top = pts.top + "px";
174 setX : function(el, x) {
175 this.setXY(el, [x, false]);
178 setY : function(el, y) {
179 this.setXY(el, [false, y]);