/* * # Semantic UI * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ !function(e,i,t,n){"use strict";e.fn.sidebar=function(o){var r,s=e(this),a=e("head"),l=s.selector||"",c=(new Date).getTime(),u=[],d=arguments[0],f="string"==typeof d,m=[].slice.call(arguments,1),b=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,p,v,g,h=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),y=h.selector,x=h.className,w=h.namespace,T=h.error,k="."+w,C="module-"+w,S=e(this),A=e(h.context),P=S.children(y.sidebar),F=A.children(y.pusher),z=this,O=S.data(C);g={initialize:function(){g.debug("Initializing sidebar",o),v=g.get.transitionEvent(),(g.is.legacy()||h.legacy)&&(h.transition="overlay",h.useLegacy=!0),b(g.setup.layout),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),O=g,S.data(C,g)},destroy:function(){g.verbose("Destroying previous module for",S),g.remove.direction(),S.off(k).removeData(C)},event:{clickaway:function(i){0===e(i.target).closest(y.sidebar).size()&&(g.verbose("User clicked on dimmed page"),g.hide())},touch:function(){},containScroll:function(){z.scrollTop<=0&&(z.scrollTop=1),z.scrollTop+z.offsetHeight>=z.scrollHeight&&(z.scrollTop=z.scrollHeight-z.offsetHeight-1)},scroll:function(i){0===e(i.target).closest(y.sidebar).size()&&i.preventDefault()}},bind:{clickaway:function(){h.scrollLock&&e(i).on("DOMMouseScroll"+k,g.event.scroll),e(t).on("touchmove"+k,g.event.touch),S.on("scroll"+k,g.event.containScroll),h.closable&&A.on("click"+k,g.event.clickaway).on("touchend"+k,g.event.clickaway)}},unbind:{clickaway:function(){A.off(k),F.off(k),e(t).off(k),e(i).off(k)}},add:{bodyCSS:function(){var i,t=S.outerWidth(),n=S.outerHeight();i='",a.append(i),s=e("style[title="+w+"]"),g.debug("Adding sizing css to head",s)}},refresh:function(){g.verbose("Refreshing selector cache"),A=e(h.context),P=A.children(y.sidebar),F=A.children(y.pusher)},repaint:function(){g.verbose("Forcing repaint event"),z.style.display="none",z.offsetHeight,z.scrollTop=z.scrollTop,z.style.display=""},setup:{layout:function(){0===A.children(y.pusher).size()&&(g.debug("Adding wrapper element for sidebar"),g.error(T.pusher),F=e('
'),A.children().not(y.omitted).not(P).wrapAll(F),g.refresh()),(0==S.nextAll(y.pusher).size()||S.nextAll(y.pusher)[0]!==F[0])&&(g.debug("Moved sidebar to correct parent element"),g.error(T.movedSidebar,z),S.detach().prependTo(A),g.refresh()),g.set.pushable(),g.set.direction()}},attachEvents:function(i,t){var n=e(i);t=e.isFunction(g[t])?g[t]:g.toggle,n.size()>0?(g.debug("Attaching sidebar events to element",i,t),n.on("click"+k,t)):g.error(T.notFound,i)},show:function(i){var t=h.useLegacy?g.legacyPushPage:g.pushPage;i=e.isFunction(i)?i:function(){},g.is.closed()?(h.overlay&&(g.error(T.overlay),h.transition="overlay"),g.refresh(),g.othersVisible()&&"overlay"!=g.get.transition()&&(g.debug("Other sidebars currently open"),h.exclusive&&g.hideOthers()),t(function(){e.proxy(i,z)(),e.proxy(h.onShow,z)()}),e.proxy(h.onChange,z)(),e.proxy(h.onVisible,z)()):g.debug("Sidebar is already visible")},hide:function(i){var t=h.useLegacy?g.legacyPullPage:g.pullPage;i=e.isFunction(i)?i:function(){},(g.is.visible()||g.is.animating())&&(g.debug("Hiding sidebar",i),t(function(){e.proxy(i,z)(),e.proxy(h.onHidden,z)()}),e.proxy(h.onChange,z)(),e.proxy(h.onHide,z)())},othersVisible:function(){return P.not(S).filter("."+x.visible).size()>0},othersActive:function(){return P.not(S).filter("."+x.active).size()>0},hideOthers:function(e){var i=P.not(S).filter("."+x.visible),e=e||function(){},t=i.size(),n=0;i.sidebar("hide",function(){n++,n==t&&e()})},toggle:function(){g.verbose("Determining toggled direction"),g.is.closed()?g.show():g.hide()},pushPage:function(i){var t,n,o=g.get.transition(),r="safe"==o?A:"overlay"==o||g.othersActive()?S:F;i=e.isFunction(i)?i:function(){},("scale down"==h.transition||g.is.mobile()&&"overlay"!==o)&&g.scrollToTop(),g.set.transition(),g.repaint(),t=function(){g.add.bodyCSS(),g.set.animating(),g.set.visible(),g.othersActive()||h.dimPage&&F.addClass(x.dimmed)},n=function(t){t.target==r[0]&&(r.off(v+k,n),g.remove.animating(),g.bind.clickaway(),e.proxy(i,z)())},r.on(v+k,n),b(t)},pullPage:function(i){var t,n,o=g.get.transition(),r="safe"==o?A:"overlay"==o||g.othersActive()?S:F;i=e.isFunction(i)?i:function(){},g.verbose("Removing context push state",g.get.direction()),g.othersActive()||g.unbind.clickaway(),t=function(){g.set.animating(),g.remove.visible(),h.dimPage&&!g.othersActive()&&F.removeClass(x.dimmed)},n=function(t){t.target==r[0]&&(r.off(v+k,n),g.remove.animating(),g.remove.transition(),g.remove.bodyCSS(),("scale down"==o||h.returnScroll&&g.is.mobile())&&g.scrollBack(),e.proxy(i,z)())},r.on(v+k,n),b(t)},legacyPushPage:function(i){var t=S.width(),n=g.get.direction(),o={};t=t||S.width(),i=e.isFunction(i)?i:function(){},o[n]=t,g.debug("Using javascript to push context",o),g.set.visible(),g.set.transition(),g.set.animating(),h.dimPage&&F.addClass(x.dimmed),A.css("position","relative").animate(o,h.duration,h.easing,function(){g.remove.animating(),g.bind.clickaway(),e.proxy(i,g)()})},legacyPullPage:function(i){var t=0,n=g.get.direction(),o={};t=t||S.width(),i=e.isFunction(i)?i:function(){},o[n]="0px",g.debug("Using javascript to pull context",o),g.unbind.clickaway(),g.set.animating(),g.remove.visible(),h.dimPage&&!g.othersVisible()&&F.removeClass(x.dimmed),A.css("position","relative").animate(o,h.duration,h.easing,function(){g.remove.animating(),e.proxy(i,g)()})},scrollToTop:function(){g.verbose("Scrolling to top of page to avoid animation issues"),p=e(i).scrollTop(),S.scrollTop(0),i.scrollTo(0,0)},scrollBack:function(){g.verbose("Scrolling back to original page position"),i.scrollTo(0,p)},set:{pushed:function(){A.addClass(x.pushed)},pushable:function(){A.addClass(x.pushable)},active:function(){S.addClass(x.active)},animating:function(){S.addClass(x.animating)},transition:function(e){e=e||g.get.transition(),S.addClass(e)},direction:function(e){e=e||g.get.direction(),S.addClass(x[e])},visible:function(){S.addClass(x.visible)},overlay:function(){S.addClass(x.overlay)}},remove:{bodyCSS:function(){g.debug("Removing body css styles",s),s.size()>0&&s.remove()},pushed:function(){A.removeClass(x.pushed)},pushable:function(){A.removeClass(x.pushable)},active:function(){S.removeClass(x.active)},animating:function(){S.removeClass(x.animating)},transition:function(e){e=e||g.get.transition(),S.removeClass(e)},direction:function(e){e=e||g.get.direction(),S.removeClass(x[e])},visible:function(){S.removeClass(x.visible)},overlay:function(){S.removeClass(x.overlay)}},get:{direction:function(){return S.hasClass(x.top)?x.top:S.hasClass(x.right)?x.right:S.hasClass(x.bottom)?x.bottom:x.left},transition:function(){var e=g.get.direction();return g.is.mobile()?"auto"==h.mobileTransition?h.defaultTransition.mobile[e]:h.mobileTransition:"auto"==h.transition?h.defaultTransition.computer[e]:h.transition},transitionEvent:function(){var e,i=t.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(i.style[e]!==n)return o[e]}},is:{ie:function(){var e=!i.ActiveXObject&&"ActiveXObject"in i,t="ActiveXObject"in i;return e||t},legacy:function(){var e,o=t.createElement("div"),r={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};t.body.insertBefore(o,null);for(var s in r)o.style[s]!==n&&(o.style[s]="translate3d(1px,1px,1px)",e=i.getComputedStyle(o).getPropertyValue(r[s]));return t.body.removeChild(o),!(e!==n&&e.length>0&&"none"!==e)},mobile:function(){var e=navigator.userAgent,i=/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/,t=i.test(e);return t?(g.verbose("Browser was found to be mobile",e),!0):(g.verbose("Browser is not mobile, using regular transition",e),!1)},closed:function(){return!g.is.visible()},visible:function(){return S.hasClass(x.visible)},vertical:function(){return S.hasClass(x.top)},animating:function(){return A.hasClass(x.animating)}},setting:function(i,t){if(g.debug("Changing setting",i,t),e.isPlainObject(i))e.extend(!0,h,i);else{if(t===n)return h[i];h[i]=t}},internal:function(i,t){if(e.isPlainObject(i))e.extend(!0,g,i);else{if(t===n)return g[i];g[i]=t}},debug:function(){h.debug&&(h.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,h.name+":"),g.debug.apply(console,arguments)))},verbose:function(){h.verbose&&h.debug&&(h.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,h.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,h.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var i,t,n;h.performance&&(i=(new Date).getTime(),n=c||i,t=i-n,c=i,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:z,"Execution Time":t})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,100)},display:function(){var i=h.name+":",t=0;c=!1,clearTimeout(g.performance.timer),e.each(u,function(e,i){t+=i["Execution Time"]}),i+=" "+t+"ms",l&&(i+=" '"+l+"'"),(console.group!==n||console.table!==n)&&u.length>0&&(console.groupCollapsed(i),console.table?console.table(u):e.each(u,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(i,t,o){var s,a,l,c=O;return t=t||m,o=z||o,"string"==typeof i&&c!==n&&(i=i.split(/[\. ]/),s=i.length-1,e.each(i,function(t,o){var r=t!=s?o+i[t+1].charAt(0).toUpperCase()+i[t+1].slice(1):i;if(e.isPlainObject(c[r])&&t!=s)c=c[r];else{if(c[r]!==n)return a=c[r],!1;if(!e.isPlainObject(c[o])||t==s)return c[o]!==n?(a=c[o],!1):(g.error(T.method,i),!1);c=c[o]}})),e.isFunction(a)?l=a.apply(o,t):a!==n&&(l=a),e.isArray(r)?r.push(l):r!==n?r=[r,l]:l!==n&&(r=l),a}},f?(O===n&&g.initialize(),g.invoke(d)):(O!==n&&g.invoke("destroy"),g.initialize())}),r!==n?r:this},e.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!0,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,useLegacy:!1,duration:500,easing:"easeInOutQuint",onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",animating:"animating",dimmed:"dimmed",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"},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"}},e.extend(e.easing,{easeInOutQuint:function(e,i,t,n,o){return(i/=o/2)<1?n/2*i*i*i*i*i+t:n/2*((i-=2)*i*i*i*i+2)+t}})}(jQuery,window,document);