6 * Dom utils (from YIU afaik)
13 * @param {Boolean} full True will get the full document, otherwise it's the view width
14 * @return {Number} The width
17 getViewWidth : function(full) {
18 return full ? this.getDocumentWidth() : this.getViewportWidth();
22 * @param {Boolean} full True will get the full document, otherwise it's the view height
23 * @return {Number} The height
25 getViewHeight : function(full) {
26 return full ? this.getDocumentHeight() : this.getViewportHeight();
29 * Get the Full Document height
30 * @return {Number} The height
32 getDocumentHeight: function() {
33 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
34 return Math.max(scrollHeight, this.getViewportHeight());
37 * Get the Full Document width
38 * @return {Number} The width
40 getDocumentWidth: function() {
41 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
42 return Math.max(scrollWidth, this.getViewportWidth());
45 * Get the Window Viewport height
46 * @return {Number} The height
48 getViewportHeight: function() {
49 var height = self.innerHeight;
50 var mode = document.compatMode;
52 if ((mode || Roo.isIE) && !Roo.isOpera) {
53 height = (mode == "CSS1Compat") ?
54 document.documentElement.clientHeight :
55 document.body.clientHeight;
61 * Get the Window Viewport width
62 * @return {Number} The width
64 getViewportWidth: function() {
65 var width = self.innerWidth;
66 var mode = document.compatMode;
68 if (mode || Roo.isIE) {
69 width = (mode == "CSS1Compat") ?
70 document.documentElement.clientWidth :
71 document.body.clientWidth;
76 isAncestor : function(p, c) {
83 if (p.contains && !Roo.isSafari) {
85 } else if (p.compareDocumentPosition) {
86 return !!(p.compareDocumentPosition(c) & 16);
88 var parent = c.parentNode;
93 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
96 parent = parent.parentNode;
102 getRegion : function(el) {
103 return Roo.lib.Region.getRegion(el);
106 getY : function(el) {
107 return this.getXY(el)[1];
110 getX : function(el) {
111 return this.getXY(el)[0];
114 getXY : function(el) {
115 var p, pe, b, scroll, bd = document.body;
117 var fly = Roo.lib.AnimBase.fly;
118 if (el.getBoundingClientRect) {
119 b = el.getBoundingClientRect();
120 scroll = fly(document).getScroll();
121 return [b.left + scroll.left, b.top + scroll.top];
127 var hasAbsolute = fly(el).getStyle("position") == "absolute";
134 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
141 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
142 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
149 if (p != el && pe.getStyle('overflow') != 'visible') {
157 if (Roo.isSafari && hasAbsolute) {
162 if (Roo.isGecko && !hasAbsolute) {
164 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
165 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
169 while (p && p != bd) {
170 if (!Roo.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
182 setXY : function(el, xy) {
183 el = Roo.fly(el, '_setXY');
185 var pts = el.translatePoints(xy);
186 if (xy[0] !== false) {
187 el.dom.style.left = pts.left + "px";
189 if (xy[1] !== false) {
190 el.dom.style.top = pts.top + "px";
194 setX : function(el, x) {
195 this.setXY(el, [x, false]);
198 setY : function(el, y) {
199 this.setXY(el, [false, y]);