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
  1. /*!
  2. * # Semantic UI 1.11.4 - 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,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(),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,C=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),T=C.selector,S=C.className,A=C.namespace,P=C.regExp,F=C.error,O="."+A,E="module-"+A,H=e(this),L=e(C.context),j=H.children(T.sidebar),D=L.children(T.fixed),z=L.children(T.pusher),M=this,R=H.data(E);x={initialize:function(){x.debug("Initializing sidebar",o),x.create.id(),k=x.get.transitionEvent(),("auto"==C.useLegacy&&x.is.legacy()||C.useLegacy===!0)&&(C.transition="overlay",C.useLegacy=!0),x.is.ios()&&x.set.ios(),C.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),t=L.is(e.target);i&&(x.verbose("User clicked on dimmed page"),x.hide()),t&&(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(T.sidebar).length&&i.preventDefault()}},bind:{clickaway:function(){x.verbose("Adding clickaway events to context",L),C.closable&&L.on("click"+p,x.event.clickaway).on("touchend"+p,x.event.clickaway)},scrollLock:function(){C.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,t=x.cache.width||H.outerWidth(),n=x.cache.height||H.outerHeight(),o=x.is.rtl(),r=x.get.direction(),a={left:t,right:-t,top:n,bottom:-n};o&&(x.verbose("RTL detected, flipping widths"),a.left=-t,a.right=t),i='<style title="'+A+'">',"left"===r||"right"===r?(x.debug("Adding CSS rules for animation distance",t),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",t),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>",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(C.context),j=L.children(T.sidebar),z=L.childr