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 1.11.3 - Sidebar
* http://github.com/semantic-org/semantic-ui/
*
*
* 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(i),l=e(n),c=e("html"),u=e("head"),d=s.selector||"",f=(new Date).getTime(),m=[],b=arguments[0],g="string"==typeof b,v=[].slice.call(arguments,1),h=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,p,y,w,k,x,T=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),C=T.selector,S=T.className,A=T.namespace,P=T.regExp,F=T.error,O="."+A,E="module-"+A,H=e(this),L=e(T.context),j=H.children(C.sidebar),D=L.children(C.fixed),z=L.children(C.pusher),M=this,R=H.data(E);x={initialize:function(){x.debug("Initializing sidebar",o),x.create.id(),k=x.get.transitionEvent(),("auto"==T.useLegacy&&x.is.legacy()||T.useLegacy===!0)&&(T.transition="overlay",T.useLegacy=!0),x.is.ios()&&x.set.ios(),T.delaySetup?h(x.setup.layout):x.setup.layout(),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),n=L.is(e.target);i&&(x.verbose("User clicked on dimmed page"),x.hide()),n&&(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(C.sidebar).length&&i.preventDefault()}},bind:{clickaway:function(){x.verbose("Adding clickaway events to context",L),T.closable&&L.on("click"+p,x.event.clickaway).on("touchend"+p,x.event.clickaway)},scrollLock:function(){T.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,n=H.outerWidth(),t=H.outerHeight(),o=x.get.direction(),r={left:n,right:-n,top:t,bottom:-t};x.is.rtl()&&(x.verbose("RTL detected, flipping widths"),r.left=-n,r.right=n),i='<style title="'+A+'">',"left"===o||"right"===o?(x.debug("Adding CSS rules for animation distance",n),i+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):("top"===o||"bottom"==o)&&(i+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),x.is.ie()&&("left"===o||"right"===o?(x.debug("Adding CSS rules for animation distance",n),i+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):("top"===o||"bottom"==o)&&(i+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),i+=" body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); }"),i+="</style>",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(T.context),j=L.children(C.sidebar),z=L.children(C.pusher),D=L.children(C.fixed)},refreshSidebars:function(){x.verbose("Refreshing other sidebars"),j=L.children(C.sidebar)},repaint:function(){x.verbose("Forcing repaint event"),M.style.display="none",M.offsetHeight,M.scrollTop=M.scrollTop,M.style.display=""},setup:{layout:function(){0===L.children(C.pusher).length&&(x.debug("Adding wrapper element for sidebar"),x.error(F.pusher),z=e('<div class="pusher" />'),L.children().not(C.omitted).not(j).wrapAll(z),x.refresh()),(0===H.nextAll(C.pusher).length||H.nextAll(C.pusher)[0]!==z[0])&&(x.debug("Moved sidebar to correct parent element"),x.error(F.movedSidebar,M),H.detach().prependTo(L),x.refresh()),x.set.pushable(),x.set.direction()}},attachEvents:function(i,n){var t=e(i);n=e.isFunction(x[n])?x[n]:x.toggle,t.length>0?(x.debug("Attaching sidebar events to element",i,n),t.on("click"+O,n)):x.error(F.notFound,i)},show:function(i){var n=T.useLegacy===!0?x.legacyPushPage:x.pushPage;if(i=e.isFunction(i)?i:function(){},x.is.hidden()){if(x.refreshSidebars(),T.overlay&&(x.error(F.overlay),T.transition="overlay"),x.refresh(),x.othersActive())if(x.debug("Other sidebars currently visible"),T.exclusive){if("overlay"!=T.transition)return void x.hideOthers(x.show);x.hideOthers()}else T.transition="overlay";n(function(){i.call(M),T.onShow.call(M)}),T.onChange.call(M),T.onVisible.call(M)}else x.debug("Sidebar is already visible")},hide:function(i){var n=T.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(),n(function(){i.call(M),T.onHidden.call(M)}),T.onChange.call(M),T.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),n=i.length,t=0;e=e||function(){},i.sidebar("hide",function(){t++,t==n&&e()})},toggle:function(){x.verbose("Determining toggled direction"),x.is.hidden()?x.show():x.hide()},pushPage:function(i){var n,t,o=x.get.transition(),r="safe"==o?L:"overlay"===o||x.othersActive()?H:z;i=e.isFunction(i)?i:function(){},"scale down"==T.transition&&x.scrollToTop(),x.set.transition(o),x.repaint(),n=function(){x.bind.clickaway(),x.add.bodyCSS(),x.set.animating(),x.set.visible(),x.othersVisible()||T.dimPage&&z.addClass(S.dimmed)},t=function(e){e.target==r[0]&&(r.off(k+p,t),x.remove.animating(),x.bind.scrollLock(),i.call(M))},r.off(k+p),r.on(k+p,t),h(n)},pullPage:function(i){var n,t,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.set.transition(o),x.unbind.clickaway(),x.unbind.scrollLock(),n=function(){x.set.animating(),x.remove.visible(),T.dimPage&&!x.othersVisible()&&z.removeClass(S.dimmed)},t=function(e){e.target==r[0]&&(r.off(k+p,t),x.remove.animating(),x.remove.transition(),x.remove.bodyCSS(),("scale down"==o||T.returnScroll&&x.is.mobile())&&x.scrollBack(),i.call(M))},r.off(k+p),r.on(k+p,t),h(n)},legacyPushPage:function(i){var n=H.width(),t=x.get.direction(),o={};n=n||H.width(),i=e.isFunction(i)?i:function(){},o[t]=n,x.debug("Using javascript to push context",o),x.set.visible(),x.set.transition(),x.set.animating(),T.dimPage&&z.addClass(S.dimmed),L.css("position","relative").animate(o,T.duration,T.easing,function(){x.remove.animating(),x.bind.clickaway(),i.call(M)})},legacyPullPage:function(i){var n=0,t=x.get.direction(),o={};n=n||H.width(),i=e.isFunction(i)?i:function(){},o[t]="0px",x.debug("Using javascript to pull context",o),x.unbind.clickaway(),x.set.animating(),x.remove.visible(),T.dimPage&&!x.othersActive()&&z.removeClass(S.dimmed),L.css("position","relative").animate(o,T.duration,T.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)},set:{ios:function(){c.addClass(S.ios)},pushed:function(){L.addClass(S.pushed)},pushable:function(){L.addClass(S.pushable)},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"==T.mobileTransition?T.defaultTransition.mobile[i]:T.mobileTransition:"auto"==T.transition?T.defaultTransition.computer[i]:T.transition,x.verbose("Determined transition",e),e},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:{ie:function(){var e=!i.ActiveXObject&&"ActiveXObject"in i,n="ActiveXObject"in i;return e||n},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)},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"rtl"==H.css("direction")}},setting:function(i,n){if(x.debug("Changing setting",i,n),e.isPlainObject(i))e.extend(!0,T,i);else{if(n===t)return T[i];T[i]=n}},internal:function(i,n){if(e.isPlainObject(i))e.extend(!0,x,i);else{if(n===t)return x[i];x[i]=n}},debug:function(){T.debug&&(T.performance?x.performance.log(arguments):(x.debug=Function.prototype.bind.call(console.info,console,T.name+":"),x.debug.apply(console,arguments)))},verbose:function(){T.verbose&&T.debug&&(T.performance?x.performance.log(arguments):(x.verbose=Function.prototype.bind.call(console.info,console,T.name+":"),x.verbose.apply(console,arguments)))},error:function(){x.error=Function.prototype.bind.call(console.error,console,T.name+":"),x.error.apply(console,arguments)},performance:{log:function(e){var i,n,t;T.performance&&(i=(new Date).getTime(),t=f||i,n=i-t,f=i,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:M,"Execution Time":n})),clearTimeout(x.performance.timer),x.performance.timer=setTimeout(x.performance.display,100)},display:function(){var i=T.name+":",n=0;f=!1,clearTimeout(x.performance.timer),e.each(m,function(e,i){n+=i["Execution Time"]}),i+=" "+n+"ms",d&&(i+=" '"+d+"'"),(console.group!==t||console.table!==t)&&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,n,o){var s,a,l,c=R;return n=n||v,o=M||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):(x.error(F.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}},g?(R===t&&x.initialize(),x.invoke(b)):(R!==t&&x.invoke("destroy"),x.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:"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,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);