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.
11 lines
14 KiB
11 lines
14 KiB
/*
|
|
* # Semantic UI - 1.9.1
|
|
* https://github.com/Semantic-Org/Semantic-UI
|
|
* http://www.semantic-ui.com/
|
|
*
|
|
* Copyright 2014 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=[],b=arguments[0],g="string"==typeof b,v=[].slice.call(arguments,1),h=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,p,y,k,w,x,T=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),C=T.selector,S=T.className,A=T.namespace,P=T.regExp,F=T.error,O="."+A,E="module-"+A,D=e(this),H=e(T.context),L=D.children(C.sidebar),j=H.children(C.fixed),z=H.children(C.pusher),M=this,R=D.data(E);x={initialize:function(){x.debug("Initializing sidebar",o),x.create.id(),w=x.get.transitionEvent(),("auto"==T.useLegacy&&x.is.legacy()||T.useLegacy===!0)&&(T.transition="overlay",T.useLegacy=!0),x.is.ios()&&x.set.ios(),T.delaySetup?h(x.setup.layout):x.setup.layout(),x.instantiate()},instantiate:function(){x.verbose("Storing instance of module",x),R=x,D.data(E,x)},create:{id:function(){x.verbose("Creating unique id for element"),y=x.get.uniqueID(),p="."+y}},destroy:function(){x.verbose("Destroying previous module for",D),x.remove.direction(),D.off(O).removeData(E),H.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=H.is(e.target);i&&(x.verbose("User clicked on dimmed page"),x.hide()),n&&(x.verbose("User clicked on dimmable context (scaled out page)"),x.hide())},touch:function(){},containScroll:function(){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(C.sidebar).length&&i.preventDefault()}},bind:{clickaway:function(){x.verbose("Adding clickaway events to context",H),T.closable&&H.on("click"+p,x.event.clickaway).on("touchend"+p,x.event.clickaway)},scrollLock:function(){T.scrollLock&&(x.debug("Disabling page scroll"),a.on("DOMMouseScroll"+p,x.event.scroll)),x.verbose("Adding events to contain sidebar scroll"),l.on("touchmove"+p,x.event.touch),D.on("scroll"+O,x.event.containScroll)}},unbind:{clickaway:function(){x.verbose("Removing clickaway events from context",H),H.off(p)},scrollLock:function(){x.verbose("Removing scroll lock from page"),l.off(p),a.off(p),D.off("scroll"+O)}},add:{bodyCSS:function(){var i,n=D.outerWidth(),t=D.outerHeight(),o=x.get.direction(),r={left:n,right:-n,top:t,bottom:-t};x.is.rtl()&&(x.verbose("RTL detected, flipping widths"),r.left=-n,r.right=n),i='<style title="'+A+'">',"left"===o||"right"===o?(x.debug("Adding CSS rules for animation distance",n),i+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):("top"===o||"bottom"==o)&&(i+=" .ui.visible."+o+".sidebar ~ .fixed, .ui.visible."+o+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"px, 0); }"),x.is.ie()&&("left"===o||"right"===o?(x.debug("Adding CSS rules for animation distance",n),i+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d("+r[o]+"px, 0, 0); transform: translate3d("+r[o]+"px, 0, 0); }"):("top"===o||"bottom"==o)&&(i+=" body.pushable > .ui.visible."+o+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+r[o]+"px, 0); transform: translate3d(0, "+r[o]+"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>",u.append(i),s=e("style[title="+A+"]"),x.debug("Adding sizing css to head",s)}},refresh:function(){x.verbose("Refreshing selector cache"),H=e(T.context),L=H.children(C.sidebar),z=H.children(C.pusher),j=H.children(C.fixed)},refreshSidebars:function(){x.verbose("Refreshing other sidebars"),L=H.children(C.sidebar)},repaint:function(){x.verbose("Forcing repaint event"),M.style.display="none",M.offsetHeight,M.scrollTop=M.scrollTop,M.style.display=""},setup:{layout:function(){0===H.children(C.pusher).length&&(x.debug("Adding wrapper element for sidebar"),x.error(F.pusher),z=e('<div class="pusher" />'),H.children().not(C.omitted).not(L).wrapAll(z),x.refresh()),(0===D.nextAll(C.pusher).length||D.nextAll(C.pusher)[0]!==z[0])&&(x.debug("Moved sidebar to correct parent element"),x.error(F.movedSidebar,M),D.detach().prependTo(H),x.refresh()),x.set.pushable(),x.set.direction()}},attachEvents:function(i,n){var t=e(i);n=e.isFunction(x[n])?x[n]:x.toggle,t.length>0?(x.debug("Attaching sidebar events to element",i,n),t.on("click"+O,n)):x.error(F.notFound,i)},show:function(i){var n=T.useLegacy===!0?x.legacyPushPage:x.pushPage;i=e.isFunction(i)?i:function(){},x.is.hidden()?(x.refreshSidebars(),T.overlay&&(x.error(F.overlay),T.transition="overlay"),x.refresh(),x.othersActive()&&"overlay"!==x.get.transition()&&(x.debug("Other sidebars currently visible"),T.transition="overlay",T.exclusive&&x.hideOthers()),n(function(){i.call(M),T.onShow.call(M)}),T.onChange.call(M),T.onVisible.call(M)):x.debug("Sidebar is already visible")},hide:function(i){var n=T.useLegacy===!0?x.legacyPullPage:x.pullPage;i=e.isFunction(i)?i:function(){},(x.is.visible()||x.is.animating())&&(x.debug("Hiding sidebar",i),x.refreshSidebars(),n(function(){i.call(M),T.onHidden.call(M)}),T.onChange.call(M),T.onHide.call(M))},othersAnimating:function(){return L.not(D).filter("."+S.animating).length>0},othersVisible:function(){return L.not(D).filter("."+S.visible).length>0},othersActive:function(){return x.othersVisible()||x.othersAnimating()},hideOthers:function(e){var i=L.not(D).filter("."+S.visible),n=i.length,t=0;e=e||function(){},i.sidebar("hide",function(){t++,t==n&&e()})},toggle:function(){x.verbose("Determining toggled direction"),x.is.hidden()?x.show():x.hide()},pushPage:function(i){var n,t,o=x.get.transition(),r="safe"==o?H:"overlay"===o||x.othersActive()?D:z;i=e.isFunction(i)?i:function(){},"scale down"==T.transition&&x.scrollToTop(),x.set.transition(o),x.repaint(),n=function(){x.bind.clickaway(),x.add.bodyCSS(),x.set.animating(),x.set.visible(),x.othersVisible()||T.dimPage&&z.addClass(S.dimmed)},t=function(e){e.target==r[0]&&(r.off(w+p,t),x.remove.animating(),x.bind.scrollLock(),i.call(M))},r.off(w+p),r.on(w+p,t),h(n)},pullPage:function(i){var n,t,o=x.get.transition(),r="safe"==o?H:"overlay"==o||x.othersActive()?D:z;i=e.isFunction(i)?i:function(){},x.verbose("Removing context push state",x.get.direction()),x.set.transition(o),x.unbind.clickaway(),x.unbind.scrollLock(),n=function(){x.set.animating(),x.remove.visible(),T.dimPage&&!x.othersVisible()&&z.removeClass(S.dimmed)},t=function(e){e.target==r[0]&&(r.off(w+p,t),x.remove.animating(),x.remove.transition(),x.remove.bodyCSS(),("scale down"==o||T.returnScroll&&x.is.mobile())&&x.scrollBack(),i.call(M))},r.off(w+p),r.on(w+p,t),h(n)},legacyPushPage:function(i){var n=D.width(),t=x.get.direction(),o={};n=n||D.width(),i=e.isFunction(i)?i:function(){},o[t]=n,x.debug("Using javascript to push context",o),x.set.visible(),x.set.transition(),x.set.animating(),T.dimPage&&z.addClass(S.dimmed),H.css("position","relative").animate(o,T.duration,T.easing,function(){x.remove.animating(),x.bind.clickaway(),i.call(M)})},legacyPullPage:function(i){var n=0,t=x.get.direction(),o={};n=n||D.width(),i=e.isFunction(i)?i:function(){},o[t]="0px",x.debug("Using javascript to pull context",o),x.unbind.clickaway(),x.set.animating(),x.remove.visible(),T.dimPage&&!x.othersActive()&&z.removeClass(S.dimmed),H.css("position","relative").animate(o,T.duration,T.easing,function(){x.remove.animating(),i.call(M)})},scrollToTop:function(){x.verbose("Scrolling to top of page to avoid animation issues"),k=e(i).scrollTop(),D.scrollTop(0),i.scrollTo(0,0)},scrollBack:function(){x.verbose("Scrolling back to original page position"),i.scrollTo(0,k)},set:{ios:function(){c.addClass(S.ios)},pushed:function(){H.addClass(S.pushed)},pushable:function(){H.addClass(S.pushable)},active:function(){D.addClass(S.active)},animating:function(){D.addClass(S.animating)},transition:function(e){e=e||x.get.transition(),D.addClass(e)},direction:function(e){e=e||x.get.direction(),D.addClass(S[e])},visible:function(){D.addClass(S.visible)},overlay:function(){D.addClass(S.overlay)}},remove:{bodyCSS:function(){x.debug("Removing body css styles",s),s&&s.length>0&&s.remove()},pushed:function(){H.removeClass(S.pushed)},pushable:function(){H.removeClass(S.pushable)},active:function(){D.removeClass(S.active)},animating:function(){D.removeClass(S.animating)},transition:function(e){e=e||x.get.transition(),D.removeClass(e)},direction:function(e){e=e||x.get.direction(),D.removeClass(S[e])},visible:function(){D.removeClass(S.visible)},overlay:function(){D.removeClass(S.overlay)}},get:{direction:function(){return D.hasClass(S.top)?S.top:D.hasClass(S.right)?S.right:D.hasClass(S.bottom)?S.bottom:S.left},transition:function(){var e,i=x.get.direction();return e=x.is.mobile()?"auto"==T.mobileTransition?T.defaultTransition.mobile[i]:T.mobileTransition:"auto"==T.transition?T.defaultTransition.computer[i]:T.transition,x.verbose("Determined transition",e),e},transitionEvent:function(){var e,i=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(i.style[e]!==t)return o[e]},uniqueID:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},is:{ie:function(){var e=!i.ActiveXObject&&"ActiveXObject"in i,n="ActiveXObject"in i;return e||n},legacy:function(){var e,o=n.createElement("div"),r={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};n.body.insertBefore(o,null);for(var s in r)o.style[s]!==t&&(o.style[s]="translate3d(1px,1px,1px)",e=i.getComputedStyle(o).getPropertyValue(r[s]));return n.body.removeChild(o),!(e!==t&&e.length>0&&"none"!==e)},ios:function(){var e=navigator.userAgent,i=e.match(P.ios);return i?(x.verbose("Browser was found to be iOS",e),!0):!1},mobile:function(){var e=navigator.userAgent,i=e.match(P.mobile);return i?(x.verbose("Browser was found to be mobile",e),!0):(x.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!x.is.visible()},visible:function(){return D.hasClass(S.visible)},open:function(){return x.is.visible()},closed:function(){return x.is.hidden()},vertical:function(){return D.hasClass(S.top)},animating:function(){return H.hasClass(S.animating)},rtl:function(){return"rtl"==D.css("direction")}},setting:function(i,n){if(x.debug("Changing setting",i,n),e.isPlainObject(i))e.extend(!0,T,i);else{if(n===t)return T[i];T[i]=n}},internal:function(i,n){if(e.isPlainObject(i))e.extend(!0,x,i);else{if(n===t)return x[i];x[i]=n}},debug:function(){T.debug&&(T.performance?x.performance.log(arguments):(x.debug=Function.prototype.bind.call(console.info,console,T.name+":"),x.debug.apply(console,arguments)))},verbose:function(){T.verbose&&T.debug&&(T.performance?x.performance.log(arguments):(x.verbose=Function.prototype.bind.call(console.info,console,T.name+":"),x.verbose.apply(console,arguments)))},error:function(){x.error=Function.prototype.bind.call(console.error,console,T.name+":"),x.error.apply(console,arguments)},performance:{log:function(e){var i,n,t;T.performance&&(i=(new Date).getTime(),t=f||i,n=i-t,f=i,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:M,"Execution Time":n})),clearTimeout(x.performance.timer),x.performance.timer=setTimeout(x.performance.display,100)},display:function(){var i=T.name+":",n=0;f=!1,clearTimeout(x.performance.timer),e.each(m,function(e,i){n+=i["Execution Time"]}),i+=" "+n+"ms",d&&(i+=" '"+d+"'"),(console.group!==t||console.table!==t)&&m.length>0&&(console.groupCollapsed(i),console.table?console.table(m):e.each(m,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(i,n,o){var s,a,l,c=R;return n=n||v,o=M||o,"string"==typeof i&&c!==t&&(i=i.split(/[\. ]/),s=i.length-1,e.each(i,function(n,o){var r=n!=s?o+i[n+1].charAt(0).toUpperCase()+i[n+1].slice(1):i;if(e.isPlainObject(c[r])&&n!=s)c=c[r];else{if(c[r]!==t)return a=c[r],!1;if(!e.isPlainObject(c[o])||n==s)return c[o]!==t?(a=c[o],!1):(x.error(F.method,i),!1);c=c[o]}})),e.isFunction(a)?l=a.apply(o,n):a!==t&&(l=a),e.isArray(r)?r.push(l):r!==t?r=[r,l]:l!==t&&(r=l),a}},g?(R===t&&x.initialize(),x.invoke(b)):(R!==t&&x.invoke("destroy"),x.initialize())}),r!==t?r:this},e.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!0,performance:!0,transition:"auto",mobileTransition:"auto",defaultTransition:{computer:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"},mobile:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"}},context:"body",exclusive:!1,closable:!0,dimPage:!0,scrollLock:!1,returnScroll:!1,delaySetup:!1,useLegacy:"auto",duration:500,easing:"easeInOutQuint",onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",animating:"animating",dimmed:"dimmed",ios:"ios",pushable:"pushable",pushed:"pushed",right:"right",top:"top",left:"left",bottom:"bottom",visible:"visible"},selector:{fixed:".fixed",omitted:"script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed",pusher:".pusher",sidebar:".ui.sidebar"},regExp:{ios:/(iPad|iPhone|iPod)/g,mobile:/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/g},error:{method:"The method you called is not defined.",pusher:"Had to add pusher element. For optimal performance make sure body content is inside a pusher element",movedSidebar:"Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag",overlay:"The overlay setting is no longer supported, use animation: overlay",notFound:"There were no elements that matched the specified selector"}},e.extend(e.easing,{easeInOutQuint:function(e,i,n,t,o){return(i/=o/2)<1?t/2*i*i*i*i*i+n:t/2*((i-=2)*i*i*i*i+2)+n}})}(jQuery,window,document);
|