angular.module("perfect_scrollbar",[]).directive("perfectScrollbar",["$parse","$window",function($parse,$window){var psOptions=["wheelSpeed","wheelPropagation","minScrollbarLength","maxScrollbarLength","useBothWheelAxes","useKeyboard","suppressScrollX","suppressScrollY","scrollXMarginOffset","scrollYMarginOffset","includePadding"];return{restrict:"EA",transclude:!0,template:"<div><div ng-transclude></div></div>",replace:!0,link:function($scope,$elem,$attr){function update(event){$scope.$evalAsync(function(){"true"==$attr.scrollDown&&"mouseenter"!=event&&setTimeout(function(){$($elem).scrollTop($($elem).prop("scrollHeight"))},100),$elem.perfectScrollbar("update")})}for(var jqWindow=angular.element($window),options={},i=0,l=psOptions.length;i<l;i++){var opt=psOptions[i];void 0!==$attr[opt]&&(options[opt]=$parse($attr[opt])())}$scope.$evalAsync(function(){$elem.perfectScrollbar(options);var onScrollHandler=$parse($attr.onScroll);$elem.scroll(function(){var scrollTop=$elem.scrollTop(),scrollHeight=$elem.prop("scrollHeight")-$elem.height(),scrollLeft=$elem.scrollLeft(),scrollWidth=$elem.prop("scrollWidth")-$elem.width();$scope.$apply(function(){onScrollHandler($scope,{scrollTop:scrollTop,scrollHeight:scrollHeight,scrollLeft:scrollLeft,scrollWidth:scrollWidth})})})}),$scope.$watch(function(){return $elem.prop("scrollHeight")},function(newValue,oldValue){newValue&&update("contentSizeChange")}),$elem.on("mouseenter",function(){update("mouseenter")}),$attr.refreshOnChange&&$scope.$watchCollection($attr.refreshOnChange,function(){update()}),$attr.refreshOnResize&&jqWindow.on("resize",update),$elem.bind("$destroy",function(){jqWindow.off("resize",update),$elem.perfectScrollbar("destroy")})}}}]);