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 getDocumentHeight: function() {
30 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
31 return Math.max(scrollHeight, this.getViewportHeight());
34 getDocumentWidth: function() {
35 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
36 return Math.max(scrollWidth, this.getViewportWidth());
39 getViewportHeight: function() {
40 var height = self.innerHeight;
41 var mode = document.compatMode;
43 if ((mode || Roo.isIE) && !Roo.isOpera) {
44 height = (mode == "CSS1Compat") ?
45 document.documentElement.clientHeight :
46 document.body.clientHeight;
52 getViewportWidth: function() {
53 var width = self.innerWidth;
54 var mode = document.compatMode;
56 if (mode || Roo.isIE) {
57 width = (mode == "CSS1Compat") ?
58 document.documentElement.clientWidth :
59 document.body.clientWidth;
64 isAncestor : function(p, c) {
71 if (p.contains && !Roo.isSafari) {
73 } else if (p.compareDocumentPosition) {
74 return !!(p.compareDocumentPosition(c) & 16);
76 var parent = c.parentNode;
81 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
84 parent = parent.parentNode;
90 getRegion : function(el) {
91 return Roo.lib.Region.getRegion(el);
95 return this.getXY(el)[1];
99 return this.getXY(el)[0];
102 getXY : function(el) {
103 var p, pe, b, scroll, bd = document.body;
105 var fly = Roo.lib.AnimBase.fly;
106 if (el.getBoundingClientRect) {
107 b = el.getBoundingClientRect();
108 scroll = fly(document).getScroll();
109 return [b.left + scroll.left, b.top + scroll.top];
115 var hasAbsolute = fly(el).getStyle("position") == "absolute";
122 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
129 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
130 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
137 if (p != el && pe.getStyle('overflow') != 'visible') {
145 if (Roo.isSafari && hasAbsolute) {
150 if (Roo.isGecko && !hasAbsolute) {
152 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
153 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
157 while (p && p != bd) {
158 if (!Roo.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
170 setXY : function(el, xy) {
171 el = Roo.fly(el, '_setXY');
173 var pts = el.translatePoints(xy);
174 if (xy[0] !== false) {
175 el.dom.style.left = pts.left + "px";
177 if (xy[1] !== false) {
178 el.dom.style.top = pts.top + "px";
182 setX : function(el, x) {
183 this.setXY(el, [x, false]);
186 setY : function(el, y) {
187 this.setXY(el, [false, y]);