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