Skip to content

Commit

Permalink
compiled js
Browse files Browse the repository at this point in the history
  • Loading branch information
samu committed Jun 16, 2013
1 parent d0a985c commit 2b29011
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
44 changes: 30 additions & 14 deletions angular-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

angular.module("angular-table").directive("atTable", [
"attributeExtractor", function(attributeExtractor) {
var capitaliseFirstLetter, constructHeader;
var capitaliseFirstLetter, constructHeader, validateInput;

capitaliseFirstLetter = function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
Expand Down Expand Up @@ -78,16 +78,22 @@
return thead.append(tr);
}
};
validateInput = function(attributes) {
if (attributes.pagination && attributes.list) {
throw "You can not specify a list if you have specified a pagination. The list defined for the pagnination will automatically be used.";
}
if (!attributes.pagination && !attributes.list) {
throw "Either a list or pagination must be specified.";
}
};
return {
restrict: "AC",
scope: true,
compile: function(element, attributes, transclude) {
var filterString, listName, paginationName, tbody, tr;

validateInput(attributes);
constructHeader(element);
if (attributes.pagination && attributes.list) {
throw "List and pagination defined on the same table.";
}
paginationName = attributes.pagination;
filterString = "";
if (paginationName) {
Expand Down Expand Up @@ -160,20 +166,30 @@
$scope.update = function() {
var x;

$scope.stub.numberOfPages = Math.ceil($scope.list.length / $scope.stub.itemsPerPage);
$scope.pages = (function() {
var _i, _ref, _results;
$scope.stub.currentPage = 0;
if ($scope.list) {
if ($scope.list.length > 0) {
$scope.stub.numberOfPages = Math.ceil($scope.list.length / $scope.stub.itemsPerPage);
$scope.pages = (function() {
var _i, _ref, _results;

_results = [];
for (x = _i = 0, _ref = $scope.stub.numberOfPages - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; x = 0 <= _ref ? ++_i : --_i) {
_results.push(x);
_results = [];
for (x = _i = 0, _ref = $scope.stub.numberOfPages - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; x = 0 <= _ref ? ++_i : --_i) {
_results.push(x);
}
return _results;
})();
} else {
$scope.stub.numberOfPages = 0;
$scope.pages = [];
}
return _results;
})();
return $scope.stub.list = $scope.list;
return $scope.stub.list = $scope.list;
}
};
$scope.stub.fromPage = function() {
return $scope.stub.itemsPerPage * $scope.stub.currentPage - $scope.list.length;
if ($scope.list) {
return $scope.stub.itemsPerPage * $scope.stub.currentPage - $scope.list.length;
}
};
$scope.goToPage = function(page) {
page = Math.max(0, page);
Expand Down
2 changes: 1 addition & 1 deletion angular-table.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b29011

Please sign in to comment.