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.

0 lines
5.2 KiB

  1. !function(a,b,c,d){a.fn.sidebar=function(b){var e,f=a(this),g=f.selector||"",h=(new Date).getTime(),i=[],j=arguments[0],k="string"==typeof j,l=[].slice.call(arguments,1);return f.each(function(){var m,n=a.isPlainObject(b)?a.extend(!0,{},a.fn.sidebar.settings,b):a.fn.sidebar.settings,o=(n.selector,n.className),p=n.namespace,q=n.error,r="."+p,s="module-"+p,t=a(this),u=a("body"),v=a("head"),w=a("style[title="+p+"]"),x=this,y=t.data(s);m={initialize:function(){m.debug("Initializing sidebar",t),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),y=m,t.data(s,m)},destroy:function(){m.verbose("Destroying previous module for",t),t.off(r).removeData(s)},refresh:function(){m.verbose("Refreshing selector cache"),w=a("style[title="+p+"]")},attachEvents:function(b,c){var d=a(b);c=a.isFunction(m[c])?m[c]:m.toggle,d.size()>0?(m.debug("Attaching sidebar events to element",b,c),d.off(r).on("click"+r,c)):m.error(q.notFound)},show:function(){m.debug("Showing sidebar"),m.is.closed()?(n.overlay||m.pushPage(),m.set.active()):m.debug("Sidebar is already visible")},hide:function(){m.is.open()&&(n.overlay||(m.pullPage(),m.remove.pushed()),m.remove.active())},toggle:function(){m.is.closed()?m.show():m.hide()},pushPage:function(){var a=m.get.direction(),b=m.is.vertical()?t.outerHeight():t.outerWidth();n.useCSS?(m.debug("Using CSS to animate body"),m.add.bodyCSS(a,b),m.set.pushed()):m.animatePage(a,b,m.set.pushed)},pullPage:function(){var a=m.get.direction();n.useCSS?(m.debug("Resetting body position css"),m.remove.bodyCSS()):(m.debug("Resetting body position using javascript"),m.animatePage(a,0)),m.remove.pushed()},animatePage:function(a,b){var c={};c["padding-"+a]=b,m.debug("Using javascript to animate body",c),u.animate(c,n.duration,m.set.pushed)},add:{bodyCSS:function(a,b){var c;a!==o.bottom&&(c='<style title="'+p+'">'+"body.pushed {"+" margin-"+a+": "+b+"px !important;"+"}"+"</style>"),v.append(c),m.debug("Adding body css to head",w)}},remove:{bodyCSS:function(){m.debug("Removing body css styles",w),m.refresh(),w.remove()},active:function(){t.removeClass(o.active)},pushed:function(){m.verbose("Removing body push state",m.get.direction()),u.removeClass(o[m.get.direction()]).removeClass(o.pushed)}},set:{active:function(){t.addClass(o.active)},pushed:function(){m.verbose("Adding body push state",m.get.direction()),u.addClass(o[m.get.direction()]).addClass(o.pushed)}},get:{direction:function(){return t.hasClass(o.top)?o.top:t.hasClass(o.right)?o.right:t.hasClass(o.bottom)?o.bottom:o.left},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:{open:function(){return t.is(":animated")||t.hasClass(o.active)},closed:function(){return!m.is.open()},vertical:function(){return t.hasClass(o.top)}},setting:function(b,c){return c===d?n[b]:(a.isPlainObject(b)?a.extend(!0,n,b):n[b]=c,void 0)},internal:function(b,c){return c===d?m[b]:(a.isPlainObject(b)?a.extend(!0,m,b):m[b]=c,void 0)},debug:function(){n.debug&&(n.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,n.name+":"),m.debug.apply(console,arguments)))},verbose:function(){n.verbose&&n.debug&&(n.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,n.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,n.name+":"),m.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;n.performance&&(b=(new Date).getTime(),d=h||b,c=b-d,h=b,i.push({Element:x,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var b=n.name+":",c=0;h=!1,clearTimeout(m.performance.timer),a.each(i,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",g&&(b+=" '"+g+"'"),f.size()>1&&(b+=" ("+f.size()+")"),(console.group!==d||cons