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

9 years ago
9 years ago
9 years ago
9 years ago
  1. /*!
  2. * # Semantic UI 2.0.0 - Sidebar
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  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(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,h=[].slice.call(arguments,1),v=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?v(x.setup.layout):x.setup.layout(),x.setup.cache(),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=x.cache.width||H.outerWidth(),t=x.cache.height||H.outerHeight(),o=x.is.rtl(),r=x.get.direction(),a={left:n,right:-n,top:t,bottom:-t};o&&(x.verbose("RTL detected, flipping widths"),a.left=-n,a.right=n),i="<style>","left"===r||"right"===r?(x.debug("Adding CSS rules for animation distance",n),i+=" .ui.visible."+r+".sidebar ~ .fixed, .ui.visible."+r+".sidebar ~ .pusher { -webkit-transform: translate3d("+a[r]+"px, 0, 0); transform: translate3d("+a[r]+"px, 0, 0); }"):("top"===r||"bottom"==r)&&(i+=" .ui.visible."+r+".sidebar ~ .fixed, .ui.visible."+r+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+a[r]+"px, 0); transform: translate3d(0, "+a[r]+"px, 0); }"),x.is.ie()&&("left"===r||"right"===r?(x.debug("Adding CSS rules for animation distance",n),i+=" body.pushable > .ui.visible."+r+".sidebar ~ .pusher:after { -webkit-transform: translate3d("+a[r]+"px, 0, 0); transform: translate3d("+a[r]+"px, 0, 0); }"):("top"===r||"bottom"==r)&&(i+=" body.pushable > .ui.visible."+r+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+a[r]+"px, 0); transform: translate3d(0, "+a[r]+"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>",s=e(i).appendTo(u),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