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"),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