toolshed-8.x-1.x-dev/js/Dock.min.js

js/Dock.min.js
"use strict";((e,n)=>{n.Dock={createItem(e,t,i={}){var o={edge:"TOP",offset:0};if(!i||i.detectOpts)for(var s,c=/(?:^|\s)tsdock--(opt|edge)-([-\w]+)(?:\s|$)/g,h=e.attr("class");null!==(s=c.exec(h));)"opt"===s[1]?o[s[2]]=!0:"edge"===s[1]&&([,,o.edge]=s);e=new n.Dock.DockItem(e,t,{...o,...i});n.Dock.addDocker(o.edge.toUpperCase()||"TOP",e)},addDocker(e,t){n.Dock.containers[e]&&n.Dock.containers[e].addItem(t)}},n.Dock.DockContainer=class{constructor(){this.active=!1,this.container=null,this.items=[]}isActive(){return this.active}addItem(e){(e.dockTo=this).items.push(e),this.active||this.init()}removeItem(t){this.items=this.items.filter(e=>e!==t),delete t.dockTo,!this.items.length&&this.container&&this.container.hide()}init(){this.container=e('<div class="tsdock-container"/>').appendTo(e("body")),this.initContainer(),this.active=!0,n.events.scroll.add(this),n.events.resize.add(this),this.onResize(new Event("resize"),n.winRect)}onScroll(e,t,i){const o=new n.Geom.Rect(t);o.offset(i.left,i.top),this.items.forEach(e=>{if(e.isDocked^this.isDocking(e,o))return e.isDocked?e.deactivateDock():e.activateDock(this.container)},this)}onResize(e,t){var i={top:document.documentElement.scrollTop||document.body.scrollTop,left:document.documentElement.scrollLeft||document.body.scrollLeft};t.top!==this.container.offset().top&&this.container.css({top:t.top}),this.onScroll(e,t,i)}destroy(){n.events.scroll.remove(this),n.events.resize.remove(this),this.container&&this.container.remove()}},n.Dock.TopDockContainer=class extends n.Dock.DockContainer{initContainer(){this.container.css({position:"fixed",top:0,width:"100%",boxSizing:"border-box"})}isDocking(e,t){var i=e.getContainerRect();let o=Math.floor(e.placeholder.offset().top+e.config.offset);return e.config.offset<0&&(o+=e.placeholder.height()),o<t.top&&i.bottom>t.top&&e.elem.outerHeight()<i.getHeight()}},n.Dock.DockItem=class{constructor(e,t,i){this.elem=e,this.bounds=t,this.config=i,this.elem.addClass("tsdock-item"),this.isDocked=!1,this.config.animate&&(this.mode=this.config.animate.type||"slide"),this.init()}init(){this.placeholder=this.elem.wrap('<div class="tsdock__placeholder"/>').parent(),this.placeholder.css({position:this.elem.css("position")}),this.height=this.elem.outerHeight(),this.config.trackMutations&&MutationObserver&&(this.observer=new MutationObserver(this._mutated.bind(this)),this.observer.observe(this.elem[0],{attributes:!0,childList:!0,subtree:!0,characterData:!0}))}_mutations(){this.observer.disconnect();var e,t=this.elem.outerHeight();this.height!==t&&(this.height=t||0,this.placeholder&&this.placeholder.height(t),t=new n.Geom.Rect(n.winRect),e=document.documentElement.scrollTop||document.body.scrollTop,this.scroll(e,t)),this.observer.observe(this.elem[0],{attributes:!0,childList:!0,subtree:!0,characterData:!0})}getContainerRect(){var{top:e,left:t}=this.bounds.offset();return new n.Geom.Rect(e,t,e+this.bounds.outerHeight(),t+this.bounds.outerWidth())}activateDock(e){this.isDocked||(this.isDocked=!0,this.placeholder.height(this.height),e.append(this.elem),this.elem.addClass("tsdock-item--docked"),this.elem.trigger("ToolshedDocking.docked"))}deactivateDock(){this.isDocked&&(this.isDocked=!1,this.placeholder.append(this.elem),this.elem.removeClass("tsdock-item--docked"),this.placeholder.css({height:""}),this.elem.trigger("ToolshedDocking.undocked"))}destroy(){this.observer&&this.observer.disconnect(),this.deactivateDock(),this.placeholder&&this.elem.unwrap(".tsdock__placeholder")}},n.Dock.containers={TOP:new n.Dock.TopDockContainer}})(jQuery,Drupal.Toolshed);

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc