You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
4.8 KiB

5 years ago
/* eslint-disable */
;(function(oojs) {oojs.define({name:"dynamicFloatDecorator",namespace:"dup.ui.painter",deps:{dom:"dup.common.utility.dom",style:"dup.common.utility.style"},decorate:function(t,e,i){this.el=t,this.width=e,this.height=i,this.topSpace=5,this.resetTargetStyle(),this.initializeEvent(),this.checkStatus()},initializeEvent:function(t){this.dom.bind(window,"scroll",oojs.proxy(this,this.onScrollHandler)),this.dom.bind(window,"resize",oojs.proxy(this,this.onScrollHandler))},resetTargetStyle:function(){this.el.style.width=this.width+"px",this.el.style.height=this.height+"px",this.el.style.display="inline-block"},onScrollHandler:function(){this.checkStatus()},checkStatus:function(){return this.el&&document.getElementById(this.el.getAttribute("id"))?void(this.style.canFixed()?this.updateStatusFixedly():this.updateStatusAbsolutly()):(this.el=null,!1)},updateStatusFixedly:function(){if(this.isFloating)this.alignTargetLeft(),this.isBackToHolder()&&(this.isFloating=!1,this.el.style.cssText=null,this.resetTargetStyle(),this.removePlaceHolder());else{var t=this.isTouchRoof();t&&(this.el.style.zIndex=2147483646,this.el.style.position="fixed",this.createPlaceHolder(),this.alignTargetLeft(),t?this.el.style.top=this.topSpace+"px":this.el.style.bottom=this.topSpace+"px",this.isFloating=!0)}},updateStatusAbsolutly:function(){if(this.isFloating)this.updatePosition(),this.isBackToHolder()&&(this.isFloating=!1,this.el.style.cssText=null,this.resetTargetStyle(),this.removePlaceHolder());else{var t=this.isTouchRoof();t&&(this.el.style.position="absolute",this.el.style.zIndex=2147483646,this.el.style.visibility="visible",this.createPlaceHolder(),this.isFloating=!0,this.updatePosition())}},updatePosition:function(){if(this.holderEl){var t=(this.style.getClientWidth(window),this.style.getClientHeight(window)),e=this.style.getScrollTop(window),i=this.style.getPositionCore(document.body),s=i.left,l=i.top,o=this.getPosition(this.holderEl),h=this.getPosition(this.el),n=this.style.getStyle(document.body,"position").toString(),r=e+this.topSpace;o.top>h.top&&(r=e+(t-this.topSpace-h.bottom+h.top)),this.el.style.top=""+r+"px",this.el.style.left=""+o.leftAbs+"px","relative"==n&&(this.el.style.top=e+this.topSpace-l+"px",this.el.style.left=o.leftAbs-s+"px"),this.el.style.visibility="visible"}},createPlaceHolder:function(){var t=this.el.id+"_placeholder";this.holderEl=document.createElement("div"),this.holderEl.id=t,this.holderEl.align&&(this.holderEl.align=this.el.getAttribute("align"));var e=this.style.getOuterWidth(this.el,!1),i=this.style.getOuterHeight(this.el,!1);this.holderEl.style.width=""+parseInt(e,10)+"px",this.holderEl.style.height=""+parseInt(i,10)+"px",this.holderEl.style.margin="0",this.holderEl.style.padding="0",this.holderEl.style.background="none",this.holderEl.style.border="none",this.holderEl.style.display="inline-block",this.holderEl.style.left=this.el.getAttribute("left"),this.el.parentNode.insertBefore(this.holderEl,this.el)},removePlaceHolder:function(){return!!this.holderEl&&(this.holderEl.parentNode.removeChild(this.holderEl),this.holderEl=null,!0)},isTouchRoof:function(){var t=this.getPosition(this.el),e=(this.style.getClientHeight(),t.top);return e<this.topSpace},isTouchBottom:function(){var t=this.getPosition(this.el),e=this.style.getClientHeight(),i=t.bottom;return i>e-this.topSpace},isBackToHolder:function(){if(this.el&&this.holderEl){var t=(this.style.getClientHeight(),this.getPosition(this.el)),e=(t.top,t.bottom,this.getPosition(this.holderEl)),i=e.top;if(i>=this.topSpace)return!0}return!1},alignTargetLeft:function(){if(this.el&&this.holderEl){var t=this.getPosition(this.holderEl).left;this.el.style.left=t+"px"}},getPosition:function(t){var e=this.style.getPositionCore(t),i=this.style.getScrollLeft(window),s=this.style.getScrollTop(window),l=this.style.getOuterWidth(t,!1),o=this.style.getOuterHeight(t,!1);return{top:e.top-s,bottom:e.top-s+o,left:e.left-i,right:e.left-i+l,topAbs:e.top,bottomAbs:e.top+o,leftAbs:e.left,rightAbs:e.left+l}}}),oojs.define({name:"dynamicFloat",namespace:"dup.ui.painter",deps:{config:"dup.common.config",dom: