wishthis/semantic/dist/components/sidebar.min.js

11 lines
16 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-10-10 08:26:02 +00:00
* # Fomantic UI - 2.9.0
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2022 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
2022-09-30 13:48:25 +00:00
!function(z,I,V,W){"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(k){var w,e=z(this),A=z(I),F=z(V),E=z("body"),O=z("html"),P=z("head"),M=e.selector||"",B=(new Date).getTime(),H=[],R=k,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(k)?z.extend(!0,{},z.fn.sidebar.settings,k):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,V].indexOf(l.context)<0?F.find(l.context):E,g=b[0]===E[0],m=h.children(i.sidebar),p=(b.children(i.fixed),b.children(i.pusher)),v=this,y=h.data(f),x="",S="",C=!1,T={initialize:function(){T.debug("Initializing sidebar",k),T.create.id(),a=T.get.transitionEvent(),l.delaySetup?D(T.setup.layout):T.setup.layout(),D(function(){T.setup.cache()}),T.instantiate()},instantiate:function(){T.verbose("Storing instance of module",T),y=T,h.data(f,T)},create:{id:function(){e=(Math.random().toString(16)+"000000000").slice(2,10),r="."+e,T.verbose("Creating unique id for element",e)}},destroy:function(){T.verbose("Destroying previous module for",h),h.off(u).removeData(f),T.is.ios()&&T.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&&(T.verbose("User clicked on dimmed page"),T.hide()),e&&(T.verbose("User clicked on dimmable context (scaled out page)"),T.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(){T.verbose("Adding clickaway events to context",b),b.on("click"+r,T.event.clickaway).on("touchend"+r,T.event.clickaway)},scrollLock:function(){l.scrollLock&&(T.debug("Disabling page scroll"),(C=T.has.scrollbar())&&(T.save.bodyMargin(),T.set.bodyMargin()),b.addClass(c.locked)),T.verbose("Adding events to contain sidebar scroll"),F.on("touchmove"+r,T.event.touch),h.on("scroll"+u,T.event.containScroll)}},unbind:{clickaway:function(){T.verbose("Removing clickaway events from context",b),b.off(r)},scrollLock:function(){T.verbose("Removing scroll lock from page"),C&&T.restore.bodyMargin(),b.removeClass(c.locked),F.off(r),h.off("scroll"+u)}},add:{inlineCSS:function(){var e=T.cache.width||h.outerWidth(),i=T.cache.height||h.outerHeight(),n=T.is.rtl(),t=T.get.direction(),i={left:e,right:-e,top:i,bottom:-i};n&&(T.verbose("RTL detected, flipping widths"),i.left=-e,i.right=e),n="<style>","left"===t||"right"===t?(T.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); }"),T.is.ie()&&("left"===t||"right"===t?(T.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); tr