You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

11 lines
12 KiB

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