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
14 KiB

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