js/core/iefix/iefix.js in rsence-2.0.0.0.pre vs js/core/iefix/iefix.js in rsence-2.0.0.pre

- old
+ new

@@ -39,21 +39,17 @@ }, // finds the next parent with fixed or absolute positioning: // NOTICE: .init() makes ._layoutHeight() from this by replacing width with height layoutWidth: function(_element) { - var _this=iefix, - _parent, - i=0, + var _this=iefix,_parent,i=0, // gets the parent from which the width is calculated _layoutParent=_element.offsetParent; while(_layoutParent&&!_this._hasLayout(_layoutParent)){ _layoutParent=_layoutParent.offsetParent; } - if(!_layoutParent._resizewidthElements){ - _layoutParent._resizewidthElements=[]; - } + if(!_layoutParent._resizewidthElements){_layoutParent._resizewidthElements=[];} if(!_element._addedResizewidthFix){ _layoutParent._resizewidthElements.push(_element); _parent=_layoutParent; while(_parent.offsetParent){ _parent=_parent.offsetParent; @@ -73,15 +69,15 @@ _layoutParent._resizewidth=true; } return (_layoutParent||document.documentElement).clientWidth; }, - // // calculates the border width of the _element: - // // NOTICE: .init() makes ._getBorderHeight() from this by replacing Width with Height - // getBorderWidth: function(_element){ - // return _element.offsetWidth-_element.clientWidth; - // }, + // calculates the border width of the _element: + // NOTICE: .init() makes ._getBorderHeight() from this by replacing Width with Height + getBorderWidth: function(_element){ + return _element.offsetWidth-_element.clientWidth; + }, // calculates the actual value in pixels from _value: getPixelValue: function(_element,_value) { var _this=iefix,_style,_runtimeStyle; if(_this._PIXEL.test(_value)){return parseInt(_value,10);} @@ -105,17 +101,17 @@ var _this=iefix; if(_this._PERCENT.test(_value)){return parseInt(parseFloat(_value)/100*_this.layoutWidth(_element),10);} return _this.getPixelValue(_element, _value); }, - // // calculates padding width of the _element: - // // NOTICE: .init() makes .getPaddingHeight() from this by replacing Left/Right/Width with Top/Bottom/Height - // // NOTICE: .init() also makes ._getMarginWidth() and ._getMarginHeight from this. - // getPaddingWidth: function(_element) { - // var _this=iefix; - // return _this.getPixelWidth(_element,_element.currentStyle.paddingLeft)+_this.getPixelWidth(_element,_element.currentStyle.paddingRight); - // }, + // calculates padding width of the _element: + // NOTICE: .init() makes .getPaddingHeight() from this by replacing Left/Right/Width with Top/Bottom/Height + // NOTICE: .init() also makes ._getMarginWidth() and ._getMarginHeight from this. + getPaddingWidth: function(_element) { + var _this=iefix; + return _this.getPixelWidth(_element,_element.currentStyle.paddingLeft)+_this.getPixelWidth(_element,_element.currentStyle.paddingRight); + }, // calculates element's position from the right edge of the parent: // NOTICE: .init() makes _resizeBottom() from this by replacing left/width with top/height resizeRight: function(_element){ var _this=iefix,_left,_width; @@ -124,12 +120,11 @@ _left=parseInt(_element.currentStyle.left,10); _width=_this.layoutWidth(_element)-parseInt(_element.currentStyle.right,10)-_left; if(parseInt(_element.runtimeStyle.width,10)===_width){return;} _element.runtimeStyle.width=""; if(_element.offsetWidth<_width){ - // Disabled, because no-one uses quirks mode anymore, right? - // _width-=_this.getBorderWidth(_element)+_this.getPaddingWidth(_element); + _width-=_this.getBorderWidth(_element)+_this.getPaddingWidth(_element); if(_width<0){_width=0;} _element.runtimeStyle.width=_width; } }, @@ -188,43 +183,33 @@ _image.onload=function(){_element.width=_image.width;_element.height=_image.height;_image=null;}; _this.addFilter(_element,_image); } }, - _noStyleTagNames: ['PARAM','HTML'], + _noStyleTagNames: ['PARAM'], // applies fixes to the _element inlineStyleChanged: function(_element){ - var _this=iefix, - _currentStyle=_element.currentStyle; - if(_this._noStyleTagNames.indexOf(_element.tagName)!==-1){ - return; - } + var _this=iefix,_currentStyle; + _currentStyle=_element.currentStyle; + if(_this._noStyleTagNames.indexOf(_element.tagName)!==-1){ return; } // check if element needs to be positioned from the right try{ - var _posMatch = (_currentStyle.position==="absolute"||_currentStyle.position==="fixed"), - _resizeWidth = _element._resizewidth, - _resizeHeight = _element._resizeheight, - _autoRight = _currentStyle.right==="auto", - _autoBottom = _currentStyle.bottom==="auto"; - if(_resizeWidth||(_posMatch&&!_autoRight)){ + if((_currentStyle.position==="absolute"||_currentStyle.position==="fixed")&&_currentStyle.left!=="auto"&&_currentStyle.right!=="auto"&&_currentStyle.width==="auto"){ _this.resizeRight(_element); } + // check if element needs to be positioned from the bottom - if(_resizeHeight||(_posMatch&&!_autoBottom)){ + if((_currentStyle.position==="absolute"||_currentStyle.position==="fixed")&&_currentStyle.top!=="auto"&&_currentStyle.bottom!=="auto"&&_currentStyle.height==="auto"){ _this.resizeBottom(_element); - if(parseInt(_element.height)>parseInt(_element.fontSize,10)){ - // TODO: needs line height calculation here too for elements smaller than the line height or font size - _element.fontSize = _element.height; - _element.lineHeight = _element.height; - } + // TODO: needs line height calculation here too for elements smaller than the line height or font size } // check if opacity needs to be fixed: if(_element.currentStyle.opacity){_this.fixOpacity(_element);} } catch(e) { - console.log("iefix error! element:",_element); + alert("iefix error! element:"+_element.tagName+" e:"+e.description); } // check if background image needs to be fixed: //if(_element.currentStyle.backgroundImage){_this.fixBackgroundImage(_element);} @@ -241,11 +226,11 @@ _traverseCount: 0, // traverses from the _element node from the bottom to fix right|bottom positioning _traverseTree: function(_element){ var _this=iefix; _this._traverseCount++; - // console.log( 'traversecount: '+_this._traverseCount ); + //window.status = 'traversecount: '+_this._traverseCount; _element=_element||document.documentElement; while(_element){ if(_element.nodeType===1){ _this.inlineStyleChanged(_element); } @@ -272,14 +257,14 @@ _this._PERCENT = /^\d+%$/; _this.pngCheck = new RegExp(".png$", "i"); // needs more work //this.pngCheck = new RegExp("((\.gif)|(\.jpg))$", "i"); // needs more work // needed for png hack _this.blankGifPath=ie_htc_path+"0.gif"; - // eval("_this.getMarginWidth="+String(_this.getPaddingWidth).replace(/padding/g,"margin")); - // eval("_this.getPaddingHeight="+String(_this.getPaddingWidth).replace(/Width/g,"Height").replace(/Left/g,"Top").replace(/Right/g,"Bottom")); - // eval("_this.getMarginHeight="+String(_this.getPaddingHeight).replace(/padding/g,"margin")); - // eval("_this.getBorderHeight="+String(_this.getBorderWidth).replace(/Width/g,"Height")); + eval("_this.getMarginWidth="+String(_this.getPaddingWidth).replace(/padding/g,"margin")); + eval("_this.getPaddingHeight="+String(_this.getPaddingWidth).replace(/Width/g,"Height").replace(/Left/g,"Top").replace(/Right/g,"Bottom")); + eval("_this.getMarginHeight="+String(_this.getPaddingHeight).replace(/padding/g,"margin")); + eval("_this.getBorderHeight="+String(_this.getBorderWidth).replace(/Width/g,"Height")); eval("_this.layoutHeight="+String(_this.layoutWidth).replace(/Width/g,"Height").replace(/width/g,"height").replace(/Right/g,"Bottom")); eval("_this.getPixelHeight="+String(_this.getPixelWidth).replace(/Width/g,"Height")); eval("_this.resizeBottom="+String(_this.resizeRight).replace(/Width/g,"Height").replace(/width/g,"height").replace(/left/g,"top").replace(/right/g,"bottom")); _this.resizing = false; }, @@ -290,11 +275,11 @@ if(document.readyState==="complete"&&window.event.srcElement.readyState==="complete"){ iefix._traverseTree(); } }, - _traverseStyleProperties: ['width','height','left','top','right','bottom','display','position','visibility'], + _traverseStyleProperties: ['width','height','left','top','right','bottom','display','position'], //_traverseStyleProperties: ['right','bottom','width','height'], //_elemEntryCount: 0, // entry point from ie_css_element.htc @@ -351,9 +336,9 @@ } ie_initialized=true; } }; ie_fixes(); -// window.onresize=function(){iefix.setWinSize();iefix._traverseTree();}; +window.onresize=function(){iefix.setWinSize();iefix._traverseTree();};