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