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

/* 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:"dup.common.utility.dom",slot:"dup.business.slot",frame:"dup.business.frame",decorator:"dup.ui.painter.dynamicFloatDecorator",viewWatch:"dup.business.viewWatch",richMaterial:"dup.ui.painter.richMaterial",monitor:"dup.business.monitor"},validate:function(t){return!0},render:function(t){if(this.slot.setStatus(t.id,this.config.STATUS_RENDERED),this.validate(t)){if(!this.slot.adInfoIsAvailable(t))return!1;this.monitor.sendLog(t);var e=this.slot.processSlotInfo(t);t.width=e.width,t.height=e.height;var i=this.richMaterial.render(t);if(!i){var s=t.response.placement,l=s.container,o=this.dom.g(t.containerId);if(o){var h=this.frame.getFrameHTML(t);o.innerHTML=h,this.decorator.decorate(o,t.width||l.width,t.height||l.height),this.viewWatch.regisetViewWatch(t)}}}}});})(_ssp_global.oojs);