perfect-scrollbar/out/js/perfect-scrollbar.min.js
2015-02-11 15:53:17 +00:00

1 line
9.5 KiB
JavaScript

!function e(t,n,o){function r(i,a){if(!n[i]){if(!t[i]){var s="function"==typeof require&&require;if(!a&&s)return s(i,!0);if(l)return l(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return r(n?n:e)},u,u.exports,e,t,n,o)}return n[i].exports}for(var l="function"==typeof require&&require,i=0;i<o.length;i++)r(o[i]);return r}({1:[function(){!function(e){"use strict";e(jQuery)}(function(e){"use strict";function t(e){return"string"==typeof e?parseInt(e,10):~~e}var n={wheelSpeed:1,wheelPropagation:!1,swipePropagation:!0,minScrollbarLength:null,maxScrollbarLength:null,useBothWheelAxes:!1,useKeyboard:!0,suppressScrollX:!1,suppressScrollY:!1,scrollXMarginOffset:0,scrollYMarginOffset:0,includePadding:!1},o=0,r=function(){var e=o++;return function(t){var n=".perfect-scrollbar-"+e;return"undefined"==typeof t?n:t+n}},l="WebkitAppearance"in document.documentElement.style;e.fn.perfectScrollbar=function(o,i){return this.each(function(){function a(e,n){var o=e+n,r=D-R;A=0>o?0:o>r?r:o;var l=t(A*(Y-D)/(D-R));x.scrollTop(l)}function s(e,n){var o=e+n,r=M-k;W=0>o?0:o>r?r:o;var l=t(W*(C-M)/(M-k));x.scrollLeft(l)}function c(e){return P.minScrollbarLength&&(e=Math.max(e,P.minScrollbarLength)),P.maxScrollbarLength&&(e=Math.min(e,P.maxScrollbarLength)),e}function u(){var e={width:I};e.left=q?x.scrollLeft()+M-C:x.scrollLeft(),j?e.bottom=N-x.scrollTop():e.top=F+x.scrollTop(),_.css(e);var t={top:x.scrollTop(),height:U};Z?t.right=q?C-x.scrollLeft()-V-J.outerWidth():V-x.scrollLeft():t.left=q?x.scrollLeft()+2*M-C-$-J.outerWidth():$+x.scrollLeft(),G.css(t),H.css({left:W,width:k-Q}),J.css({top:A,height:R-et})}function p(){x.removeClass("ps-active-x"),x.removeClass("ps-active-y"),M=P.includePadding?x.innerWidth():x.width(),D=P.includePadding?x.innerHeight():x.height(),C=x.prop("scrollWidth"),Y=x.prop("scrollHeight"),!P.suppressScrollX&&M+P.scrollXMarginOffset<C?(X=!0,I=M-z,k=c(t(I*M/C)),W=t(x.scrollLeft()*(I-k)/(C-M))):(X=!1,k=0,W=0,x.scrollLeft(0)),!P.suppressScrollY&&D+P.scrollYMarginOffset<Y?(O=!0,U=D-tt,R=c(t(U*D/Y)),A=t(x.scrollTop()*(U-R)/(Y-D))):(O=!1,R=0,A=0,x.scrollTop(0)),W>=I-k&&(W=I-k),A>=U-R&&(A=U-R),u(),X&&x.addClass("ps-active-x"),O&&x.addClass("ps-active-y")}function d(){var t,n,o=function(e){s(t,e.pageX-n),p(),e.stopPropagation(),e.preventDefault()},r=function(){x.removeClass("ps-in-scrolling"),e(K).unbind(B("mousemove"),o)};H.bind(B("mousedown"),function(l){n=l.pageX,t=H.position().left,x.addClass("ps-in-scrolling"),e(K).bind(B("mousemove"),o),e(K).one(B("mouseup"),r),l.stopPropagation(),l.preventDefault()}),t=n=null}function f(){var t,n,o=function(e){a(t,e.pageY-n),p(),e.stopPropagation(),e.preventDefault()},r=function(){x.removeClass("ps-in-scrolling"),e(K).unbind(B("mousemove"),o)};J.bind(B("mousedown"),function(l){n=l.pageY,t=J.position().top,x.addClass("ps-in-scrolling"),e(K).bind(B("mousemove"),o),e(K).one(B("mouseup"),r),l.stopPropagation(),l.preventDefault()}),t=n=null}function v(e,t){var n=x.scrollTop();if(0===e){if(!O)return!1;if(0===n&&t>0||n>=Y-D&&0>t)return!P.wheelPropagation}var o=x.scrollLeft();if(0===t){if(!X)return!1;if(0===o&&0>e||o>=C-M&&e>0)return!P.wheelPropagation}return!0}function g(e,t){var n=x.scrollTop(),o=x.scrollLeft(),r=Math.abs(e),l=Math.abs(t);if(l>r){if(0>t&&n===Y-D||t>0&&0===n)return!P.swipePropagation}else if(r>l&&(0>e&&o===C-M||e>0&&0===o))return!P.swipePropagation;return!0}function b(){function e(e){var t=e.originalEvent.deltaX,n=-1*e.originalEvent.deltaY;return("undefined"==typeof t||"undefined"==typeof n)&&(t=-1*e.originalEvent.wheelDeltaX/6,n=e.originalEvent.wheelDeltaY/6),e.originalEvent.deltaMode&&1===e.originalEvent.deltaMode&&(t*=10,n*=10),t!==t&&n!==n&&(t=0,n=e.originalEvent.wheelDelta),[t,n]}function t(t){if(l||!(x.find("select:focus").length>0)){var o=e(t),r=o[0],i=o[1];n=!1,P.useBothWheelAxes?O&&!X?(x.scrollTop(i?x.scrollTop()-i*P.wheelSpeed:x.scrollTop()+r*P.wheelSpeed),n=!0):X&&!O&&(x.scrollLeft(r?x.scrollLeft()+r*P.wheelSpeed:x.scrollLeft()-i*P.wheelSpeed),n=!0):(x.scrollTop(x.scrollTop()-i*P.wheelSpeed),x.scrollLeft(x.scrollLeft()+r*P.wheelSpeed)),p(),n=n||v(r,i),n&&(t.stopPropagation(),t.preventDefault())}}var n=!1;"undefined"!=typeof window.onwheel?x.bind(B("wheel"),t):"undefined"!=typeof window.onmousewheel&&x.bind(B("mousewheel"),t)}function h(){var t=!1;x.bind(B("mouseenter"),function(){t=!0}),x.bind(B("mouseleave"),function(){t=!1});var n=!1;e(K).bind(B("keydown"),function(o){if((!o.isDefaultPrevented||!o.isDefaultPrevented())&&t){for(var r=document.activeElement?document.activeElement:K.activeElement;r.shadowRoot;)r=r.shadowRoot.activeElement;if(!e(r).is(":input,[contenteditable]")){var l=0,i=0;switch(o.which){case 37:l=-30;break;case 38:i=30;break;case 39:l=30;break;case 40:i=-30;break;case 33:i=90;break;case 32:case 34:i=-90;break;case 35:i=o.ctrlKey?-Y:-D;break;case 36:i=o.ctrlKey?x.scrollTop():D;break;default:return}x.scrollTop(x.scrollTop()-i),x.scrollLeft(x.scrollLeft()+l),n=v(l,i),n&&o.preventDefault()}}})}function w(){function e(e){e.stopPropagation()}J.bind(B("click"),e),G.bind(B("click"),function(e){var n=t(R/2),o=e.pageY-G.offset().top-n,r=D-R,l=o/r;0>l?l=0:l>1&&(l=1),x.scrollTop((Y-D)*l)}),H.bind(B("click"),e),_.bind(B("click"),function(e){var n=t(k/2),o=e.pageX-_.offset().left-n,r=M-k,l=o/r;0>l?l=0:l>1&&(l=1),x.scrollLeft((C-M)*l)})}function m(){function t(){var e=window.getSelection?window.getSelection():document.getSlection?document.getSlection():{rangeCount:0};return 0===e.rangeCount?null:e.getRangeAt(0).commonAncestorContainer}function n(){r||(r=setInterval(function(){return E()?(x.scrollTop(x.scrollTop()+l.top),x.scrollLeft(x.scrollLeft()+l.left),void p()):void clearInterval(r)},50))}function o(){r&&(clearInterval(r),r=null),x.removeClass("ps-in-scrolling"),x.removeClass("ps-in-scrolling")}var r=null,l={top:0,left:0},i=!1;e(K).bind(B("selectionchange"),function(){e.contains(x[0],t())?i=!0:(i=!1,o())}),e(window).bind(B("mouseup"),function(){i&&(i=!1,o())}),e(window).bind(B("mousemove"),function(e){if(i){var t={x:e.pageX,y:e.pageY},r=x.offset(),a={left:r.left,right:r.left+x.outerWidth(),top:r.top,bottom:r.top+x.outerHeight()};t.x<a.left+3?(l.left=-5,x.addClass("ps-in-scrolling")):t.x>a.right-3?(l.left=5,x.addClass("ps-in-scrolling")):l.left=0,t.y<a.top+3?(l.top=a.top+3-t.y<5?-5:-20,x.addClass("ps-in-scrolling")):t.y>a.bottom-3?(l.top=t.y-a.bottom+3<5?5:20,x.addClass("ps-in-scrolling")):l.top=0,0===l.top&&0===l.left?o():n()}})}function T(t,n){function o(e,t){x.scrollTop(x.scrollTop()-t),x.scrollLeft(x.scrollLeft()-e),p()}function r(){h=!0}function l(){h=!1}function i(e){return e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e.originalEvent}function a(e){var t=e.originalEvent;return t.targetTouches&&1===t.targetTouches.length?!0:t.pointerType&&"mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE?!0:!1}function s(e){if(a(e)){w=!0;var t=i(e);d.pageX=t.pageX,d.pageY=t.pageY,f=(new Date).getTime(),null!==b&&clearInterval(b),e.stopPropagation()}}function c(e){if(!h&&w&&a(e)){var t=i(e),n={pageX:t.pageX,pageY:t.pageY},r=n.pageX-d.pageX,l=n.pageY-d.pageY;o(r,l),d=n;var s=(new Date).getTime(),c=s-f;c>0&&(v.x=r/c,v.y=l/c,f=s),g(r,l)&&(e.stopPropagation(),e.preventDefault())}}function u(){!h&&w&&(w=!1,clearInterval(b),b=setInterval(function(){return E()?Math.abs(v.x)<.01&&Math.abs(v.y)<.01?void clearInterval(b):(o(30*v.x,30*v.y),v.x*=.8,void(v.y*=.8)):void clearInterval(b)},10))}var d={},f=0,v={},b=null,h=!1,w=!1;t&&(e(window).bind(B("touchstart"),r),e(window).bind(B("touchend"),l),x.bind(B("touchstart"),s),x.bind(B("touchmove"),c),x.bind(B("touchend"),u)),n&&(window.PointerEvent?(e(window).bind(B("pointerdown"),r),e(window).bind(B("pointerup"),l),x.bind(B("pointerdown"),s),x.bind(B("pointermove"),c),x.bind(B("pointerup"),u)):window.MSPointerEvent&&(e(window).bind(B("MSPointerDown"),r),e(window).bind(B("MSPointerUp"),l),x.bind(B("MSPointerDown"),s),x.bind(B("MSPointerMove"),c),x.bind(B("MSPointerUp"),u)))}function y(){x.bind(B("scroll"),function(){p()})}function L(){x.unbind(B()),e(window).unbind(B()),e(K).unbind(B()),x.data("perfect-scrollbar",null),x.data("perfect-scrollbar-update",null),x.data("perfect-scrollbar-destroy",null),H.remove(),J.remove(),_.remove(),G.remove(),x=_=G=H=J=X=O=M=D=C=Y=k=W=N=j=F=R=A=V=Z=$=q=B=null}function S(){p(),y(),d(),f(),w(),m(),b(),(nt||ot)&&T(nt,ot),P.useKeyboard&&h(),x.data("perfect-scrollbar",x),x.data("perfect-scrollbar-update",p),x.data("perfect-scrollbar-destroy",L)}var P=e.extend(!0,{},n),x=e(this),E=function(){return!!x};if("object"==typeof o?e.extend(!0,P,o):i=o,"update"===i)return x.data("perfect-scrollbar-update")&&x.data("perfect-scrollbar-update")(),x;if("destroy"===i)return x.data("perfect-scrollbar-destroy")&&x.data("perfect-scrollbar-destroy")(),x;if(x.data("perfect-scrollbar"))return x.data("perfect-scrollbar");x.addClass("ps-container");var M,D,C,Y,X,k,W,I,O,R,A,U,q="rtl"===x.css("direction"),B=r(),K=this.ownerDocument||document,_=e("<div class='ps-scrollbar-x-rail'>").appendTo(x),H=e("<div class='ps-scrollbar-x'>").appendTo(_),N=t(_.css("bottom")),j=N===N,F=j?null:t(_.css("top")),Q=t(_.css("borderLeftWidth"))+t(_.css("borderRightWidth")),z=t(_.css("marginLeft"))+t(_.css("marginRight")),G=e("<div class='ps-scrollbar-y-rail'>").appendTo(x),J=e("<div class='ps-scrollbar-y'>").appendTo(G),V=t(G.css("right")),Z=V===V,$=Z?null:t(G.css("left")),et=t(G.css("borderTopWidth"))+t(G.css("borderBottomWidth")),tt=t(G.css("marginTop"))+t(G.css("marginBottom")),nt="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,ot=null!==window.navigator.msMaxTouchPoints;return S(),x})}})},{}]},{},[1]);