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