Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ module.exports = function(grunt) {
'src/scripts/04-*.js',
'src/scripts/05-*.js',
'src/scripts/06-*.js',
'src/scripts/07-*.js',
'./.temp/scripts/views.js',
'src/scripts/07-*.js'
'src/scripts/08-*.js'
],
dest: './dist/ng-table.js'
}
Expand Down
70 changes: 69 additions & 1 deletion dist/ng-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ app.factory('NgTableParams', ['$q', '$log', 'ngTableDefaults', function($q, $log
counts: [10, 25, 50, 100],
sortingIndicator: 'span',
getGroups: this.getGroups,
getData: this.getData
getData: this.getData,
isPagination: true
};
angular.extend(settings, ngTableDefaults.settings);

Expand Down Expand Up @@ -949,6 +950,9 @@ app.directive('ngTablePagination', ['$compile',
scope.$watch('templateUrl', function(templateUrl) {
if (angular.isUndefined(templateUrl)) {
return;
}
if(!scope.params.settings().isPagination){
return;
}
var template = angular.element(document.createElement('div'))
template.attr({
Expand All @@ -961,6 +965,70 @@ app.directive('ngTablePagination', ['$compile',
};
}
]);
app.directive('ngTablePaginationScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
'use strict';
return {
restrict: 'A',
scope: true,
link: function(scope, elem, attrs){
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
scrollDistance = 0;
if (attrs.infiniteScrollDistance != null) {
scope.$watch(attrs.infiniteScrollDistance, function(value) {
return scrollDistance = parseInt(value, 10);
});
}
scrollEnabled = true;
checkWhenEnabled = false;
if (attrs.infiniteScrollDisabled != null) {
scope.$watch(attrs.infiniteScrollDisabled, function(value) {
scrollEnabled = !value;
if (scrollEnabled && checkWhenEnabled) {
checkWhenEnabled = false;
return handler();
}
});
}
handler = function() {
var elementBottom, remaining, shouldScroll, windowBottom, documentInfo;
documentInfo = $window[0].document.body;
windowBottom = document.documentElement.clientHeight + documentInfo.scrollTop;
elementBottom = elem[0].offsetTop + elem[0].scrollHeight;
remaining = elementBottom - windowBottom;
shouldScroll = remaining <= document.documentElement.clientHeight * scrollDistance;
if (shouldScroll && scrollEnabled && documentInfo.scrollTop) {
var total = scope.params.total();
var qtyItems = scope.params.data.length;
var qtyPages = Math.ceil(total / scope.params.count());
var pageCurrent = scope.params.page();
var pageNew = pageCurrent + 1;
if(qtyItems<=total && pageNew<=qtyPages){
scope.params.page( scope.params.page() + 1 );
scope.$apply(scope);
}
} else if (shouldScroll) {
return checkWhenEnabled = true;
}
};
var promise = null;
$window.on('scroll', handler);
scope.$on('$destroy', function() {
return $window.off('scroll', handler);
});
return $timeout((function() {
if (attrs.infiniteScrollImmediateCheck) {
if (scope.$eval(attrs.infiniteScrollImmediateCheck)) {
return handler();
}
} else {
return handler();
}
}), 300);
}
};
}]);
angular.module('ngTable').run(['$templateCache', function ($templateCache) {
$templateCache.put('ng-table/filters/select-multiple.html', '<select ng-options="data.id as data.title for data in $column.data" ng-disabled="$filterRow.disabled" multiple ng-multiple="true" ng-model="params.filter()[name]" ng-show="filter==\'select-multiple\'" class="filter filter-select-multiple form-control" name="{{name}}"> </select>');
$templateCache.put('ng-table/filters/select.html', '<select ng-options="data.id as data.title for data in $column.data" ng-disabled="$filterRow.disabled" ng-model="params.filter()[name]" ng-show="filter==\'select\'" class="filter filter-select form-control" name="{{name}}"> </select>');
Expand Down
40 changes: 40 additions & 0 deletions dist/ng-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,43 @@
.ng-table-pagination {}
.ng-table-counts {}
}
.loading-indicator {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
text-align: center;
padding: 0.7em;
&:before{
display: inline-block;
margin: 0 0.4em;
min-width: 1em;
min-height: 1em;
border-top: 4px solid #646464;
border-right: 4px solid #e6e6e6;
border-left: 4px solid #e6e6e6;
border-bottom: 4px solid #646464;
content: "";
-webkit-animation: halfspin 1s ease infinite;
-moz-animation: halfspin 1s ease infinite;
-o-animation: halfspin 1s ease infinite;
animation: halfspin 1s ease infinite;
border-radius: 100%;
}
}

@-webkit-keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }
@-moz-keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }
@keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }
3 changes: 2 additions & 1 deletion src/scripts/03-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ app.factory('NgTableParams', ['$q', '$log', 'ngTableDefaults', function($q, $log
counts: [10, 25, 50, 100],
sortingIndicator: 'span',
getGroups: this.getGroups,
getData: this.getData
getData: this.getData,
isPagination: true
};
angular.extend(settings, ngTableDefaults.settings);

Expand Down
3 changes: 3 additions & 0 deletions src/scripts/06-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ app.directive('ngTablePagination', ['$compile',
if (angular.isUndefined(templateUrl)) {
return;
}
if(!scope.params.settings().isPagination){
return;
}
var template = angular.element(document.createElement('div'))
template.attr({
'ng-include': 'templateUrl'
Expand Down
77 changes: 77 additions & 0 deletions src/scripts/07-pagination-scrolling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* ngTable: Table + Angular JS
*
* @author Bruno Oliveira <321.bruno@gmail.com>
* @url https://github.com/esvit/ng-table/
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

/**
* @ngdoc directive
* @name ngTable.directive:ngTablePaginationScroll
* @restrict A
*/
app.directive('ngTablePaginationScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
'use strict';
return {
restrict: 'A',
scope: true,
link: function(scope, elem, attrs){
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
scrollDistance = 0;
if (attrs.infiniteScrollDistance != null) {
scope.$watch(attrs.infiniteScrollDistance, function(value) {
return scrollDistance = parseInt(value, 10);
});
}
scrollEnabled = true;
checkWhenEnabled = false;
if (attrs.infiniteScrollDisabled != null) {
scope.$watch(attrs.infiniteScrollDisabled, function(value) {
scrollEnabled = !value;
if (scrollEnabled && checkWhenEnabled) {
checkWhenEnabled = false;
return handler();
}
});
}
handler = function() {
var elementBottom, remaining, shouldScroll, windowBottom, documentInfo;
documentInfo = $window[0].document.body;
windowBottom = document.documentElement.clientHeight + documentInfo.scrollTop;
elementBottom = elem[0].offsetTop + elem[0].scrollHeight;
remaining = elementBottom - windowBottom;
shouldScroll = remaining <= document.documentElement.clientHeight * scrollDistance;
if (shouldScroll && scrollEnabled && documentInfo.scrollTop) {
var total = scope.params.total();
var qtyItems = scope.params.data.length;
var qtyPages = Math.ceil(total / scope.params.count());
var pageCurrent = scope.params.page();
var pageNew = pageCurrent + 1;
if(qtyItems<=total && pageNew<=qtyPages){
scope.params.page( scope.params.page() + 1 );
scope.$apply(scope);
}
} else if (shouldScroll) {
return checkWhenEnabled = true;
}
};
var promise = null;
$window.on('scroll', handler);
scope.$on('$destroy', function() {
return $window.off('scroll', handler);
});
return $timeout((function() {
if (attrs.infiniteScrollImmediateCheck) {
if (scope.$eval(attrs.infiniteScrollImmediateCheck)) {
return handler();
}
} else {
return handler();
}
}), 300);
}
};
}]);
File renamed without changes.
40 changes: 40 additions & 0 deletions src/styles/ng-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,43 @@
.ng-table-pagination {}
.ng-table-counts {}
}
.loading-indicator {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
text-align: center;
padding: 0.7em;
&:before{
display: inline-block;
margin: 0 0.4em;
min-width: 1em;
min-height: 1em;
border-top: 4px solid #646464;
border-right: 4px solid #e6e6e6;
border-left: 4px solid #e6e6e6;
border-bottom: 4px solid #646464;
content: "";
-webkit-animation: halfspin 1s ease infinite;
-moz-animation: halfspin 1s ease infinite;
-o-animation: halfspin 1s ease infinite;
animation: halfspin 1s ease infinite;
border-radius: 100%;
}
}

@-webkit-keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }
@-moz-keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }
@keyframes halfspin {
to {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg); } }