11 lines
No EOL
16 KiB
JavaScript
11 lines
No EOL
16 KiB
JavaScript
/*
|
|
* # Fomantic UI - 2.9.0
|
|
* 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,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); transform: translate3d(0, 0, 0); }"),o=z(n+="</style>").appendTo(P),T.debug("Adding sizing css to head",o)}},refresh:function(){T.verbose("Refreshing selector cache"),b=[I,V].indexOf(l.context)<0?F.find(l.context):E,T.refreshSidebars(),p=b.children(i.pusher),b.children(i.fixed),T.clear.cache()},refreshSidebars:function(){T.verbose("Refreshing other sidebars"),m=b.children(i.sidebar)},repaint:function(){T.verbose("Forcing repaint event"),v.style.display="none";v.offsetHeight;v.scrollTop=v.scrollTop,v.style.display=""},setup:{cache:function(){T.cache={width:h.outerWidth(),height:h.outerHeight()}},layout:function(){0===b.children(i.pusher).length&&(T.debug("Adding wrapper element for sidebar"),T.error(d.pusher),p=z('<div class="pusher" />'),b.children().not(i.omitted).not(m).wrapAll(p),T.refresh()),0!==h.nextAll(i.pusher).length&&h.nextAll(i.pusher)[0]===p[0]||(T.debug("Moved sidebar to correct parent element"),T.error(d.movedSidebar,v),h.detach().prependTo(b),T.refresh()),T.clear.cache(),T.set.pushable(),T.set.direction()}},attachEvents:function(e,i){var n=z(e);i=z.isFunction(T[i])?T[i]:T.toggle,0<n.length?(T.debug("Attaching sidebar events to element",e,i),n.on("click"+u,i)):T.error(d.notFound,e)},can:{leftBodyScrollbar:function(){return T.cache.leftBodyScrollbar===W&&(T.cache.leftBodyScrollbar=T.is.rtl()&&(T.is.iframe&&!T.is.firefox()||T.is.safari()||T.is.edge()||T.is.ie())),T.cache.leftBodyScrollbar}},save:{bodyMargin:function(){x=b.css((g?"margin-":"padding-")+(T.can.leftBodyScrollbar()?"left":"right"));var e=parseInt(x.replace(/[^\d.]/g,"")),i=g?I.innerWidth-V.documentElement.clientWidth:b[0].offsetWidth-b[0].clientWidth;S=e+i}},show:function(e){if(e=z.isFunction(e)?e:function(){},T.is.hidden())if(!1===l.onShow.call(v))T.verbose("Show callback returned false cancelling show");else{if(l.overlay&&(T.error(d.overlay),l.transition="overlay"),T.refresh(),T.othersActive())if(T.debug("Other sidebars currently visible"),l.exclusive){if("overlay"!=l.transition)return void T.hideOthers(T.show);T.hideOthers()}else l.transition="overlay";T.set.dimmerStyles(),T.pushPage(function(){e.call(v),l.onVisible.call(v)}),l.onChange.call(v)}else T.debug("Sidebar is already visible")},hide:function(e){e=z.isFunction(e)?e:function(){},(T.is.visible()||T.is.animating())&&!1!==l.onHide.call(v)&&(T.debug("Hiding sidebar",e),T.refreshSidebars(),T.pullPage(function(){e.call(v),l.onHidden.call(v)}),l.onChange.call(v))},othersAnimating:function(){return 0<m.not(h).filter("."+c.animating).length},othersVisible:function(){return 0<m.not(h).filter("."+c.visible).length},othersActive:function(){return T.othersVisible()||T.othersAnimating()},hideOthers:function(e){var i=m.not(h).filter("."+c.visible),n=i.length,t=0;e=e||function(){},i.sidebar("hide",function(){++t==n&&e()})},toggle:function(){T.verbose("Determining toggled direction"),T.is.hidden()?T.show():T.hide()},pushPage:function(i){var e,n,t=T.get.transition(),o="overlay"===t||T.othersActive()?h:p;i=z.isFunction(i)?i:function(){},l.returnScroll&&(s=(g?A:b).scrollTop()),"scale down"===l.transition&&T.scrollToTop(),T.bind.scrollLock(),T.set.transition(t),T.repaint(),t=function(){T.bind.clickaway(),T.add.inlineCSS(),T.set.animating(),T.set.visible()},e=function(){T.set.dimmed()},n=function(e){e.target==o[0]&&(o.off(a+r,n),T.remove.animating(),i.call(v))},o.off(a+r),o.on(a+r,n),D(t),l.dimPage&&!T.othersVisible()&&D(e)},pullPage:function(i){var e,n,t=T.get.transition(),o="overlay"==t||T.othersActive()?h:p;i=z.isFunction(i)?i:function(){},T.verbose("Removing context push state",T.get.direction()),T.unbind.clickaway(),T.unbind.scrollLock(),e=function(){T.set.transition(t),T.set.animating(),l.dimPage&&!T.othersVisible()&&T.set.closing(),T.remove.visible()},n=function(e){e.target==o[0]&&(o.off(a+r,n),T.remove.animating(),T.remove.closing(),T.remove.transition(),T.remove.inlineCSS(),"scale down"!==t&&!l.returnScroll||T.scrollBack(),l.dimPage&&!T.othersVisible()&&p.removeClass(c.dimmed),i.call(v))},o.off(a+r),o.on(a+r,n),D(e)},scrollToTop:function(){T.verbose("Scrolling to top of page to avoid animation issues"),h.scrollTop(0),(g?A:b)[0].scrollTo(0,0)},scrollBack:function(){T.verbose("Scrolling back to original page position"),(g?A:b)[0].scrollTo(0,s)},clear:{cache:function(){T.verbose("Clearing cached dimensions"),T.cache={}}},set:{bodyMargin:function(){var n=T.can.leftBodyScrollbar()?"left":"right";b.css((g?"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)")})},dimmerStyles:function(){l.blurring?p.addClass(c.blurring):p.removeClass(c.blurring)},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)},closing:function(){p.addClass(c.closing)},transition:function(e){e=e||T.get.transition(),h.addClass(e)},direction:function(e){e=e||T.get.direction(),h.addClass(c[e])},visible:function(){h.addClass(c.visible)},overlay:function(){h.addClass(c.overlay)}},remove:{inlineCSS:function(){T.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)},closing:function(){p.removeClass(c.closing)},transition:function(e){e=e||T.get.transition(),h.removeClass(e)},direction:function(e){e=e||T.get.direction(),h.removeClass(c[e])},visible:function(){h.removeClass(c.visible)},overlay:function(){h.removeClass(c.overlay)}},restore:{bodyMargin:function(){var n=T.can.leftBodyScrollbar()?"left":"right";b.css((g?"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=T.get.direction(),e=T.is.mobile()?"auto"==l.mobileTransition?l.defaultTransition.mobile[e]:l.mobileTransition:"auto"==l.transition?l.defaultTransition.computer[e]:l.transition;return T.verbose("Determined transition",e),e},transitionEvent:function(){var e,i=V.createElement("element"),n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in n)if(i.style[e]!==W)return n[e]}},has:{scrollbar:function(){return g||"hidden"!==b.css("overflow-y")}},is:{safari:function(){return T.cache.isSafari===W&&(T.cache.isSafari=/constructor/i.test(I.HTMLElement)||!!I.ApplePaySession),T.cache.isSafari},edge:function(){return T.cache.isEdge===W&&(T.cache.isEdge=!!I.setImmediate&&!T.is.ie()),T.cache.isEdge},firefox:function(){return T.cache.isFirefox===W&&(T.cache.isFirefox=!!I.InstallTrigger),T.cache.isFirefox},iframe:function(){return!(self===top)},ie:function(){var e,i;return T.cache.isIE===W&&(e=!I.ActiveXObject&&"ActiveXObject"in I,i="ActiveXObject"in I,T.cache.isIE=e||i),T.cache.isIE},ios:function(){var e=navigator.userAgent,i=e.match(t.ios),n=e.match(t.mobileChrome);return!(!i||n||(T.verbose("Browser was found to be iOS",e),0))},mobile:function(){var e=navigator.userAgent;return e.match(t.mobile)?(T.verbose("Browser was found to be mobile",e),!0):(T.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!T.is.visible()},visible:function(){return h.hasClass(c.visible)},open:function(){return T.is.visible()},closed:function(){return T.is.hidden()},vertical:function(){return h.hasClass(c.top)},animating:function(){return b.hasClass(c.animating)},rtl:function(){return T.cache.isRTL===W&&(T.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")),T.cache.isRTL}},setting:function(e,i){if(T.debug("Changing setting",e,i),z.isPlainObject(e))z.extend(!0,l,e);else{if(i===W)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,T,e);else{if(i===W)return T[e];T[e]=i}},debug:function(){!l.silent&&l.debug&&(l.performance?T.performance.log(arguments):(T.debug=Function.prototype.bind.call(console.info,console,l.name+":"),T.debug.apply(console,arguments)))},verbose:function(){!l.silent&&l.verbose&&l.debug&&(l.performance?T.performance.log(arguments):(T.verbose=Function.prototype.bind.call(console.info,console,l.name+":"),T.verbose.apply(console,arguments)))},error:function(){l.silent||(T.error=Function.prototype.bind.call(console.error,console,l.name+":"),T.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(T.performance.timer),T.performance.timer=setTimeout(T.performance.display,500)},display:function(){var e=l.name+":",n=0;B=!1,clearTimeout(T.performance.timer),z.each(H,function(e,i){n+=i["Execution Time"]}),e+=" "+n+"ms",M&&(e+=" '"+M+"'"),(console.group!==W||console.table!==W)&&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!==W&&(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]!==W)return r=s[n],!1;{if(!z.isPlainObject(s[i])||e==o)return s[i]!==W?r=s[i]:T.error(d.method,t),!1;s=s[i]}}})),z.isFunction(r)?n=r.apply(i,e):r!==W&&(n=r),Array.isArray(w)?w.push(n):w!==W?w=[w,n]:n!==W&&(w=n),r}};L?(y===W&&T.initialize(),T.invoke(R)):(y!==W&&T.invoke("destroy"),T.initialize())}),w!==W?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",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); |