agenda-libre-ruby/public/webshims/1.15.8/shims/sticky.js

1 line
9.3 KiB
JavaScript
Raw Normal View History

webshim.register("sticky",function(a,b,c,d,e,f){"use strict";function g(a,b,c){var e=a+":",f=d.createElement("test"),g=f.style;return g.cssText=c?e+b:e+["-webkit-","-moz-","-ms-","-o-",""].join(b+";"+e)+b+";",g[a]}function h(){return{top:a.css(this,"top"),bottom:a.css(this,"bottom")}}function i(b){k++,l++,this.evtid=".wsstickyid"+k,this.$el=a(b).data("wsSticky",this),this.isTable=this.$el.is("thead, tbody, tfoot"),this.$parent=this.$el.parent(),this.elStyle=b.style,this.ankered="",this.isSticky=!1,this.$placeholder=null,this.stickyData={inline:{}},this.parentData={},this.getParentData=this.getCommonParentData,this.addEvents(),this.update(!0)}function j(b){k++,l++,this.evtid=".wsstickyid"+k,this.$el=a(b).data("wsSticky",this),this.isTable=this.$el.is("thead, tbody, tfoot"),this.$parent=this.$el.parent(),this.elStyle=b.style,this.ankered="",this.isSticky=!1,this.$placeholder=null,this.stickyData={inline:{}},this.parentData={},"static"==this.$parent.css("position")&&this.$parent.css("position","relative"),this.updatePos2=this.updatePos2.bind(this),this.addEvents(),this.update(!0)}var k=0,l=0,m=a(c),n=function(){var a,b="pageYOffset";return b in c?function(){return c[b]}:(a=d.documentElement,function(){return a.scrollTop})}(),o="ontouchstart"in c||c.matchMedia("(max-device-width: 721px)").matches,p={fixed:g("position","fixed",!0),sticky:g("position","sticky")},q={getPosition:function(){this.isSticky||(this.position={top:this.$el.css("top"),bottom:this.$el.css("bottom")},("auto"!=this.position.top&&"auto"!=this.position.bottom||"auto"==this.position.top&&"auto"==this.position.bottom)&&"static"==this.$el.css("position")&&(this.position=a.swap(this.$el[0],{position:"absolute"},h)),"auto"!==this.position.top?this.ankered="top":"auto"!==this.position.bottom&&(this.ankered="bottom"),"top"==this.ankered?this.position.top=parseFloat(this.position.top,10)||0:"bottom"==this.ankered&&(this.position.bottom=parseFloat(this.position.bottom,10)||0))},update:function(a){!this.disabled&&this.$el[0].offsetWidth&&(a&&(this.isSticky&&this.removeSticky(),this.getPosition()),this.updateDimension())},setTdWidth:function(){this.isTable&&this.$el.find("td, th").each(this._setInlineWidth)},_setInlineWidth:function(){a.data(this,"inlineWidth",this.style.width),a(this).innerWidth(a(this).innerWidth())},_restoreInlineWidth:function(){this.style.width=a.data(this,"inlineWidth")||"",a.removeData(this,"inlineWidth")},removeSticky:function(){this.$el.removeClass("ws-sticky-on"),this.$el.css(this.stickyData.inline),this.$placeholder.detach(),this.isSticky=!1,this.isTable&&this.$el.find("td, th").each(this._restoreInlineWidth)},commonAddEvents:function(){var b,e=this,f=function(){e.update()},g=this.$el.data("stickymedia"),h=c.matchMedia&&g?matchMedia(g):!1;m.one("load",f),a(d).on("updateshadowdom"+this.evtid,f),this.$el.on("updatesticky"+this.evtid,function(a){e.update(!0),a.stopPropagation()}),this.$el.on("disablesticky"+this.evtid,function(a){e.disable(!0),a.stopPropagation()}),this.$el.on("enablesticky"+this.evtid,function(a){e.disable(!1),a.stopPropagation()}),this.$el.on("remove"+this.evtid+" destroysticky"+this.evtid,function(b){m.off(e.evtid),a(d).off(e.evtid),e.$el.off(e.evtid),e.$parent.off(e.evtid),e.$el.removeData("wsSticky").removeClass("ws-sticky"),e.$placeholder&&(e.$el.removeClass("ws-sticky-on"),e.$placeholder.remove()),l--,b.stopPropagation()}),h&&h.addListener&&(b=function(){e.disable(!h.matches)},h.addListener(b),b())},disable:function(a){return arguments.length?void(this.disabled!=a&&(this.disabled=!!a,this.disabled?this.isSticky&&this.removeSticky():this.update(!0))):this.disabled},setSticky:function(){this.$placeholder||(this.$placeholder=a(this.isTable?this.$el[0].cloneNode(!0):d.createElement(this.$el[0].nodeName||"div")),this.$placeholder.addClass("ws-fixedsticky-placeholder").removeClass("ws-sticky")),this.setTdWidth(),this.$placeholder.insertAfter(this.$el).outerHeight(this.stickyData.outerHeight,!0).outerWidth(this.stickyData.outerWidth),this.isSticky=!0,this.$el.addClass("ws-sticky-on"),this.isTable||this.stickyData.width!=this.$