Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-scrollable-table

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-scrollable-table - npm Package Compare versions

Comparing version 1.0.1 to 1.1.2

.gitattributes

6

angular-scrollable-table.js

@@ -176,6 +176,10 @@ (function (angular) {

angular.element(window).on('resize', function(){
var onResizeCallback = function(){
$timeout(function(){
$scope.$apply();
});
};
angular.element(window).on('resize', onResizeCallback);
$scope.$on('$destroy', function() {
angular.element(window).off('resize', onResizeCallback);
});

@@ -182,0 +186,0 @@ $scope.$watch(function(){

2

angular-scrollable-table.min.js

@@ -1,1 +0,1 @@

!function(e){"use strict";function t(e){return parseInt(e.replace(/px|%/,""),10)}var n=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;e.module("scrollable-table",[]).directive("scrollableTable",["$timeout","$q","$parse",function(i,r,s){return{transclude:!0,restrict:"E",scope:{rows:"=watch",sortFn:"="},template:'<div class="scrollableContainer"><div class="headerSpacer"></div><div class="scrollArea" ng-transclude></div></div>',controller:["$scope","$element","$attrs",function(a,l,o){function c(e,t){var n=a.sortExpr.match(/(.+)\s+as\s+(.+)/),i={};i[n[1]]=e;var r=s(n[2])(i);i[n[1]]=t;var l=s(n[2])(i);return r===l?0:r>l?1:-1}function d(e){var t=l.find(".headerSpacer").height(),n=l.find(".scrollArea").scrollTop();l.find(".scrollArea").scrollTop(n+e.position().top-t)}function h(){function e(){0===l.find("table:visible").length?i(e,100):t.resolve()}var t=r.defer();return i(e),t.promise}function f(){l.find("thead th .th-inner").length||l.find("thead th").wrapInner('<div class="th-inner"></div>'),l.find("thead th .th-inner:not(:has(.box))").length&&l.find("thead th .th-inner:not(:has(.box))").wrapInner('<div class="box"></div>'),l.find("table th .th-inner:visible").each(function(n,i){i=e.element(i);var r=i.parent().width(),s=l.find("table th:visible:last"),a=r;if("center"!==s.css("text-align")){var o=l.find(".scrollArea").height()<l.find("table").height();s[0]==i.parent()[0]&&o&&(a+=l.find(".scrollArea").width()-l.find("tbody tr").width(),a=Math.max(a,r))}var c=t(i.parent().css("min-width")),d=i.parent().attr("title");a=Math.max(c,a),i.css("width",a),d||(d=i.find(".title .ng-scope").text()||i.find(".box").text()),i.attr("title",d.trim())}),v.resolve()}function u(){for(var e=h().then(f),t=a.headerResizeHanlers||[],n=0;n<t.length;n++)e=e.then(t[n]);return e}this.getSortExpr=function(){return a.sortExpr},this.isAsc=function(){return a.asc},this.setSortExpr=function(e){a.asc=!0,a.sortExpr=e},this.toggleSort=function(){a.asc=!a.asc},this.doSort=function(e){e?a.rows.sort(function(t,n){var i=e(t,n);return a.asc?i:i*-1}):a.rows.sort(function(e,t){var n=c(e,t);return a.asc?n:n*-1})},this.renderTalble=function(){return h().then(f)},this.getTableElement=function(){return l},this.appendTableResizingHandler=function(e){for(var t=a.headerResizeHanlers||[],n=0;n<t.length;n++)if(t[n].name===e.name)return;t.push(e),a.headerResizeHanlers=t},a.$on("rowSelected",function(e,t){var n=l.find(".scrollArea table tr[row-id='"+t+"']");1===n.length&&r.all([h(),v.promise]).then(function(){d(n)})});var v=r.defer();a.$watch("rows",function(e,t){e&&(u(l.find(".scrollArea").width()),a.sortExpr=null,l.find(".scrollArea").scrollTop(0))}),a.asc=!o.hasOwnProperty("desc"),a.sortAttr=o.sortAttr;var p=n?"thead":"thead th .th-inner";l.find(".scrollArea").scroll(function(e){l.find(p).css("margin-left",0-e.target.scrollLeft)}),a.$on("renderScrollableTable",function(){u(l.find(".scrollArea").width())}),e.element(window).on("resize",function(){i(function(){a.$apply()})}),a.$watch(function(){return l.find(".scrollArea").width()},function(e,t){e*t<=0||u()})}]}}]).directive("sortableHeader",[function(){return{transclude:!0,scope:!0,require:"^scrollableTable",template:'<div class="box"><div ng-mouseenter="enter()" ng-mouseleave="leave()"><div class="title" ng-transclude></div><span class="orderWrapper"><span class="order" ng-show="focused || isActive()" ng-click="toggleSort($event)" ng-class="{active:isActive()}"><i ng-show="isAscending()" class="glyphicon glyphicon-chevron-up"></i><i ng-show="!isAscending()" class="glyphicon glyphicon-chevron-down"></i></span></span></div></div>',link:function(t,n,i,r){var s=i.on||"a as a."+i.col;t.element=e.element(n),t.isActive=function(){return r.getSortExpr()===s},t.toggleSort=function(e){t.isActive()?r.toggleSort():r.setSortExpr(s),r.doSort(t[i.comparatorFn]),e.preventDefault()},t.isAscending=function(){return!(!t.focused||t.isActive())||r.isAsc()},t.enter=function(){t.focused=!0},t.leave=function(){t.focused=!1},t.isLastCol=function(){return n.parent().find("th:last-child").get(0)===n.get(0)}}}}]).directive("resizable",["$compile",function(n){return{restrict:"A",priority:0,scope:!1,require:"scrollableTable",link:function(i,r,s,a){function l(){var t=r.find("table th:not(:last-child) .th-inner");if(0==t.find(".resize-rod").length){a.getTableElement().find(".scrollArea table").css("table-layout","auto");var s=e.element('<div class="resize-rod" ng-mousedown="resizing($event)"></div>');t.append(n(s)(i))}}function o(){var n=a.getTableElement(),i=1;n.find("table th .th-inner:visible").each(function(n,r){r=e.element(r);var s=r.parent().width(),a=t(r.parent().css("min-width"));s=Math.max(a,s),r.css("left",i),i+=s})}function c(){var n=1,i=a.getTableElement();a.getTableElement().find("table th .th-inner:visible").each(function(r,s){s=e.element(s);var a=s.parent().width(),l=i.find("table th:visible:last"),o=t(s.parent().css("min-width"));a=Math.max(o,a),l[0]!=s.parent()[0]&&s.parent().css("width",a),s.css("left",n),n+=a})}function d(n){var i=a.getTableElement(),r=i.find("table th:visible").length,s=i.find("table th:visible:last");i.find("table th:visible").each(function(i,a){if(a=e.element(a),s.get(0)==a.get(0))return void a.css("width","auto");var l=a.data("width");l=/\d+%$/.test(l)?Math.ceil(n*t(l)/100):n/r,a.css("width",l+"px")}),a.renderTalble().then(c())}a.appendTableResizingHandler(function(){l()}),a.appendTableResizingHandler(function(){var e=a.getTableElement().find(".scrollArea table");"auto"===e.css("table-layout")?o():d(e.parent().width())}),i.resizing=function(n){var i=a.getTableElement().find(".scrollArea").scrollLeft(),r=e.element(n.target).parent(),s=r.parent(),l=t(r.css("left"))+r.width()-i,o=n.pageX,d=e.element(document),h=e.element("body"),f=e.element(".scrollableContainer .resizing-cover"),u=e.element('<div class="scaler">');h.addClass("scrollable-resizing"),f.addClass("active"),e.element(".scrollableContainer").append(u),u.css("left",l),d.bind("mousemove",function(e){var n=e.pageX-o,i=t(u.css("left"))-l,r=s.width(),a=s.nextAll("th:visible").first(),c=t(s.css("min-width")),d=a.width(),h=t(a.css("min-width"));o=e.pageX,e.preventDefault(),n>0&&d-i<=h||n<0&&r+i<=c||u.css("left",t(u.css("left"))+n)}),d.bind("mouseup",function(n){n.preventDefault(),u.remove(),h.removeClass("scrollable-resizing"),f.removeClass("active"),d.unbind("mousemove"),d.unbind("mouseup");var i=t(u.css("left"))-l,r=s.width(),o=t(s.css("min-width")),v=s.nextAll("th:visible").first(),p=v.width(),b=t(v.css("min-width")),g=a.getTableElement().find(".scrollArea table");"auto"===g.css("table-layout")&&g.find("th .th-inner").each(function(t,n){n=e.element(n);var i=n.parent().width();n.parent().css("width",i)}),g.css("table-layout","fixed"),i>0&&p-i<=b&&(i=p-b),v.removeAttr("style"),r+=i,s.css("width",Math.max(o,r)),v.css("width",p-i),a.renderTalble().then(c())})}}}}])}(angular);
!function(e){"use strict";function t(e){return parseInt(e.replace(/px|%/,""),10)}var n=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;e.module("scrollable-table",[]).directive("scrollableTable",["$timeout","$q","$parse",function(i,r,s){return{transclude:!0,restrict:"E",scope:{rows:"=watch",sortFn:"="},template:'<div class="scrollableContainer"><div class="headerSpacer"></div><div class="scrollArea" ng-transclude></div></div>',controller:["$scope","$element","$attrs",function(a,l,o){function c(e,t){var n=a.sortExpr.match(/(.+)\s+as\s+(.+)/),i={};i[n[1]]=e;var r=s(n[2])(i);i[n[1]]=t;var l=s(n[2])(i);return r===l?0:r>l?1:-1}function d(e){var t=l.find(".headerSpacer").height(),n=l.find(".scrollArea").scrollTop();l.find(".scrollArea").scrollTop(n+e.position().top-t)}function h(){function e(){0===l.find("table:visible").length?i(e,100):t.resolve()}var t=r.defer();return i(e),t.promise}function f(){l.find("thead th .th-inner").length||l.find("thead th").wrapInner('<div class="th-inner"></div>'),l.find("thead th .th-inner:not(:has(.box))").length&&l.find("thead th .th-inner:not(:has(.box))").wrapInner('<div class="box"></div>'),l.find("table th .th-inner:visible").each(function(n,i){i=e.element(i);var r=i.parent().width(),s=l.find("table th:visible:last"),a=r;if("center"!==s.css("text-align")){var o=l.find(".scrollArea").height()<l.find("table").height();s[0]==i.parent()[0]&&o&&(a+=l.find(".scrollArea").width()-l.find("tbody tr").width(),a=Math.max(a,r))}var c=t(i.parent().css("min-width")),d=i.parent().attr("title");a=Math.max(c,a),i.css("width",a),d||(d=i.find(".title .ng-scope").text()||i.find(".box").text()),i.attr("title",d.trim())}),v.resolve()}function u(){for(var e=h().then(f),t=a.headerResizeHanlers||[],n=0;n<t.length;n++)e=e.then(t[n]);return e}this.getSortExpr=function(){return a.sortExpr},this.isAsc=function(){return a.asc},this.setSortExpr=function(e){a.asc=!0,a.sortExpr=e},this.toggleSort=function(){a.asc=!a.asc},this.doSort=function(e){e?a.rows.sort(function(t,n){var i=e(t,n);return a.asc?i:i*-1}):a.rows.sort(function(e,t){var n=c(e,t);return a.asc?n:n*-1})},this.renderTalble=function(){return h().then(f)},this.getTableElement=function(){return l},this.appendTableResizingHandler=function(e){for(var t=a.headerResizeHanlers||[],n=0;n<t.length;n++)if(t[n].name===e.name)return;t.push(e),a.headerResizeHanlers=t},a.$on("rowSelected",function(e,t){var n=l.find(".scrollArea table tr[row-id='"+t+"']");1===n.length&&r.all([h(),v.promise]).then(function(){d(n)})});var v=r.defer();a.$watch("rows",function(e,t){e&&(u(l.find(".scrollArea").width()),a.sortExpr=null,l.find(".scrollArea").scrollTop(0))}),a.asc=!o.hasOwnProperty("desc"),a.sortAttr=o.sortAttr;var p=n?"thead":"thead th .th-inner";l.find(".scrollArea").scroll(function(e){l.find(p).css("margin-left",0-e.target.scrollLeft)}),a.$on("renderScrollableTable",function(){u(l.find(".scrollArea").width())});var b=function(){i(function(){a.$apply()})};e.element(window).on("resize",b),a.$on("$destroy",function(){e.element(window).off("resize",b)}),a.$watch(function(){return l.find(".scrollArea").width()},function(e,t){e*t<=0||u()})}]}}]).directive("sortableHeader",[function(){return{transclude:!0,scope:!0,require:"^scrollableTable",template:'<div class="box"><div ng-mouseenter="enter()" ng-mouseleave="leave()"><div class="title" ng-transclude></div><span class="orderWrapper"><span class="order" ng-show="focused || isActive()" ng-click="toggleSort($event)" ng-class="{active:isActive()}"><i ng-show="isAscending()" class="glyphicon glyphicon-chevron-up"></i><i ng-show="!isAscending()" class="glyphicon glyphicon-chevron-down"></i></span></span></div></div>',link:function(t,n,i,r){var s=i.on||"a as a."+i.col;t.element=e.element(n),t.isActive=function(){return r.getSortExpr()===s},t.toggleSort=function(e){t.isActive()?r.toggleSort():r.setSortExpr(s),r.doSort(t[i.comparatorFn]),e.preventDefault()},t.isAscending=function(){return!(!t.focused||t.isActive())||r.isAsc()},t.enter=function(){t.focused=!0},t.leave=function(){t.focused=!1},t.isLastCol=function(){return n.parent().find("th:last-child").get(0)===n.get(0)}}}}]).directive("resizable",["$compile",function(n){return{restrict:"A",priority:0,scope:!1,require:"scrollableTable",link:function(i,r,s,a){function l(){var t=r.find("table th:not(:last-child) .th-inner");if(0==t.find(".resize-rod").length){a.getTableElement().find(".scrollArea table").css("table-layout","auto");var s=e.element('<div class="resize-rod" ng-mousedown="resizing($event)"></div>');t.append(n(s)(i))}}function o(){var n=a.getTableElement(),i=1;n.find("table th .th-inner:visible").each(function(n,r){r=e.element(r);var s=r.parent().width(),a=t(r.parent().css("min-width"));s=Math.max(a,s),r.css("left",i),i+=s})}function c(){var n=1,i=a.getTableElement();a.getTableElement().find("table th .th-inner:visible").each(function(r,s){s=e.element(s);var a=s.parent().width(),l=i.find("table th:visible:last"),o=t(s.parent().css("min-width"));a=Math.max(o,a),l[0]!=s.parent()[0]&&s.parent().css("width",a),s.css("left",n),n+=a})}function d(n){var i=a.getTableElement(),r=i.find("table th:visible").length,s=i.find("table th:visible:last");i.find("table th:visible").each(function(i,a){if(a=e.element(a),s.get(0)==a.get(0))return void a.css("width","auto");var l=a.data("width");l=/\d+%$/.test(l)?Math.ceil(n*t(l)/100):n/r,a.css("width",l+"px")}),a.renderTalble().then(c())}a.appendTableResizingHandler(function(){l()}),a.appendTableResizingHandler(function(){var e=a.getTableElement().find(".scrollArea table");"auto"===e.css("table-layout")?o():d(e.parent().width())}),i.resizing=function(n){var i=a.getTableElement().find(".scrollArea").scrollLeft(),r=e.element(n.target).parent(),s=r.parent(),l=t(r.css("left"))+r.width()-i,o=n.pageX,d=e.element(document),h=e.element("body"),f=e.element(".scrollableContainer .resizing-cover"),u=e.element('<div class="scaler">');h.addClass("scrollable-resizing"),f.addClass("active"),e.element(".scrollableContainer").append(u),u.css("left",l),d.bind("mousemove",function(e){var n=e.pageX-o,i=t(u.css("left"))-l,r=s.width(),a=s.nextAll("th:visible").first(),c=t(s.css("min-width")),d=a.width(),h=t(a.css("min-width"));o=e.pageX,e.preventDefault(),n>0&&d-i<=h||n<0&&r+i<=c||u.css("left",t(u.css("left"))+n)}),d.bind("mouseup",function(n){n.preventDefault(),u.remove(),h.removeClass("scrollable-resizing"),f.removeClass("active"),d.unbind("mousemove"),d.unbind("mouseup");var i=t(u.css("left"))-l,r=s.width(),o=t(s.css("min-width")),v=s.nextAll("th:visible").first(),p=v.width(),b=t(v.css("min-width")),g=a.getTableElement().find(".scrollArea table");"auto"===g.css("table-layout")&&g.find("th .th-inner").each(function(t,n){n=e.element(n);var i=n.parent().width();n.parent().css("width",i)}),g.css("table-layout","fixed"),i>0&&p-i<=b&&(i=p-b),v.removeAttr("style"),r+=i,s.css("width",Math.max(o,r)),v.css("width",p-i),a.renderTalble().then(c())})}}}}])}(angular);

@@ -7,3 +7,3 @@ {

],
"version": "1.1.1",
"version": "1.1.2",
"homepage": "https://github.com/alalonde/angular-scrollable-table",

@@ -10,0 +10,0 @@ "authors": [

@@ -11,3 +11,3 @@ {

"description": "A fixed-header scrollable table which auto-truncates overly-long headers, has resizable columns and sortable headers",
"version": "1.0.1",
"version": "1.1.2",
"license": "MIT",

@@ -14,0 +14,0 @@ "repository": {

@@ -13,4 +13,13 @@ angular-scrollable-table

Usage:
## Installation
```
npm install angular-scrollable-table
```
OR
```
bower install angular-scrollable-table
```
## Usage
```js

@@ -20,3 +29,3 @@ angular.module('myApp', ['scrollable-table', ...]);

Example:
## Example

@@ -71,3 +80,3 @@ ```html

### FAQ
## FAQ

@@ -74,0 +83,0 @@ 1. How do I change the height of the table?

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc