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">
16 * Dom utils (from YIU afaik)
22 * @param {Boolean} full True will get the full document, otherwise it's the view width
23 * @return {Number} The width
26 getViewWidth : function(full) {
27 return full ? this.getDocumentWidth() : this.getViewportWidth();
31 * @param {Boolean} full True will get the full document, otherwise it's the view height
32 * @return {Number} The height
34 getViewHeight : function(full) {
35 return full ? this.getDocumentHeight() : this.getViewportHeight();
38 getDocumentHeight: function() {
39 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
40 return Math.max(scrollHeight, this.getViewportHeight());
43 getDocumentWidth: function() {
44 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
45 return Math.max(scrollWidth, this.getViewportWidth());
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 getViewportWidth: function() {
62 var width = self.innerWidth;
63 var mode = document.compatMode;
65 if (mode || Roo.isIE) {
66 width = (mode == "CSS1Compat") ?
67 document.documentElement.clientWidth :
68 document.body.clientWidth;
73 isAncestor : function(p, c) {
80 if (p.contains && !Roo.isSafari) {
82 } else if (p.compareDocumentPosition) {
83 return !!(p.compareDocumentPosition(c) & 16);
85 var parent = c.parentNode;
90 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
93 parent = parent.parentNode;
99 getRegion : function(el) {
100 return Roo.lib.Region.getRegion(el);
103 getY : function(el) {
104 return this.getXY(el)[1];
107 getX : function(el) {
108 return this.getXY(el)[0];
111 getXY : function(el) {
112 var p, pe, b, scroll, bd = document.body;
114 var fly = Roo.lib.AnimBase.fly;
115 if (el.getBoundingClientRect) {
116 b = el.getBoundingClientRect();
117 scroll = fly(document).getScroll();
118 return [b.left + scroll.left, b.top + scroll.top];
124 var hasAbsolute = fly(el).getStyle("position") == "absolute";
131 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
138 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
139 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
146 if (p != el && pe.getStyle('overflow') != 'visible') {
154 if (Roo.isSafari && hasAbsolute) {
159 if (Roo.isGecko && !hasAbsolute) {
161 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
162 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
166 while (p && p != bd) {
167 if (!Roo.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
179 setXY : function(el, xy) {
180 el = Roo.fly(el, '_setXY');
182 var pts = el.translatePoints(xy);
183 if (xy[0] !== false) {
184 el.dom.style.left = pts.left + "px";
186 if (xy[1] !== false) {
187 el.dom.style.top = pts.top + "px";
191 setX : function(el, x) {
192 this.setXY(el, [x, false]);
195 setY : function(el, y) {
196 this.setXY(el, [false, y]);