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
8.2 KiB
1 lines
8.2 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=a.isPlainObject(e)?a.extend(!0,{},a.fn.sidebar.settings,e):a.extend({},a.fn.sidebar.settings),q=p.selector,r=p.className,s=p.namespace,t=p.error,u="."+s,v="module-"+s,w=a(this),x=a(p.context),y=a("style[title="+s+"]"),z=x.children(q.sidebar),A=x.children(q.pusher),B=A.children(q.page),C=A.find(q.fixed),D=this,E=w.data(v);o={initialize:function(){o.debug("Initializing sidebar",w),g=o.get.transitionEvent(),o.setup.context(),n(o.setup.layout),o.instantiate()},instantiate:function(){o.verbose("Storing instance of module",o),E=o,w.data(v,o)},destroy:function(){o.verbose("Destroying previous module for",w),w.off(u).removeData(v)},event:{clickaway:function(b){0===w.find(b.target).size()&&0===a(b.target).filter(w).size()&&(o.verbose("User clicked on dimmed page"),o.hide())},scroll:function(b){0===w.find(b.target).size()&&0===a(b.target).filter(w).size()&&b.preventDefault()}},bind:{clickaway:function(){a(b).on("DOMMouseScroll"+u,o.event.scroll),x.on("click"+u,o.event.clickaway).on("touchend"+u,o.event.clickaway)}},unbind:{clickaway:function(){x.off(u),a(b).off("DOMMouseScroll"+u)}},refresh:function(){o.verbose("Refreshing selector cache"),x=a(p.context),y=a("style[title="+s+"]"),z=x.children(q.sidebar),A=x.children(q.pusher),B=A.children(q.page),C=A.find(q.fixed)},repaint:function(){o.verbose("Forcing repaint event");x[0].offsetWidth},setup:{layout:function(){0===x.find(q.pusher).size()&&(o.debug("Adding wrapper element for sidebar"),A=a('<div class="pusher" />'),B=a('<div class="page" />'),A.append(B),x.children().not(q.omitted).not(z).wrapAll(A)),w.prevAll(B)[0]!==B[0]&&(o.debug("Moved sidebar to correct parent element"),w.detach().prependTo(x)),o.refresh()},context:function(){o.verbose("Adding pusshable class to wrapper"),x.addClass(r.pushable)}},attachEvents:function(b,c){var d=a(b);c=a.isFunction(o[c])?o[c]:o.toggle,d.size()>0?(o.debug("Attaching sidebar events to element",b,c),d.off(u).on("click"+u,c)):o.error(t.notFound)},show:function(b){b=a.isFunction(b)?b:function(){},o.debug("Showing sidebar",b),o.is.closed()?(p.overlay&&(p.transition="overlay"),"overlay"!==p.transition&&o.hideAll(),o.pushPage(function(){o.set.active(),a.proxy(b,D)(),a.proxy(p.onShow,D)()}),a.proxy(p.onChange,D)(),a.proxy(p.onVisible,D)()):o.debug("Sidebar is already visible")},hide:function(b){b=a.isFunction(b)?b:function(){},o.debug("Hiding sidebar",b),o.is.visible()&&(o.pullPage(function(){a.proxy(b,D)(),a.proxy(p.onHidden,D)()}),a.proxy(p.onChange,D)(),a.proxy(p.onHide,D)())},hideAll:function(){var a=z.find("."+r.visible);a.sidebar("hide")},toggle:function(){o.verbose("Determining toggled direction"),o.is.closed()?o.show():o.hide()},pushPage:function(c){var d,e="safe"==p.transition?x:"overlay"==p.transition?w:A;c=a.isFunction(c)?c:function(){},d=function(){o.set.visible(),o.set.transition(),o.set.direction(),n(function(){o.set.inward(),o.set.pushed()})},e.on(g,function(b){b.target==e[0]&&(e.off(g),o.remove.inward(),o.bind.clickaway(),a.proxy(c,D)())}),o.verbose("Adding context push state",x),"overlay"===p.transition?n(d):("safe"!==p.transition&&(w.scrollTop(0),"scroll"===p.workaround&&b.scrollTo(0,0)),o.remove.allVisible(),n(d))},pullPage:function(b){var c="safe"==p.transition?x:"overlay"==p.transition?w:A;b=a.isFunction(b)?b:function(){},o.verbose("Removing context push state",o.get.direction()),o.unbind.clickaway(),c.on(g,function(d){d.target==c[0]&&(c.off(g),o.remove.transition(),o.remove.direction(),o.remove.outward(),o.remove.visible(),a.proxy(b,D)())}),o.set.outward(),o.remove.active(),o.remove.pushed()},set:{active:function(){x.addClass(r.active)},direction:function(a){a=a||o.get.direction(),x.addClass(r[a])},visible:function(){w.addClass(r.visible)},transition:function(a){a=a||o.is.mobile()?p.mobileTransition:p.transition,x.addClass(a)},inward:function(){x.addClass(r.inward)},outward:function(){x.addClass(r.outward)},pushed:function(){x.addClass(r.pushed)}},remove:{active:function(){x.removeClass(r.active)},visible:function(){w.removeClass(r.visible)},allVisible:function(){z.hasClass(r.visible)&&(o.debug("Other sidebars visible, hiding"),z.removeClass(r.visible))},transition:function(a){a=a||o.is.mobile()?p.mobileTransition:p.transition,x.removeClass(a)},pushed:function(){x.removeClass(r.pushed)},inward:function(){x.removeClass(r.inward)},outward:function(){x.removeClass(r.outward)},direction:function(a){a=a||o.get.direction(),x.removeClass(r[a])}},get:{direction:function(){return w.hasClass(r.top)?r.top:w.hasClass(r.right)?r.right:w.hasClass(r.bottom)?r.bottom:r.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:{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?(o.verbose("Browser was found to be mobile",a),!0):(o.verbose("Browser is not mobile, using regular transition",a),!1)},closed:function(){return!o.is.visible()},visible:function(){return w.hasClass(r.visible)},vertical:function(){return w.hasClass(r.top)},inward:function(){return x.hasClass(r.inward)},outward:function(){return x.hasClass(r.outward)},animating:function(){return o.is.inward()||o.is.outward()}},setting:function(b,c){if(o.debug("Changing setting",b,c),a.isPlainObject(b))a.extend(!0,p,b);else{if(c===d)return p[b];p[b]=c}},internal:function(b,c){if(a.isPlainObject(b))a.extend(!0,o,b);else{if(c===d)return o[b];o[b]=c}},debug:function(){p.debug&&(p.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,p.name+":"),o.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),o.verbose.apply(console,arguments)))},error:function(){o.error=Function.prototype.bind.call(console.error,console,p.name+":"),o.error.apply(console,arguments)},performance:{log:function(a){var b,c,d;p.performance&&(b=(new Date).getTime(),d=i||b,c=b-d,i=b,j.push({Element:D,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(o.performance.timer),o.performance.timer=setTimeout(o.performance.display,100)},display:function(){var b=p.name+":",c=0;i=!1,clearTimeout(o.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=E;return c=c||m,e=D||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):(o.error(t.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?(E===d&&o.initialize(),o.invoke(k)):(E!==d&&o.destroy(),o.initialize())}),f!==d?f:this},a.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!1,performance:!1,transition:"overlay",mobileTransition:"slide along",context:"body",useCSS:!0,duration:300,dimPage:!0,exclusive:!0,onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},workaround:"scroll",className:{pushable:"pushable",active:"active",visible:"visible",pushed:"pushed",inward:"show",outward:"hide"},selector:{sidebar:".ui.sidebar",pusher:".pusher",fixed:".ui.fixed",page:".page",omitted:"script, link, style, .ui.modal, .ui.nag"},error:{method:"The method you called is not defined.",notFound:"There were no elements that matched the specified selector"}}}(jQuery,window,document);
|