/*
* 返回该htmlEl的最大子元素(包括自身)的width值
*/
getMaxWidth : function(htmlEl, includeSelf) {
var self = this;
if(htmlEl) {
var children = $(htmlEl).children(),
maxWidth = includeSelf ? $(htmlEl).width() : 0;
hx.each(children, function(item){
var curWidth;
// width()等于0的情况是,用户没有指定其width
curWidth = (0===$(item).width() ? this.getMaxWidth(item) : $(item).width());
maxWidth = (curWidth > maxWidth) ? curWidth : maxWidth;
}, self);
return maxWidth;
} else {
return 0;
}
}
/*
* 返回该htmlEl的最大子元素(包括自身)的height值
*/
getMaxHeight : function(htmlEl, includeSelf) {
var self = this;
if(htmlEl) {
var children = $(htmlEl).children(),
maxHeight = includeSelf ? $(htmlEl).height() : 0;
hx.each(children, function(item){
var curHeight;
// height()等于0的情况是,用户没有指定其height
curHeight = (0===$(item).height() ? this.getMaxHeight(item) : $(item).height());
maxHeight = (curHeight > maxHeight) ? curHeight : maxWidth;
}, self);
return maxHeight;
} else {
return 0;
}
}