X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..92c2b89db26be16707f4a805d3303ab2531006e1:/docs/source/Element.style-more.html diff --git a/docs/source/Element.style-more.html b/docs/source/Element.style-more.html index 180f2e0d..d4c30a6b 100644 --- a/docs/source/Element.style-more.html +++ b/docs/source/Element.style-more.html @@ -15,7 +15,7 @@ Ext.Element.boxMarkup = '
{width: <element width>, height: <element height>}
- */
- getViewSize : function(contentBox){
+ *
+ *
+ * getViewSize utilizes clientHeight/clientWidth which excludes sizing of scrollbars.
+ * To obtain the size including scrollbars, use getStyleSize
+ *
+ * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.
+ */
+
+ getViewSize : function(){
var doc = document,
- me = this,
- d = me.dom,
- extdom = Ext.lib.Dom,
- isDoc = (d == doc || d == doc.body),
- isBB, w, h, tbBorder = 0, lrBorder = 0,
- tbPadding = 0, lrPadding = 0;
- if (isDoc) {
- return { width: extdom.getViewWidth(), height: extdom.getViewHeight() };
- }
- isBB = me.isBorderBox();
- tbBorder = me.getBorderWidth('tb');
- lrBorder = me.getBorderWidth('lr');
- tbPadding = me.getPadding('tb');
- lrPadding = me.getPadding('lr');
+ d = this.dom,
+ isDoc = (d == doc || d == doc.body);
- // Width calcs
- // Try the style first, then clientWidth, then offsetWidth
- if (w = me.getStyle('width').match(pxMatch)){
- if ((w = parseInt(w[1], 10)) && isBB){
- // Style includes the padding and border if isBB
- w -= (lrBorder + lrPadding);
- }
- if (!contentBox){
- w += lrPadding;
+ // If the body, use Ext.lib.Dom
+ if (isDoc) {
+ var extdom = Ext.lib.Dom;
+ return {
+ width : extdom.getViewWidth(),
+ height : extdom.getViewHeight()
}
+
+ // Else use clientHeight/clientWidth
} else {
- if (!(w = d.clientWidth) && (w = d.offsetWidth)){
- w -= lrBorder;
- }
- if (w && contentBox){
- w -= lrPadding;
+ return {
+ width : d.clientWidth,
+ height : d.clientHeight
}
}
+ },
- // Height calcs
- // Try the style first, then clientHeight, then offsetHeight
- if (h = me.getStyle('height').match(pxMatch)){
- if ((h = parseInt(h[1], 10)) && isBB){
- // Style includes the padding and border if isBB
- h -= (tbBorder + tbPadding);
- }
- if (!contentBox){
- h += tbPadding;
+ /**
+ * Returns the dimensions of the element available to lay content out in.
+ * + * getStyleSize utilizes prefers style sizing if present, otherwise it chooses the larger of offsetHeight/clientHeight and offsetWidth/clientWidth. + * To obtain the size excluding scrollbars, use getViewSize + * + * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc. + */ + + getStyleSize : function(){ + var me = this, + w, h, + doc = document, + d = this.dom, + isDoc = (d == doc || d == doc.body), + s = d.style; + + // If the body, use Ext.lib.Dom + if (isDoc) { + var extdom = Ext.lib.Dom; + return { + width : extdom.getViewWidth(), + height : extdom.getViewHeight() } - } else { - if (!(h = d.clientHeight) && (h = d.offsetHeight)){ - h -= tbBorder; + } + // Use Styles if they are set + if(s.width && s.width != 'auto'){ + w = parseFloat(s.width); + if(me.isBorderBox()){ + w -= me.getFrameWidth('lr'); } - if (h && contentBox){ - h -= tbPadding; + } + // Use Styles if they are set + if(s.height && s.height != 'auto'){ + h = parseFloat(s.height); + if(me.isBorderBox()){ + h -= me.getFrameWidth('tb'); } } - - return { - width : w, - height : h - }; + // Use getWidth/getHeight if style not set. + return {width: w || me.getWidth(true), height: h || me.getHeight(true)}; },
/** @@ -366,7 +351,7 @@ Ext.Element.addMethods(function(){ if (!side) { for (key in me.margins){ - o[hash[key]] = parseInt(me.getStyle(me.margins[key]), 10) || 0; + o[hash[key]] = parseFloat(me.getStyle(me.margins[key])) || 0; } return o; } else {