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

11 lines
15 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
2022-09-15 12:58:37 +00:00
* # Fomantic UI - 2.9.0-beta.315+0963809
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-15 12:58:37 +00:00
!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);