diff --git a/src/pager/docs/demo.html b/src/pager/docs/demo.html new file mode 100644 index 0000000000..cebdfba944 --- /dev/null +++ b/src/pager/docs/demo.html @@ -0,0 +1,4 @@ +
+

Pager

+ +
diff --git a/src/pager/docs/demo.js b/src/pager/docs/demo.js new file mode 100644 index 0000000000..b0d0d6cd1f --- /dev/null +++ b/src/pager/docs/demo.js @@ -0,0 +1,4 @@ +angular.module('ui.bootstrap.demo').controller('PagerDemoCtrl', function($scope) { + $scope.totalItems = 64; + $scope.currentPage = 4; +}); diff --git a/src/pager/docs/readme.md b/src/pager/docs/readme.md new file mode 100644 index 0000000000..d659d5aefd --- /dev/null +++ b/src/pager/docs/readme.md @@ -0,0 +1,26 @@ +A lightweight pager directive that is focused on providing previous/next paging functionality + +### Pager Settings ### + +Settings can be provided as attributes in the `` or globally configured through the `uibPagerConfig`. +For `ng-model`, `total-items`, `items-per-page` and `num-pages` see pagination settings. Other settings are: + + * `align` + _(Default: true)_ : + Whether to align each link to the sides. + + * `previous-text` + _(Default: '« Previous')_ : + Text for Previous button. + + * `next-text` + _(Default: 'Next »')_ : + Text for Next button. + + * `template-url` + _(Default: 'template/pagination/pager.html') : + Override the template for the component with a custom provided template + + * `ng-disabled` + : + Used to disable the pager component diff --git a/src/pager/pager.js b/src/pager/pager.js new file mode 100644 index 0000000000..b0f2d4f557 --- /dev/null +++ b/src/pager/pager.js @@ -0,0 +1,37 @@ +angular.module('ui.bootstrap.pager', ['ui.bootstrap.pagination']) + +.constant('uibPagerConfig', { + itemsPerPage: 10, + previousText: '« Previous', + nextText: 'Next »', + align: true +}) + +.directive('uibPager', ['uibPagerConfig', function(pagerConfig) { + return { + restrict: 'EA', + scope: { + totalItems: '=', + previousText: '@', + nextText: '@', + ngDisabled: '=' + }, + require: ['uibPager', '?ngModel'], + controller: 'UibPaginationController', + controllerAs: 'pagination', + templateUrl: function(element, attrs) { + return attrs.templateUrl || 'uib/template/pager/pager.html'; + }, + replace: true, + link: function(scope, element, attrs, ctrls) { + var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1]; + + if (!ngModelCtrl) { + return; // do nothing if no ng-model + } + + scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align; + paginationCtrl.init(ngModelCtrl, pagerConfig); + } + }; +}]); diff --git a/src/pagination/test/pager.spec.js b/src/pager/test/pager.spec.js similarity index 97% rename from src/pagination/test/pager.spec.js rename to src/pager/test/pager.spec.js index b6773f354f..5fab491fa0 100644 --- a/src/pagination/test/pager.spec.js +++ b/src/pager/test/pager.spec.js @@ -1,7 +1,7 @@ describe('pager directive', function() { var $compile, $rootScope, $document, $templateCache, body, element; - beforeEach(module('ui.bootstrap.pagination')); - beforeEach(module('uib/template/pagination/pager.html')); + beforeEach(module('ui.bootstrap.pager')); + beforeEach(module('uib/template/pager/pager.html')); beforeEach(inject(function(_$compile_, _$rootScope_, _$document_, _$templateCache_) { $compile = _$compile_; $rootScope = _$rootScope_; @@ -54,7 +54,7 @@ describe('pager directive', function() { }); it('exposes the controller on the template', function() { - $templateCache.put('uib/template/pagination/pager.html', '
{{pagination.text}}
'); + $templateCache.put('uib/template/pager/pager.html', '
{{pagination.text}}
'); element = $compile('')($rootScope); $rootScope.$digest(); diff --git a/src/pagination/docs/demo.html b/src/pagination/docs/demo.html index fa26e2e07c..9fe06af177 100644 --- a/src/pagination/docs/demo.html +++ b/src/pagination/docs/demo.html @@ -21,8 +21,4 @@
boundary-link-numbers set to true and rotate
Page: {{bigCurrentPage}} / {{numPages}}
-
-

Pager

- - diff --git a/src/pagination/docs/readme.md b/src/pagination/docs/readme.md index 96322217ef..d32ee8a136 100644 --- a/src/pagination/docs/readme.md +++ b/src/pagination/docs/readme.md @@ -72,28 +72,3 @@ Settings can be provided as attributes in the `` or globally con * `template-url` _(Default: 'uib/template/pagination/pagination.html')_ : Override the template for the component with a custom provided template - -### Pager Settings ### - -Settings can be provided as attributes in the `` or globally configured through the `uibPagerConfig`. -For `ng-model`, `total-items`, `items-per-page` and `num-pages` see pagination settings. Other settings are: - - * `align` - _(Default: true)_ : - Whether to align each link to the sides. - - * `previous-text` - _(Default: '« Previous')_ : - Text for Previous button. - - * `next-text` - _(Default: 'Next »')_ : - Text for Next button. - - * `template-url` - _(Default: 'template/pagination/pager.html') : - Override the template for the component with a custom provided template - - * `ng-disabled` - : - Used to disable the pager component diff --git a/src/pagination/pagination.js b/src/pagination/pagination.js index 9ce43a0c26..a20b70d9f4 100644 --- a/src/pagination/pagination.js +++ b/src/pagination/pagination.js @@ -221,40 +221,4 @@ angular.module('ui.bootstrap.pagination', []) }; } }; -}]) - -.constant('uibPagerConfig', { - itemsPerPage: 10, - previousText: '« Previous', - nextText: 'Next »', - align: true -}) - -.directive('uibPager', ['uibPagerConfig', function(pagerConfig) { - return { - restrict: 'EA', - scope: { - totalItems: '=', - previousText: '@', - nextText: '@', - ngDisabled: '=' - }, - require: ['uibPager', '?ngModel'], - controller: 'UibPaginationController', - controllerAs: 'pagination', - templateUrl: function(element, attrs) { - return attrs.templateUrl || 'uib/template/pagination/pager.html'; - }, - replace: true, - link: function(scope, element, attrs, ctrls) { - var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - - if (!ngModelCtrl) { - return; // do nothing if no ng-model - } - - scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align; - paginationCtrl.init(ngModelCtrl, pagerConfig); - } - }; }]); diff --git a/template/pagination/pager.html b/template/pager/pager.html similarity index 100% rename from template/pagination/pager.html rename to template/pager/pager.html