wishthis/semantic/dist/components/sidebar.min.js
2023-08-17 11:47:40 +02:00

11 lines
No EOL
15 KiB
JavaScript

/*
* # Fomantic UI - 2.9.2
* https://github.com/fomantic/Fomantic-UI
* https://fomantic-ui.com/
*
* Copyright 2023 Contributors
* Released under the MIT license
* https://opensource.org/licenses/MIT
*
*/
!function(D,R,I){"use strict";function V(e){return"function"==typeof e&&"number"!=typeof e.nodeType}R=void 0!==R&&R.Math===Math?R:globalThis,D.fn.sidebar=function(T){var k,e=D(this),w=D(R),A=D(I),F=D("body"),O=D("html"),P=D("head"),E=e.selector||"",B=Date.now(),H=[],M=T,L="string"==typeof M,j=[].slice.call(arguments,1);return e.each(function(){var t,r,e,s,a=D.isPlainObject(T)?D.extend(!0,{},D.fn.sidebar.settings,T):D.extend({},D.fn.sidebar.settings),i=a.selector,l=a.className,n=a.namespace,o=a.regExp,c=a.error,d="."+n,u="module-"+n,f=D(this),h=[R,I].indexOf(a.context)<0?A.find(a.context):F,b=h[0]===F[0],g=f.children(i.sidebar),m=(h.children(i.fixed),h.children(i.pusher)),v=this,p=f.data(u),y="",x="",S=!1,C={initialize:function(){C.debug("Initializing sidebar",T),C.create.id(),a.delaySetup?requestAnimationFrame(C.setup.layout):C.setup.layout(),requestAnimationFrame(function(){C.setup.cache()}),C.instantiate()},instantiate:function(){C.verbose("Storing instance of module",C),p=C,f.data(u,C)},create:{id:function(){e=(Math.random().toString(16)+"000000000").slice(2,10),r="."+e,C.verbose("Creating unique id for element",e)}},destroy:function(){C.verbose("Destroying previous module for",f),f.off(d).removeData(u),C.is.ios()&&C.remove.ios(),h.off(r),w.off(r),A.off(r)},event:{clickaway:function(e){var i;a.closable&&(i=0<m.find(e.target).length||m.is(e.target),e=h.is(e.target),i&&(C.verbose("User clicked on dimmed page"),C.hide()),e)&&(C.verbose("User clicked on dimmable context (scaled out page)"),C.hide())},touch:function(e){},containScroll:function(e){v.scrollTop<=0&&(v.scrollTop=1),v.scrollTop+v.offsetHeight>=v.scrollHeight&&(v.scrollTop=v.scrollHeight-v.offsetHeight-1)},scroll:function(e){0===D(e.target).closest(i.sidebar).length&&e.preventDefault()}},bind:{clickaway:function(){C.verbose("Adding clickaway events to context",h),h.on("click"+r,C.event.clickaway).on("touchend"+r,C.event.clickaway)},scrollLock:function(){a.scrollLock&&(C.debug("Disabling page scroll"),(S=C.has.scrollbar())&&(C.save.bodyMargin(),C.set.bodyMargin()),h.addClass(l.locked)),C.verbose("Adding events to contain sidebar scroll"),A.on("touchmove"+r,C.event.touch),f.on("scroll"+d,C.event.containScroll)}},unbind:{clickaway:function(){C.verbose("Removing clickaway events from context",h),h.off(r)},scrollLock:function(){C.verbose("Removing scroll lock from page"),S&&C.restore.bodyMargin(),h.removeClass(l.locked),A.off(r),f.off("scroll"+d)}},add:{inlineCSS:function(){var e=C.cache.width||f.outerWidth(),i=C.cache.height||f.outerHeight(),n=C.is.rtl(),o=C.get.direction(),i={left:e,right:-e,top:i,bottom:-i};n&&(C.verbose("RTL detected, flipping widths"),i.left=-e,i.right=e),n="<style>","left"===o||"right"===o?(C.debug("Adding CSS rules for animation distance",e),n+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { transform: translate3d("+i[o]+"px, 0, 0); }"):"top"!==o&&"bottom"!==o||(n+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { transform: translate3d(0, "+i[o]+"px, 0); }"),C.is.ie()&&("left"===o||"right"===o?(C.debug("Adding CSS rules for animation distance",e),n+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher::after { transform: translate3d("+i[o]+"px, 0, 0); }"):"top"!==o&&"bottom"!==o||(n+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher::after { transform: translate3d(0, "+i[o]+"px, 0); }"),n+=" body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher::after, body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher::after { transform: translate3d(0, 0, 0); }"),t=D(n+="</style>").appendTo(P),C.debug("Adding sizing css to head",t)}},refresh:function(){C.verbose("Refreshing selector cache"),h=[R,I].indexOf(a.context)<0?A.find(a.context):F,C.refreshSidebars(),m=h.children(i.pusher),h.children(i.fixed),C.clear.cache()},refreshSidebars:function(){C.verbose("Refreshing other sidebars"),g=h.children(i.sidebar)},repaint:function(){C.verbose("Forcing repaint event"),v.style.display="none";v.offsetHeight;v.scrollTop=v.scrollTop,v.style.display=""},setup:{cache:function(){C.cache={width:f.outerWidth(),height:f.outerHeight()}},layout:function(){0===h.children(i.pusher).length&&(C.debug("Adding wrapper element for sidebar"),C.error(c.pusher),m=D('<div class="pusher" />'),h.children().not(i.omitted).not(g).wrapAll(m),C.refresh()),0!==f.nextAll(i.pusher).length&&f.nextAll(i.pusher)[0]===m[0]||(C.debug("Moved sidebar to correct parent element"),C.error(c.movedSidebar,v),f.detach().prependTo(h),C.refresh()),C.clear.cache(),C.set.pushable(),C.set.direction()}},attachEvents:function(e,i){var n=D(e);i=V(C[i])?C[i]:C.toggle,0<n.length?(C.debug("Attaching sidebar events to element",e,i),n.on("click"+d,i)):C.error(c.notFound,e)},can:{leftBodyScrollbar:function(){return void 0===C.cache.leftBodyScrollbar&&(C.cache.leftBodyScrollbar=C.is.rtl()&&(C.is.iframe&&!C.is.firefox()||C.is.safari()||C.is.edge()||C.is.ie())),C.cache.leftBodyScrollbar}},save:{bodyMargin:function(){y=h.css((b?"margin-":"padding-")+(C.can.leftBodyScrollbar()?"left":"right"));var e=parseInt(y.replace(/[^\d.]/g,""),10),i=b?R.innerWidth-I.documentElement.clientWidth:h[0].offsetWidth-h[0].clientWidth;x=e+i}},show:function(e){if(e=V(e)?e:function(){},C.is.hidden())if(!1===a.onShow.call(v))C.verbose("Show callback returned false cancelling show");else{if(a.overlay&&(C.error(c.overlay),a.transition="overlay"),C.refresh(),C.othersActive())if(C.debug("Other sidebars currently visible"),a.exclusive){if("overlay"!==a.transition)return void C.hideOthers(C.show);C.hideOthers()}else a.transition="overlay";C.set.dimmerStyles(),C.pushPage(function(){e.call(v),a.onVisible.call(v)}),a.onChange.call(v)}else C.debug("Sidebar is already visible")},hide:function(e){e=V(e)?e:function(){},(C.is.visible()||C.is.animating())&&!1!==a.onHide.call(v)&&(C.debug("Hiding sidebar",e),C.refreshSidebars(),C.pullPage(function(){e.call(v),a.onHidden.call(v)}),a.onChange.call(v))},othersAnimating:function(){return 0<g.not(f).filter("."+l.animating).length},othersVisible:function(){return 0<g.not(f).filter("."+l.visible).length},othersActive:function(){return C.othersVisible()||C.othersAnimating()},hideOthers:function(e){var i=g.not(f).filter("."+l.visible),n=i.length,o=0;e=e||function(){},i.sidebar("hide",function(){++o===n&&e()})},toggle:function(){C.verbose("Determining toggled direction"),C.is.hidden()?C.show():C.hide()},pushPage:function(i){var e,n,o=C.get.transition(),t="overlay"===o||C.othersActive()?f:m;i=V(i)?i:function(){},a.returnScroll&&(s=(b?w:h).scrollTop()),"scale down"===a.transition&&C.scrollToTop(),C.bind.scrollLock(),C.set.transition(o),C.repaint(),o=function(){C.bind.clickaway(),C.add.inlineCSS(),C.set.animating(),C.set.visible()},e=function(){C.set.dimmed()},n=function(e){e.target===t[0]&&(t.off("transitionend"+r,n),C.remove.animating(),i.call(v))},t.off("transitionend"+r),t.on("transitionend"+r,n),requestAnimationFrame(o),a.dimPage&&!C.othersVisible()&&requestAnimationFrame(e)},pullPage:function(i){var e,n,o=C.get.transition(),t="overlay"===o||C.othersActive()?f:m;i=V(i)?i:function(){},C.verbose("Removing context push state",C.get.direction()),C.unbind.clickaway(),C.unbind.scrollLock(),e=function(){C.set.transition(o),C.set.animating(),a.dimPage&&!C.othersVisible()&&C.set.closing(),C.remove.visible()},n=function(e){e.target===t[0]&&(t.off("transitionend"+r,n),C.remove.animating(),C.remove.closing(),C.remove.transition(),C.remove.inlineCSS(),"scale down"!==o&&!a.returnScroll||C.scrollBack(),a.dimPage&&!C.othersVisible()&&m.removeClass(l.dimmed),i.call(v))},t.off("transitionend"+r),t.on("transitionend"+r,n),requestAnimationFrame(e)},scrollToTop:function(){C.verbose("Scrolling to top of page to avoid animation issues"),f.scrollTop(0),(b?w:h)[0].scrollTo(0,0)},scrollBack:function(){C.verbose("Scrolling back to original page position"),(b?w:h)[0].scrollTo(0,s)},clear:{cache:function(){C.verbose("Clearing cached dimensions"),C.cache={}}},set:{bodyMargin:function(){var n=C.can.leftBodyScrollbar()?"left":"right";h.css((b?"margin-":"padding-")+n,x+"px"),h.find(i.bodyFixed.replace("right",n)).each(function(){var e=D(this),i="fixed"===e.css("position")?"padding-"+n:n;e.css(i,"calc("+e.css(i)+" + "+x+"px)")})},dimmerStyles:function(){a.blurring?m.addClass(l.blurring):m.removeClass(l.blurring)},ios:function(){O.addClass(l.ios)},pushed:function(){h.addClass(l.pushed)},pushable:function(){h.addClass(l.pushable)},dimmed:function(){m.addClass(l.dimmed)},active:function(){f.addClass(l.active)},animating:function(){f.addClass(l.animating)},closing:function(){m.addClass(l.closing)},transition:function(e){e=e||C.get.transition(),f.addClass(e)},direction:function(e){e=e||C.get.direction(),f.addClass(l[e])},visible:function(){f.addClass(l.visible)},overlay:function(){f.addClass(l.overlay)}},remove:{inlineCSS:function(){C.debug("Removing inline css styles",t),t&&0<t.length&&t.remove()},ios:function(){O.removeClass(l.ios)},pushed:function(){h.removeClass(l.pushed)},pushable:function(){h.removeClass(l.pushable)},active:function(){f.removeClass(l.active)},animating:function(){f.removeClass(l.animating)},closing:function(){m.removeClass(l.closing)},transition:function(e){e=e||C.get.transition(),f.removeClass(e)},direction:function(e){e=e||C.get.direction(),f.removeClass(l[e])},visible:function(){f.removeClass(l.visible)},overlay:function(){f.removeClass(l.overlay)}},restore:{bodyMargin:function(){var n=C.can.leftBodyScrollbar()?"left":"right";h.css((b?"margin-":"padding-")+n,y),h.find(i.bodyFixed.replace("right",n)).each(function(){var e=D(this),i="fixed"===e.css("position")?"padding-"+n:n;e.css(i,"")})}},get:{direction:function(){return f.hasClass(l.top)?l.top:f.hasClass(l.right)?l.right:f.hasClass(l.bottom)?l.bottom:l.left},transition:function(){var e=C.get.direction(),e=C.is.mobile()?"auto"===a.mobileTransition?a.defaultTransition.mobile[e]:a.mobileTransition:"auto"===a.transition?a.defaultTransition.computer[e]:a.transition;return C.verbose("Determined transition",e),e}},has:{scrollbar:function(){return b||"hidden"!==h.css("overflow-y")}},is:{safari:function(){return void 0===C.cache.isSafari&&(C.cache.isSafari=/constructor/i.test(R.HTMLElement)||!!R.ApplePaySession),C.cache.isSafari},edge:function(){return void 0===C.cache.isEdge&&(C.cache.isEdge=!!R.setImmediate&&!C.is.ie()),C.cache.isEdge},firefox:function(){return void 0===C.cache.isFirefox&&(C.cache.isFirefox=!!R.InstallTrigger),C.cache.isFirefox},iframe:function(){return!(self===top)},ie:function(){var e,i;return void 0===C.cache.isIE&&(e=!R.ActiveXObject&&"ActiveXObject"in R,i="ActiveXObject"in R,C.cache.isIE=e||i),C.cache.isIE},ios:function(){var e=navigator.userAgent,i=e.match(o.ios),n=e.match(o.mobileChrome);return!(!i||n||(C.verbose("Browser was found to be iOS",e),0))},mobile:function(){var e=navigator.userAgent;return e.match(o.mobile)?(C.verbose("Browser was found to be mobile",e),!0):(C.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!C.is.visible()},visible:function(){return f.hasClass(l.visible)},open:function(){return C.is.visible()},closed:function(){return C.is.hidden()},vertical:function(){return f.hasClass(l.top)},animating:function(){return h.hasClass(l.animating)},rtl:function(){return void 0===C.cache.isRTL&&(C.cache.isRTL="rtl"===f.attr("dir")||"rtl"===f.css("direction")||"rtl"===F.attr("dir")||"rtl"===F.css("direction")||"rtl"===h.attr("dir")||"rtl"===h.css("direction")),C.cache.isRTL}},setting:function(e,i){if(C.debug("Changing setting",e,i),D.isPlainObject(e))D.extend(!0,a,e);else{if(void 0===i)return a[e];D.isPlainObject(a[e])?D.extend(!0,a[e],i):a[e]=i}},internal:function(e,i){if(D.isPlainObject(e))D.extend(!0,C,e);else{if(void 0===i)return C[e];C[e]=i}},debug:function(){!a.silent&&a.debug&&(a.performance?C.performance.log(arguments):(C.debug=Function.prototype.bind.call(console.info,console,a.name+":"),C.debug.apply(console,arguments)))},verbose:function(){!a.silent&&a.verbose&&a.debug&&(a.performance?C.performance.log(arguments):(C.verbose=Function.prototype.bind.call(console.info,console,a.name+":"),C.verbose.apply(console,arguments)))},error:function(){a.silent||(C.error=Function.prototype.bind.call(console.error,console,a.name+":"),C.error.apply(console,arguments))},performance:{log:function(e){var i,n;a.performance&&(n=(i=Date.now())-(B||i),B=i,H.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:v,"Execution Time":n})),clearTimeout(C.performance.timer),C.performance.timer=setTimeout(C.performance.display,500)},display:function(){var e=a.name+":",n=0;B=!1,clearTimeout(C.performance.timer),D.each(H,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",E&&(e+=" '"+E+"'"),0<H.length&&(console.groupCollapsed(e),console.table?console.table(H):D.each(H,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),H=[]}},invoke:function(o,e,i){var t,r,n,s=p;return e=e||j,i=i||v,"string"==typeof o&&void 0!==s&&(o=o.split(/[ .]/),t=o.length-1,D.each(o,function(e,i){var n=e!==t?i+o[e+1].charAt(0).toUpperCase()+o[e+1].slice(1):o;if(D.isPlainObject(s[n])&&e!==t)s=s[n];else{if(void 0!==s[n])return r=s[n],!1;{if(!D.isPlainObject(s[i])||e===t)return void 0!==s[i]?r=s[i]:C.error(c.method,o),!1;s=s[i]}}})),V(r)?n=r.apply(i,e):void 0!==r&&(n=r),Array.isArray(k)?k.push(n):void 0!==k?k=[k,n]:void 0!==n&&(k=n),r}};L?(void 0===p&&C.initialize(),C.invoke(M)):(void 0!==p&&C.invoke("destroy"),C.initialize())}),void 0!==k?k:this},D.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",silent:!1,debug:!1,verbose:!1,performance:!0,transition:"auto",mobileTransition:"auto",defaultTransition:{computer:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"},mobile:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"}},context:"body",exclusive:!1,closable:!0,dimPage:!0,scrollLock:!1,returnScroll:!1,delaySetup:!1,onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",animating:"animating",blurring:"blurring",closing:"closing",dimmed:"dimmed",ios:"ios",locked:"locked",pushable:"pushable",pushed:"pushed",right:"right",top:"top",left:"left",bottom:"bottom",visible:"visible"},selector:{bodyFixed:"> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close",fixed:".fixed",omitted:"script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed",pusher:".pusher",sidebar:".ui.sidebar"},regExp:{ios:/(iPad|iPhone|iPod)/g,mobileChrome:/(CriOS)/g,mobile:/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g},error:{method:"The method you called is not defined.",pusher:"Had to add pusher element. For optimal performance make sure body content is inside a pusher element",movedSidebar:"Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag",overlay:"The overlay setting is no longer supported, use animation: overlay",notFound:"There were no elements that matched the specified selector"}}}(jQuery,window,document);