!function(e){"function"==typeof define&&define.amd?define(["jquery"],function(t){return e(t,window,document)}):"object"==typeof exports?module.exports=e(require("jquery"),window,document):e(jQuery,window,document)}(function(s,n,o){"use strict";var p,d,i,c,a,u,e,g,v,f,l,r,h,S,m,T,y,b,w,x,$,H,C,O,A;function t(t,e){this.el=t,this.options=e,d=d||w(),this.$el=s(this.el),this.doc=s(this.options.documentContext||o),this.win=s(this.options.windowContext||n),this.body=this.doc.find("body"),this.$content=this.$el.children("."+this.options.contentClass),this.$content.attr("tabindex",this.options.tabIndex||0),this.content=this.$content[0],this.previousPosition=0,this.options.iOSNativeScrolling&&null!=this.el.style.WebkitOverflowScrolling?this.nativeScrolling():this.generate(),this.createEvents(),this.addEvents(),this.reset()}b={paneClass:"nano-pane",sliderClass:"nano-slider",contentClass:"nano-content",iOSNativeScrolling:!1,preventPageScrolling:!1,disableResize:!1,alwaysVisible:!1,flashDelay:1500,sliderMinHeight:20,sliderMaxHeight:null,documentContext:null,windowContext:null},S="scroll",e="mousedown",g="mouseenter",v="mousemove",l="mousewheel",f="mouseup",h="resize",a="drag",u="enter",T="up",i="DOMMouseScroll",c="down",m="touchmove",p="Microsoft Internet Explorer"===n.navigator.appName&&/msie 7./i.test(n.navigator.appVersion)&&n.ActiveXObject,d=null,H=n.requestAnimationFrame,y=n.cancelAnimationFrame,O=o.createElement("div").style,A=function(){for(var t,e=["t","webkitT","MozT","msT","OT"],i=t=0,s=e.length;tthis.previousPosition?"down":this.contentScrollTop=r.maxScrollTop&&r.prevScrollTop!==r.maxScrollTop?r.$el.trigger("scrollend"):0===r.contentScrollTop&&0!==r.prevScrollTop&&r.$el.trigger("scrolltop"),!1},up:function(t){return l.isBeingDragged=!1,l.pane.removeClass("active"),l.doc.unbind(v,l.events[a]).unbind(f,l.events.up),l.body.unbind(g,l.events[u]),!1},resize:function(t){n.reset()},panedown:function(t){return o.sliderY=(t.offsetY||t.originalEvent.layerY)-.5*o.sliderHeight,o.scroll(),o.events.down(t),!1},scroll:function(t){e.updateScrollValues(),e.isBeingDragged||(e.iOSNativeScrolling||(e.sliderY=e.sliderTop,e.setOnScrollStyles()),null!=t&&(e.contentScrollTop>=e.maxScrollTop?(e.options.preventPageScrolling&&e.preventScrolling(t,c),e.prevScrollTop!==e.maxScrollTop&&e.$el.trigger("scrollend")):0===e.contentScrollTop&&(e.options.preventPageScrolling&&e.preventScrolling(t,T),0!==e.prevScrollTop&&e.$el.trigger("scrolltop"))))},wheel:function(t){var e;if(null!=t)return(e=t.delta||t.wheelDelta||t.originalEvent&&t.originalEvent.wheelDelta||-t.detail||t.originalEvent&&-t.originalEvent.detail)&&(s.sliderY+=-e/3),s.scroll(),!1},enter:(i=s=e=o=n=l=r=h=this,function(t){var e;if(i.isBeingDragged)return 1!==(t.buttons||t.which)?(e=i.events).up.apply(e,arguments):void 0})}},t.prototype.addEvents=function(){var t;this.removeEvents(),t=this.events,this.options.disableResize||this.win.bind(h,t[h]),this.iOSNativeScrolling||(this.slider.bind(e,t[c]),this.pane.bind(e,t.panedown).bind(l+" "+i,t.wheel)),this.$content.bind(S+" "+l+" "+i+" "+m,t[S])},t.prototype.removeEvents=function(){var t=this.events;this.win.unbind(h,t[h]),this.iOSNativeScrolling||(this.slider.unbind(),this.pane.unbind()),this.$content.unbind(S+" "+l+" "+i+" "+m,t[S])},t.prototype.generate=function(){var t,e,i=this.options,s=i.paneClass,o=i.sliderClass;i.contentClass;return(e=this.$el.children("."+s)).length||e.children("."+o).length||this.$el.append('
'),this.pane=this.$el.children("."+s),this.slider=this.pane.find("."+o),0===d&&$()?t={right:-14,paddingRight:+n.getComputedStyle(this.content,null).getPropertyValue("padding-right").replace(/[^0-9.]+/g,"")+14}:d&&(t={right:-d},this.$el.addClass("has-scrollbar")),null!=t&&this.$content.css(t),this},t.prototype.restore=function(){this.stopped=!1,this.iOSNativeScrolling||this.pane.show(),this.addEvents()},t.prototype.reset=function(){var t,e,i,s,o,n,l,r,h,c,a;if(!this.iOSNativeScrolling)return this.$el.find("."+this.options.paneClass).length||this.generate().stop(),this.stopped&&this.restore(),o=(s=(t=this.content).style).overflowY,p&&this.$content.css({height:this.$content.height()}),e=t.scrollHeight+d,0<(h=parseInt(this.$el.css("max-height"),10))&&(this.$el.height(""),this.$el.height(t.scrollHeight>h?h:t.scrollHeight)),l=(n=this.pane.outerHeight(!1))+(r=parseInt(this.pane.css("top"),10))+parseInt(this.pane.css("bottom"),10),(a=Math.round(l/e*n))this.options.sliderMaxHeight&&(a=this.options.sliderMaxHeight),o===S&&s.overflowX!==S&&(a+=d),this.maxSliderTop=l-a,this.contentHeight=e,this.paneHeight=n,this.paneOuterHeight=l,this.sliderHeight=a,this.paneTop=r,this.slider.height(a),this.events.scroll(),this.pane.show(),this.isActive=!0,t.scrollHeight===t.clientHeight||this.pane.outerHeight(!0)>=t.scrollHeight&&o!==S?(this.pane.hide(),this.isActive=!1):this.el.clientHeight===t.scrollHeight&&o===S?this.slider.hide():this.slider.show(),this.pane.css({opacity:this.options.alwaysVisible?1:"",visibility:this.options.alwaysVisible?"visible":""}),"static"!==(i=this.$content.css("position"))&&"relative"!==i||(c=parseInt(this.$content.css("right"),10))&&this.$content.css({right:"",marginRight:c}),this;this.contentHeight=this.content.scrollHeight},t.prototype.scroll=function(){if(this.isActive)return this.sliderY=Math.max(0,this.sliderY),this.sliderY=Math.min(this.maxSliderTop,this.sliderY),this.$content.scrollTop(this.maxScrollTop*this.sliderY/this.maxSliderTop),this.iOSNativeScrolling||(this.updateScrollValues(),this.setOnScrollStyles()),this},t.prototype.scrollBottom=function(t){if(this.isActive)return this.$content.scrollTop(this.contentHeight-this.$content.height()-t).trigger(l),this.stop().restore(),this},t.prototype.scrollTop=function(t){if(this.isActive)return this.$content.scrollTop(+t).trigger(l),this.stop().restore(),this},t.prototype.scrollTo=function(t){if(this.isActive)return this.scrollTop(this.$el.find(t).get(0).offsetTop),this},t.prototype.stop=function(){return y&&this.scrollRAF&&(y(this.scrollRAF),this.scrollRAF=null),this.stopped=!0,this.removeEvents(),this.iOSNativeScrolling||this.pane.hide(),this},t.prototype.destroy=function(){return this.stopped||this.stop(),!this.iOSNativeScrolling&&this.pane.length&&this.pane.remove(),p&&this.$content.height(""),this.$content.removeAttr("tabindex"),this.$el.hasClass("has-scrollbar")&&(this.$el.removeClass("has-scrollbar"),this.$content.css({right:""})),this},t.prototype.flash=function(){var t;if(!this.iOSNativeScrolling&&this.isActive)return this.reset(),this.pane.addClass("flashed"),setTimeout(function(){t.pane.removeClass("flashed")},(t=this).options.flashDelay),this},r=t,s.fn.nanoScroller=function(i){return this.each(function(){var t,e;if((e=this.nanoscroller)||(t=s.extend({},b,i),this.nanoscroller=e=new r(this,t)),i&&"object"==typeof i){if(s.extend(e.options,i),null!=i.scrollBottom)return e.scrollBottom(i.scrollBottom);if(null!=i.scrollTop)return e.scrollTop(i.scrollTop);if(i.scrollTo)return e.scrollTo(i.scrollTo);if("bottom"===i.scroll)return e.scrollBottom(0);if("top"===i.scroll)return e.scrollTop(0);if(i.scroll&&i.scroll instanceof s)return e.scrollTo(i.scroll);if(i.stop)return e.stop();if(i.destroy)return e.destroy();if(i.flash)return e.flash()}return e.reset()})},s.fn.nanoScroller.Constructor=r});