angular-data-grid-new
Version:
Light, flexible and performant Data Grid for AngularJS apps, with built-in sorting, pagination and filtering options, unified API for client-side and server-side data fetching, seamless synchronization with browser address bar and total freedom in mark-
1 lines • 1.32 kB
JavaScript
!function(){"use strict";angular.module("dataGridUtils",[])}(),function(){"use strict";function e(e,t){function n(n,f,i){function d(){for(var e=f.find("th"),t=0;t<e.length;t++){var n=f.find("td").eq(t)[0];if(!n)return;var o=n.offsetWidth;angular.element(e[t]).css({width:o+"px"})}}function r(){var e=f.find("thead"),t=f.find("tbody"),n=t[0].getBoundingClientRect().left;if(e.addClass("fixed-header"),i.offsetFromElement){var o=document.querySelector(i.offsetFromElement),d=o.getBoundingClientRect().top+o.offsetHeight;e.css({top:d})}e.css({left:n}),t.addClass("tbody-offset")}function s(){var e=f.find("thead"),t=f.find("tbody");e.removeClass("fixed-header"),e.css({left:""}),e.css({top:""}),t.removeClass("tbody-offset")}function a(){var t=i.offsetFromElement?l.getBoundingClientRect().top+l.offsetHeight:e.pageYOffset,n=i.offsetFromElement?f[0].getBoundingClientRect().top:f[0].getBoundingClientRect().top+t,o=n+f[0].offsetHeight-f.find("thead")[0].offsetHeight;t<n||t>o?s():t>=n&&t<=o&&r(),d()}var l=i.offsetFromElement?document.querySelector(i.offsetFromElement):o;n.$on("gridReloaded",function(){t(function(){d(),a()},0)}),o.on("resize",d),o.on("scroll",a)}var o=angular.element(e);return{restrict:"A",link:n}}angular.module("dataGridUtils.fixedHeader",[]).directive("fixedHeader",e),e.$inject=["$window","$timeout"]}();