|
|
/*! * # Semantic UI 2.0.0 - Sidebar * http://github.com/semantic-org/semantic-ui/
* * * Copyright 2015 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT
* */ !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,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,C,k,x=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),T=x.selector,S=x.className,A=x.namespace,P=x.regExp,F=x.error,O="."+A,E="module-"+A,H=e(this),L=e(x.context),j=H.children(T.sidebar),D=L.children(T.fixed),z=L.children(T.pusher),M=this,R=H.data(E);k={initialize:function(){k.debug("Initializing sidebar",o),k.create.id(),C=k.get.transitionEvent(),("auto"==x.useLegacy&&k.is.legacy()||x.useLegacy===!0)&&(x.transition="overlay",x.useLegacy=!0),k.is.ios()&&k.set.ios(),x.delaySetup?v(k.setup.layout):k.setup.layout(),v(function(){k.setup.cache()}),k.instantiate()},instantiate:function(){k.verbose("Storing instance of module",k),R=k,H.data(E,k)},create:{id:function(){y=(Math.random().toString(16)+"000000000").substr(2,8),p="."+y,k.verbose("Creating unique id for element",y)}},destroy:function(){k.verbose("Destroying previous module for",H),k.remove.direction(),H.off(O).removeData(E),k.is.ios()&&k.remove.ios(),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&&(k.verbose("User clicked on dimmed page"),k.hide()),n&&(k.verbose("User clicked on dimmable context (scaled out page)"),k.hide())},touch:function(e){},containScroll:function(e){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(){k.verbose("Adding clickaway events to context",L),x.closable&&L.on("click"+p,k.event.clickaway).on("touchend"+p,k.event.clickaway)},scrollLock:function(){x.scrollLock&&(k.debug("Disabling page scroll"),a.on("DOMMouseScroll"+p,k.event.scroll)),k.verbose("Adding events to contain sidebar scroll"),l.on("touchmove"+p,k.event.touch),H.on("scroll"+O,k.event.containScroll)}},unbind:{clickaway:function(){k.verbose("Removing clickaway events from context",L),L.off(p)},scrollLock:function(){k.verbose("Removing scroll lock from page"),l.off(p),a.off(p),H.off("scroll"+O)}},add:{inlineCSS:function(){var i,n=k.cache.width||H.outerWidth(),t=k.cache.height||H.outerHeight(),o=k.is.rtl(),r=k.get.direction(),a={left:n,right:-n,top:t,bottom:-t};o&&(k.verbose("RTL detected, flipping widths"),a.left=-n,a.right=n),i="<style>","left"===r||"right"===r?(k.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); }"),k.is.ie()&&("left"===r||"right"===r?(k.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),k.debug("Adding sizing css to head",s)}},refresh:function(){k.verbose("Refreshing selector cache"),L=e(x.context),j=L.children(T.sideba
|