2 * @class Ext.core.Element
6 isCSS1 = doc.compatMode == "CSS1Compat",
7 ELEMENT = Ext.core.Element,
10 _fly = new Ext.core.Element.Flyweight();
17 isAncestor : function(p, c) {
25 } else if (p.compareDocumentPosition) {
26 return !!(p.compareDocumentPosition(c) & 16);
28 while ((c = c.parentNode)) {
36 getViewWidth : function(full) {
37 return full ? ELEMENT.getDocumentWidth() : ELEMENT.getViewportWidth();
40 getViewHeight : function(full) {
41 return full ? ELEMENT.getDocumentHeight() : ELEMENT.getViewportHeight();
44 getDocumentHeight: function() {
45 return Math.max(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, ELEMENT.getViewportHeight());
48 getDocumentWidth: function() {
49 return Math.max(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, ELEMENT.getViewportWidth());
52 getViewportHeight: function(){
54 (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
58 getViewportWidth : function() {
59 return (!Ext.isStrict && !Ext.isOpera) ? doc.body.clientWidth :
60 Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
64 return ELEMENT.getXY(el)[1];
68 return ELEMENT.getXY(el)[0];
71 getXY : function(el) {
82 bd = (doc.body || doc.documentElement),
88 hasAbsolute = fly(el).isStyle("position", "absolute");
90 if (el.getBoundingClientRect) {
91 b = el.getBoundingClientRect();
92 scroll = fly(document).getScroll();
93 ret = [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
102 hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
105 y += bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
106 x += bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
108 if (p != el && !pe.isStyle('overflow','visible')) {
116 if (Ext.isSafari && hasAbsolute) {
121 if (Ext.isGecko && !hasAbsolute) {
123 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
124 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
128 while (p && p != bd) {
129 if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
141 setXY : function(el, xy) {
142 (el = Ext.fly(el, '_setXY')).position();
144 var pts = el.translatePoints(xy),
145 style = el.dom.style,
149 if (!isNaN(pts[pos])) {
150 style[pos] = pts[pos] + "px";
155 setX : function(el, x) {
156 ELEMENT.setXY(el, [x, false]);
159 setY : function(el, y) {
160 ELEMENT.setXY(el, [false, y]);
164 * Serializes a DOM form into a url encoded string
165 * @param {Object} form The form
166 * @return {String} The url encoded form
168 serializeForm: function(form) {
169 var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
171 encoder = encodeURIComponent,
177 Ext.each(fElements, function(element){
181 if (!element.disabled && name) {
182 if (/select-(one|multiple)/i.test(type)) {
183 Ext.each(element.options, function(opt){
185 hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified;
186 data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text));
189 } else if (!(/file|undefined|reset|button/i.test(type))) {
190 if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
191 data += encoder(name) + '=' + encoder(element.value) + '&';
192 hasSubmit = /submit/i.test(type);
197 return data.substr(0, data.length - 1);