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

10 years ago
  1. /*
  2. * # Semantic UI - 1.7.2
  3. * https://github.com/Semantic-Org/Semantic-UI
  4. * http://www.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(i),l=e(n),c=e("html"),u=e("head"),d=s.selector||"",f=(new Date).getTime(),m=[],g=arguments[0],b="string"==typeof g,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,T,C=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),x=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),D=H.children(x.sidebar),j=L.children(x.pusher),z=this,M=H.data(E);T={initialize:function(){T.debug("Initializing sidebar",o),T.create.id(),k=T.get.transitionEvent(),("auto"==C.useLegacy&&T.is.legacy()||C.useLegacy===!0)&&(C.transition="overlay",C.useLegacy=!0),T.is.ios()&&T.set.ios(),C.delaySetup?h(T.setup.layout):T.setup.layout(),T.instantiate()},instantiate:function(){T.verbose("Storing instance of module",T),M=T,H.data(E,T)},create:{id:function(){T.verbose("Creating unique id for element"),y=T.get.uniqueID(),p="."+y}},destroy:function(){T.verbose("Destroying previous module for",H),T.remove.direction(),H.off(O).removeData(E),L.off(p),a.off(p),l.off(p)},event:{clickaway:function(i){0===e(i.target).closest(x.sidebar).length&&(T.verbose("User clicked on dimmed page"),T.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(x.sidebar).length&&i.preventDefault()}},bind:{clickaway:function(){T.verbose("Adding clickaway events to context",L),C.closable&&L.on("click"+p,T.event.clickaway).on("touchend"+p,T.event.clickaway)},scrollLock:function(){C.scrollLock&&(T.debug("Disabling page scroll"),a.on("DOMMouseScroll"+p,T.event.scroll)),T.verbose("Adding events to contain sidebar scroll"),l.on("touchmove"+p,T.event.touch),H.on("scroll"+O,T.event.containScroll)}},unbind:{clickaway:function(){T.verbose("Removing clickaway events from context",L),L.off(p)},scrollLock:function(){T.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=T.get.direction(),r={left:n,right:-n,top:t,bottom:-t};T.is.rtl()&&(T.verbose("RTL detected, flipping widths"),r.left=-n,r.right=n),i='<style title="'+A+'">',"left"===o||"right"===o?(T.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); }"),T.is.ie()&&("left"===o||"right"===o?(T.debug("Adding CSS rules for animation distance",n),i+=" .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+=" .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),i+=" .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, .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+"]"),T.debug("Adding sizing css to head",s)}},refresh:function(){T.verbose("Refreshing selector cache"),L=e(C.context),D=L.children(x.sidebar),j=L.children(x.pusher)},refreshSidebars:function(){T.verbose("Refreshing other sidebars"),D=L.children(x.sidebar)},repaint:function(){T.verbose("Forcing repaint event"),z.style.display="none",z.offsetHeight,z.scrollTop=z.scrollTop,z.style.display=""},setup:{layout:function(){0===L.childr