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.
 
 
 

1 lines
10 KiB

!function(a,b,c,d){"use strict";a.fn.sidebar=function(e){var f,g=a(this),h=(a("head"),g.selector||""),i=(new Date).getTime(),j=[],k=arguments[0],l="string"==typeof k,m=[].slice.call(arguments,1),n=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame||function(a){setTimeout(a,0)};return g.each(function(){var g,o,p,q=a.isPlainObject(e)?a.extend(!0,{},a.fn.sidebar.settings,e):a.extend({},a.fn.sidebar.settings),r=q.selector,s=q.className,t=q.namespace,u=q.error,v="."+t,w="module-"+t,x=a(this),y=a(q.context),z=a("style[title="+t+"]"),A=y.children(r.sidebar),B=y.children(r.pusher),C=B.children(r.page),D=B.find(r.fixed),E=this,F=x.data(w);p={initialize:function(){p.debug("Initializing sidebar",x),o=p.get.transitionEvent(),p.is.legacy()&&(q.useLegacy=!0),p.setup.context(),n(p.setup.layout),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),F=p,x.data(w,p)},destroy:function(){p.verbose("Destroying previous module for",x),x.off(v).removeData(w)},event:{clickaway:function(b){0===x.find(b.target).size()&&0===a(b.target).filter(x).size()&&(p.verbose("User clicked on dimmed page"),p.hide())},scroll:function(b){0===x.find(b.target).size()&&0===a(b.target).filter(x).size()&&b.preventDefault()}},bind:{clickaway:function(){q.scrollLock&&a(b).on("DOMMouseScroll"+v,p.event.scroll),y.on("click"+v,p.event.clickaway).on("touchend"+v,p.event.clickaway)}},unbind:{clickaway:function(){y.off(v),q.scrollLock&&a(b).off("DOMMouseScroll"+v)}},refresh:function(){p.verbose("Refreshing selector cache"),y=a(q.context),z=a("style[title="+t+"]"),A=y.children(r.sidebar),B=y.children(r.pusher),C=B.children(r.page),D=B.find(r.fixed)},repaint:function(){p.verbose("Forcing repaint event");y[0].offsetWidth},setup:{layout:function(){0===y.find(r.pusher).size()&&(p.debug("Adding wrapper element for sidebar"),B=a('<div class="pusher" />'),C=a('<div class="page" />'),B.append(C),y.children().not(r.omitted).not(A).wrapAll(B)),x.prevAll(C)[0]!==C[0]&&(p.debug("Moved sidebar to correct parent element"),x.detach().prependTo(y)),p.refresh()},context:function(){p.verbose("Adding pusshable class to wrapper"),y.addClass(s.pushable)}},attachEvents:function(b,c){var d=a(b);c=a.isFunction(p[c])?p[c]:p.toggle,d.size()>0?(p.debug("Attaching sidebar events to element",b,c),d.off(v).on("click"+v,c)):p.error(u.notFound)},show:function(b){var c=q.useLegacy?p.legacyPushPage:p.pushPage;b=a.isFunction(b)?b:function(){},p.is.closed()?(q.overlay&&(p.error(u.overlay),q.transition="overlay"),"overlay"!==q.transition&&p.hideAll(),c(function(){a.proxy(b,E)(),a.proxy(q.onShow,E)()}),a.proxy(q.onChange,E)(),a.proxy(q.onVisible,E)()):p.debug("Sidebar is already visible")},hide:function(b){var c=q.useLegacy?p.legacyPullPage:p.pullPage;b=a.isFunction(b)?b:function(){},p.is.visible()&&(p.debug("Hiding sidebar",b),c(function(){a.proxy(b,E)(),a.proxy(q.onHidden,E)()}),a.proxy(q.onChange,E)(),a.proxy(q.onHide,E)())},hideAll:function(){var a=A.find("."+s.visible);a.sidebar("hide")},toggle:function(){p.verbose("Determining toggled direction"),p.is.closed()?p.show():p.hide()},pushPage:function(c){var d,e=p.get.transition(),f="safe"==e?y:"overlay"==e?x:B;c=a.isFunction(c)?c:function(){},d=function(){p.set.visible(),p.set.transition(),p.set.direction(),n(function(){p.set.inward(),p.set.pushed()})},f.on(o,function(b){b.target==f[0]&&(f.off(o),p.remove.inward(),p.bind.clickaway(),p.set.active(),a.proxy(c,E)())}),p.verbose("Adding context push state",y),"overlay"===e?n(d):(p.is.mobile()&&(x.scrollTop(0),g=a(b).scrollTop(),b.scrollTo(0,0)),p.remove.allVisible(),n(d))},pullPage:function(c){var d=p.get.transition(),e="safe"==d?y:"overlay"==d?x:B;c=a.isFunction(c)?c:function(){},p.verbose("Removing context push state",p.get.direction()),p.unbind.clickaway(),e.on(o,function(d){d.target==e[0]&&(e.off(o),p.remove.transition(),p.remove.direction(),p.remove.outward(),p.remove.visible(),p.is.mobile()&&q.returnScroll&&b.scrollTo(0,g),a.proxy(c,E)())}),n(function(){p.set.outward(),p.remove.active(),p.remove.pushed()})},legacyPushPage:function(b){var c=x.width(),d=p.get.direction(),e={};c=c||x.width(),b=a.isFunction(b)?b:function(){},e[d]=c,p.debug("Using javascript to push context",e),p.set.visible(),p.set.transition(),p.set.direction(),p.set.inward(),p.set.pushed(),y.animate(e,q.duration,q.easing,function(){p.remove.inward(),p.bind.clickaway(),p.set.active(),a.proxy(b,p)()})},legacyPullPage:function(b){var c=0,d=p.get.direction(),e={};c=c||x.width(),b=a.isFunction(b)?b:function(){},e[d]="0px",p.debug("Using javascript to pull context",e),p.unbind.clickaway(),p.set.outward(),p.remove.active(),p.remove.pushed(),y.animate(e,q.duration,q.easing,function(){p.remove.transition(),p.remove.direction(),p.remove.outward(),p.remove.visible(),a.proxy(b,p)()})},set:{active:function(){y.addClass(s.active)},direction:function(a){a=a||p.get.direction(),y.addClass(s[a])},visible:function(){x.addClass(s.visible)},transition:function(a){a=a||p.get.transition(),y.addClass(a)},inward:function(){y.addClass(s.inward)},outward:function(){y.addClass(s.outward)},pushed:function(){q.dimPage&&C.addClass(s.dimmed),y.addClass(s.pushed)}},remove:{active:function(){y.removeClass(s.active)},visible:function(){x.removeClass(s.visible)},allVisible:function(){A.hasClass(s.visible)&&(p.debug("Other sidebars visible, hiding"),A.removeClass(s.visible))},transition:function(a){a=a||p.get.transition(),y.removeClass(a)},pushed:function(){q.dimPage&&C.removeClass(s.dimmed),y.removeClass(s.pushed)},inward:function(){y.removeClass(s.inward)},outward:function(){y.removeClass(s.outward)},direction:function(a){a=a||p.get.direction(),y.removeClass(s[a])}},get:{direction:function(){return x.hasClass(s.top)?s.top:x.hasClass(s.right)?s.right:x.hasClass(s.bottom)?s.bottom:s.left},transition:function(){var a=p.get.direction();return p.is.mobile()?"auto"==q.mobileTransition?q.defaultTransition.mobile[a]:q.mobileTransition:"auto"==q.transition?q.defaultTransition.computer[a]:q.transition},transitionEvent:function(){var a,b=c.createElement("element"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in e)if(b.style[a]!==d)return e[a]}},is:{legacy:function(){var a,e=c.createElement("div"),f={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};c.body.insertBefore(e,null);for(var g in f)e.style[g]!==d&&(e.style[g]="translate3d(1px,1px,1px)",a=b.getComputedStyle(e).getPropertyValue(f[g]));return c.body.removeChild(e),!(a!==d&&a.length>0&&"none"!==a)},mobile:function(){var a=navigator.userAgent,b=/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/,c=b.test(a);return c?(p.verbose("Browser was found to be mobile",a),!0):(p.verbose("Browser is not mobile, using regular transition",a),!1)},closed:function(){return!p.is.visible()},visible:function(){return x.hasClass(s.visible)},vertical:function(){return x.hasClass(s.top)},inward:function(){return y.hasClass(s.inward)},outward:function(){return y.hasClass(s.outward)},animating:function(){return p.is.inward()||p.is.outward()}},setting:function(b,c){if(p.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,q,b);else{if(c===d)return q[b];q[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,p,b);else{if(c===d)return p[b];p[b]=c}},debug:function(){q.debug&&(q.performance?p.performance.log(arguments):(p.debug=Function.prototype.bind.call(console.info,console,q.name+":"),p.debug.apply(console,arguments)))},verbose:function(){q.verbose&&q.debug&&(q.performance?p.performance.log(arguments):(p.verbose=Function.prototype.bind.call(console.info,console,q.name+":"),p.verbose.apply(console,arguments)))},error:function(){p.error=Function.prototype.bind.call(console.error,console,q.name+":"),p.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;q.performance&&(b=(new Date).getTime(),d=i||b,c=b-d,i=b,j.push({Element:E,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(p.performance.timer),p.performance.timer=setTimeout(p.performance.display,100)},display:function(){var b=q.name+":",c=0;i=!1,clearTimeout(p.performance.timer),a.each(j,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",h&&(b+=" '"+h+"'"),(console.group!==d||console.table!==d)&&j.length>0&&(console.groupCollapsed(b),console.table?console.table(j):a.each(j,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),j=[]}},invoke:function(b,c,e){var g,h,i,j=F;return c=c||m,e=E||e,"string"==typeof b&&j!==d&&(b=b.split(/[\. ]/),g=b.length-1,a.each(b,function(c,e){var f=c!=g?e+b[c+1].charAt(0).toUpperCase()+b[c+1].slice(1):b;if(a.isPlainObject(j[f])&&c!=g)j=j[f];else{if(j[f]!==d)return h=j[f],!1;if(!a.isPlainObject(j[e])||c==g)return j[e]!==d?(h=j[e],!1):(p.error(u.method,b),!1);j=j[e]}})),a.isFunction(h)?i=h.apply(e,c):h!==d&&(i=h),a.isArray(f)?f.push(i):f!==d?f=[f,i]:i!==d&&(f=i),h}},l?(F===d&&p.initialize(),p.invoke(k)):(F!==d&&p.destroy(),p.initialize())}),f!==d?f:this},a.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!1,performance:!1,workaround:!1,transition:"auto",mobileTransition:"auto",defaultTransition:{computer:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"},mobile:{left:"overlay",right:"overlay",top:"overlay",bottom:"overlay"}},context:"body",exclusive:!0,dimPage:!0,scrollLock:!1,returnScroll:!1,useLegacy:!1,duration:500,easing:"easeInOutQuint",onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",bottom:"bottom",dimmed:"dimmed",inward:"show",left:"left",outward:"hide",pushable:"pushable",pushed:"pushed",right:"right",top:"top",visible:"visible"},selector:{fixed:".ui.fixed",omitted:"script, link, style, .ui.modal, .ui.nag, .ui.fixed",page:".page",pusher:".pusher",sidebar:".ui.sidebar"},error:{method:"The method you called is not defined.",overlay:"The overlay setting is no longer supported, use animation: overlay",notFound:"There were no elements that matched the specified selector"}},a.extend(a.easing,{easeInOutQuint:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c}})}(jQuery,window,document);