10 lines
13 KiB
JavaScript
10 lines
13 KiB
JavaScript
|
/*!
|
||
|
* # Semantic UI 2.2.7 - Sidebar
|
||
|
* http://github.com/semantic-org/semantic-ui/
|
||
|
*
|
||
|
*
|
||
|
* Released under the MIT license
|
||
|
* http://opensource.org/licenses/MIT
|
||
|
*
|
||
|
*/
|
||
|
!function(e,i,n,t){"use strict";i="undefined"!=typeof i&&i.Math==Math?i:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.sidebar=function(o){var r,s=e(this),a=e(i),l=e(n),c=e("html"),d=e("head"),u=s.selector||"",f=(new Date).getTime(),b=[],h=arguments[0],m="string"==typeof h,g=[].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,C,k,w,T=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),x=T.selector,S=T.className,A=T.namespace,F=T.regExp,O=T.error,P="."+A,E="module-"+A,H=e(this),M=e(T.context),D=H.children(x.sidebar),j=M.children(x.fixed),R=M.children(x.pusher),z=this,B=H.data(E);w={initialize:function(){w.debug("Initializing sidebar",o),w.create.id(),k=w.get.transitionEvent(),w.is.ios()&&w.set.ios(),T.delaySetup?v(w.setup.layout):w.setup.layout(),v(function(){w.setup.cache()}),w.instantiate()},instantiate:function(){w.verbose("Storing instance of module",w),B=w,H.data(E,w)},create:{id:function(){y=(Math.random().toString(16)+"000000000").substr(2,8),p="."+y,w.verbose("Creating unique id for element",y)}},destroy:function(){w.verbose("Destroying previous module for",H),H.off(P).removeData(E),w.is.ios()&&w.remove.ios(),M.off(p),a.off(p),l.off(p)},event:{clickaway:function(e){var i=R.find(e.target).length>0||R.is(e.target),n=M.is(e.target);i&&(w.verbose("User clicked on dimmed page"),w.hide()),n&&(w.verbose("User clicked on dimmable context (scaled out page)"),w.hide())},touch:function(e){},containScroll:function(e){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(){w.verbose("Adding clickaway events to context",M),T.closable&&M.on("click"+p,w.event.clickaway).on("touchend"+p,w.event.clickaway)},scrollLock:function(){T.scrollLock&&(w.debug("Disabling page scroll"),a.on("DOMMouseScroll"+p,w.event.scroll)),w.verbose("Adding events to contain sidebar scroll"),l.on("touchmove"+p,w.event.touch),H.on("scroll"+P,w.event.containScroll)}},unbind:{clickaway:function(){w.verbose("Removing clickaway events from context",M),M.off(p)},scrollLock:function(){w.verbose("Removing scroll lock from page"),l.off(p),a.off(p),H.off("scroll"+P)}},add:{inlineCSS:function(){var i,n=w.cache.width||H.outerWidth(),t=w.cache.height||H.outerHeight(),o=w.is.rtl(),r=w.get.direction(),a={left:n,right:-n,top:t,bottom:-t};o&&(w.verbose("RTL detected, flipping widths"),a.left=-n,a.right=n),i="<style>","left"===r||"right"===r?(w.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); }"),w.is.ie()&&("left"===r||"right"===r?(w.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(d),w.debug("Adding sizing css to head",s)}},refresh:function(){w.verbose("Refreshing selector cache"),M=e(T.context),D=M.children(x.sidebar),R=M.c
|