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

9 years ago
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,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