/* * # 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(i),l=e(t),c=e("head"),u=s.selector||"",d=(new Date).getTime(),f=[],b=arguments[0],m="string"==typeof b,p=[].slice.call(arguments,1),g=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,v,h,y,x,k,w=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),T=w.selector,C=w.className,S=w.namespace,P=w.error,F="."+S,A="module-"+S,z=e(this),O=e(w.context),E=z.children(T.sidebar),H=O.children(T.pusher),D=this,j=z.data(A);k={initialize:function(){k.debug("Initializing sidebar",o),x=k.get.transitionEvent(),(k.is.legacy()||w.legacy)&&(w.transition="overlay",w.useLegacy=!0),h=k.get.uniqueID(),v="."+h,g(k.setup.layout),k.instantiate()},instantiate:function(){k.verbose("Storing instance of module",k),j=k,z.data(A,k)},destroy:function(){k.verbose("Destroying previous module for",z),k.remove.direction(),z.off(F).removeData(A),O.off(v),a.off(v),l.off(v)},event:{clickaway:function(i){0===e(i.target).closest(T.sidebar).size()&&(k.verbose("User clicked on dimmed page"),k.hide())},touch:function(){},containScroll:function(){D.scrollTop<=0&&(D.scrollTop=1),D.scrollTop+D.offsetHeight>=D.scrollHeight&&(D.scrollTop=D.scrollHeight-D.offsetHeight-1)},scroll:function(i){0===e(i.target).closest(T.sidebar).size()&&i.preventDefault()}},bind:{clickaway:function(){k.verbose("Adding clickaway events to context",O),w.closable&&O.on("click"+v,k.event.clickaway).on("touchend"+v,k.event.clickaway)},scrollLock:function(){w.scrollLock&&(k.debug("Disabling page scroll"),a.on("DOMMouseScroll"+v,k.event.scroll)),k.verbose("Adding events to contain sidebar scroll"),l.on("touchmove"+v,k.event.touch),z.on("scroll"+F,k.event.containScroll)}},unbind:{clickaway:function(){k.verbose("Removing clickaway events from context",O),O.off(v)},scrollLock:function(){k.verbose("Removing scroll lock from page"),l.off(v),a.off(v),z.off("scroll"+F)}},add:{bodyCSS:function(){var i,t=z.outerWidth(),n=z.outerHeight();i='",c.append(i),s=e("style[title="+S+"]"),k.debug("Adding sizing css to head",s)}},refresh:function(){k.verbose("Refreshing selector cache"),O=e(w.context),E=O.children(T.sidebar),H=O.children(T.pusher)},refreshSidebars:function(){k.verbose("Refreshing other sidebars"),E=O.children(T.sidebar)},repaint:function(){k.verbose("Forcing repaint event"),D.style.display="none",D.offsetHeight,D.scrollTop=D.scrollTop,D.style.display=""},setup:{layout:function(){0===O.children(T.pusher).size()&&(k.debug("Adding wrapper element for sidebar"),k.error(P.pusher),H=e('
'),O.children().not(T.omitted).not(E).wrapAll(H),k.refresh()),(0===z.nextAll(T.pusher).size()||z.nextAll(T.pusher)[0]!==H[0])&&(k.debug("Moved sidebar to correct parent element"),k.error(P.movedSidebar,D),z.detach().prependTo(O),k.refresh()),k.set.pushable(),k.set.direction()}},attachEvents:function(i,t){var n=e(i);t=e.isFunction(k[t])?k[t]:k.toggle,n.size()>0?(k.debug("Attaching sidebar events to element",i,t),n.on("click"+F,t)):k.error(P.notFound,i)},show:function(i){var t=w.useLegacy?k.legacyPushPage:k.pushPage;i=e.isFunction(i)?i:function(){},k.is.hidden()?(k.refreshSidebars(),w.overlay&&(k.error(P.overlay),w.transition="overlay"),k.refresh(),k.othersVisible()&&"overlay"!=k.get.transition()&&(k.debug("Other sidebars currently open"),w.exclusive&&k.hideOthers()),t(function(){e.proxy(i,D)(),e.proxy(w.onShow,D)()}),e.proxy(w.onChange,D)(),e.proxy(w.onVisible,D)()):k.debug("Sidebar is already visible")},hide:function(i){var t=w.useLegacy?k.legacyPullPage:k.pullPage;i=e.isFunction(i)?i:function(){},(k.is.visible()||k.is.animating())&&(k.debug("Hiding sidebar",i),k.refreshSidebars(),t(function(){e.proxy(i,D)(),e.proxy(w.onHidden,D)()}),e.proxy(w.onChange,D)(),e.proxy(w.onHide,D)())},othersVisible:function(){return E.not(z).filter("."+C.visible).size()>0},hideOthers:function(e){var i=E.not(z).filter("."+C.visible),e=e||function(){},t=i.size(),n=0;i.sidebar("hide",function(){n++,n==t&&e()})},toggle:function(){k.verbose("Determining toggled direction"),k.is.hidden()?k.show():k.hide()},pushPage:function(i){var t,n,o=k.get.transition(),r="safe"==o?O:"overlay"==o||k.othersVisible()?z:H;i=e.isFunction(i)?i:function(){},("scale down"==w.transition||k.is.mobile()&&"overlay"!==o)&&k.scrollToTop(),k.set.transition(),k.repaint(),t=function(){k.bind.clickaway(),k.add.bodyCSS(),k.set.animating(),k.set.visible(),k.othersVisible()||w.dimPage&&H.addClass(C.dimmed)},n=function(t){t.target==r[0]&&(r.off(x+v,n),k.remove.animating(),k.bind.scrollLock(),e.proxy(i,D)())},r.off(x+v),r.on(x+v,n),g(t)},pullPage:function(i){var t,n,o=k.get.transition(),r="safe"==o?O:"overlay"==o||k.othersVisible()?z:H;i=e.isFunction(i)?i:function(){},k.verbose("Removing context push state",k.get.direction()),k.unbind.clickaway(),k.unbind.scrollLock(),t=function(){k.set.animating(),k.remove.visible(),w.dimPage&&!k.othersVisible()&&H.removeClass(C.dimmed)},n=function(t){t.target==r[0]&&(r.off(x+v,n),k.remove.animating(),k.remove.transition(),k.remove.bodyCSS(),("scale down"==o||w.returnScroll&&k.is.mobile())&&k.scrollBack(),e.proxy(i,D)())},r.off(x+v),r.on(x+v,n),g(t)},legacyPushPage:function(i){var t=z.width(),n=k.get.direction(),o={};t=t||z.width(),i=e.isFunction(i)?i:function(){},o[n]=t,k.debug("Using javascript to push context",o),k.set.visible(),k.set.transition(),k.set.animating(),w.dimPage&&H.addClass(C.dimmed),O.css("position","relative").animate(o,w.duration,w.easing,function(){k.remove.animating(),k.bind.clickaway(),e.proxy(i,k)()})},legacyPullPage:function(i){var t=0,n=k.get.direction(),o={};t=t||z.width(),i=e.isFunction(i)?i:function(){},o[n]="0px",k.debug("Using javascript to pull context",o),k.unbind.clickaway(),k.set.animating(),k.remove.visible(),w.dimPage&&!k.othersVisible()&&H.removeClass(C.dimmed),O.css("position","relative").animate(o,w.duration,w.easing,function(){k.remove.animating(),e.proxy(i,k)()})},scrollToTop:function(){k.verbose("Scrolling to top of page to avoid animation issues"),y=e(i).scrollTop(),z.scrollTop(0),i.scrollTo(0,0)},scrollBack:function(){k.verbose("Scrolling back to original page position"),i.scrollTo(0,y)},set:{pushed:function(){O.addClass(C.pushed)},pushable:function(){O.addClass(C.pushable)},active:function(){z.addClass(C.active)},animating:function(){z.addClass(C.animating)},transition:function(e){e=e||k.get.transition(),z.addClass(e)},direction:function(e){e=e||k.get.direction(),z.addClass(C[e])},visible:function(){z.addClass(C.visible)},overlay:function(){z.addClass(C.overlay)}},remove:{bodyCSS:function(){k.debug("Removing body css styles",s),s.size()>0&&s.remove()},pushed:function(){O.removeClass(C.pushed)},pushable:function(){O.removeClass(C.pushable)},active:function(){z.removeClass(C.active)},animating:function(){z.removeClass(C.animating)},transition:function(e){e=e||k.get.transition(),z.removeClass(e)},direction:function(e){e=e||k.get.direction(),z.removeClass(C[e])},visible:function(){z.removeClass(C.visible)},overlay:function(){z.removeClass(C.overlay)}},get:{direction:function(){return z.hasClass(C.top)?C.top:z.hasClass(C.right)?C.right:z.hasClass(C.bottom)?C.bottom:C.left},transition:function(){var e=k.get.direction();return k.is.mobile()?"auto"==w.mobileTransition?w.defaultTransition.mobile[e]:w.mobileTransition:"auto"==w.transition?w.defaultTransition.computer[e]:w.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]},uniqueID:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},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?(k.verbose("Browser was found to be mobile",e),!0):(k.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!k.is.visible()},visible:function(){return z.hasClass(C.visible)},open:function(){return k.is.visible()},closed:function(){return k.is.hidden()},vertical:function(){return z.hasClass(C.top)},animating:function(){return O.hasClass(C.animating)}},setting:function(i,t){if(k.debug("Changing setting",i,t),e.isPlainObject(i))e.extend(!0,w,i);else{if(t===n)return w[i];w[i]=t}},internal:function(i,t){if(e.isPlainObject(i))e.extend(!0,k,i);else{if(t===n)return k[i];k[i]=t}},debug:function(){w.debug&&(w.performance?k.performance.log(arguments):(k.debug=Function.prototype.bind.call(console.info,console,w.name+":"),k.debug.apply(console,arguments)))},verbose:function(){w.verbose&&w.debug&&(w.performance?k.performance.log(arguments):(k.verbose=Function.prototype.bind.call(console.info,console,w.name+":"),k.verbose.apply(console,arguments)))},error:function(){k.error=Function.prototype.bind.call(console.error,console,w.name+":"),k.error.apply(console,arguments)},performance:{log:function(e){var i,t,n;w.performance&&(i=(new Date).getTime(),n=d||i,t=i-n,d=i,f.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:D,"Execution Time":t})),clearTimeout(k.performance.timer),k.performance.timer=setTimeout(k.performance.display,100)},display:function(){var i=w.name+":",t=0;d=!1,clearTimeout(k.performance.timer),e.each(f,function(e,i){t+=i["Execution Time"]}),i+=" "+t+"ms",u&&(i+=" '"+u+"'"),(console.group!==n||console.table!==n)&&f.length>0&&(console.groupCollapsed(i),console.table?console.table(f):e.each(f,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),f=[]}},invoke:function(i,t,o){var s,a,l,c=j;return t=t||p,o=D||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):(k.error(P.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}},m?(j===n&&k.initialize(),k.invoke(b)):(j!==n&&k.invoke("destroy"),k.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);