diff --git a/release/dataTable.cjs.js b/release/dataTable.cjs.js index 88d7e58..999f2ed 100644 --- a/release/dataTable.cjs.js +++ b/release/dataTable.cjs.js @@ -718,49 +718,62 @@ var DataTableController = function () { * @param {scope} * @param {filter} */ - /*@ngInject*/ - DataTableController.$inject = ["$scope", "$filter", "$log", "$transclude"]; - function DataTableController($scope, $filter, $log, $transclude) { - var _this = this; + /* @ngInject */ + DataTableController.$inject = ["$scope", "$filter"]; + function DataTableController($scope, $filter) { _classCallCheck(this, DataTableController); _extends(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); - this.defaults(); + // if preAssignBindingsEnabled === true and no $onInit + if (_angular2.default.version.major === 1 && _angular2.default.version.minor < 5) { + this.init(); + } + } - // set scope to the parent - this.options.$outer = $scope.$parent; + _createClass(DataTableController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this = this; - $scope.$watch('dt.options.columns', function (newVal, oldVal) { - _this.transposeColumnDefaults(); + this.defaults(); - if (newVal.length !== oldVal.length) { - _this.adjustColumns(); - } + // set scope to the parent + this.options.$outer = this.$scope.$parent; - _this.calculateColumns(); - }, true); + this.$scope.$watch('dt.options.columns', function (newVal, oldVal) { + _this.transposeColumnDefaults(); - // default sort - var watch = $scope.$watch('dt.rows', function (newVal) { - if (newVal) { - watch(); - _this.onSorted(); - } - }); - } + if (newVal.length !== oldVal.length) { + _this.adjustColumns(); + } - /** - * Creates and extends default options for the grid control - */ + _this.calculateColumns(); + }, true); + // default sort + var watch = this.$scope.$watch('dt.rows', function (newVal) { + if (newVal) { + watch(); + _this.onSorted(); + } + }); + } - _createClass(DataTableController, [{ + /** + * Creates and extends default options for the grid control + */ + + }, { key: 'defaults', value: function defaults() { var _this2 = this; @@ -1527,23 +1540,38 @@ var HeaderCellController = function () { function HeaderCellController($scope) { _classCallCheck(this, HeaderCellController); - this.$scope = $scope; + _extends(this, { + $scope: $scope + }); - if (this.$scope.$parent.$parent.$parent.$parent.dt) { - this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } + } - if (this.column.headerCheckbox) { - this.column.headerCheckboxCallback = this.rowSelected; + _createClass(HeaderCellController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); } - } - /** - * Calculates the styles for the header cell directive - * @return {styles} - */ + }, { + key: 'init', + value: function init() { + if (this.column.headerCheckbox) { + this.column.headerCheckboxCallback = this.rowSelected; + } + if (this.$scope.$parent.$parent.$parent.$parent.dt) { + this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + } + } + /** + * Calculates the styles for the header cell directive + * @return {styles} + */ - _createClass(HeaderCellController, [{ + }, { key: 'styles', value: function styles() { return { @@ -1689,54 +1717,67 @@ function HeaderCellDirective($compile) { } var BodyController = function () { - /** - * A tale body controller + * A body controller * @param {$scope} * @return {BodyController} */ + /*@ngInject*/ BodyController.$inject = ["$scope"]; function BodyController($scope) { - var _this4 = this; - _classCallCheck(this, BodyController); - this.$scope = $scope; + _extends(this, { + $scope: $scope + }); this.tempRows = []; this.watchListeners = []; - if (this.options) { + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + _createClass(BodyController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this4 = this; + this.setTreeAndGroupColumns(); this.setConditionalWatches(); - } - $scope.$watch('body.options.columns', function (newVal, oldVal) { - if (newVal) { - var origTreeColumn = _this4.treeColumn, - origGroupColumn = _this4.groupColumn; + this.$scope.$watch('body.options.columns', function (newVal, oldVal) { + if (newVal) { + var origTreeColumn = _this4.treeColumn, + origGroupColumn = _this4.groupColumn; - _this4.setTreeAndGroupColumns(); + _this4.setTreeAndGroupColumns(); - _this4.setConditionalWatches(); + _this4.setConditionalWatches(); - if (_this4.treeColumn && origGroupColumn !== _this4.treeColumn || _this4.groupColumn && origGroupColumn !== _this4.groupColumn) { - _this4.rowsUpdated(_this4.rows); + if (_this4.treeColumn && origGroupColumn !== _this4.treeColumn || _this4.groupColumn && origGroupColumn !== _this4.groupColumn) { + _this4.rowsUpdated(_this4.rows); - if (_this4.treeColumn) { - _this4.refreshTree(); - } else if (_this4.groupColumn) { - _this4.refreshGroups(); + if (_this4.treeColumn) { + _this4.refreshTree(); + } else if (_this4.groupColumn) { + _this4.refreshGroups(); + } } } - } - }, true); - - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); - } + }, true); - _createClass(BodyController, [{ + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + } + }, { key: 'setTreeAndGroupColumns', value: function setTreeAndGroupColumns() { this.treeColumn = this.options.columns.find(function (c) { @@ -2009,8 +2050,6 @@ var BodyController = function () { var temp = []; angular.forEach(this.rowsByGroup, function (v, k) { - console.log('buildGroups', _this6.rowsByGroup, v, k); - temp.push({ name: k, group: true @@ -2347,7 +2386,7 @@ function BodyDirective($timeout) { onRowDblClick: '&' }, scope: true, - template: '\n
\n
\n
\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n
\n
' + template: '\n \n
\n
\n
\n \n
\n \n \n \n \n \n \n
\n
\n
\n
\n
' }; } @@ -3012,26 +3051,45 @@ var FooterController = function () { * @param {scope} * @return {[type]} */ + /*@ngInject*/ FooterController.$inject = ["$scope"]; function FooterController($scope) { - var _this7 = this; - _classCallCheck(this, FooterController); - this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', function (newVal) { - _this7.offsetChanged(newVal); + _extends(this, { + $scope: $scope }); + + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } - /** - * The offset ( page ) changed externally, update the page - * @param {new offset} - */ + _createClass(FooterController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this7 = this; + this.page = this.paging.offset + 1; - _createClass(FooterController, [{ + this.$scope.$watch('footer.paging.offset', function (newVal) { + _this7.offsetChanged(newVal); + }); + } + + /** + * The offset ( page ) changed externally, update the page + * @param {new offset} + */ + + }, { key: 'offsetChanged', value: function offsetChanged(newVal) { this.page = newVal + 1; @@ -3075,41 +3133,59 @@ var PagerController = function () { /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ PagerController.$inject = ["$scope"]; function PagerController($scope) { - var _this8 = this; - _classCallCheck(this, PagerController); - $scope.$watch('pager.count', function (newVal) { - _this8.calcTotalPages(_this8.size, _this8.count); - _this8.getPages(_this8.page || 1); + _extends(this, { + $scope: $scope }); - $scope.$watch('pager.size', function (newVal) { - _this8.calcTotalPages(_this8.size, _this8.count); - _this8.getPages(_this8.page || 1); - }); + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - $scope.$watch('pager.page', function (newVal) { - if (newVal !== 0 && newVal <= _this8.totalPages) { - _this8.getPages(newVal); - } - }); + _createClass(PagerController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this8 = this; - this.getPages(this.page || 1); - } + this.$scope.$watch('pager.count', function (newVal) { + _this8.calcTotalPages(_this8.size, _this8.count); + _this8.getPages(_this8.page || 1); + }); - /** - * Calculates the total number of pages given the count. - * @return {int} page count - */ + this.$scope.$watch('pager.size', function (newVal) { + _this8.calcTotalPages(_this8.size, _this8.count); + _this8.getPages(_this8.page || 1); + }); + this.$scope.$watch('pager.page', function (newVal) { + if (newVal !== 0 && newVal <= _this8.totalPages) { + _this8.getPages(newVal); + } + }); - _createClass(PagerController, [{ + this.getPages(this.page || 1); + } + + /** + * Calculates the total number of pages given the count. + * @return {int} page count + */ + + }, { key: 'calcTotalPages', value: function calcTotalPages(size, count) { var count = size < 1 ? 1 : Math.ceil(count / size); @@ -3118,7 +3194,7 @@ var PagerController = function () { /** * Select a page - * @param {int} num + * @param {int} num */ }, { @@ -3167,7 +3243,7 @@ var PagerController = function () { /** * Determines if the pager can go forward - * @return {boolean} + * @return {boolean} */ }, { @@ -3178,7 +3254,7 @@ var PagerController = function () { /** * Gets the page set given the current page - * @param {int} page + * @param {int} page */ }, { @@ -3584,8 +3660,8 @@ var popover = _angular2.default.module('dt.popover', []).service('PopoverRegistr var MenuController = function () { /*@ngInject*/ - MenuController.$inject = ["$scope", "$timeout"]; - function MenuController($scope, $timeout) { + MenuController.$inject = ["$scope"]; + function MenuController($scope) { _classCallCheck(this, MenuController); this.$scope = $scope; diff --git a/release/dataTable.es6.js b/release/dataTable.es6.js index e7c7d06..00d1802 100644 --- a/release/dataTable.es6.js +++ b/release/dataTable.es6.js @@ -667,20 +667,31 @@ class DataTableController { * @param {scope} * @param {filter} */ - /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){ + + /* @ngInject */ + constructor($scope, $filter) { Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); + // if preAssignBindingsEnabled === true and no $onInit + if (angular$1.version.major === 1 && angular$1.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){ @@ -691,8 +702,8 @@ class DataTableController { }, true); // default sort - var watch = $scope.$watch('dt.rows', (newVal) => { - if(newVal){ + var watch = this.$scope.$watch('dt.rows', (newVal) => { + if (newVal) { watch(); this.onSorted(); } @@ -1474,17 +1485,30 @@ function HeaderDirective($timeout){ }; } -class HeaderCellController{ - constructor($scope){ - this.$scope = $scope; +class HeaderCellController { + constructor($scope) { + Object.assign(this, { + $scope + }); - if (this.$scope.$parent.$parent.$parent.$parent.dt) { - this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } + } + $onInit() { + this.init(); + } + + init() { if (this.column.headerCheckbox) { this.column.headerCheckboxCallback = this.rowSelected; } + + if (this.$scope.$parent.$parent.$parent.$parent.dt) { + this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + } } /** * Calculates the styles for the header cell directive @@ -1636,26 +1660,37 @@ function HeaderCellDirective($compile){ }; } -class BodyController{ - +class BodyController { /** - * A tale body controller + * A body controller * @param {$scope} * @return {BodyController} */ + /*@ngInject*/ - constructor($scope){ - this.$scope = $scope; + constructor($scope) { + Object.assign(this, { + $scope + }); this.tempRows = []; this.watchListeners = []; - if (this.options) { - this.setTreeAndGroupColumns(); - this.setConditionalWatches(); + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } + } - $scope.$watch('body.options.columns', (newVal, oldVal) => { + $onInit() { + this.init(); + } + + init() { + this.setTreeAndGroupColumns(); + this.setConditionalWatches(); + + this.$scope.$watch('body.options.columns', (newVal, oldVal) => { if (newVal) { const origTreeColumn = this.treeColumn, origGroupColumn = this.groupColumn; @@ -1677,7 +1712,7 @@ class BodyController{ } }, true); - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); } setTreeAndGroupColumns() { @@ -1930,8 +1965,6 @@ class BodyController{ var temp = []; angular.forEach(this.rowsByGroup, (v, k) => { - console.log('buildGroups', this.rowsByGroup, v, k); - temp.push({ name: k, group: true @@ -2225,9 +2258,9 @@ function BodyDirective($timeout){ }, scope: true, template: ` -
@@ -2237,7 +2270,7 @@ function BodyDirective($timeout){ -
-
@@ -2922,10 +2955,27 @@ class FooterController { * @param {scope} * @return {[type]} */ + /*@ngInject*/ - constructor($scope){ + constructor($scope) { + Object.assign(this, { + $scope + }); + + // if preAssignBindingsEnabled === true and no $onInit + 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); }); } @@ -2980,26 +3030,42 @@ class PagerController { /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ constructor($scope){ - $scope.$watch('pager.count', (newVal) => { + Object.assign(this, { + $scope + }); + + // if preAssignBindingsEnabled === true and no $onInit + 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); } @@ -3014,7 +3080,7 @@ class PagerController { /** * Select a page - * @param {int} num + * @param {int} num */ selectPage(num){ if (num > 0 && num <= this.totalPages) { @@ -3051,7 +3117,7 @@ class PagerController { /** * Determines if the pager can go forward - * @return {boolean} + * @return {boolean} */ canNext(){ return this.page < this.totalPages; @@ -3059,11 +3125,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; @@ -3488,10 +3554,10 @@ var popover = angular$1 .factory('PositionHelper', PositionHelper) .directive('popover', PopoverDirective); -class MenuController{ +class MenuController { /*@ngInject*/ - constructor($scope, $timeout){ + constructor($scope){ this.$scope = $scope; } @@ -3513,7 +3579,7 @@ class MenuController{ this.$scope.current.splice(idx, 1); } } - + } function MenuDirective(){ diff --git a/release/dataTable.js b/release/dataTable.js index fde4a1c..d046360 100644 --- a/release/dataTable.js +++ b/release/dataTable.js @@ -775,49 +775,57 @@ * @param {scope} * @param {filter} */ - /*@ngInject*/ - DataTableController.$inject = ["$scope", "$filter", "$log", "$transclude"]; - function DataTableController($scope, $filter, $log, $transclude) { - var _this = this; + /* @ngInject */ + DataTableController.$inject = ["$scope", "$filter"]; + function DataTableController($scope, $filter) { _classCallCheck(this, DataTableController); _extends(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); - this.defaults(); - - // set scope to the parent - this.options.$outer = $scope.$parent; + // if preAssignBindingsEnabled === true and no $onInit + if (_angular2.default.version.major === 1 && _angular2.default.version.minor < 5) { + this.init(); + } + } - $scope.$watch('dt.options.columns', function (newVal, oldVal) { - _this.transposeColumnDefaults(); + _createClass(DataTableController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this = this; - if (newVal.length !== oldVal.length) { - _this.adjustColumns(); - } + this.defaults(); - _this.calculateColumns(); - }, true); + // set scope to the parent + this.options.$outer = this.$scope.$parent; - // default sort - var watch = $scope.$watch('dt.rows', function (newVal) { - if (newVal) { - watch(); - _this.onSorted(); - } - }); - } + this.$scope.$watch('dt.options.columns', function (newVal, oldVal) { + _this.transposeColumnDefaults(); - /** - * Creates and extends default options for the grid control - */ + if (newVal.length !== oldVal.length) { + _this.adjustColumns(); + } + _this.calculateColumns(); + }, true); - _createClass(DataTableController, [{ + // default sort + var watch = this.$scope.$watch('dt.rows', function (newVal) { + if (newVal) { + watch(); + _this.onSorted(); + } + }); + } + }, { key: 'defaults', value: function defaults() { var _this2 = this; @@ -1451,23 +1459,33 @@ function HeaderCellController($scope) { _classCallCheck(this, HeaderCellController); - this.$scope = $scope; - - if (this.$scope.$parent.$parent.$parent.$parent.dt) { - this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; - } + _extends(this, { + $scope: $scope + }); - if (this.column.headerCheckbox) { - this.column.headerCheckboxCallback = this.rowSelected; + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } } - /** - * Calculates the styles for the header cell directive - * @return {styles} - */ - _createClass(HeaderCellController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + if (this.column.headerCheckbox) { + this.column.headerCheckboxCallback = this.rowSelected; + } + + if (this.$scope.$parent.$parent.$parent.$parent.dt) { + this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + } + } + }, { key: 'styles', value: function styles() { return { @@ -1586,54 +1604,67 @@ } var BodyController = function () { - /** - * A tale body controller + * A body controller * @param {$scope} * @return {BodyController} */ + /*@ngInject*/ BodyController.$inject = ["$scope"]; function BodyController($scope) { - var _this4 = this; - _classCallCheck(this, BodyController); - this.$scope = $scope; + _extends(this, { + $scope: $scope + }); this.tempRows = []; this.watchListeners = []; - if (this.options) { + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } + + _createClass(BodyController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this4 = this; + this.setTreeAndGroupColumns(); this.setConditionalWatches(); - } - $scope.$watch('body.options.columns', function (newVal, oldVal) { - if (newVal) { - var origTreeColumn = _this4.treeColumn, - origGroupColumn = _this4.groupColumn; + this.$scope.$watch('body.options.columns', function (newVal, oldVal) { + if (newVal) { + var origTreeColumn = _this4.treeColumn, + origGroupColumn = _this4.groupColumn; - _this4.setTreeAndGroupColumns(); + _this4.setTreeAndGroupColumns(); - _this4.setConditionalWatches(); + _this4.setConditionalWatches(); - if (_this4.treeColumn && origGroupColumn !== _this4.treeColumn || _this4.groupColumn && origGroupColumn !== _this4.groupColumn) { - _this4.rowsUpdated(_this4.rows); + if (_this4.treeColumn && origGroupColumn !== _this4.treeColumn || _this4.groupColumn && origGroupColumn !== _this4.groupColumn) { + _this4.rowsUpdated(_this4.rows); - if (_this4.treeColumn) { - _this4.refreshTree(); - } else if (_this4.groupColumn) { - _this4.refreshGroups(); + if (_this4.treeColumn) { + _this4.refreshTree(); + } else if (_this4.groupColumn) { + _this4.refreshGroups(); + } } } - } - }, true); - - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); - } + }, true); - _createClass(BodyController, [{ + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + } + }, { key: 'setTreeAndGroupColumns', value: function setTreeAndGroupColumns() { this.treeColumn = this.options.columns.find(function (c) { @@ -1864,8 +1895,6 @@ var temp = []; angular.forEach(this.rowsByGroup, function (v, k) { - console.log('buildGroups', _this6.rowsByGroup, v, k); - temp.push({ name: k, group: true @@ -2122,7 +2151,7 @@ onRowDblClick: '&' }, scope: true, - template: '\n
\n
\n
\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n
\n
' + template: '\n \n
\n
\n
\n
\n
\n \n \n \n \n \n \n
\n
\n
\n
\n
' }; } @@ -2682,26 +2711,39 @@ * @param {scope} * @return {[type]} */ + /*@ngInject*/ FooterController.$inject = ["$scope"]; function FooterController($scope) { - var _this7 = this; - _classCallCheck(this, FooterController); - this.page = this.paging.offset + 1; - $scope.$watch('footer.paging.offset', function (newVal) { - _this7.offsetChanged(newVal); + _extends(this, { + $scope: $scope }); + + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } } - /** - * The offset ( page ) changed externally, update the page - * @param {new offset} - */ + _createClass(FooterController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this7 = this; + this.page = this.paging.offset + 1; - _createClass(FooterController, [{ + this.$scope.$watch('footer.paging.offset', function (newVal) { + _this7.offsetChanged(newVal); + }); + } + }, { key: 'offsetChanged', value: function offsetChanged(newVal) { this.page = newVal + 1; @@ -2739,41 +2781,53 @@ /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ PagerController.$inject = ["$scope"]; function PagerController($scope) { - var _this8 = this; - _classCallCheck(this, PagerController); - $scope.$watch('pager.count', function (newVal) { - _this8.calcTotalPages(_this8.size, _this8.count); - _this8.getPages(_this8.page || 1); + _extends(this, { + $scope: $scope }); - $scope.$watch('pager.size', function (newVal) { - _this8.calcTotalPages(_this8.size, _this8.count); - _this8.getPages(_this8.page || 1); - }); + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); + } + } - $scope.$watch('pager.page', function (newVal) { - if (newVal !== 0 && newVal <= _this8.totalPages) { - _this8.getPages(newVal); - } - }); + _createClass(PagerController, [{ + key: '$onInit', + value: function $onInit() { + this.init(); + } + }, { + key: 'init', + value: function init() { + var _this8 = this; - this.getPages(this.page || 1); - } + this.$scope.$watch('pager.count', function (newVal) { + _this8.calcTotalPages(_this8.size, _this8.count); + _this8.getPages(_this8.page || 1); + }); - /** - * Calculates the total number of pages given the count. - * @return {int} page count - */ + this.$scope.$watch('pager.size', function (newVal) { + _this8.calcTotalPages(_this8.size, _this8.count); + _this8.getPages(_this8.page || 1); + }); + this.$scope.$watch('pager.page', function (newVal) { + if (newVal !== 0 && newVal <= _this8.totalPages) { + _this8.getPages(newVal); + } + }); - _createClass(PagerController, [{ + this.getPages(this.page || 1); + } + }, { key: 'calcTotalPages', value: function calcTotalPages(size, count) { var count = size < 1 ? 1 : Math.ceil(count / size); @@ -3214,8 +3268,8 @@ var MenuController = function () { /*@ngInject*/ - MenuController.$inject = ["$scope", "$timeout"]; - function MenuController($scope, $timeout) { + MenuController.$inject = ["$scope"]; + function MenuController($scope) { _classCallCheck(this, MenuController); this.$scope = $scope; diff --git a/release/dataTable.min.js b/release/dataTable.min.js index 1aed9af..26cba65 100644 --- a/release/dataTable.min.js +++ b/release/dataTable.min.js @@ -4,5 +4,5 @@ * @link http://swimlane.com/ * @license MIT */ -!function(e,t){if("function"==typeof define&&define.amd)define("DataTable",["exports","angular"],t);else if("undefined"!=typeof exports)t(exports,require("angular"));else{var n={exports:{}};t(n.exports,e.angular),e.DataTable=n.exports}}(this,function(e,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t=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 s(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:L.default.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 l(){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 a(e){for(var t={left:[],center:[],right:[]},n=0,o=e.length;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 y(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 b(e,t,n){return{restrict:"E",replace:!0,controller:U,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=l();return X.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()}X.buildColumns(o,n);var a=i.attr("data-column-id"),c=X.columns[a];c&&(s.options.columns=c),s.transposeColumnDefaults(),s.options.internal.scrollBarWidth=h(),e.addEventListener("resize",y(function(){t(l)}));var u=function e(){var n=i[0].getBoundingClientRect(),o=n.width&&n.height;o?l():t(e,100)};u(),i.addClass("dt-loaded"),o.$on("$destroy",function(){L.default.element(e).off("resize")})}}}}}function C(e){var t=d(e);return _[t]||(void 0!==K[Y.css+e]?_[t]=Y.css+e:void 0!==K[e]&&(_[t]=e)),_[t]}function x(e,t,n){Q?!ne&&ee?(e[Z]="translate3d("+t+"px, "+n+"px, 0)",e[J]="hidden"):e[d(Z)]="translate("+t+"px, "+n+"px)":(e.top=n+"px",e.left=t+"px")}function k(e){return{restrict:"E",controller:oe,controllerAs:"header",scope:!0,bindToController:{options:"=",columns:"=",columnWidths:"=",selectedRows:"=?",allRows:"=",onSort:"&",onResize:"&"},template:'\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=L.default.element(t.currentTarget),l=-1;L.default.forEach(s.children(),function(e,t){n===L.default.element(e).attr("data-id")&&(l=t)}),e(function(){L.default.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 $(e){return{restrict:"E",controller:ie,controllerAs:"hcell",scope:!0,bindToController:{options:"=",column:"=",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=L.default.element(""+i.column.headerTemplate.trim()+"");L.default.element(r).append(e(l)(s))}else if(i.column.headerRenderer){var a=L.default.element(i.column.headerRenderer(n));L.default.element(r).append(e(a)(s)[0])}else{var c=i.column.name;void 0!==c&&null!==c||(c=""),r.textContent=c}}}}}}function T(e){return{restrict:"E",controller:re,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 R(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||(q(i),s=!0)}var s=!1,l=0,a=0,c=t.parent();o.options.internal.styleTranslator=new se(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 P(){return{controller:ae,restrict:"A",require:"^dtBody",controllerAs:"selCtrl"}}function S(){return{restrict:"E",controller:ce,controllerAs:"rowCtrl",scope:!0,bindToController:{row:"=",columns:"=",columnWidths:"=",expanded:"=",selected:"=",hasChildren:"=",options:"=",onCheckboxChange:"&",onTreeToggle:"&"},link:function(e,t,n,o){o.row&&x(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 z(){return{restrict:"E",controller:ue,controllerAs:"group",bindToController:{row:"=",onGroupToggle:"&",expanded:"=",options:"="},scope:!0,replace:!0,template:'\n
\n \n \n \n \n
',link:function(e,t,n,o){x(t[0].style,0,o.row.$$index*o.options.rowHeight),o.options.internal.styleTranslator.register(e.$index,t)}}}function E(e,t,n,o){return{restrict:"E",controller:de,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=L.default.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=L.default.element(""+i.column.template.trim()+"");l.append(t(e)(s))}else if(i.column.cellRenderer){l.empty();var e=L.default.element(i.column.cellRenderer(s,l));l.append(t(e)(s))}else l[0].innerHTML=i.getValue()},!0)}}}}}function A(){return{restrict:"E",controller:he,controllerAs:"footer",scope:!0,bindToController:{paging:"=",onPage:"&"},template:'',replace:!0}}function W(){return{restrict:"E",controller:pe,controllerAs:"pager",scope:!0,bindToController:{page:"=",size:"=",count:"=",onPage:"&"},template:'
\n
    \n
  • \n \n
  • \n
  • \n \n
  • \n
  • \n {{pg.text}}\n
  • \n
  • \n \n
  • \n
  • \n \n
  • \n
\n
',replace:!0}}function G(e,t,n,o,i,r,s){function l(e,t){return e?L.default.isString(e)&&t?e:n.get(e)||$http.get(e,{cache:!0}):""}function a(e){if(e&&0!==e.length){var t=e.toString().toLowerCase();e="true"==t}else e=!1;return e}return{restrict:"A",scope:!0,replace:!1,link:function(n,c,u){function d(){n.exitTimeout=t(p,500)}function h(){t.cancel(n.exitTimeout);var r=document.getElementById("#"+n.popoverId);n.popover&&r||(n.options.group&&i.removeGroup(n.options.group,n.popoverId),n.options.text&&!n.options.template?(n.popover=L.default.element('
'),n.popover.html(n.options.text),L.default.element(document.body).append(n.popover),f(c,n.popover,n.options),i.add(n.popoverId,{element:c,popover:n.popover,group:n.options.group})):e.when(l(n.options.template,n.options.plain)).then(function(e){L.default.isString(e)||(e=e.data&&L.default.isString(e.data)?e.data:""),n.popover=L.default.element('
'),n.popover.html(e),o(n.popover)(n),L.default.element(document.body).append(n.popover),f(c,n.popover,n.options),n.popover.off("mouseleave",d),n.popover.on("mouseleave",d),n.popover.on("mouseenter",function(){t.cancel(n.exitTimeout)}),i.add(n.popoverId,{element:c,popover:n.popover,group:n.options.group})}))}function p(){n.popover&&n.popover.remove(),n.popover=void 0,i.remove(n.popoverId)}function f(e,o,i){t(function(){function t(){return r.calculateVerticalAlignment(u,d,i.alignment)}function l(){return r.calculateHorizontalAlignment(u,d,i.alignment)}var a,c,u=e[0].getBoundingClientRect(),d=o[0].getBoundingClientRect();i.placement===fe.RIGHT&&(c=u.left+u.width+i.spacing,a=t()),i.placement===fe.LEFT&&(c=u.left-d.width-i.spacing,a=t()),i.placement===fe.TOP&&(a=u.top-d.height-i.spacing,c=l()),i.placement===fe.BOTTOM&&(a=u.top+u.height+i.spacing,c=l()),o.css({top:a+"px",left:c+"px"}),n.options.showCaret&&g(n.popover,u,d),s.addClass(n.popover,"popover-animation")},50)}function g(e,t,o){function i(){return r.calculateVerticalCaret(t,o,u,n.options.alignment)}function s(){return r.calculateHorizontalCaret(t,o,u,n.options.alignment)}var l=L.default.element('');e.append(l);var a,c,u=l[0].getBoundingClientRect();n.options.placement===fe.RIGHT&&(a=-6,c=i()),n.options.placement===fe.LEFT&&(a=o.width-2,c=i()),n.options.placement===fe.TOP&&(c=o.height-5,a=s()),n.options.placement===fe.BOTTOM&&(c=-8,a=s()),l.css({top:c+"px",left:a+"px"})}n.popover=null,n.popoverId=Date.now(),n.options={text:u.popoverText,template:u.popoverTemplate,plain:a(u.popoverPlain||!1),placement:u.popoverPlacement||"right",alignment:u.popoverAlignment||"center",group:u.popoverGroup,spacing:parseInt(u.popoverSpacing)||0,showCaret:a(u.popoverPlain||!1)},c.off("mouseenter",h),c.on("mouseenter",h),c.off("mouseleave",d),c.on("mouseleave",d)}}}function B(e){var t={};this.add=function(e,n){t[e]=n},this.find=function(e){t[e]},this.remove=function(e){delete t[e]},this.removeGroup=function(n,o){angular.forEach(t,function(i,r){r!==o&&i.group&&i.group===n&&e.removeClass(i.popover,"sw-popover-animate").then(function(){i.popover.remove(),delete t[r]})})}}function H(){return{calculateVerticalAlignment:function(e,t,n){switch(n){case fe.TOP:return e.top;case fe.BOTTOM:return e.top+e.height-t.height;case fe.CENTER:return e.top+e.height/2-t.height/2;default:return console.log("calculateVerticalAlignment issue",this)}},calculateVerticalCaret:function(e,t,n,o){switch(o){case fe.TOP:return e.height/2-n.height/2-1;case fe.BOTTOM:return t.height-e.height/2-n.height/2-1;case fe.CENTER:return t.height/2-n.height/2-1;default:return console.log("calculateVerticalCaret issue",this)}},calculateHorizontalCaret:function(e,t,n,o){switch(o){case fe.LEFT:return e.width/2-n.height/2-1;case fe.RIGHT:return t.width-e.width/2-n.height/2-1;case fe.CENTER:return t.width/2-n.height/2-1;default:return console.log("calculateHorizontalCaret issue",this)}},calculateHorizontalAlignment:function(e,t,n){switch(n){case fe.LEFT:return e.left;case fe.RIGHT:return e.left+e.width-t.width;case fe.CENTER:return e.left+e.width/2-t.width/2;default:return console.log("calculateHorizontalAlignment issue",this)}}}}function M(){return{restrict:"E",controller:"MenuController",controllerAs:"dtm",scope:{current:"=",available:"="},template:''}}function O(e,t){return{restrict:"C",controller:"DropdownController",link:function(n,o,i){function r(e){o[0].contains(e.target)||t(function(){n.open=!1,l()})}function s(e){27===e.which&&t(function(){n.open=!1,l()})}function l(){e.unbind("click",r),e.unbind("keydown",s)}n.$watch("open",function(t){t&&(e.bind("click",r),e.bind("keydown",s))})}}}function D(e){return{restrict:"C",controller:"DropdownController",require:"?^dropdown",link:function(t,n,o,i){function r(n){n.preventDefault(),e(function(){i.toggle(t)})}function s(){n.unbind("click",r)}n.bind("click",r),t.$on("$destroy",s)}}}function I(e){return{restrict:"C",require:"?^dropdown",link:function(t,n,o,i){t.$watch("open",function(){e[t.open?"addClass":"removeClass"](n,"ddm-open")})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.dtMenu=e.dtPopover=void 0;var L=n(t),N=Object.assign||function(e){for(var t=1;t>>0,i=arguments[1],r=0;r>>0,i=arguments[1],r=0;rt.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}(),X={columns:{},dTables:{},saveColumns:function(e,t){if(t&&t.length){var n=[].slice.call(t);this.dTables[e]=n}},buildColumns:function(e,t){var n=this;L.default.forEach(this.dTables,function(o,i){n.columns[i]=[],L.default.forEach(o,function(o){var r={},s=!0;L.default.forEach(o.attributes,function(n){var o=d(n.name);switch(o){case"class":r.className=n.value;break;case"name":case"prop":r[o]=n.value;break;case"headerRenderer":case"cellRenderer":case"cellDataGetter":r[o]=t(n.value);break;case"visible":s=t(n.value)(e);break;default:r[o]=t(n.value)(e)}});var l=o.getElementsByTagName("column-header");l.length&&(r.headerTemplate=l[0].innerHTML,o.removeChild(l[0])),""!==o.innerHTML&&(r.template=o.innerHTML),s&&n.columns[i].push(r)})}),this.dTables={}}},_={},K=document.createElement("div").style,Y=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)}}(),Z=C("transform"),J=C("backfaceVisibility"),Q=!!C("transform"),ee=!!C("perspective"),te=window.navigator.userAgent,ne=/Safari\//.test(te)&&!/Chrome\//.test(te),oe=function(){function e(){i(this,e)}return V(e,[{key:"styles",value:function(){return{width:this.options.internal.innerWidth+"px",height:this.options.headerHeight+"px"}}},{key:"innerStyles",value:function(){return{width:this.columnWidths.total+"px"}}},{key:"onSorted",value:function(e){if("single"===this.options.sortType){var t=function(t){t!==e&&(t.sort=void 0)};this.columns.left.forEach(t),this.columns.center.forEach(t),this.columns.right.forEach(t)}this.onSort({column:e})}},{key:"stylesByGroup",value:function(e){var t={width:this.columnWidths[e]+"px"};if("center"===e)x(t,this.options.internal.offsetX*-1,0);else if("right"===e){var n=(this.columnWidths.total-this.options.internal.innerWidth)*-1;x(t,n,0)}return t}},{key:"onResized",value:function(e,t){this.onResize({column:e,width:t})}}]),e}(),ie=function(){function e(t){i(this,e),this.$scope=t,this.$scope.$parent.$parent.$parent.$parent.dt&&(this.dt=this.$scope.$parent.$parent.$parent.$parent.dt),this.column.headerCheckbox&&(this.column.headerCheckboxCallback=this.rowSelected)}return V(e,[{key:"styles",value:function(){return{width:this.column.width+"px",minWidth:this.column.minWidth+"px",maxWidth:this.column.maxWidth+"px",height:this.column.height+"px"}}},{key:"cellClass",value:function(){var e={sortable:this.column.sortable,resizable:this.column.resizable};return this.column.headerClassName&&(e[this.column.headerClassName]=!0),e}},{key:"onSorted",value:function(){this.column.sortable&&(this.column.sort=p(this.sortType,this.column.sort),void 0===this.column.sort&&(this.column.sortPriority=void 0),this.onSort({column:this.column}))}},{key:"sortClass",value:function(){return{"sort-btn":!0,"sort-asc icon-down":"asc"===this.column.sort,"sort-desc icon-up":"desc"===this.column.sort}}},{key:"onResized",value:function(e,t){this.onResize({column:t,width:e})}},{key:"rowSelected",value:function(e){this.allRowsSelected=e.selected&&e.rows.length===e.selected.length}},{key:"checkboxChangeCallback",value:function(){return this.isAllRowsSelected=this.column.allRowsSelected?this.dt.selectAllRows():this.dt.deselectAllRows()}}]),e}(),re=function(){function e(t){var n=this;i(this,e),this.$scope=t,this.tempRows=[],this.watchListeners=[],this.options&&(this.setTreeAndGroupColumns(),this.setConditionalWatches()),t.$watch("body.options.columns",function(e,t){if(e){var o=(n.treeColumn,n.groupColumn);n.setTreeAndGroupColumns(),n.setConditionalWatches(),(n.treeColumn&&o!==n.treeColumn||n.groupColumn&&o!==n.groupColumn)&&(n.rowsUpdated(n.rows),n.treeColumn?n.refreshTree():n.groupColumn&&n.refreshGroups())}},!0),t.$watchCollection("body.rows",this.rowsUpdated.bind(this))}return e.$inject=["$scope"],V(e,[{key:"setTreeAndGroupColumns",value:function(){this.treeColumn=this.options.columns.find(function(e){return e.isTreeColumn}),this.treeColumn||(this.groupColumn=this.options.columns.find(function(e){return e.group}))}},{key:"setConditionalWatches",value:function(){var e=this;if(this.watchListeners.map(function(e){return e()}),this.options.scrollbarV||!this.options.scrollbarV&&this.options.paging.externalPaging){var t=!1;this.watchListeners.push(this.$scope.$watch("body.options.paging.size",function(n,o){(!t||n>o)&&(e.getRows(),t=!0)})),this.watchListeners.push(this.$scope.$watch("body.options.paging.count",function(t){e.count=t,e.updatePage()})),this.watchListeners.push(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,t){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 n=e&&t&&(e.length===t.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);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=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&&o0&&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}},{key:"onCheck",value:function(e){var t=this.getColumnIndex(e);t===-1?this.$scope.current.push(e):this.$scope.current.splice(t,1)}}]),e}(),ve=function(){function e(t){i(this,e),t.open=!1}return e.$inject=["$scope"],V(e,[{key:"toggle",value:function(e){e.open=!e.open}}]),e}(),we=L.default.module("dt.dropdown",[]).controller("DropdownController",ve).directive("dropdown",O).directive("dropdownToggle",D).directive("dropdownMenu",I),ye=L.default.module("dt.menu",[we.name]).controller("MenuController",me).directive("dtm",M),be=L.default.module("data-table",[]).directive("dtable",b).directive("resizable",r).directive("sortable",s).directive("dtHeader",k).directive("dtHeaderCell",$).directive("dtBody",T).directive("dtScroller",R).directive("dtSeletion",P).directive("dtRow",S).directive("dtGroupRow",z).directive("dtCell",E).directive("dtFooter",A).directive("dtPager",W);e.dtPopover=ge,e.dtMenu=ye,e.default=be}); \ No newline at end of file +!function(e,t){if("function"==typeof define&&define.amd)define("DataTable",["exports","angular"],t);else if("undefined"!=typeof exports)t(exports,require("angular"));else{var n={exports:{}};t(n.exports,e.angular),e.DataTable=n.exports}}(this,function(e,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t=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 s(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:L.default.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 l(){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 a(e){for(var t={left:[],center:[],right:[]},n=0,o=e.length;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 y(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 b(e,t,n){return{restrict:"E",replace:!0,controller:U,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=l();return X.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()}X.buildColumns(o,n);var a=i.attr("data-column-id"),c=X.columns[a];c&&(s.options.columns=c),s.transposeColumnDefaults(),s.options.internal.scrollBarWidth=h(),e.addEventListener("resize",y(function(){t(l)}));var u=function e(){var n=i[0].getBoundingClientRect(),o=n.width&&n.height;o?l():t(e,100)};u(),i.addClass("dt-loaded"),o.$on("$destroy",function(){L.default.element(e).off("resize")})}}}}}function C(e){var t=d(e);return _[t]||(void 0!==K[Y.css+e]?_[t]=Y.css+e:void 0!==K[e]&&(_[t]=e)),_[t]}function x(e,t,n){Q?!ne&&ee?(e[Z]="translate3d("+t+"px, "+n+"px, 0)",e[J]="hidden"):e[d(Z)]="translate("+t+"px, "+n+"px)":(e.top=n+"px",e.left=t+"px")}function k(e){return{restrict:"E",controller:oe,controllerAs:"header",scope:!0,bindToController:{options:"=",columns:"=",columnWidths:"=",selectedRows:"=?",allRows:"=",onSort:"&",onResize:"&"},template:'\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=L.default.element(t.currentTarget),l=-1;L.default.forEach(s.children(),function(e,t){n===L.default.element(e).attr("data-id")&&(l=t)}),e(function(){L.default.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 $(e){return{restrict:"E",controller:ie,controllerAs:"hcell",scope:!0,bindToController:{options:"=",column:"=",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=L.default.element(""+i.column.headerTemplate.trim()+"");L.default.element(r).append(e(l)(s))}else if(i.column.headerRenderer){var a=L.default.element(i.column.headerRenderer(n));L.default.element(r).append(e(a)(s)[0])}else{var c=i.column.name;void 0!==c&&null!==c||(c=""),r.textContent=c}}}}}}function T(e){return{restrict:"E",controller:re,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 R(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||(q(i),s=!0)}var s=!1,l=0,a=0,c=t.parent();o.options.internal.styleTranslator=new se(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 P(){return{controller:ae,restrict:"A",require:"^dtBody",controllerAs:"selCtrl"}}function S(){return{restrict:"E",controller:ce,controllerAs:"rowCtrl",scope:!0,bindToController:{row:"=",columns:"=",columnWidths:"=",expanded:"=",selected:"=",hasChildren:"=",options:"=",onCheckboxChange:"&",onTreeToggle:"&"},link:function(e,t,n,o){o.row&&x(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 z(){return{restrict:"E",controller:ue,controllerAs:"group",bindToController:{row:"=",onGroupToggle:"&",expanded:"=",options:"="},scope:!0,replace:!0,template:'\n
\n \n \n \n \n
',link:function(e,t,n,o){x(t[0].style,0,o.row.$$index*o.options.rowHeight),o.options.internal.styleTranslator.register(e.$index,t)}}}function E(e,t,n,o){return{restrict:"E",controller:de,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=L.default.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=L.default.element(""+i.column.template.trim()+"");l.append(t(e)(s))}else if(i.column.cellRenderer){l.empty();var e=L.default.element(i.column.cellRenderer(s,l));l.append(t(e)(s))}else l[0].innerHTML=i.getValue()},!0)}}}}}function A(){return{restrict:"E",controller:he,controllerAs:"footer",scope:!0,bindToController:{paging:"=",onPage:"&"},template:'',replace:!0}}function W(){return{restrict:"E",controller:pe,controllerAs:"pager",scope:!0,bindToController:{page:"=",size:"=",count:"=",onPage:"&"},template:'
\n \n
',replace:!0}}function B(e,t,n,o,i,r,s){function l(e,t){return e?L.default.isString(e)&&t?e:n.get(e)||$http.get(e,{cache:!0}):""}function a(e){if(e&&0!==e.length){var t=e.toString().toLowerCase();e="true"==t}else e=!1;return e}return{restrict:"A",scope:!0,replace:!1,link:function(n,c,u){function d(){n.exitTimeout=t(p,500)}function h(){t.cancel(n.exitTimeout);var r=document.getElementById("#"+n.popoverId);n.popover&&r||(n.options.group&&i.removeGroup(n.options.group,n.popoverId),n.options.text&&!n.options.template?(n.popover=L.default.element('
'),n.popover.html(n.options.text),L.default.element(document.body).append(n.popover),f(c,n.popover,n.options),i.add(n.popoverId,{element:c,popover:n.popover,group:n.options.group})):e.when(l(n.options.template,n.options.plain)).then(function(e){L.default.isString(e)||(e=e.data&&L.default.isString(e.data)?e.data:""),n.popover=L.default.element('
'),n.popover.html(e),o(n.popover)(n),L.default.element(document.body).append(n.popover),f(c,n.popover,n.options),n.popover.off("mouseleave",d),n.popover.on("mouseleave",d),n.popover.on("mouseenter",function(){t.cancel(n.exitTimeout)}),i.add(n.popoverId,{element:c,popover:n.popover,group:n.options.group})}))}function p(){n.popover&&n.popover.remove(),n.popover=void 0,i.remove(n.popoverId)}function f(e,o,i){t(function(){function t(){return r.calculateVerticalAlignment(u,d,i.alignment)}function l(){return r.calculateHorizontalAlignment(u,d,i.alignment)}var a,c,u=e[0].getBoundingClientRect(),d=o[0].getBoundingClientRect();i.placement===fe.RIGHT&&(c=u.left+u.width+i.spacing,a=t()),i.placement===fe.LEFT&&(c=u.left-d.width-i.spacing,a=t()),i.placement===fe.TOP&&(a=u.top-d.height-i.spacing,c=l()),i.placement===fe.BOTTOM&&(a=u.top+u.height+i.spacing,c=l()),o.css({top:a+"px",left:c+"px"}),n.options.showCaret&&g(n.popover,u,d),s.addClass(n.popover,"popover-animation")},50)}function g(e,t,o){function i(){return r.calculateVerticalCaret(t,o,u,n.options.alignment)}function s(){return r.calculateHorizontalCaret(t,o,u,n.options.alignment)}var l=L.default.element('');e.append(l);var a,c,u=l[0].getBoundingClientRect();n.options.placement===fe.RIGHT&&(a=-6,c=i()),n.options.placement===fe.LEFT&&(a=o.width-2,c=i()),n.options.placement===fe.TOP&&(c=o.height-5,a=s()),n.options.placement===fe.BOTTOM&&(c=-8,a=s()),l.css({top:c+"px",left:a+"px"})}n.popover=null,n.popoverId=Date.now(),n.options={text:u.popoverText,template:u.popoverTemplate,plain:a(u.popoverPlain||!1),placement:u.popoverPlacement||"right",alignment:u.popoverAlignment||"center",group:u.popoverGroup,spacing:parseInt(u.popoverSpacing)||0,showCaret:a(u.popoverPlain||!1)},c.off("mouseenter",h),c.on("mouseenter",h),c.off("mouseleave",d),c.on("mouseleave",d)}}}function G(e){var t={};this.add=function(e,n){t[e]=n},this.find=function(e){t[e]},this.remove=function(e){delete t[e]},this.removeGroup=function(n,o){angular.forEach(t,function(i,r){r!==o&&i.group&&i.group===n&&e.removeClass(i.popover,"sw-popover-animate").then(function(){i.popover.remove(),delete t[r]})})}}function H(){return{calculateVerticalAlignment:function(e,t,n){switch(n){case fe.TOP:return e.top;case fe.BOTTOM:return e.top+e.height-t.height;case fe.CENTER:return e.top+e.height/2-t.height/2;default:return console.log("calculateVerticalAlignment issue",this)}},calculateVerticalCaret:function(e,t,n,o){switch(o){case fe.TOP:return e.height/2-n.height/2-1;case fe.BOTTOM:return t.height-e.height/2-n.height/2-1;case fe.CENTER:return t.height/2-n.height/2-1;default:return console.log("calculateVerticalCaret issue",this)}},calculateHorizontalCaret:function(e,t,n,o){switch(o){case fe.LEFT:return e.width/2-n.height/2-1;case fe.RIGHT:return t.width-e.width/2-n.height/2-1;case fe.CENTER:return t.width/2-n.height/2-1;default:return console.log("calculateHorizontalCaret issue",this)}},calculateHorizontalAlignment:function(e,t,n){switch(n){case fe.LEFT:return e.left;case fe.RIGHT:return e.left+e.width-t.width;case fe.CENTER:return e.left+e.width/2-t.width/2;default:return console.log("calculateHorizontalAlignment issue",this)}}}}function M(){return{restrict:"E",controller:"MenuController",controllerAs:"dtm",scope:{current:"=",available:"="},template:''}}function O(e,t){return{restrict:"C",controller:"DropdownController",link:function(n,o,i){function r(e){o[0].contains(e.target)||t(function(){n.open=!1,l()})}function s(e){27===e.which&&t(function(){n.open=!1,l()})}function l(){e.unbind("click",r),e.unbind("keydown",s)}n.$watch("open",function(t){t&&(e.bind("click",r),e.bind("keydown",s))})}}}function I(e){return{restrict:"C",controller:"DropdownController",require:"?^dropdown",link:function(t,n,o,i){function r(n){n.preventDefault(),e(function(){i.toggle(t)})}function s(){n.unbind("click",r)}n.bind("click",r),t.$on("$destroy",s)}}}function D(e){return{restrict:"C",require:"?^dropdown",link:function(t,n,o,i){t.$watch("open",function(){e[t.open?"addClass":"removeClass"](n,"ddm-open")})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.dtMenu=e.dtPopover=void 0;var L=n(t),N=Object.assign||function(e){for(var t=1;t>>0,i=arguments[1],r=0;r>>0,i=arguments[1],r=0;rt.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}(),X={columns:{},dTables:{},saveColumns:function(e,t){if(t&&t.length){var n=[].slice.call(t);this.dTables[e]=n}},buildColumns:function(e,t){var n=this;L.default.forEach(this.dTables,function(o,i){n.columns[i]=[],L.default.forEach(o,function(o){var r={},s=!0;L.default.forEach(o.attributes,function(n){var o=d(n.name);switch(o){case"class":r.className=n.value;break;case"name":case"prop":r[o]=n.value;break;case"headerRenderer":case"cellRenderer":case"cellDataGetter":r[o]=t(n.value);break;case"visible":s=t(n.value)(e);break;default:r[o]=t(n.value)(e)}});var l=o.getElementsByTagName("column-header");l.length&&(r.headerTemplate=l[0].innerHTML,o.removeChild(l[0])),""!==o.innerHTML&&(r.template=o.innerHTML),s&&n.columns[i].push(r)})}),this.dTables={}}},_={},K=document.createElement("div").style,Y=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)}}(),Z=C("transform"),J=C("backfaceVisibility"),Q=!!C("transform"),ee=!!C("perspective"),te=window.navigator.userAgent,ne=/Safari\//.test(te)&&!/Chrome\//.test(te),oe=function(){function e(){i(this,e)}return V(e,[{key:"styles",value:function(){return{width:this.options.internal.innerWidth+"px",height:this.options.headerHeight+"px"}}},{key:"innerStyles",value:function(){return{width:this.columnWidths.total+"px"}}},{key:"onSorted",value:function(e){if("single"===this.options.sortType){var t=function(t){t!==e&&(t.sort=void 0)};this.columns.left.forEach(t),this.columns.center.forEach(t),this.columns.right.forEach(t)}this.onSort({column:e})}},{key:"stylesByGroup",value:function(e){var t={width:this.columnWidths[e]+"px"};if("center"===e)x(t,this.options.internal.offsetX*-1,0);else if("right"===e){var n=(this.columnWidths.total-this.options.internal.innerWidth)*-1;x(t,n,0)}return t}},{key:"onResized",value:function(e,t){this.onResize({column:e,width:t})}}]),e}(),ie=function(){function e(t){i(this,e),N(this,{$scope:t}),1===angular.version.major&&angular.version.minor<5&&this.init()}return V(e,[{key:"$onInit",value:function(){this.init()}},{key:"init",value:function(){this.column.headerCheckbox&&(this.column.headerCheckboxCallback=this.rowSelected),this.$scope.$parent.$parent.$parent.$parent.dt&&(this.dt=this.$scope.$parent.$parent.$parent.$parent.dt)}},{key:"styles",value:function(){return{width:this.column.width+"px",minWidth:this.column.minWidth+"px",maxWidth:this.column.maxWidth+"px",height:this.column.height+"px"}}},{key:"cellClass",value:function(){var e={sortable:this.column.sortable,resizable:this.column.resizable};return this.column.headerClassName&&(e[this.column.headerClassName]=!0),e}},{key:"onSorted",value:function(){this.column.sortable&&(this.column.sort=p(this.sortType,this.column.sort),void 0===this.column.sort&&(this.column.sortPriority=void 0),this.onSort({column:this.column}))}},{key:"sortClass",value:function(){return{"sort-btn":!0,"sort-asc icon-down":"asc"===this.column.sort,"sort-desc icon-up":"desc"===this.column.sort}}},{key:"onResized",value:function(e,t){this.onResize({column:t,width:e})}},{key:"rowSelected",value:function(e){this.allRowsSelected=e.selected&&e.rows.length===e.selected.length}},{key:"checkboxChangeCallback",value:function(){return this.isAllRowsSelected=this.column.allRowsSelected?this.dt.selectAllRows():this.dt.deselectAllRows()}}]),e}(),re=function(){function e(t){i(this,e),N(this,{$scope:t}),this.tempRows=[],this.watchListeners=[],1===angular.version.major&&angular.version.minor<5&&this.init()}return e.$inject=["$scope"],V(e,[{key:"$onInit",value:function(){this.init()}},{key:"init",value:function(){var e=this;this.setTreeAndGroupColumns(),this.setConditionalWatches(),this.$scope.$watch("body.options.columns",function(t,n){if(t){var o=(e.treeColumn,e.groupColumn);e.setTreeAndGroupColumns(),e.setConditionalWatches(),(e.treeColumn&&o!==e.treeColumn||e.groupColumn&&o!==e.groupColumn)&&(e.rowsUpdated(e.rows),e.treeColumn?e.refreshTree():e.groupColumn&&e.refreshGroups())}},!0),this.$scope.$watchCollection("body.rows",this.rowsUpdated.bind(this))}},{key:"setTreeAndGroupColumns",value:function(){this.treeColumn=this.options.columns.find(function(e){return e.isTreeColumn}),this.treeColumn||(this.groupColumn=this.options.columns.find(function(e){return e.group}))}},{key:"setConditionalWatches",value:function(){var e=this;if(this.watchListeners.map(function(e){return e()}),this.options.scrollbarV||!this.options.scrollbarV&&this.options.paging.externalPaging){var t=!1;this.watchListeners.push(this.$scope.$watch("body.options.paging.size",function(n,o){(!t||n>o)&&(e.getRows(),t=!0)})),this.watchListeners.push(this.$scope.$watch("body.options.paging.count",function(t){e.count=t,e.updatePage()})),this.watchListeners.push(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,t){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 n=e&&t&&(e.length===t.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);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=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&&o0&&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}},{key:"onCheck",value:function(e){var t=this.getColumnIndex(e);t===-1?this.$scope.current.push(e):this.$scope.current.splice(t,1)}}]),e}(),ve=function(){function e(t){i(this,e),t.open=!1}return e.$inject=["$scope"],V(e,[{key:"toggle",value:function(e){e.open=!e.open}}]),e}(),we=L.default.module("dt.dropdown",[]).controller("DropdownController",ve).directive("dropdown",O).directive("dropdownToggle",I).directive("dropdownMenu",D),ye=L.default.module("dt.menu",[we.name]).controller("MenuController",me).directive("dtm",M),be=L.default.module("data-table",[]).directive("dtable",b).directive("resizable",r).directive("sortable",s).directive("dtHeader",k).directive("dtHeaderCell",$).directive("dtBody",T).directive("dtScroller",R).directive("dtSeletion",P).directive("dtRow",S).directive("dtGroupRow",z).directive("dtCell",E).directive("dtFooter",A).directive("dtPager",W);e.dtPopover=ge,e.dtMenu=ye,e.default=be}); \ No newline at end of file diff --git a/release/icons.css b/release/icons.css index 5c5d101..a9947ba 100644 --- a/release/icons.css +++ b/release/icons.css @@ -1,17 +1,12 @@ @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"); + 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); @@ -24,7 +19,6 @@ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } - [class^="icon-"]:before, [class*=" icon-"]:before { font-family: "data-table" !important; @@ -37,7 +31,6 @@ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } - .icon-filter:before { content: "b"; } diff --git a/src/components/DataTableController.js b/src/components/DataTableController.js index 7c4bc3b..419fead 100644 --- a/src/components/DataTableController.js +++ b/src/components/DataTableController.js @@ -9,20 +9,31 @@ export class DataTableController { * @param {scope} * @param {filter} */ - /*@ngInject*/ - constructor($scope, $filter, $log, $transclude){ + + /* @ngInject */ + constructor($scope, $filter) { Object.assign(this, { $scope: $scope, - $filter: $filter, - $log: $log + $filter: $filter }); + // if preAssignBindingsEnabled === true and no $onInit + 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){ @@ -33,8 +44,8 @@ export class DataTableController { }, true); // default sort - var watch = $scope.$watch('dt.rows', (newVal) => { - if(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 2394c34..4ddf72f 100644 --- a/src/components/body/BodyController.js +++ b/src/components/body/BodyController.js @@ -1,23 +1,34 @@ -export class BodyController{ - +export default class BodyController { /** - * A tale body controller + * A body controller * @param {$scope} * @return {BodyController} */ + /*@ngInject*/ - constructor($scope){ - this.$scope = $scope; + constructor($scope) { + Object.assign(this, { + $scope + }); this.tempRows = []; this.watchListeners = []; - if (this.options) { - this.setTreeAndGroupColumns(); - this.setConditionalWatches(); + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } + } + + $onInit() { + this.init(); + } + + init() { + this.setTreeAndGroupColumns(); + this.setConditionalWatches(); - $scope.$watch('body.options.columns', (newVal, oldVal) => { + this.$scope.$watch('body.options.columns', (newVal, oldVal) => { if (newVal) { const origTreeColumn = this.treeColumn, origGroupColumn = this.groupColumn; @@ -39,7 +50,7 @@ export class BodyController{ } }, true); - $scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); + this.$scope.$watchCollection('body.rows', this.rowsUpdated.bind(this)); } setTreeAndGroupColumns() { @@ -292,8 +303,6 @@ export class BodyController{ var temp = []; angular.forEach(this.rowsByGroup, (v, k) => { - console.log('buildGroups', this.rowsByGroup, v, k); - temp.push({ name: k, group: true diff --git a/src/components/body/BodyController.spec.js b/src/components/body/BodyController.spec.js index 4451803..48cd718 100644 --- a/src/components/body/BodyController.spec.js +++ b/src/components/body/BodyController.spec.js @@ -1,4 +1,4 @@ -import { BodyController } from './BodyController'; +import BodyController from './BodyController'; describe('BodyController', function () { const defaultOptions = { diff --git a/src/components/body/BodyDirective.js b/src/components/body/BodyDirective.js index 4db3b7e..5c0ab3b 100644 --- a/src/components/body/BodyDirective.js +++ b/src/components/body/BodyDirective.js @@ -1,4 +1,4 @@ -import { BodyController } from './BodyController'; +import BodyController from './BodyController'; export function BodyDirective($timeout){ return { @@ -20,9 +20,9 @@ export function BodyDirective($timeout){ }, scope: true, template: ` -
@@ -32,7 +32,7 @@ export function BodyDirective($timeout){ -
-
diff --git a/src/components/footer/FooterController.js b/src/components/footer/FooterController.js index 49dcda8..c7d6a7a 100644 --- a/src/components/footer/FooterController.js +++ b/src/components/footer/FooterController.js @@ -5,10 +5,27 @@ export class FooterController { * @param {scope} * @return {[type]} */ + /*@ngInject*/ - constructor($scope){ + constructor($scope) { + Object.assign(this, { + $scope + }); + + // if preAssignBindingsEnabled === true and no $onInit + 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..01aa13f 100644 --- a/src/components/footer/PagerController.js +++ b/src/components/footer/PagerController.js @@ -2,26 +2,42 @@ export class PagerController { /** * Creates an instance of the Pager Controller - * @param {object} $scope + * @param {object} $scope */ + /*@ngInject*/ constructor($scope){ - $scope.$watch('pager.count', (newVal) => { + Object.assign(this, { + $scope + }); + + // if preAssignBindingsEnabled === true and no $onInit + 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 +52,7 @@ export class PagerController { /** * Select a page - * @param {int} num + * @param {int} num */ selectPage(num){ if (num > 0 && num <= this.totalPages) { @@ -73,7 +89,7 @@ export class PagerController { /** * Determines if the pager can go forward - * @return {boolean} + * @return {boolean} */ canNext(){ return this.page < this.totalPages; @@ -81,11 +97,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/header/HeaderCellController.js b/src/components/header/HeaderCellController.js index 23fe67b..30ad1fd 100644 --- a/src/components/header/HeaderCellController.js +++ b/src/components/header/HeaderCellController.js @@ -1,16 +1,29 @@ import { NextSortDirection } from '../../utils/utils'; -export class HeaderCellController{ - constructor($scope){ - this.$scope = $scope; +export class HeaderCellController { + constructor($scope) { + Object.assign(this, { + $scope + }); - if (this.$scope.$parent.$parent.$parent.$parent.dt) { - this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + // if preAssignBindingsEnabled === true and no $onInit + if (angular.version.major === 1 && angular.version.minor < 5) { + this.init(); } + } + + $onInit() { + this.init(); + } + init() { if (this.column.headerCheckbox) { this.column.headerCheckboxCallback = this.rowSelected; } + + if (this.$scope.$parent.$parent.$parent.$parent.dt) { + this.dt = this.$scope.$parent.$parent.$parent.$parent.dt; + } } /** * Calculates the styles for the header cell directive diff --git a/src/components/menu/MenuController.js b/src/components/menu/MenuController.js index 75841b2..d3cfa57 100644 --- a/src/components/menu/MenuController.js +++ b/src/components/menu/MenuController.js @@ -1,7 +1,7 @@ -export class MenuController{ +export class MenuController { /*@ngInject*/ - constructor($scope, $timeout){ + constructor($scope){ this.$scope = $scope; } @@ -23,5 +23,5 @@ export class MenuController{ this.$scope.current.splice(idx, 1); } } - + } diff --git a/src/themes/icons.less b/src/themes/icons.less new file mode 100644 index 0000000..5c5d101 --- /dev/null +++ b/src/themes/icons.less @@ -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"; +}