wishthis/semantic/dist/components/sidebar.min.js
2022-09-15 14:58:37 +02:00

11 lines
No EOL
15 KiB
JavaScript

/*
* # Fomantic UI - 2.9.0-beta.315+0963809
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(z,I,W,V){"use strict";z.isFunction=z.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},I=void 0!==I&&I.Math==Math?I:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),z.fn.sidebar=function(C){var w,e=z(this),A=z(I),F=z(W),E=z("body"),O=z("html"),M=z("head"),P=e.selector||"",B=(new Date).getTime(),H=[],R=C,L="string"==typeof R,j=[].slice.call(arguments,1),D=I.requestAnimationFrame||I.mozRequestAnimationFrame||I.webkitRequestAnimationFrame||I.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var o,r,e,s,a,l=z.isPlainObject(C)?z.extend(!0,{},z.fn.sidebar.settings,C):z.extend({},z.fn.sidebar.settings),i=l.selector,c=l.className,n=l.namespace,t=l.regExp,d=l.error,u="."+n,f="module-"+n,h=z(this),b=[I,W].indexOf(l.context)<0?z(W).find(l.context):E,m=b[0]===E[0],g=h.children(i.sidebar),p=(b.children(i.fixed),b.children(i.pusher)),v=this,y=h.data(f),x="",S="",T=!1,k={initialize:function(){k.debug("Initializing sidebar",C),k.create.id(),a=k.get.transitionEvent(),l.delaySetup?D(k.setup.layout):k.setup.layout(),D(function(){k.setup.cache()}),k.instantiate()},instantiate:function(){k.verbose("Storing instance of module",k),y=k,h.data(f,k)},create:{id:function(){e=(Math.random().toString(16)+"000000000").slice(2,10),r="."+e,k.verbose("Creating unique id for element",e)}},destroy:function(){k.verbose("Destroying previous module for",h),h.off(u).removeData(f),k.is.ios()&&k.remove.ios(),b.off(r),A.off(r),F.off(r)},event:{clickaway:function(e){var i;l.closable&&(i=0<p.find(e.target).length||p.is(e.target),e=b.is(e.target),i&&(k.verbose("User clicked on dimmed page"),k.hide()),e&&(k.verbose("User clicked on dimmable context (scaled out page)"),k.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===z(e.target).closest(i.sidebar).length&&e.preventDefault()}},bind:{clickaway:function(){k.verbose("Adding clickaway events to context",b),b.on("click"+r,k.event.clickaway).on("touchend"+r,k.event.clickaway)},scrollLock:function(){l.scrollLock&&(k.debug("Disabling page scroll"),(T=k.has.scrollbar())&&(k.save.bodyMargin(),k.set.bodyMargin()),b.addClass(c.locked)),k.verbose("Adding events to contain sidebar scroll"),F.on("touchmove"+r,k.event.touch),h.on("scroll"+u,k.event.containScroll)}},unbind:{clickaway:function(){k.verbose("Removing clickaway events from context",b),b.off(r)},scrollLock:function(){k.verbose("Removing scroll lock from page"),T&&k.restore.bodyMargin(),b.removeClass(c.locked),F.off(r),h.off("scroll"+u)}},add:{inlineCSS:function(){var e=k.cache.width||h.outerWidth(),i=k.cache.height||h.outerHeight(),n=k.is.rtl(),t=k.get.direction(),i={left:e,right:-e,top:i,bottom:-i};n&&(k.verbose("RTL detected, flipping widths"),i.left=-e,i.right=e),n="<style>","left"===t||"right"===t?(k.debug("Adding CSS rules for animation distance",e),n+=" .ui.visible."+t+".sidebar ~ .fixed, .ui.visible."+t+".sidebar ~ .pusher { -webkit-transform: translate3d("+i[t]+"px, 0, 0); transform: translate3d("+i[t]+"px, 0, 0); }"):"top"!==t&&"bottom"!=t||(n+=" .ui.visible."+t+".sidebar ~ .fixed, .ui.visible."+t+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+i[t]+"px, 0); transform: translate3d(0, "+i[t]+"px, 0); }"),k.is.ie()&&("left"===t||"right"===t?(k.debug("Adding CSS rules for animation distance",e),n+=" body.pushable > .ui.visible."+t+".sidebar ~ .pusher::after { -webkit-transform: translate3d("+i[t]+"px, 0, 0); transform: translate3d("+i[t]+"px, 0, 0); }"):"top"!==t&&"bottom"!=t||(n+=" body.pushable > .ui.visible."+t+".sidebar ~ .pusher::after { -webkit-transform: translate3d(0, "+i[t]+"px, 0); transform: translate3d(0, "+i[t]+"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 { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }"),o=z(n+="</style>").appendTo(M),k.debug("Adding sizing css to head",o)}},refresh:function(){k.verbose("Refreshing selector cache"),b=[I,W].indexOf(l.context)<0?z(W).find(l.context):z(l.context),g=b.children(i.sidebar),p=b.children(i.pusher),b.children(i.fixed),k.clear.cache()},refreshSidebars:function(){k.verbose("Refreshing other sidebars"),g=b.children(i.sidebar)},repaint:function(){k.verbose("Forcing repaint event"),v.style.display="none";v.offsetHeight;v.scrollTop=v.scrollTop,v.style.display=""},setup:{cache:function(){k.cache={width:h.outerWidth(),height:h.outerHeight()}},layout:function(){0===b.children(i.pusher).length&&(k.debug("Adding wrapper element for sidebar"),k.error(d.pusher),p=z('<div class="pusher" />'),b.children().not(i.omitted).not(g).wrapAll(p),k.refresh()),0!==h.nextAll(i.pusher).length&&h.nextAll(i.pusher)[0]===p[0]||(k.debug("Moved sidebar to correct parent element"),k.error(d.movedSidebar,v),h.detach().prependTo(b),k.refresh()),k.clear.cache(),k.set.pushable(),k.set.direction()}},attachEvents:function(e,i){var n=z(e);i=z.isFunction(k[i])?k[i]:k.toggle,0<n.length?(k.debug("Attaching sidebar events to element",e,i),n.on("click"+u,i)):k.error(d.notFound,e)},can:{leftBodyScrollbar:function(){return k.cache.leftBodyScrollbar===V&&(k.cache.leftBodyScrollbar=k.is.rtl()&&(k.is.iframe&&!k.is.firefox()||k.is.safari()||k.is.edge()||k.is.ie())),k.cache.leftBodyScrollbar}},save:{bodyMargin:function(){x=b.css((m?"margin-":"padding-")+(k.can.leftBodyScrollbar()?"left":"right"));var e=parseInt(x.replace(/[^\d.]/g,"")),i=m?I.innerWidth-W.documentElement.clientWidth:b[0].offsetWidth-b[0].clientWidth;S=e+i}},show:function(e){if(e=z.isFunction(e)?e:function(){},k.is.hidden())if(!1===l.onShow.call(v))k.verbose("Show callback returned false cancelling show");else{if(k.refreshSidebars(),l.overlay&&(k.error(d.overlay),l.transition="overlay"),k.refresh(),k.othersActive())if(k.debug("Other sidebars currently visible"),l.exclusive){if("overlay"!=l.transition)return void k.hideOthers(k.show);k.hideOthers()}else l.transition="overlay";k.pushPage(function(){e.call(v),l.onVisible.call(v)}),l.onChange.call(v)}else k.debug("Sidebar is already visible")},hide:function(e){e=z.isFunction(e)?e:function(){},(k.is.visible()||k.is.animating())&&!1!==l.onHide.call(v)&&(k.debug("Hiding sidebar",e),k.refreshSidebars(),k.pullPage(function(){e.call(v),l.onHidden.call(v)}),l.onChange.call(v))},othersAnimating:function(){return 0<g.not(h).filter("."+c.animating).length},othersVisible:function(){return 0<g.not(h).filter("."+c.visible).length},othersActive:function(){return k.othersVisible()||k.othersAnimating()},hideOthers:function(e){var i=g.not(h).filter("."+c.visible),n=i.length,t=0;e=e||function(){},i.sidebar("hide",function(){++t==n&&e()})},toggle:function(){k.verbose("Determining toggled direction"),k.is.hidden()?k.show():k.hide()},pushPage:function(i){var e,n,t=k.get.transition(),o="overlay"===t||k.othersActive()?h:p;i=z.isFunction(i)?i:function(){},l.returnScroll&&(s=(m?A:b).scrollTop()),"scale down"===l.transition&&k.scrollToTop(),k.bind.scrollLock(),k.set.transition(t),k.repaint(),t=function(){k.bind.clickaway(),k.add.inlineCSS(),k.set.animating(),k.set.visible()},e=function(){k.set.dimmed()},n=function(e){e.target==o[0]&&(o.off(a+r,n),k.remove.animating(),i.call(v))},o.off(a+r),o.on(a+r,n),D(t),l.dimPage&&!k.othersVisible()&&D(e)},pullPage:function(i){var e,n,t=k.get.transition(),o="overlay"==t||k.othersActive()?h:p;i=z.isFunction(i)?i:function(){},k.verbose("Removing context push state",k.get.direction()),k.unbind.clickaway(),k.unbind.scrollLock(),e=function(){k.set.transition(t),k.set.animating(),k.remove.visible(),l.dimPage&&!k.othersVisible()&&p.removeClass(c.dimmed)},n=function(e){e.target==o[0]&&(o.off(a+r,n),k.remove.animating(),k.remove.transition(),k.remove.inlineCSS(),"scale down"!==t&&!l.returnScroll||k.scrollBack(),i.call(v))},o.off(a+r),o.on(a+r,n),D(e)},scrollToTop:function(){k.verbose("Scrolling to top of page to avoid animation issues"),h.scrollTop(0),(m?A:b)[0].scrollTo(0,0)},scrollBack:function(){k.verbose("Scrolling back to original page position"),(m?A:b)[0].scrollTo(0,s)},clear:{cache:function(){k.verbose("Clearing cached dimensions"),k.cache={}}},set:{bodyMargin:function(){var n=k.can.leftBodyScrollbar()?"left":"right";b.css((m?"margin-":"padding-")+n,S+"px"),b.find(i.bodyFixed.replace("right",n)).each(function(){var e=z(this),i="fixed"===e.css("position")?"padding-"+n:n;e.css(i,"calc("+e.css(i)+" + "+S+"px)")})},ios:function(){O.addClass(c.ios)},pushed:function(){b.addClass(c.pushed)},pushable:function(){b.addClass(c.pushable)},dimmed:function(){p.addClass(c.dimmed)},active:function(){h.addClass(c.active)},animating:function(){h.addClass(c.animating)},transition:function(e){e=e||k.get.transition(),h.addClass(e)},direction:function(e){e=e||k.get.direction(),h.addClass(c[e])},visible:function(){h.addClass(c.visible)},overlay:function(){h.addClass(c.overlay)}},remove:{inlineCSS:function(){k.debug("Removing inline css styles",o),o&&0<o.length&&o.remove()},ios:function(){O.removeClass(c.ios)},pushed:function(){b.removeClass(c.pushed)},pushable:function(){b.removeClass(c.pushable)},active:function(){h.removeClass(c.active)},animating:function(){h.removeClass(c.animating)},transition:function(e){e=e||k.get.transition(),h.removeClass(e)},direction:function(e){e=e||k.get.direction(),h.removeClass(c[e])},visible:function(){h.removeClass(c.visible)},overlay:function(){h.removeClass(c.overlay)}},restore:{bodyMargin:function(){var n=k.can.leftBodyScrollbar()?"left":"right";b.css((m?"margin-":"padding-")+n,x),b.find(i.bodyFixed.replace("right",n)).each(function(){var e=z(this),i="fixed"===e.css("position")?"padding-"+n:n;e.css(i,"")})}},get:{direction:function(){return h.hasClass(c.top)?c.top:h.hasClass(c.right)?c.right:h.hasClass(c.bottom)?c.bottom:c.left},transition:function(){var e=k.get.direction(),e=k.is.mobile()?"auto"==l.mobileTransition?l.defaultTransition.mobile[e]:l.mobileTransition:"auto"==l.transition?l.defaultTransition.computer[e]:l.transition;return k.verbose("Determined transition",e),e},transitionEvent:function(){var e,i=W.createElement("element"),n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in n)if(i.style[e]!==V)return n[e]}},has:{scrollbar:function(){return m||"hidden"!==b.css("overflow-y")}},is:{safari:function(){return k.cache.isSafari===V&&(k.cache.isSafari=/constructor/i.test(I.HTMLElement)||!!I.ApplePaySession),k.cache.isSafari},edge:function(){return k.cache.isEdge===V&&(k.cache.isEdge=!!I.setImmediate&&!k.is.ie()),k.cache.isEdge},firefox:function(){return k.cache.isFirefox===V&&(k.cache.isFirefox=!!I.InstallTrigger),k.cache.isFirefox},iframe:function(){return!(self===top)},ie:function(){var e,i;return k.cache.isIE===V&&(e=!I.ActiveXObject&&"ActiveXObject"in I,i="ActiveXObject"in I,k.cache.isIE=e||i),k.cache.isIE},ios:function(){var e=navigator.userAgent,i=e.match(t.ios),n=e.match(t.mobileChrome);return!(!i||n)&&(k.verbose("Browser was found to be iOS",e),!0)},mobile:function(){var e=navigator.userAgent;return e.match(t.mobile)?(k.verbose("Browser was found to be mobile",e),!0):(k.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!k.is.visible()},visible:function(){return h.hasClass(c.visible)},open:function(){return k.is.visible()},closed:function(){return k.is.hidden()},vertical:function(){return h.hasClass(c.top)},animating:function(){return b.hasClass(c.animating)},rtl:function(){return k.cache.isRTL===V&&(k.cache.isRTL="rtl"===h.attr("dir")||"rtl"===h.css("direction")||"rtl"===E.attr("dir")||"rtl"===E.css("direction")||"rtl"===b.attr("dir")||"rtl"===b.css("direction")),k.cache.isRTL}},setting:function(e,i){if(k.debug("Changing setting",e,i),z.isPlainObject(e))z.extend(!0,l,e);else{if(i===V)return l[e];z.isPlainObject(l[e])?z.extend(!0,l[e],i):l[e]=i}},internal:function(e,i){if(z.isPlainObject(e))z.extend(!0,k,e);else{if(i===V)return k[e];k[e]=i}},debug:function(){!l.silent&&l.debug&&(l.performance?k.performance.log(arguments):(k.debug=Function.prototype.bind.call(console.info,console,l.name+":"),k.debug.apply(console,arguments)))},verbose:function(){!l.silent&&l.verbose&&l.debug&&(l.performance?k.performance.log(arguments):(k.verbose=Function.prototype.bind.call(console.info,console,l.name+":"),k.verbose.apply(console,arguments)))},error:function(){l.silent||(k.error=Function.prototype.bind.call(console.error,console,l.name+":"),k.error.apply(console,arguments))},performance:{log:function(e){var i,n;l.performance&&(n=(i=(new Date).getTime())-(B||i),B=i,H.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:v,"Execution Time":n})),clearTimeout(k.performance.timer),k.performance.timer=setTimeout(k.performance.display,500)},display:function(){var e=l.name+":",n=0;B=!1,clearTimeout(k.performance.timer),z.each(H,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",P&&(e+=" '"+P+"'"),(console.group!==V||console.table!==V)&&0<H.length&&(console.groupCollapsed(e),console.table?console.table(H):z.each(H,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),H=[]}},invoke:function(t,e,i){var o,r,n,s=y;return e=e||j,i=i||v,"string"==typeof t&&s!==V&&(t=t.split(/[\. ]/),o=t.length-1,z.each(t,function(e,i){var n=e!=o?i+t[e+1].charAt(0).toUpperCase()+t[e+1].slice(1):t;if(z.isPlainObject(s[n])&&e!=o)s=s[n];else{if(s[n]!==V)return r=s[n],!1;{if(!z.isPlainObject(s[i])||e==o)return s[i]!==V?r=s[i]:k.error(d.method,t),!1;s=s[i]}}})),z.isFunction(r)?n=r.apply(i,e):r!==V&&(n=r),Array.isArray(w)?w.push(n):w!==V?w=[w,n]:n!==V&&(w=n),r}};L?(y===V&&k.initialize(),k.invoke(R)):(y!==V&&k.invoke("destroy"),k.initialize())}),w!==V?w:this},z.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",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);