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.

10 lines
12 KiB

10 years ago
10 years ago
  1. /*
  2. * # Semantic UI
  3. * https://github.com/Semantic-Org/Semantic-UI
  4. * http://beta.semantic-ui.com/
  5. *
  6. * Copyright 2014 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. !function(e,i,n,t){"use strict";e.fn.sidebar=function(o){var r,s=e(this),a=(e("head"),s.selector||""),l=(new Date).getTime(),c=[],u=arguments[0],d="string"==typeof u,f=[].slice.call(arguments,1),m=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,g,b,p,v=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),h=v.selector,y=v.className,x=v.namespace,T=v.error,w="."+x,C="module-"+x,k=e(this),P=e(v.context),S=k.children(h.sidebar),A=P.children(h.pusher),z=this,F=k.data(C);p={initialize:function(){p.debug("Initializing sidebar",o),b=p.get.transitionEvent(),p.is.legacy()&&(v.useLegacy=!0),m(p.setup.layout),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),F=p,k.data(C,p)},destroy:function(){p.verbose("Destroying previous module for",k),p.remove.direction(),k.off(w).removeData(C)},event:{clickaway:function(i){0===k.find(i.target).size()&&0===e(i.target).filter(k).size()&&(p.verbose("User clicked on dimmed page"),p.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===k.find(i.target).size()&&0===e(i.target).filter(k).size()&&i.preventDefault()}},bind:{clickaway:function(){v.scrollLock&&e(i).on("DOMMouseScroll"+w,p.event.scroll),e(n).on("touchmove"+w,p.event.touch),k.on("scroll"+w,p.event.containScroll),v.closable&&P.on("click"+w,p.event.clickaway).on("touchend"+w,p.event.clickaway)}},unbind:{clickaway:function(){P.off(w),A.off(w),e(n).off(w),e(i).off(w)}},add:{bodyCSS:function(){var i=k.outerWidth(),n=k.outerHeight(),t='<style title="'+x+'"> .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.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>";P.append(t),s=e("style[title="+x+"]"),p.debug("Adding sizing css to head",s)}},refresh:function(){p.verbose("Refreshing selector cache"),P=e(v.context),S=P.children(h.sidebar),A=P.children(h.pusher)},repaint:function(){p.verbose("Forcing repaint event"),z.style.display="none",z.offsetHeight,z.scrollTop=z.scrollTop,z.style.display=""},setup:{layout:function(){0===P.find(h.pusher).size()&&(p.debug("Adding wrapper element for sidebar"),A=e('<div class="pusher" />'),P.children().not(h.omitted).not(S).wrapAll(A),p.refresh()),k.nextAll(h.pusher)[0]!==A[0]&&(p.debug("Moved sidebar to correct parent element"),k.detach().prependTo(P),p.refresh()),p.set.pushable(),p.set.direction()}},attachEvents:function(i,n){var t=e(i);n=e.isFunction(p[n])?p[n]:p.toggle,t.size()>0?(p.debug("Attaching sidebar events to element",i,n),t.on("click"+w,n)):p.error(T.notFound,i)},show:function(i){var n=v.useLegacy?p.legacyPushPage:p.pushPage;i=e.isFunction(i)?i:function(){},p.is.closed()?(v.overlay&&(p.error(T.overlay),v.transition="overlay"),p.refresh(),p.othersVisible()&&"overlay"!=p.get.transition()&&(p.debug("Other sidebars currently open"),v.exclusive&&p.hideOthers()),n(function(){e.proxy(i,z)(),e.proxy(v.onShow,z)()}),e.proxy(v.onChange,z)(),e.proxy(v.onVisible,z)()):p.debug("Sidebar is already visible")},hide:function(i){var n=v.useLegacy?p.legacyPullPage:p.pullPage;i=e.isFunction(i)?i:function(){},(p.is.visible()||p.is.animating())&&(p.debug("Hiding sidebar",i),n(function(){e.proxy(i,z)(),e.proxy(v.onHidden,z)()}),e.proxy(v.onChange,z)(),e.proxy(v.onHide,z)())},othersVisible:function(){retu