From e784796558fcfed6559da5737812b91850eb86d2 Mon Sep 17 00:00:00 2001 From: Jon Shaffer Date: Tue, 13 Dec 2016 11:02:29 -0500 Subject: [PATCH 1/6] Up to date with readme updates (#18) * Update README.md Added badges and proper code highlighting. * Update README.md Development section pushed to the bottom * Update README.md Documented the options. * Added file icons.css --- README.md | 87 ++++++++++++++++++++++++++++++++++++++-------- release/icons.css | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 14 deletions(-) create mode 100644 release/icons.css diff --git a/README.md b/README.md index 7fbe4cc..de1e650 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -# angular-data-table [![Join the chat at https://gitter.im/Swimlane/angular-data-table](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/swimlane/angular-data-table?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Dependency Status](https://david-dm.org/swimlane/angular-data-table.svg)](https://david-dm.org/swimlane/angular-data-table) [![devDependency Status](https://david-dm.org/swimlane/angular-data-table/dev-status.svg)](https://david-dm.org/swimlane/angular-data-table#info=devDependencies) +# angular-data-table + +[![Join the chat at https://gitter.im/Swimlane/angular-data-table](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/swimlane/angular-data-table?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +![npm-version](https://img.shields.io/npm/v/angular-data-table.svg) +![Dependency Status](https://david-dm.org/swimlane/angular-data-table.svg) +![devDependency Status](https://david-dm.org/swimlane/angular-data-table/dev-status.svg) +![download-count](https://img.shields.io/npm/dm/angular-data-table.svg) `angular-data-table` is a AngularJS directive for presenting large and complex data. It has all the features you would expect from any other table but in a light package with _no external depedencies_. The table was designed to be extremely flexible and light; it doesn't make any assumptions about your data or how you: filter, sort or page it. @@ -39,20 +45,7 @@ See live demos [here]( http://swimlane.github.io/angular-data-table/). or Github download or clone of course! -#### Run Demos - -Ensure you have the latest NPM and JSPM installed globally. If you don't already have JSPM installed run: `npm install jspm -g`. - -- `npm install` -- `jspm install` -- `gulp watch serve` -- Open your browser to `http://localhost:9000` - -docs coming soon, in the meantime, 'View Source' is your friend ;)! -#### Build - -`gulp release` to build Modules, ES* via Babel and compile. #### Include @@ -69,11 +62,13 @@ There is also the CSS too: - `./release/dataTable.css` - The base CSS, pretty much required - `./release/material.css` - Material theme +- `./release/icons.css` - If you want to show fancy icons when sorting #### Usage Include the module in your angular app module like: +```javascript var myApp = angular.module('myApp', [ 'data-table' ]); module.controller('HomeController', function($scope){ @@ -86,18 +81,82 @@ Include the module in your angular app module like: { name: 'Marjan', gender: 'Male' } ]; }); +``` then using expressive markup in your template: +```html {{$row.name}}: {{$cell}} +``` and your off to the races! See live demos [here](http://swimlane.github.io/angular-data-table/). +## API + +The data table can be created with the following `options`: + +- `checkboxSelection`: Checkbox selection vs row click (default: `false`) +- `columnMode`: Possible values are `flex`, `force` and `standard` (default: `standard`) +- `columns` + - `canAutoResize`: Whether the column can automatically resize to fill space in the table (default: `true`) + - `cellDataGetter`: Type `function`. Returns content for the `cellRenderer`. If not provided, the cell data will be collected from row data instead (default: `undefined`) + - `cellRenderer`: Type `function`. Returns HTML for the cell. + - `className`: CSS class for the body cell (default: `undefined`) + - `comparator`: Type `function`. Custom sort comparator, pass `false` if you want to do server sort + - `flexGrow`: The growth factor relative to other columns (default: `0`) + - `frozenLeft`: Column is pinned to the left (default: `false`) + - `frozenRight`: Column is pinned to the right (default: `false`) + - `headerCheckbox`: Toggles the checkbox column in the header for selecting all values given to the grid (default: `false`) + - `headerClassName`: CSS class for the header cell (default: `undefined`) + - `headerRenderer`: Type `function`. Returns HTML for the cell (default: `undefined`) + - `isCheckboxColumn`: Adds the checkbox selection to the column (default: `false`) + - `isTreeColumn`: Adds +/- button and makes a secondary call to load nested data (default: `false`) + - `maxWidth`: Maximum width, in pixels (default: `undefined`) + - `minWidth`: Minimum width, in pixels (default: `100`) + - `name`: Name of the column + - `prop`: Property to use to get the data + - `resizable`: Whether the column can be resized (default: `true`) + - `sort`: Default sort asecending/descending for the column (default: `undefined`) + - `sortBy`: Property by which to sort (default: `undefined`) + - `sortable`: Whether the column can be sorted (default: `true`) + - `template` + - `width`: Width, in pixels (default: `150`) +- `emptyMessage`: Message to show when array is presented but contains no values (default: `'No data to display'`) +- `footerHeight`: Footer height in pixels. Pass a `falsey` value for no footer (default: `0`) +- `headerHeight`: Header height in pixels. Pass a `falsey` value for no header (default: `30`) +- `loadingMessage`: Loading message presented when the array is undefined (default: `'Loading...'`) +- `multiSelect`: Whether users can select multiple items (default: `false`) +- `paging` + - `externalPaging`. Default `false` + - `size`. Default `undefined` + - `count`. Default `0` + - `offset`. Default `0` + - `loadingIndicator`. Default `false` +- `reorderable`: Whether you can reorder columns (default: `true`) +- `rowHeight`: Row height in pixels, necessary if using lazy rendering (default: `30`) +- `scrollbarV`: Enable vertical scrollbars (default: `true`) +- `selectable`: Whether users can select items (default: `false`) + +## Contributing + +#### Run Demos + +Ensure you have the latest NPM and JSPM installed globally. If you don't already have JSPM installed run: `npm install jspm -g`. + +- `npm install` +- `jspm install` +- `gulp watch serve` +- Open your browser to `http://localhost:9000` + +#### Build + +`gulp release` to build Modules, ES* via Babel and compile. + ## Credits `angular-data-table` is a [Swimlane](http://swimlane.com) open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations. diff --git a/release/icons.css b/release/icons.css new file mode 100644 index 0000000..5c5d101 --- /dev/null +++ b/release/icons.css @@ -0,0 +1,88 @@ +@charset "UTF-8"; + +/* data-table */ +@font-face { + font-family: "data-table"; + src:url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.eot"); + src:url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.eot?#iefix") format("embedded-opentype"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.woff") format("woff"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.ttf") format("truetype"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.svg#1447204703") format("svg"); + font-weight: normal; + font-style: normal; +} + +[data-icon]:before { + font-family: "data-table" !important; + content: attr(data-icon); + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +[class^="icon-"]:before, +[class*=" icon-"]:before { + font-family: "data-table" !important; + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-filter:before { + content: "b"; +} +.icon-collapse:before { + content: "a"; +} +.icon-expand:before { + content: "c"; +} +.icon-close:before { + content: "d"; +} +.icon-up:before { + content: "e"; +} +.icon-down:before { + content: "f"; +} +.icon-sort:before { + content: "g"; +} +.icon-done:before { + content: "h"; +} +.icon-done-all:before { + content: "i"; +} +.icon-search:before { + content: "j"; +} +.icon-pin:before { + content: "k"; +} +.icon-add:before { + content: "m"; +} +.icon-left:before { + content: "o"; +} +.icon-right:before { + content: "p"; +} +.icon-skip:before { + content: "q"; +} +.icon-prev:before { + content: "r"; +} From c5130022b156ab55f184d288a6dc331f3c7286ca Mon Sep 17 00:00:00 2001 From: Jonathan Shaffer Date: Fri, 16 Dec 2016 12:17:54 -0500 Subject: [PATCH 2/6] adding angular 1.6 support --- src/components/DataTableController.js | 22 +++++++++--- src/components/body/BodyController.js | 27 ++++++++++---- src/components/body/SelectionController.js | 24 ++++++++++--- src/components/body/StyleTranslator.js | 3 +- src/components/footer/FooterController.js | 20 +++++++++-- src/components/footer/PagerController.js | 35 +++++++++++++------ src/components/menu/MenuController.js | 9 ++--- .../menu/dropdown/DropdownController.js | 2 +- 8 files changed, 107 insertions(+), 35 deletions(-) diff --git a/src/components/DataTableController.js b/src/components/DataTableController.js index 94b1d37..5d4282e 100644 --- a/src/components/DataTableController.js +++ b/src/components/DataTableController.js @@ -10,20 +10,32 @@ export class DataTableController { * @param {scope} * @param {filter} */ + /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){ + constructor($scope, $filter, $log, $transclude){window.dt = this; Object.assign(this, { $scope: $scope, $filter: $filter, - $log: $log + $log: $log, + $transclude: $transclude }); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init() + } + + init(){ this.defaults(); // set scope to the parent - this.options.$outer = $scope.$parent; + this.options.$outer = this.$scope.$parent; - $scope.$watch('dt.options.columns', (newVal, oldVal) => { + this.$scope.$watch('dt.options.columns', (newVal, oldVal) => { this.transposeColumnDefaults(); if(newVal.length !== oldVal.length){ @@ -34,7 +46,7 @@ export class DataTableController { }, true); // default sort - var watch = $scope.$watch('dt.rows', (newVal) => { + var watch = this.$scope.$watch('dt.rows', (newVal) => { if(newVal){ watch(); this.onSorted(); diff --git a/src/components/body/BodyController.js b/src/components/body/BodyController.js index c511746..7110e84 100644 --- a/src/components/body/BodyController.js +++ b/src/components/body/BodyController.js @@ -8,9 +8,24 @@ export class BodyController{ * @param {$timeout} * @return {BodyController} */ + /*@ngInject*/ - constructor($scope, $timeout){ - this.$scope = $scope; + constructor($scope, $timeout) { + Object.assign(this, { + $scope: $scope, + $timeout: $timeout + }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + $onInit(){ this.tempRows = []; this.treeColumn = this.options.columns.find((c) => { @@ -21,23 +36,23 @@ export class BodyController{ return c.group; }); - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); if(this.options.scrollbarV || (!this.options.scrollbarV && this.options.paging.externalPaging)){ var sized = false; - $scope.$watch('body.options.paging.size', (newVal, oldVal) => { + this.$scope.$watch('body.options.paging.size', (newVal, oldVal) => { if(!sized || newVal > oldVal){ this.getRows(); sized = true; } }); - $scope.$watch('body.options.paging.count', (count) => { + this.$scope.$watch('body.options.paging.count', (count) => { this.count = count; this.updatePage(); }); - $scope.$watch('body.options.paging.offset', (newVal) => { + this.$scope.$watch('body.options.paging.offset', (newVal) => { if(this.options.paging.size){ this.onPage({ offset: newVal, diff --git a/src/components/body/SelectionController.js b/src/components/body/SelectionController.js index 5398f0f..61e3a5c 100644 --- a/src/components/body/SelectionController.js +++ b/src/components/body/SelectionController.js @@ -3,10 +3,24 @@ import { KEYS } from '../../utils/keys'; export class SelectionController { /*@ngInject*/ - constructor($scope){ - this.body = $scope.body; - this.options = $scope.body.options; - this.selected = $scope.body.selected; + constructor($scope) { + Object.assign(this, { + $scope: $scope + }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ + this.body = this.$scope.body; + this.options = this.$scope.body.options; + this.selected = this.$scope.body.selected; } /** @@ -49,7 +63,7 @@ export class SelectionController { this.body.onRowClick({ row: row }); } - + /** * Handler for the row double click event * @param {object} event diff --git a/src/components/body/StyleTranslator.js b/src/components/body/StyleTranslator.js index 9b7c7fb..0dc96e7 100644 --- a/src/components/body/StyleTranslator.js +++ b/src/components/body/StyleTranslator.js @@ -5,8 +5,7 @@ import { TranslateXY } from '../../utils/translate'; * This only exists because Angular's binding process is too slow. */ export class StyleTranslator{ - - constructor(height){ + constructor(height) { this.height = height; this.map = new Map(); } diff --git a/src/components/footer/FooterController.js b/src/components/footer/FooterController.js index 49dcda8..65388e5 100644 --- a/src/components/footer/FooterController.js +++ b/src/components/footer/FooterController.js @@ -5,10 +5,26 @@ export class FooterController { * @param {scope} * @return {[type]} */ + /*@ngInject*/ - constructor($scope){ + constructor($scope) { + Object.assign(this, { + $scope: $scope + }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', (newVal) => { + + this.$scope.$watch('footer.paging.offset', (newVal) => { this.offsetChanged(newVal) }); } diff --git a/src/components/footer/PagerController.js b/src/components/footer/PagerController.js index f34c967..fb3431f 100644 --- a/src/components/footer/PagerController.js +++ b/src/components/footer/PagerController.js @@ -2,26 +2,41 @@ export class PagerController { /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ - constructor($scope){ - $scope.$watch('pager.count', (newVal) => { + constructor($scope) { + Object.assign(this, { + $scope: $scope + }) + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ + this.$scope.$watch('pager.count', (newVal) => { this.calcTotalPages(this.size, this.count); this.getPages(this.page || 1); }); - $scope.$watch('pager.size', (newVal) => { + this.$scope.$watch('pager.size', (newVal) => { this.calcTotalPages(this.size, this.count); this.getPages(this.page || 1); }); - $scope.$watch('pager.page', (newVal) => { + this.$scope.$watch('pager.page', (newVal) => { if (newVal !== 0 && newVal <= this.totalPages) { this.getPages(newVal); } }); - + this.getPages(this.page || 1); } @@ -36,7 +51,7 @@ export class PagerController { /** * Select a page - * @param {int} num + * @param {int} num */ selectPage(num){ if (num > 0 && num <= this.totalPages) { @@ -73,7 +88,7 @@ export class PagerController { /** * Determines if the pager can go forward - * @return {boolean} + * @return {boolean} */ canNext(){ return this.page < this.totalPages; @@ -81,11 +96,11 @@ export class PagerController { /** * Gets the page set given the current page - * @param {int} page + * @param {int} page */ getPages(page) { var pages = [], - startPage = 1, + startPage = 1, endPage = this.totalPages, maxSize = 5, isMaxSized = maxSize < this.totalPages; diff --git a/src/components/menu/MenuController.js b/src/components/menu/MenuController.js index 75841b2..345d6d8 100644 --- a/src/components/menu/MenuController.js +++ b/src/components/menu/MenuController.js @@ -1,8 +1,9 @@ export class MenuController{ - /*@ngInject*/ - constructor($scope, $timeout){ - this.$scope = $scope; + constructor($scope, $timeout) { + Object.assign(this, { + $scope: $scope + }); } getColumnIndex(model){ @@ -23,5 +24,5 @@ export class MenuController{ this.$scope.current.splice(idx, 1); } } - + } diff --git a/src/components/menu/dropdown/DropdownController.js b/src/components/menu/dropdown/DropdownController.js index 263028d..de78b49 100644 --- a/src/components/menu/dropdown/DropdownController.js +++ b/src/components/menu/dropdown/DropdownController.js @@ -1,6 +1,6 @@ export class DropdownController{ /*@ngInject*/ - constructor($scope){ + constructor($scope) { $scope.open = false; } From 8473b7c675155bbd4c09fcd8bbf63a99e803bd65 Mon Sep 17 00:00:00 2001 From: Jonathan Shaffer Date: Fri, 16 Dec 2016 12:23:21 -0500 Subject: [PATCH 3/6] removing console log --- src/components/DataTableController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DataTableController.js b/src/components/DataTableController.js index 5d4282e..90e177d 100644 --- a/src/components/DataTableController.js +++ b/src/components/DataTableController.js @@ -10,9 +10,9 @@ export class DataTableController { * @param {scope} * @param {filter} */ - + /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){window.dt = this; + constructor($scope, $filter, $log, $transclude){ Object.assign(this, { $scope: $scope, $filter: $filter, From df1f598d98990cfcbd61eb24ae3e191e3a37edd1 Mon Sep 17 00:00:00 2001 From: Jonathan Shaffer Date: Fri, 16 Dec 2016 12:46:34 -0500 Subject: [PATCH 4/6] readded asterisk to readme, removed some unnecessary code --- README.md | 6 +++--- src/components/DataTableController.js | 6 ++---- src/components/body/SelectionController.js | 20 +++----------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 08e021a..1f04c65 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# angular-data-table +# angular-data-table [![Join the chat at https://gitter.im/Swimlane/angular-data-table](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/swimlane/angular-data-table?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![npm-version](https://img.shields.io/npm/v/angular-data-table.svg) @@ -8,7 +8,7 @@ `angular-data-table` is a AngularJS directive for presenting large and complex data. It has all the features you would expect from any other table but in a light package with _no external depedencies_. The table was designed to be extremely flexible and light; it doesn't make any assumptions about your data or how you: filter, sort or page it. -It was engineered from its conception to handle thousands of rows without sacrificing performance. It was built for modern browsers using _ES6, CSS3 and HTML5_ and **only supports [Evergreen Browsers](http://eisenbergeffect.bluespire.com/evergreen-browsers/) and Angular >= 1.4.x and < 1.7.0. +It was engineered from its conception to handle thousands of rows without sacrificing performance. It was built for modern browsers using _ES6, CSS3 and HTML5_ and **only supports [Evergreen Browsers](http://eisenbergeffect.bluespire.com/evergreen-browsers/) and Angular >= 1.4.x and < 1.7.0**. Sadly, this project is **not Angular2 upgrade compatible**. Fortunately, we have authored [angular2-data-table](https://github.com/swimlane/angular2-data-table) which is the successor to this project. **We are going to slowly be transitioning this project maintenance mode**. We will continue to provide feedback to the community and accept PRs but we won't be doing any major new development. @@ -55,7 +55,7 @@ You've got 5 different options to include this in your build depending on your s - `./release/dataTable.min.js` - A minified standalone file that was compiled with Babel (UMD) - `./release/dataTable.cjs.js` - A standalone file that was compiled with Babel (CommonJS) - `./release/dataTable.es6.js` - Raw ES6 Version. - + All distributions include babel helpers, so they do not have to be included separately. There is also the CSS too: diff --git a/src/components/DataTableController.js b/src/components/DataTableController.js index 90e177d..a6e8652 100644 --- a/src/components/DataTableController.js +++ b/src/components/DataTableController.js @@ -12,12 +12,10 @@ export class DataTableController { */ /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){ + constructor($scope, $filter){ Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log, - $transclude: $transclude + $filter: $filter }); if (angular.version.major === 1 && angular.version.minor < 5) { diff --git a/src/components/body/SelectionController.js b/src/components/body/SelectionController.js index 61e3a5c..bc99cca 100644 --- a/src/components/body/SelectionController.js +++ b/src/components/body/SelectionController.js @@ -4,23 +4,9 @@ export class SelectionController { /*@ngInject*/ constructor($scope) { - Object.assign(this, { - $scope: $scope - }); - - if (angular.version.major === 1 && angular.version.minor < 5) { - this.init(); - } - } - - $onInit(){ - this.init(); - } - - init(){ - this.body = this.$scope.body; - this.options = this.$scope.body.options; - this.selected = this.$scope.body.selected; + this.body = $scope.body; + this.options = $scope.body.options; + this.selected = $scope.body.selected; } /** From 6d93af0e2801a1d01e215bc5d23fc4d81a8b0938 Mon Sep 17 00:00:00 2001 From: Jonathan Shaffer Date: Fri, 16 Dec 2016 12:50:01 -0500 Subject: [PATCH 5/6] fat finger fix --- src/components/body/BodyController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/body/BodyController.js b/src/components/body/BodyController.js index 7110e84..9fa056d 100644 --- a/src/components/body/BodyController.js +++ b/src/components/body/BodyController.js @@ -25,7 +25,7 @@ export class BodyController{ this.init(); } - $onInit(){ + init(){ this.tempRows = []; this.treeColumn = this.options.columns.find((c) => { From b3375ec17cd1c8131d2d168df7c1b9686fb613e2 Mon Sep 17 00:00:00 2001 From: Jonathan Shaffer Date: Mon, 19 Dec 2016 09:38:43 -0500 Subject: [PATCH 6/6] releases built --- release/dataTable.cjs.js | 216 +++++++++++++++++++++++++-------------- release/dataTable.es6.js | 111 +++++++++++++++----- release/dataTable.js | 216 +++++++++++++++++++++++++-------------- release/dataTable.min.js | 4 +- 4 files changed, 361 insertions(+), 186 deletions(-) diff --git a/release/dataTable.cjs.js b/release/dataTable.cjs.js index cb34ff8..0494f2f 100644 --- a/release/dataTable.cjs.js +++ b/release/dataTable.cjs.js @@ -65,30 +65,46 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var PagerController = function () { PagerController.$inject = ["$scope"]; function PagerController($scope) { - var _this = this; - _classCallCheck(this, PagerController); - $scope.$watch('pager.count', function (newVal) { - _this.calcTotalPages(_this.size, _this.count); - _this.getPages(_this.page || 1); - }); - - $scope.$watch('pager.size', function (newVal) { - _this.calcTotalPages(_this.size, _this.count); - _this.getPages(_this.page || 1); - }); - - $scope.$watch('pager.page', function (newVal) { - if (newVal !== 0 && newVal <= _this.totalPages) { - _this.getPages(newVal); - } + Object.assign(this, { + $scope: $scope }); - this.getPages(this.page || 1); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } _createClass(PagerController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this = this; + + this.$scope.$watch('pager.count', function (newVal) { + _this.calcTotalPages(_this.size, _this.count); + _this.getPages(_this.page || 1); + }); + + this.$scope.$watch('pager.size', function (newVal) { + _this.calcTotalPages(_this.size, _this.count); + _this.getPages(_this.page || 1); + }); + + this.$scope.$watch('pager.page', function (newVal) { + if (newVal !== 0 && newVal <= _this.totalPages) { + _this.getPages(newVal); + } + }); + + this.getPages(this.page || 1); + } + }, { key: "calcTotalPages", value: function calcTotalPages(size, count) { var count = size < 1 ? 1 : Math.ceil(count / size); @@ -175,17 +191,34 @@ function PagerDirective() { var FooterController = function () { FooterController.$inject = ["$scope"]; function FooterController($scope) { - var _this2 = this; - _classCallCheck(this, FooterController); - this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', function (newVal) { - _this2.offsetChanged(newVal); + Object.assign(this, { + $scope: $scope }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } _createClass(FooterController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this2 = this; + + this.page = this.paging.offset + 1; + + this.$scope.$watch('footer.paging.offset', function (newVal) { + _this2.offsetChanged(newVal); + }); + } + }, { key: "offsetChanged", value: function offsetChanged(newVal) { this.page = newVal + 1; @@ -819,49 +852,65 @@ function ScrollerDirective($timeout, $rootScope) { var BodyController = function () { BodyController.$inject = ["$scope", "$timeout"]; function BodyController($scope, $timeout) { - var _this3 = this; - _classCallCheck(this, BodyController); - this.$scope = $scope; - this.tempRows = []; - - this.treeColumn = this.options.columns.find(function (c) { - return c.isTreeColumn; + Object.assign(this, { + $scope: $scope, + $timeout: $timeout }); - this.groupColumn = this.options.columns.find(function (c) { - return c.group; - }); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + _createClass(BodyController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this3 = this; - if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) { - var sized = false; - $scope.$watch('body.options.paging.size', function (newVal, oldVal) { - if (!sized || newVal > oldVal) { - _this3.getRows(); - sized = true; - } - }); + this.tempRows = []; - $scope.$watch('body.options.paging.count', function (count) { - _this3.count = count; - _this3.updatePage(); + this.treeColumn = this.options.columns.find(function (c) { + return c.isTreeColumn; }); - $scope.$watch('body.options.paging.offset', function (newVal) { - if (_this3.options.paging.size) { - _this3.onPage({ - offset: newVal, - size: _this3.options.paging.size - }); - } + this.groupColumn = this.options.columns.find(function (c) { + return c.group; }); - } - } - _createClass(BodyController, [{ + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + + if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) { + var sized = false; + this.$scope.$watch('body.options.paging.size', function (newVal, oldVal) { + if (!sized || newVal > oldVal) { + _this3.getRows(); + sized = true; + } + }); + + this.$scope.$watch('body.options.paging.count', function (count) { + _this3.count = count; + _this3.updatePage(); + }); + + this.$scope.$watch('body.options.paging.offset', function (newVal) { + if (_this3.options.paging.size) { + _this3.onPage({ + offset: newVal, + size: _this3.options.paging.size + }); + } + }); + } + } + }, { key: "rowsUpdated", value: function rowsUpdated(newVal, oldVal) { if (newVal) { @@ -957,7 +1006,7 @@ var BodyController = function () { }, { key: "calculateDepth", value: function calculateDepth(row) { - var depth = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var parentProp = this.treeColumn ? this.treeColumn.relationProp : this.groupColumn.prop; var prop = this.treeColumn.prop; @@ -2057,41 +2106,52 @@ var TableDefaults = { }; var DataTableController = function () { - DataTableController.$inject = ["$scope", "$filter", "$log", "$transclude"]; - function DataTableController($scope, $filter, $log, $transclude) { - var _this6 = this; - + DataTableController.$inject = ["$scope", "$filter"]; + function DataTableController($scope, $filter) { _classCallCheck(this, DataTableController); Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); - this.defaults(); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - this.options.$outer = $scope.$parent; + _createClass(DataTableController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this6 = this; - $scope.$watch('dt.options.columns', function (newVal, oldVal) { - _this6.transposeColumnDefaults(); + this.defaults(); - if (newVal.length !== oldVal.length) { - _this6.adjustColumns(); - } + this.options.$outer = this.$scope.$parent; - _this6.calculateColumns(); - }, true); + this.$scope.$watch('dt.options.columns', function (newVal, oldVal) { + _this6.transposeColumnDefaults(); - var watch = $scope.$watch('dt.rows', function (newVal) { - if (newVal) { - watch(); - _this6.onSorted(); - } - }); - } + if (newVal.length !== oldVal.length) { + _this6.adjustColumns(); + } - _createClass(DataTableController, [{ + _this6.calculateColumns(); + }, true); + + var watch = this.$scope.$watch('dt.rows', function (newVal) { + if (newVal) { + watch(); + _this6.onSorted(); + } + }); + } + }, { key: "defaults", value: function defaults() { var _this7 = this; diff --git a/release/dataTable.es6.js b/release/dataTable.es6.js index 3a3f3b9..a46e23d 100644 --- a/release/dataTable.es6.js +++ b/release/dataTable.es6.js @@ -41,26 +41,41 @@ class PagerController { /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ - constructor($scope){ - $scope.$watch('pager.count', (newVal) => { + constructor($scope) { + Object.assign(this, { + $scope: $scope + }) + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ + this.$scope.$watch('pager.count', (newVal) => { this.calcTotalPages(this.size, this.count); this.getPages(this.page || 1); }); - $scope.$watch('pager.size', (newVal) => { + this.$scope.$watch('pager.size', (newVal) => { this.calcTotalPages(this.size, this.count); this.getPages(this.page || 1); }); - $scope.$watch('pager.page', (newVal) => { + this.$scope.$watch('pager.page', (newVal) => { if (newVal !== 0 && newVal <= this.totalPages) { this.getPages(newVal); } }); - + this.getPages(this.page || 1); } @@ -75,7 +90,7 @@ class PagerController { /** * Select a page - * @param {int} num + * @param {int} num */ selectPage(num){ if (num > 0 && num <= this.totalPages) { @@ -112,7 +127,7 @@ class PagerController { /** * Determines if the pager can go forward - * @return {boolean} + * @return {boolean} */ canNext(){ return this.page < this.totalPages; @@ -120,11 +135,11 @@ class PagerController { /** * Gets the page set given the current page - * @param {int} page + * @param {int} page */ getPages(page) { var pages = [], - startPage = 1, + startPage = 1, endPage = this.totalPages, maxSize = 5, isMaxSized = maxSize < this.totalPages; @@ -208,10 +223,26 @@ class FooterController { * @param {scope} * @return {[type]} */ + /*@ngInject*/ - constructor($scope){ + constructor($scope) { + Object.assign(this, { + $scope: $scope + }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', (newVal) => { + + this.$scope.$watch('footer.paging.offset', (newVal) => { this.offsetChanged(newVal) }); } @@ -743,7 +774,7 @@ var KEYS = { class SelectionController { /*@ngInject*/ - constructor($scope){ + constructor($scope) { this.body = $scope.body; this.options = $scope.body.options; this.selected = $scope.body.selected; @@ -789,7 +820,7 @@ class SelectionController { this.body.onRowClick({ row: row }); } - + /** * Handler for the row double click event * @param {object} event @@ -927,8 +958,7 @@ var requestAnimFrame = (function(){ * This only exists because Angular's binding process is too slow. */ class StyleTranslator{ - - constructor(height){ + constructor(height) { this.height = height; this.map = new Map(); } @@ -1032,9 +1062,24 @@ class BodyController{ * @param {$timeout} * @return {BodyController} */ + /*@ngInject*/ - constructor($scope, $timeout){ - this.$scope = $scope; + constructor($scope, $timeout) { + Object.assign(this, { + $scope: $scope, + $timeout: $timeout + }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init(); + } + + init(){ this.tempRows = []; this.treeColumn = this.options.columns.find((c) => { @@ -1045,23 +1090,23 @@ class BodyController{ return c.group; }); - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); if(this.options.scrollbarV || (!this.options.scrollbarV && this.options.paging.externalPaging)){ var sized = false; - $scope.$watch('body.options.paging.size', (newVal, oldVal) => { + this.$scope.$watch('body.options.paging.size', (newVal, oldVal) => { if(!sized || newVal > oldVal){ this.getRows(); sized = true; } }); - $scope.$watch('body.options.paging.count', (count) => { + this.$scope.$watch('body.options.paging.count', (count) => { this.count = count; this.updatePage(); }); - $scope.$watch('body.options.paging.offset', (newVal) => { + this.$scope.$watch('body.options.paging.offset', (newVal) => { if(this.options.paging.size){ this.onPage({ offset: newVal, @@ -2639,20 +2684,30 @@ class DataTableController { * @param {scope} * @param {filter} */ + /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){ + constructor($scope, $filter){ Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + $onInit(){ + this.init() + } + + init(){ this.defaults(); // set scope to the parent - this.options.$outer = $scope.$parent; + this.options.$outer = this.$scope.$parent; - $scope.$watch('dt.options.columns', (newVal, oldVal) => { + this.$scope.$watch('dt.options.columns', (newVal, oldVal) => { this.transposeColumnDefaults(); if(newVal.length !== oldVal.length){ @@ -2663,7 +2718,7 @@ class DataTableController { }, true); // default sort - var watch = $scope.$watch('dt.rows', (newVal) => { + var watch = this.$scope.$watch('dt.rows', (newVal) => { if(newVal){ watch(); this.onSorted(); diff --git a/release/dataTable.js b/release/dataTable.js index 10dc89c..27fe941 100644 --- a/release/dataTable.js +++ b/release/dataTable.js @@ -106,30 +106,46 @@ var PagerController = function () { PagerController.$inject = ["$scope"]; function PagerController($scope) { - var _this = this; - _classCallCheck(this, PagerController); - $scope.$watch('pager.count', function (newVal) { - _this.calcTotalPages(_this.size, _this.count); - _this.getPages(_this.page || 1); - }); - - $scope.$watch('pager.size', function (newVal) { - _this.calcTotalPages(_this.size, _this.count); - _this.getPages(_this.page || 1); - }); - - $scope.$watch('pager.page', function (newVal) { - if (newVal !== 0 && newVal <= _this.totalPages) { - _this.getPages(newVal); - } + Object.assign(this, { + $scope: $scope }); - this.getPages(this.page || 1); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } _createClass(PagerController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this = this; + + this.$scope.$watch('pager.count', function (newVal) { + _this.calcTotalPages(_this.size, _this.count); + _this.getPages(_this.page || 1); + }); + + this.$scope.$watch('pager.size', function (newVal) { + _this.calcTotalPages(_this.size, _this.count); + _this.getPages(_this.page || 1); + }); + + this.$scope.$watch('pager.page', function (newVal) { + if (newVal !== 0 && newVal <= _this.totalPages) { + _this.getPages(newVal); + } + }); + + this.getPages(this.page || 1); + } + }, { key: "calcTotalPages", value: function calcTotalPages(size, count) { var count = size < 1 ? 1 : Math.ceil(count / size); @@ -216,17 +232,34 @@ var FooterController = function () { FooterController.$inject = ["$scope"]; function FooterController($scope) { - var _this2 = this; - _classCallCheck(this, FooterController); - this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', function (newVal) { - _this2.offsetChanged(newVal); + Object.assign(this, { + $scope: $scope }); + + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } _createClass(FooterController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this2 = this; + + this.page = this.paging.offset + 1; + + this.$scope.$watch('footer.paging.offset', function (newVal) { + _this2.offsetChanged(newVal); + }); + } + }, { key: "offsetChanged", value: function offsetChanged(newVal) { this.page = newVal + 1; @@ -860,49 +893,65 @@ var BodyController = function () { BodyController.$inject = ["$scope", "$timeout"]; function BodyController($scope, $timeout) { - var _this3 = this; - _classCallCheck(this, BodyController); - this.$scope = $scope; - this.tempRows = []; - - this.treeColumn = this.options.columns.find(function (c) { - return c.isTreeColumn; + Object.assign(this, { + $scope: $scope, + $timeout: $timeout }); - this.groupColumn = this.options.columns.find(function (c) { - return c.group; - }); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + _createClass(BodyController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this3 = this; - if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) { - var sized = false; - $scope.$watch('body.options.paging.size', function (newVal, oldVal) { - if (!sized || newVal > oldVal) { - _this3.getRows(); - sized = true; - } - }); + this.tempRows = []; - $scope.$watch('body.options.paging.count', function (count) { - _this3.count = count; - _this3.updatePage(); + this.treeColumn = this.options.columns.find(function (c) { + return c.isTreeColumn; }); - $scope.$watch('body.options.paging.offset', function (newVal) { - if (_this3.options.paging.size) { - _this3.onPage({ - offset: newVal, - size: _this3.options.paging.size - }); - } + this.groupColumn = this.options.columns.find(function (c) { + return c.group; }); - } - } - _createClass(BodyController, [{ + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + + if (this.options.scrollbarV || !this.options.scrollbarV && this.options.paging.externalPaging) { + var sized = false; + this.$scope.$watch('body.options.paging.size', function (newVal, oldVal) { + if (!sized || newVal > oldVal) { + _this3.getRows(); + sized = true; + } + }); + + this.$scope.$watch('body.options.paging.count', function (count) { + _this3.count = count; + _this3.updatePage(); + }); + + this.$scope.$watch('body.options.paging.offset', function (newVal) { + if (_this3.options.paging.size) { + _this3.onPage({ + offset: newVal, + size: _this3.options.paging.size + }); + } + }); + } + } + }, { key: "rowsUpdated", value: function rowsUpdated(newVal, oldVal) { if (newVal) { @@ -998,7 +1047,7 @@ }, { key: "calculateDepth", value: function calculateDepth(row) { - var depth = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; + var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var parentProp = this.treeColumn ? this.treeColumn.relationProp : this.groupColumn.prop; var prop = this.treeColumn.prop; @@ -2098,41 +2147,52 @@ }; var DataTableController = function () { - DataTableController.$inject = ["$scope", "$filter", "$log", "$transclude"]; - function DataTableController($scope, $filter, $log, $transclude) { - var _this6 = this; - + DataTableController.$inject = ["$scope", "$filter"]; + function DataTableController($scope, $filter) { _classCallCheck(this, DataTableController); Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); - this.defaults(); + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - this.options.$outer = $scope.$parent; + _createClass(DataTableController, [{ + key: "$onInit", + value: function $onInit() { + this.init(); + } + }, { + key: "init", + value: function init() { + var _this6 = this; - $scope.$watch('dt.options.columns', function (newVal, oldVal) { - _this6.transposeColumnDefaults(); + this.defaults(); - if (newVal.length !== oldVal.length) { - _this6.adjustColumns(); - } + this.options.$outer = this.$scope.$parent; - _this6.calculateColumns(); - }, true); + this.$scope.$watch('dt.options.columns', function (newVal, oldVal) { + _this6.transposeColumnDefaults(); - var watch = $scope.$watch('dt.rows', function (newVal) { - if (newVal) { - watch(); - _this6.onSorted(); - } - }); - } + if (newVal.length !== oldVal.length) { + _this6.adjustColumns(); + } - _createClass(DataTableController, [{ + _this6.calculateColumns(); + }, true); + + var watch = this.$scope.$watch('dt.rows', function (newVal) { + if (newVal) { + watch(); + _this6.onSorted(); + } + }); + } + }, { key: "defaults", value: function defaults() { var _this7 = this; diff --git a/release/dataTable.min.js b/release/dataTable.min.js index a01c68b..e7ec505 100644 --- a/release/dataTable.min.js +++ b/release/dataTable.min.js @@ -4,5 +4,5 @@ * @link http://swimlane.com/ * @license */ -!function(e,t){if("function"==typeof define&&define.amd)define("DataTable",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var n={exports:{}};t(n.exports),e.DataTable=n.exports}}(this,function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t\n
    \n
  • \n \n
  • \n
  • \n \n
  • \n
  • \n {{pg.text}}\n
  • \n
  • \n \n
  • \n
  • \n \n
  • \n
\n ',replace:!0}}function i(){return{restrict:"E",controller:B,controllerAs:"footer",scope:!0,bindToController:{paging:"=",onPage:"&"},template:'',replace:!0}}function r(e,t,n,o){return{restrict:"E",controller:G,scope:!0,controllerAs:"cell",bindToController:{options:"=",value:"=",selected:"=",column:"=",row:"=",expanded:"=",hasChildren:"=",onTreeToggle:"&",onCheckboxChange:"&"},template:'
\n \n \n \n
',replace:!0,compile:function(){return{pre:function(e,n,o,i){function r(){s=i.options.$outer.$new(!1),s.getValue=i.getValue}var s,l=angular.element(n[0].querySelector(".dt-cell-content"));(i.column.template||i.column.cellRenderer)&&r(),e.$watch("cell.row",function(){if(s&&(s.$destroy(),r(),s.$cell=i.value,s.$row=i.row,s.$column=i.column,s.$$watchers=null),i.column.template){l.empty();var e=angular.element(""+i.column.template.trim()+"");l.append(t(e)(s))}else if(i.column.cellRenderer){l.empty();var e=angular.element(i.column.cellRenderer(s,l));l.append(t(e)(s))}else l[0].innerHTML=i.getValue()},!0)}}}}}function s(e){return e=e.replace(/[^a-zA-Z0-9 ]/g," "),e=e.replace(/([a-z](?=[A-Z]))/g,"$1 "),e=e.replace(/([^a-zA-Z0-9 ])|^[0-9]+/g,"").trim().toLowerCase(),e=e.replace(/([ 0-9]+)([a-zA-Z])/g,function(e,t,n){return t.trim()+n.toUpperCase()})}function l(e){var t=s(e);return D[t]||(void 0!==H[M.css+e]?D[t]=M.css+e:void 0!==H[e]&&(D[t]=e)),D[t]}function a(e,t,n){V?!I&&j?(e[N]="translate3d("+t+"px, "+n+"px, 0)",e[O]="hidden"):e[s(N)]="translate("+t+"px, "+n+"px)":(e.top=n+"px",e.left=t+"px")}function c(){return{restrict:"E",controller:F,controllerAs:"group",bindToController:{row:"=",onGroupToggle:"&",expanded:"=",options:"="},scope:!0,replace:!0,template:'\n
\n \n \n \n \n
',link:function(e,t,n,o){a(t[0].style,0,o.row.$$index*o.options.rowHeight),o.options.internal.styleTranslator.register(e.$index,t)}}}function d(e,t){if(!e||!t)return e;var n=e,o=t.split(".");if(o.length)for(var i=0,r=o.length;r>i;i++)n=n[o[i]];return n}function u(){return{restrict:"E",controller:U,controllerAs:"rowCtrl",scope:!0,bindToController:{row:"=",columns:"=",columnWidths:"=",expanded:"=",selected:"=",hasChildren:"=",options:"=",onCheckboxChange:"&",onTreeToggle:"&"},link:function(e,t,n,o){o.row&&a(t[0].style,0,o.row.$$index*o.options.rowHeight),o.options.internal.styleTranslator.register(e.$index,t)},template:'\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
',replace:!0}}function h(){return{controller:q,restrict:"A",require:"^dtBody",controllerAs:"selCtrl"}}function p(e,t){return{restrict:"E",require:"^dtBody",transclude:!0,replace:!0,template:'
',link:function(e,t,n,o){function i(){o.options.internal.offsetY=l,o.options.internal.offsetX=a,o.updatePage(),o.options.scrollbarV&&o.getRows(),o.options.$outer.$digest(),s=!1}function r(){s||(Y(i),s=!0)}var s=!1,l=0,a=0,c=t.parent();o.options.internal.styleTranslator=new Z(o.options.rowHeight),o.options.internal.setYOffset=function(e){c[0].scrollTop=e},c.on("scroll",function(e){l=this.scrollTop,a=this.scrollLeft,r()}),e.$on("$destroy",function(){c.off("scroll")}),e.scrollerStyles=function(){return o.options.scrollbarV?{height:o.count*o.options.rowHeight+"px"}:void 0}}}}function g(e){return{restrict:"E",controller:_,controllerAs:"body",bindToController:{columns:"=",columnWidths:"=",rows:"=",options:"=",selected:"=?",expanded:"=?",onPage:"&",onTreeToggle:"&",onSelect:"&",onRowClick:"&",onRowDblClick:"&"},scope:!0,template:'\n
\n
\n
\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n
\n
'}}function f(e,t){return"single"===e?"asc"===t?"desc":"asc":t?"asc"===t?"desc":void 0:"asc"}function m(e){return{restrict:"E",controller:K,controllerAs:"hcell",scope:!0,bindToController:{options:"=",column:"=",onCheckboxChange:"&",onSort:"&",sortType:"=",onResize:"&",selected:"="},replace:!0,template:'
\n
\n \n \n \n \n
\n
',compile:function(){return{pre:function(t,n,o,i){var r=n[0].querySelector(".dt-header-cell-label"),s=void 0;if((i.column.headerTemplate||i.column.headerRenderer)&&(s=i.options.$outer.$new(!1),s.$header=i.column.name,s.$index=t.$index),i.column.headerTemplate){var l=angular.element(""+i.column.headerTemplate.trim()+"");angular.element(r).append(e(l)(s))}else if(i.column.headerRenderer){var a=angular.element(i.column.headerRenderer(n));angular.element(r).append(e(a)(s)[0])}else{var c=i.column.name;void 0!==c&&null!==c||(c=""),r.textContent=c}}}}}}function v(e){return{restrict:"E",controller:J,controllerAs:"header",scope:!0,bindToController:{options:"=",columns:"=",columnWidths:"=",onSort:"&",onResize:"&",onCheckboxChange:"&"},template:'\n
\n\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
',replace:!0,link:function(t,n,o,i){t.columnsResorted=function(t,n){var o=r(n),s=angular.element(t.currentTarget),l=-1;angular.forEach(s.children(),function(e,t){n===angular.element(e).attr("data-id")&&(l=t)}),e(function(){angular.forEach(i.columns,function(e){var t=e.indexOf(o);if(t>-1){var n=e[l],r=i.options.columns.indexOf(n),s=i.options.columns.indexOf(o);return i.options.columns.splice(s,1),i.options.columns.splice(r,0,o),!1}})})};var r=function(e){var t=i.columns.left.concat(i.columns.center).concat(i.columns.right);return t.find(function(t){return t.$id===e})}}}}function w(e){return{restrict:"A",scope:{isSortable:"=sortable",onSortableSort:"&"},link:function(e,t,n){function o(e,t){if(e.parentNode==t.parentNode)for(var n=e;n;n=n.previousSibling)if(n===t)return!0;return!1}function i(e){var t=e.target;o(l,t)?t.parentNode.insertBefore(l,t):t.nextSibling&&t.hasAttribute("draggable")&&t.parentNode.insertBefore(l,t.nextSibling.nextSibling)}function r(n){n.preventDefault(),l.classList.remove("dt-clone"),t.off("dragend",r),t.off("dragenter",i),a!==l.nextSibling&&e.onSortableSort({event:n,columnId:angular.element(l).attr("data-id")})}function s(n){return e.isSortable?(n=n.originalEvent||n,l=n.target,a=l.nextSibling,l.classList.add("dt-clone"),n.dataTransfer.effectAllowed="move",n.dataTransfer.setData("Text",l.textContent),t.on("dragenter",i),void t.on("dragend",r)):!1}var l,a;t[0];t.on("dragstart",s),e.$on("$destroy",function(){t.off("dragstart",s)})}}}function y(e,t){return{restrict:"A",scope:{isResizable:"=resizable",minWidth:"=",maxWidth:"=",onResize:"&"},link:function(n,o,i){function r(e){e=e.originalEvent||e;var t=c[0].clientWidth,o=e.movementX||e.mozMovementX||e.screenX-l,i=t+(o||0);l=e.screenX,(!n.minWidth||i>=n.minWidth)&&(!n.maxWidth||i<=n.maxWidth)&&c.css({width:i+"px"})}function s(){n.onResize&&t(function(){var e=c[0].clientWidth;e'),c=o.parent();a.on("mousedown",function(t){return o[0].classList.contains("resizable")?(t.stopPropagation(),t.preventDefault(),e.on("mousemove",r),void e.on("mouseup",s)):!1}),o.append(a)}}}function b(e,t,n){var o,i,r,s=null,l=0;n||(n={});var a=function(){l=n.leading===!1?0:new Date,s=null,r=e.apply(o,i)};return function(){var c=new Date;l||n.leading!==!1||(l=c);var d=t-(c-l);return o=this,i=arguments,0>=d?(clearTimeout(s),s=null,l=c,r=e.apply(o,i)):s||n.trailing===!1||(s=setTimeout(a,d)),r}}function C(){var e=document.createElement("div");e.style.visibility="hidden",e.style.width="100px",e.style.msOverflowStyle="scrollbar",document.body.appendChild(e);var t=e.offsetWidth;e.style.overflow="scroll";var n=document.createElement("div");n.style.width="100%",e.appendChild(n);var o=n.offsetWidth;return e.parentNode.removeChild(e),t-o}function x(){var e=((new Date).getTime()/1e3|0).toString(16);return e+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)}).toLowerCase()}function k(e,t,n){angular.forEach(e,function(e){e.forEach(function(e){e.canAutoResize?e.width=0:(t-=e.width,n-=e.flexGrow)})});var o={},i=t,r=function(){var t=i/n;i=0,angular.forEach(e,function(e){e.forEach(function(e,n){if(e.canAutoResize&&!o[n]){var r=e.width+e.flexGrow*t;void 0!==e.minWidth&&rn;n++){var i=e[n];i.frozenLeft?t.left.push(i):i.frozenRight?t.right.push(i):t.center.push(i)}return t}function R(e){var t=0,n=!0,o=!1,i=void 0;try{for(var r,s=e[Symbol.iterator]();!(n=(r=s.next()).done);n=!0){var l=r.value;t+=l.flexGrow||0}}catch(a){o=!0,i=a}finally{try{!n&&s["return"]&&s["return"]()}finally{if(o)throw i}}return t}function T(e,t){var n=0;return e.forEach(function(e){var o=t&&e[t];n+=o?e[t]:e.width}),n}function P(e,t){var n=T(e),o=R(e),i=$(e);n!==t&&k(i,t,o)}function S(e,t,n){var o=0,i=n>-1?e.slice(n,e.length).filter(function(e){return e.canAutoResize}):e.filter(function(e){return e.canAutoResize});e.forEach(function(e){o+=e.canAutoResize?e.$$oldWidth||e.width:e.width});var r=t-o,s=r/i.length,l=o>t;i.forEach(function(e){if(l)e.width=e.$$oldWidth||e.width;else{e.$$oldWidth||(e.$$oldWidth=e.width);var t=e.$$oldWidth+s;e.minWith&&te.maxWidth?e.width=e.maxWidth:e.width=t}})}function z(e,t){return{left:T(e.left),center:T(e.center),right:T(e.right),total:T(t)}}function W(e,t,n){return{restrict:"E",replace:!0,controller:ne,scope:!0,bindToController:{options:"=",rows:"=",selected:"=?",expanded:"=?",onSelect:"&",onSort:"&",onTreeToggle:"&",onPage:"&",onRowClick:"&",onRowDblClick:"&",onColumnResize:"&"},controllerAs:"dt",template:function(e){var t=e[0].getElementsByTagName("column"),n=x();return Q.saveColumns(n,t),'
\n \n \n \n \n \n \n
'},compile:function(o,i){return{pre:function(o,i,r,s){function l(){var e=i[0].getBoundingClientRect();if(s.options.internal.innerWidth=Math.floor(e.width),s.options.scrollbarV){var t=e.height;s.options.headerHeight&&(t-=s.options.headerHeight),s.options.footerHeight&&(t-=s.options.footerHeight),s.options.internal.bodyHeight=t,s.calculatePageSize()}s.adjustColumns()}Q.buildColumns(o,n);var a=i.attr("data-column-id"),c=Q.columns[a];c&&(s.options.columns=c),s.transposeColumnDefaults(),s.options.internal.scrollBarWidth=C(),e.addEventListener("resize",b(function(){t(l)}));var d=function u(){var e=i[0].getBoundingClientRect(),n=e.width&&e.height;n?l():t(u,100)};d(),i.addClass("dt-loaded"),o.$on("$destroy",function(){angular.element(e).off("resize")})}}}}}W.$inject=["$window","$timeout","$parse"],y.$inject=["$document","$timeout"],w.$inject=["$timeout"],v.$inject=["$timeout"],m.$inject=["$compile"],g.$inject=["$timeout"],p.$inject=["$timeout","$rootScope"],r.$inject=["$rootScope","$compile","$log","$timeout"],Object.defineProperty(e,"__esModule",{value:!0});var E=function(){function e(e,t){for(var n=0;nn;n++)if(i(this[n],n,this)===!0)return"find"===e?this[n]:n;return"find"!==e?-1:void 0})}for(var t in{find:1,findIndex:1})e(t)}();var A=function(){function e(t){var o=this;n(this,e),t.$watch("pager.count",function(e){o.calcTotalPages(o.size,o.count),o.getPages(o.page||1)}),t.$watch("pager.size",function(e){o.calcTotalPages(o.size,o.count),o.getPages(o.page||1)}),t.$watch("pager.page",function(e){0!==e&&e<=o.totalPages&&o.getPages(e)}),this.getPages(this.page||1)}return e.$inject=["$scope"],E(e,[{key:"calcTotalPages",value:function(e,t){var t=1>e?1:Math.ceil(t/e);this.totalPages=Math.max(t||0,1)}},{key:"selectPage",value:function(e){e>0&&e<=this.totalPages&&(this.page=e,this.onPage({page:e}))}},{key:"prevPage",value:function(){this.page>1&&this.selectPage(--this.page)}},{key:"nextPage",value:function(){this.selectPage(++this.page)}},{key:"canPrevious",value:function(){return this.page>1}},{key:"canNext",value:function(){return this.page=s;s++)t.push({number:s,text:s,active:s===e});this.pages=t}}]),e}(),B=function(){function e(t){var o=this;n(this,e),this.page=this.paging.offset+1,t.$watch("footer.paging.offset",function(e){o.offsetChanged(e)})}return e.$inject=["$scope"],E(e,[{key:"offsetChanged",value:function(e){this.page=e+1}},{key:"onPaged",value:function(e){this.paging.offset=e-1,this.onPage({offset:this.paging.offset,size:this.paging.size})}}]),e}(),G=function(){function e(){n(this,e)}return E(e,[{key:"styles",value:function(){return{width:this.column.width+"px","min-width":this.column.width+"px"}}},{key:"cellClass",value:function(){var e={"dt-tree-col":this.column.isTreeColumn};return this.column.className&&(e[this.column.className]=!0),e}},{key:"treeClass",value:function(){return{"dt-tree-toggle":!0,"icon-right":!this.expanded,"icon-down":this.expanded}}},{key:"onTreeToggled",value:function(e){e.stopPropagation(),this.expanded=!this.expanded,this.onTreeToggle({cell:{value:this.value,column:this.column,expanded:this.expanded}})}},{key:"onCheckboxChanged",value:function(e){e.stopPropagation(),this.onCheckboxChange({$event:e})}},{key:"getValue",value:function(){var e=this.column.cellDataGetter?this.column.cellDataGetter(this.value):this.value;return void 0!==e&&null!==e||(e=""),e}}]),e}(),D={},H=document.createElement("div").style,M=function(){var e=window.getComputedStyle(document.documentElement,""),t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1],n="WebKit|Moz|MS|O".match(new RegExp("("+t+")","i"))[1];return{dom:n,lowercase:t,css:"-"+t+"-",js:t[0].toUpperCase()+t.substr(1)}}(),N=l("transform"),O=l("backfaceVisibility"),V=!!l("transform"),j=!!l("perspective"),L=window.navigator.userAgent,I=/Safari\//.test(L)&&!/Chrome\//.test(L),F=function(){function e(){n(this,e)}return E(e,[{key:"onGroupToggled",value:function(e){e.stopPropagation(),this.onGroupToggle({group:this.row})}},{key:"treeClass",value:function(){return{"dt-tree-toggle":!0,"icon-right":!this.expanded,"icon-down":this.expanded}}}]),e}(),U=function(){function e(){n(this,e)}return E(e,[{key:"getValue",value:function(e){return e.prop?d(this.row,e.prop):""}},{key:"onTreeToggled",value:function(e){this.onTreeToggle({cell:e,row:this.row})}},{key:"stylesByGroup",value:function(e){var t={width:this.columnWidths[e]+"px"};if("left"===e)a(t,this.options.internal.offsetX,0);else if("right"===e){var n=-1*(this.columnWidths.total-this.options.internal.innerWidth-this.options.internal.offsetX+this.options.internal.scrollBarWidth);a(t,n,0)}return t}},{key:"onCheckboxChanged",value:function(e){this.onCheckboxChange({$event:e,row:this.row})}}]),e}(),X={BACKSPACE:8,TAB:9,RETURN:13,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46,COMMA:188,PERIOD:190,A:65,Z:90,ZERO:48,NUMPAD_0:96,NUMPAD_9:105},q=function(){function e(t){n(this,e),this.body=t.body,this.options=t.body.options,this.selected=t.body.selected}return e.$inject=["$scope"],E(e,[{key:"keyDown",value:function(e,t,n){if(X[e.keyCode]&&e.preventDefault(),e.keyCode===X.DOWN){var o=e.target.nextElementSibling;o&&o.focus()}else if(e.keyCode===X.UP){var i=e.target.previousElementSibling;i&&i.focus()}else e.keyCode===X.RETURN&&this.selectRow(t,n)}},{key:"rowClicked",value:function(e,t,n){this.options.checkboxSelection||this.selectRow(e,t,n),this.body.onRowClick({row:n})}},{key:"rowDblClicked",value:function(e,t,n){this.options.checkboxSelection||(e.preventDefault(),this.selectRow(e,t,n)),this.body.onRowDblClick({row:n})}},{key:"onCheckboxChange",value:function(e,t,n){this.selectRow(e,t,n)}},{key:"selectRow",value:function(e,t,n){if(this.options.selectable)if(this.options.multiSelect){var o=(e.ctrlKey||e.metaKey,e.shiftKey);if(o)this.selectRowsBetween(t,n);else{var i=this.selected.indexOf(n);i>-1?this.selected.splice(i,1):(this.options.multiSelectOnShift&&1===this.selected.length&&this.selected.splice(0,1),this.selected.push(n),this.body.onSelect({rows:[n]}))}this.prevIndex=t}else this.selected=n,this.body.onSelect({rows:[n]})}},{key:"selectRowsBetween",value:function(e){for(var t=eo;o++){var r=this.body.rows[o],s=o>=this.prevIndex&&e>=o,l=o<=this.prevIndex&&o>=e,a={};if(a=t?{start:e,end:this.prevIndex-e}:{start:this.prevIndex,end:e+1},t&&l||!t&&s){var c=this.selected.indexOf(r);if(t&&c>-1){this.selected.splice(c,1);continue}o>=a.start&&ot)&&(i.getRows(),r=!0)}),t.$watch("body.options.paging.count",function(e){i.count=e,i.updatePage()}),t.$watch("body.options.paging.offset",function(e){i.options.paging.size&&i.onPage({offset:e,size:i.options.paging.size})})}}return e.$inject=["$scope","$timeout"],E(e,[{key:"rowsUpdated",value:function(e,n){if(e)if(this.options.paging.externalPaging||(this.options.paging.count=e.length),this.count=this.options.paging.count,(this.treeColumn||this.groupColumn)&&this.buildRowsByGroup(),this.options.scrollbarV){var o=e&&n&&(e.length===n.length||e.lengtho?Math.floor(o):o>n?Math.ceil(o):e,isNaN(o)||(this.options.paging.offset=o)}},{key:"calculateDepth",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1],n=this.treeColumn?this.treeColumn.relationProp:this.groupColumn.prop,o=this.treeColumn.prop;if(!e[n])return t;if(e.$$depth)return e.$$depth+t;var i=this.index[e[n]];if(i)return t+=1,this.calculateDepth(i,t);for(var r=0,s=this.rows.length;s>r;r++){var l=this.rows[r];if(l[o]==e[n])return t+=1,this.calculateDepth(l,t)}return t}},{key:"buildRowsByGroup",value:function(){this.index={},this.rowsByGroup={};for(var e=this.treeColumn?this.treeColumn.relationProp:this.groupColumn.prop,t=0,n=this.rows.length;n>t;t++){var o=this.rows[t],i=o[e];if(i&&(this.rowsByGroup[i]?this.rowsByGroup[i].push(o):this.rowsByGroup[i]=[o]),this.treeColumn){var r=this.treeColumn.prop;if(this.index[o[r]]=o,void 0===o[e])o.$$depth=0;else{var s=this.index[o[e]];if(void 0===s)for(var l=0;n>l;l++)if(this.rows[l][r]==i){s=this.rows[l]; -break}void 0===s.$$depth&&(s.$$depth=this.calculateDepth(s)),o.$$depth=s.$$depth+1,s.$$children?s.$$children.push(o[r]):s.$$children=[o[r]]}}}}},{key:"buildGroups",value:function(){var e=this,n=[];return angular.forEach(this.rowsByGroup,function(o,i){n.push({name:i,group:!0}),e.expanded[i]&&n.push.apply(n,t(o))}),n}},{key:"isSelected",value:function(e){var t=!1;return this.options.selectable&&(t=this.options.multiSelect?this.selected.indexOf(e)>-1:this.selected===e),t}},{key:"buildTree",value:function(){function e(t,o,i){t.forEach(function(t){var r=t[n.treeColumn.relationProp],s=t[n.treeColumn.prop],l=n.rowsByGroup[s],a=n.expanded[s];(i>0||!r)&&(o.push(t),l&&l.length>0&&a&&e(l,o,i+1))})}var t=[],n=this;return e(this.rows,t,0),t}},{key:"getRows",value:function(e){if((this.treeColumn||this.groupColumn)&&!this.rowsByGroup)return!1;var t;this.treeColumn?(t=this.treeTemp||[],!e&&this.treeTemp||(this.treeTemp=t=this.buildTree(),this.count=t.length,this.tempRows.splice(0,this.tempRows.length))):this.groupColumn?(t=this.groupsTemp||[],!e&&this.groupsTemp||(this.groupsTemp=t=this.buildGroups(),this.count=t.length)):(t=this.rows,e===!0&&this.tempRows.splice(0,this.tempRows.length));var n=0,o=this.getFirstLastIndexes(),i=o.first;for(this.tempRows.splice(0,o.last-o.first);ie;e++){var n=this.options.columns[e];n.$id=x(),angular.forEach(ee,function(e,t){n.hasOwnProperty(t)||(n[t]=e)}),n.name&&!n.prop&&(n.prop=s(n.name)),this.options.columns[e]=n}}},{key:"calculateColumns",value:function(){var e=this.options.columns;this.columnsByPin=$(e),this.columnWidths=z(this.columnsByPin,e)}},{key:"tableCss",value:function(){return{fixed:this.options.scrollbarV,selectable:this.options.selectable,checkboxable:this.options.checkboxSelection}}},{key:"adjustColumns",value:function(e){var t=this.options.internal.innerWidth-this.options.internal.scrollBarWidth;"force"===this.options.columnMode?S(this.options.columns,t,e):"flex"===this.options.columnMode&&P(this.options.columns,t)}},{key:"calculatePageSize",value:function(){this.options.paging.size=Math.ceil(this.options.internal.bodyHeight/this.options.rowHeight)+1}},{key:"onSorted",value:function(){if(this.rows){var e=this.options.columns.filter(function(e){return e.sort}).sort(function(e,t){if(e.sortPriority&&t.sortPriority){if(e.sortPriority>t.sortPriority)return 1;if(e.sortPriorityo;o++){var r=e[o];if(r.comparator!==!1){var s="asc"===r.sort?"":"-";void 0!==r.sortBy?n.push(s+r.sortBy):n.push(s+r.prop)}}if(n.length){var l,a=this.$filter("orderBy")(this.rows,n);this.rows.splice(0,this.rows.length),(l=this.rows).push.apply(l,t(a))}}this.options.internal.setYOffset(0)}}},{key:"onTreeToggled",value:function(e,t){this.onTreeToggle({row:e,cell:t})}},{key:"onBodyPage",value:function(e,t){this.onPage({offset:e,size:t})}},{key:"onFooterPage",value:function(e,t){var n=this.options.rowHeight*t,o=n*e;this.options.internal.setYOffset(o)}},{key:"onHeaderCheckboxChange",value:function(){if(this.rows){var e=this.selected.length===this.rows.length;if(this.selected.splice(0,this.selected.length),!e){var n;(n=this.selected).push.apply(n,t(this.rows))}}}},{key:"isAllRowsSelected",value:function(){return this.rows?!1:this.selected.length===this.rows.length}},{key:"onResized",value:function(e,t){var n=this.options.columns.indexOf(e);if(n>-1){var e=this.options.columns[n];e.width=t,e.canAutoResize=!1,this.adjustColumns(n),this.calculateColumns()}this.onColumnResize&&this.onColumnResize({column:e,width:t})}},{key:"onSelected",value:function(e){this.onSelect({rows:e})}},{key:"onRowClicked",value:function(e){this.onRowClick({row:e})}},{key:"onRowDblClicked",value:function(e){this.onRowDblClick({row:e})}}]),e}(),oe=angular.module("data-table",[]).directive("dtable",W).directive("resizable",y).directive("sortable",w).directive("dtHeader",v).directive("dtHeaderCell",m).directive("dtBody",g).directive("dtScroller",p).directive("dtSeletion",h).directive("dtRow",u).directive("dtGroupRow",c).directive("dtCell",r).directive("dtFooter",i).directive("dtPager",o);e["default"]=oe}); \ No newline at end of file +!function(e,t){if("function"==typeof define&&define.amd)define("DataTable",["exports"],t);else if("undefined"!=typeof exports)t(exports);else{var n={exports:{}};t(n.exports),e.DataTable=n.exports}}(this,function(e){"use strict";function t(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t\n
    \n
  • \n \n
  • \n
  • \n \n
  • \n
  • \n {{pg.text}}\n
  • \n
  • \n \n
  • \n
  • \n \n
  • \n
\n ',replace:!0}}function i(){return{restrict:"E",controller:B,controllerAs:"footer",scope:!0,bindToController:{paging:"=",onPage:"&"},template:'',replace:!0}}function r(e,t,n,o){return{restrict:"E",controller:G,scope:!0,controllerAs:"cell",bindToController:{options:"=",value:"=",selected:"=",column:"=",row:"=",expanded:"=",hasChildren:"=",onTreeToggle:"&",onCheckboxChange:"&"},template:'
\n \n \n \n
',replace:!0,compile:function(){return{pre:function(e,n,o,i){function r(){s=i.options.$outer.$new(!1),s.getValue=i.getValue}var s,l=angular.element(n[0].querySelector(".dt-cell-content"));(i.column.template||i.column.cellRenderer)&&r(),e.$watch("cell.row",function(){if(s&&(s.$destroy(),r(),s.$cell=i.value,s.$row=i.row,s.$column=i.column,s.$$watchers=null),i.column.template){l.empty();var e=angular.element(""+i.column.template.trim()+"");l.append(t(e)(s))}else if(i.column.cellRenderer){l.empty();var e=angular.element(i.column.cellRenderer(s,l));l.append(t(e)(s))}else l[0].innerHTML=i.getValue()},!0)}}}}}function s(e){return e=e.replace(/[^a-zA-Z0-9 ]/g," "),e=e.replace(/([a-z](?=[A-Z]))/g,"$1 "),e=e.replace(/([^a-zA-Z0-9 ])|^[0-9]+/g,"").trim().toLowerCase(),e=e.replace(/([ 0-9]+)([a-zA-Z])/g,function(e,t,n){return t.trim()+n.toUpperCase()})}function l(e){var t=s(e);return D[t]||(void 0!==H[M.css+e]?D[t]=M.css+e:void 0!==H[e]&&(D[t]=e)),D[t]}function a(e,t,n){O?!L&&V?(e[j]="translate3d("+t+"px, "+n+"px, 0)",e[N]="hidden"):e[s(j)]="translate("+t+"px, "+n+"px)":(e.top=n+"px",e.left=t+"px")}function c(){return{restrict:"E",controller:F,controllerAs:"group",bindToController:{row:"=",onGroupToggle:"&",expanded:"=",options:"="},scope:!0,replace:!0,template:'\n
\n \n \n \n \n
',link:function(e,t,n,o){a(t[0].style,0,o.row.$$index*o.options.rowHeight),o.options.internal.styleTranslator.register(e.$index,t)}}}function u(e,t){if(!e||!t)return e;var n=e,o=t.split(".");if(o.length)for(var i=0,r=o.length;i\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n ',replace:!0}}function h(){return{controller:q,restrict:"A",require:"^dtBody",controllerAs:"selCtrl"}}function p(e,t){return{restrict:"E",require:"^dtBody",transclude:!0,replace:!0,template:'
',link:function(e,t,n,o){function i(){o.options.internal.offsetY=l,o.options.internal.offsetX=a,o.updatePage(),o.options.scrollbarV&&o.getRows(),o.options.$outer.$digest(),s=!1}function r(){s||(Y(i),s=!0)}var s=!1,l=0,a=0,c=t.parent();o.options.internal.styleTranslator=new Z(o.options.rowHeight),o.options.internal.setYOffset=function(e){c[0].scrollTop=e},c.on("scroll",function(e){l=this.scrollTop,a=this.scrollLeft,r()}),e.$on("$destroy",function(){c.off("scroll")}),e.scrollerStyles=function(){if(o.options.scrollbarV)return{height:o.count*o.options.rowHeight+"px"}}}}}function g(e){return{restrict:"E",controller:_,controllerAs:"body",bindToController:{columns:"=",columnWidths:"=",rows:"=",options:"=",selected:"=?",expanded:"=?",onPage:"&",onTreeToggle:"&",onSelect:"&",onRowClick:"&",onRowDblClick:"&"},scope:!0,template:'\n
\n
\n
\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n
\n
'}}function f(e,t){return"single"===e?"asc"===t?"desc":"asc":t?"asc"===t?"desc":void 0:"asc"}function m(e){return{restrict:"E",controller:K,controllerAs:"hcell",scope:!0,bindToController:{options:"=",column:"=",onCheckboxChange:"&",onSort:"&",sortType:"=",onResize:"&",selected:"="},replace:!0,template:'
\n
\n \n \n \n \n
\n
',compile:function(){return{pre:function(t,n,o,i){var r=n[0].querySelector(".dt-header-cell-label"),s=void 0;if((i.column.headerTemplate||i.column.headerRenderer)&&(s=i.options.$outer.$new(!1),s.$header=i.column.name,s.$index=t.$index),i.column.headerTemplate){var l=angular.element(""+i.column.headerTemplate.trim()+"");angular.element(r).append(e(l)(s))}else if(i.column.headerRenderer){var a=angular.element(i.column.headerRenderer(n));angular.element(r).append(e(a)(s)[0])}else{var c=i.column.name;void 0!==c&&null!==c||(c=""),r.textContent=c}}}}}}function v(e){return{restrict:"E",controller:J,controllerAs:"header",scope:!0,bindToController:{options:"=",columns:"=",columnWidths:"=",onSort:"&",onResize:"&",onCheckboxChange:"&"},template:'\n
\n\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n
',replace:!0,link:function(t,n,o,i){t.columnsResorted=function(t,n){var o=r(n),s=angular.element(t.currentTarget),l=-1;angular.forEach(s.children(),function(e,t){n===angular.element(e).attr("data-id")&&(l=t)}),e(function(){angular.forEach(i.columns,function(e){var t=e.indexOf(o);if(t>-1){var n=e[l],r=i.options.columns.indexOf(n),s=i.options.columns.indexOf(o);return i.options.columns.splice(s,1),i.options.columns.splice(r,0,o),!1}})})};var r=function(e){var t=i.columns.left.concat(i.columns.center).concat(i.columns.right);return t.find(function(t){return t.$id===e})}}}}function w(e){return{restrict:"A",scope:{isSortable:"=sortable",onSortableSort:"&"},link:function(e,t,n){function o(e,t){if(e.parentNode==t.parentNode)for(var n=e;n;n=n.previousSibling)if(n===t)return!0;return!1}function i(e){var t=e.target;o(l,t)?t.parentNode.insertBefore(l,t):t.nextSibling&&t.hasAttribute("draggable")&&t.parentNode.insertBefore(l,t.nextSibling.nextSibling)}function r(n){n.preventDefault(),l.classList.remove("dt-clone"),t.off("dragend",r),t.off("dragenter",i),a!==l.nextSibling&&e.onSortableSort({event:n,columnId:angular.element(l).attr("data-id")})}function s(n){return!!e.isSortable&&(n=n.originalEvent||n,l=n.target,a=l.nextSibling,l.classList.add("dt-clone"),n.dataTransfer.effectAllowed="move",n.dataTransfer.setData("Text",l.textContent),t.on("dragenter",i),void t.on("dragend",r))}var l,a;t[0];t.on("dragstart",s),e.$on("$destroy",function(){t.off("dragstart",s)})}}}function y(e,t){return{restrict:"A",scope:{isResizable:"=resizable",minWidth:"=",maxWidth:"=",onResize:"&"},link:function(n,o,i){function r(e){e=e.originalEvent||e;var t=c[0].clientWidth,o=e.movementX||e.mozMovementX||e.screenX-l,i=t+(o||0);l=e.screenX,(!n.minWidth||i>=n.minWidth)&&(!n.maxWidth||i<=n.maxWidth)&&c.css({width:i+"px"})}function s(){n.onResize&&t(function(){var e=c[0].clientWidth;e'),c=o.parent();a.on("mousedown",function(t){return!!o[0].classList.contains("resizable")&&(t.stopPropagation(),t.preventDefault(),e.on("mousemove",r),void e.on("mouseup",s))}),o.append(a)}}}function b(e,t,n){var o,i,r,s=null,l=0;n||(n={});var a=function(){l=n.leading===!1?0:new Date,s=null,r=e.apply(o,i)};return function(){var c=new Date;l||n.leading!==!1||(l=c);var u=t-(c-l);return o=this,i=arguments,u<=0?(clearTimeout(s),s=null,l=c,r=e.apply(o,i)):s||n.trailing===!1||(s=setTimeout(a,u)),r}}function C(){var e=document.createElement("div");e.style.visibility="hidden",e.style.width="100px",e.style.msOverflowStyle="scrollbar",document.body.appendChild(e);var t=e.offsetWidth;e.style.overflow="scroll";var n=document.createElement("div");n.style.width="100%",e.appendChild(n);var o=n.offsetWidth;return e.parentNode.removeChild(e),t-o}function x(){var e=((new Date).getTime()/1e3|0).toString(16);return e+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(16*Math.random()|0).toString(16)}).toLowerCase()}function k(e,t,n){angular.forEach(e,function(e){e.forEach(function(e){e.canAutoResize?e.width=0:(t-=e.width,n-=e.flexGrow)})});var o={},i=t,r=function(){var t=i/n;i=0,angular.forEach(e,function(e){e.forEach(function(e,n){if(e.canAutoResize&&!o[n]){var r=e.width+e.flexGrow*t;void 0!==e.minWidth&&r-1?e.slice(n,e.length).filter(function(e){return e.canAutoResize}):e.filter(function(e){return e.canAutoResize});e.forEach(function(e){o+=e.canAutoResize?e.$$oldWidth||e.width:e.width});var r=t-o,s=r/i.length,l=o>t;i.forEach(function(e){if(l)e.width=e.$$oldWidth||e.width;else{e.$$oldWidth||(e.$$oldWidth=e.width);var t=e.$$oldWidth+s;e.minWith&&te.maxWidth?e.width=e.maxWidth:e.width=t}})}function z(e,t){return{left:T(e.left),center:T(e.center),right:T(e.right),total:T(t)}}function W(e,t,n){return{restrict:"E",replace:!0,controller:ne,scope:!0,bindToController:{options:"=",rows:"=",selected:"=?",expanded:"=?",onSelect:"&",onSort:"&",onTreeToggle:"&",onPage:"&",onRowClick:"&",onRowDblClick:"&",onColumnResize:"&"},controllerAs:"dt",template:function(e){var t=e[0].getElementsByTagName("column"),n=x();return Q.saveColumns(n,t),'
\n \n \n \n \n \n \n
'},compile:function(o,i){return{pre:function(o,i,r,s){function l(){var e=i[0].getBoundingClientRect();if(s.options.internal.innerWidth=Math.floor(e.width),s.options.scrollbarV){var t=e.height;s.options.headerHeight&&(t-=s.options.headerHeight),s.options.footerHeight&&(t-=s.options.footerHeight),s.options.internal.bodyHeight=t,s.calculatePageSize()}s.adjustColumns()}Q.buildColumns(o,n);var a=i.attr("data-column-id"),c=Q.columns[a];c&&(s.options.columns=c),s.transposeColumnDefaults(),s.options.internal.scrollBarWidth=C(),e.addEventListener("resize",b(function(){t(l)}));var u=function d(){var e=i[0].getBoundingClientRect(),n=e.width&&e.height;n?l():t(d,100)};u(),i.addClass("dt-loaded"),o.$on("$destroy",function(){angular.element(e).off("resize")})}}}}}W.$inject=["$window","$timeout","$parse"],y.$inject=["$document","$timeout"],w.$inject=["$timeout"],v.$inject=["$timeout"],m.$inject=["$compile"],g.$inject=["$timeout"],p.$inject=["$timeout","$rootScope"],r.$inject=["$rootScope","$compile","$log","$timeout"],Object.defineProperty(e,"__esModule",{value:!0});var E=function(){function e(e,t){for(var n=0;n0&&e<=this.totalPages&&(this.page=e,this.onPage({page:e}))}},{key:"prevPage",value:function(){this.page>1&&this.selectPage(--this.page)}},{key:"nextPage",value:function(){this.selectPage(++this.page)}},{key:"canPrevious",value:function(){return this.page>1}},{key:"canNext",value:function(){return this.page-1?this.selected.splice(i,1):(this.options.multiSelectOnShift&&1===this.selected.length&&this.selected.splice(0,1),this.selected.push(n),this.body.onSelect({rows:[n]}))}this.prevIndex=t}else this.selected=n,this.body.onSelect({rows:[n]})}},{key:"selectRowsBetween",value:function(e){for(var t=e=this.prevIndex&&o<=e,l=o<=this.prevIndex&&o>=e,a={};if(a=t?{start:e,end:this.prevIndex-e}:{start:this.prevIndex,end:e+1},t&&l||!t&&s){var c=this.selected.indexOf(r);if(t&&c>-1){this.selected.splice(c,1);continue}o>=a.start&&oo)&&(e.getRows(),t=!0)}),this.$scope.$watch("body.options.paging.count",function(t){e.count=t,e.updatePage()}),this.$scope.$watch("body.options.paging.offset",function(t){e.options.paging.size&&e.onPage({offset:t,size:e.options.paging.size})})}}},{key:"rowsUpdated",value:function(e,n){if(e)if(this.options.paging.externalPaging||(this.options.paging.count=e.length),this.count=this.options.paging.count,(this.treeColumn||this.groupColumn)&&this.buildRowsByGroup(),this.options.scrollbarV){var o=e&&n&&(e.length===n.length||e.lengthn?Math.ceil(o):e,isNaN(o)||(this.options.paging.offset=o)}},{key:"calculateDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.treeColumn?this.treeColumn.relationProp:this.groupColumn.prop,o=this.treeColumn.prop;if(!e[n])return t;if(e.$$depth)return e.$$depth+t;var i=this.index[e[n]];if(i)return t+=1,this.calculateDepth(i,t);for(var r=0,s=this.rows.length;r-1:this.selected===e),t}},{key:"buildTree",value:function(){function e(t,o,i){t.forEach(function(t){var r=t[n.treeColumn.relationProp],s=t[n.treeColumn.prop],l=n.rowsByGroup[s],a=n.expanded[s];(i>0||!r)&&(o.push(t),l&&l.length>0&&a&&e(l,o,i+1))})}var t=[],n=this;return e(this.rows,t,0),t}},{key:"getRows",value:function(e){if((this.treeColumn||this.groupColumn)&&!this.rowsByGroup)return!1;var t;this.treeColumn?(t=this.treeTemp||[],!e&&this.treeTemp||(this.treeTemp=t=this.buildTree(),this.count=t.length,this.tempRows.splice(0,this.tempRows.length))):this.groupColumn?(t=this.groupsTemp||[],!e&&this.groupsTemp||(this.groupsTemp=t=this.buildGroups(),this.count=t.length)):(t=this.rows,e===!0&&this.tempRows.splice(0,this.tempRows.length));var n=0,o=this.getFirstLastIndexes(),i=o.first;for(this.tempRows.splice(0,o.last-o.first);it.sortPriority)return 1;if(e.sortPriority-1){var e=this.options.columns[n];e.width=t,e.canAutoResize=!1,this.adjustColumns(n),this.calculateColumns()}this.onColumnResize&&this.onColumnResize({column:e,width:t})}},{key:"onSelected",value:function(e){this.onSelect({rows:e})}},{key:"onRowClicked",value:function(e){this.onRowClick({row:e})}},{key:"onRowDblClicked",value:function(e){this.onRowDblClick({row:e})}}]),e}(),oe=angular.module("data-table",[]).directive("dtable",W).directive("resizable",y).directive("sortable",w).directive("dtHeader",v).directive("dtHeaderCell",m).directive("dtBody",g).directive("dtScroller",p).directive("dtSeletion",h).directive("dtRow",d).directive("dtGroupRow",c).directive("dtCell",r).directive("dtFooter",i).directive("dtPager",o);e["default"]=oe}); \ No newline at end of file