From 997230631bac00a068486fa44685a0f3a68d9bef Mon Sep 17 00:00:00 2001 From: zheyakush Date: Thu, 4 Dec 2014 14:43:57 +0200 Subject: [PATCH 1/3] Changed a view pagination --- app/scripts/design/directives/guiPaginator.js | 42 ++++++++++++++++++- .../default/views/design/gui/paginator.html | 18 +++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/app/scripts/design/directives/guiPaginator.js b/app/scripts/design/directives/guiPaginator.js index 0c6a1ee2..eb136f94 100644 --- a/app/scripts/design/directives/guiPaginator.js +++ b/app/scripts/design/directives/guiPaginator.js @@ -14,7 +14,47 @@ scope: { 'parent': '=object' }, - templateUrl: $designService.getTemplate('design/gui/paginator.html') + templateUrl: $designService.getTemplate('design/gui/paginator.html'), + controller: ["$scope", + function ($scope) { + + $scope.pages = $scope.parent.getPages(); + + var countNeighbors = 2; + $scope.leftBreak = false; + $scope.rightBreak = false; + + $scope.isNeighbors = function (page) { + return Math.abs($scope.parent.paginator.page - page) <= countNeighbors; + }; + + $scope.hasLeftBreak = function () { + return $scope.leftBreak; + }; + + $scope.hasRightBreak = function () { + return $scope.rightBreak; + }; + + + $scope.$watch("parent.paginator.page", function () { + if (typeof $scope.parent.paginator === "undefined") { + return true; + } + + var leftBorder = $scope.parent.paginator.page - countNeighbors; + var rightBorder = $scope.parent.paginator.page + countNeighbors; + + if (leftBorder > $scope.parent.getPages()[0] + 1 ) { + $scope.leftBreak = true; + } + + if (rightBorder < $scope.parent.getPages()[$scope.parent.getPages().length-1]-1) { + $scope.rightBreak = true; + } + }, true); + } + ] }; }]); diff --git a/app/themes/default/views/design/gui/paginator.html b/app/themes/default/views/design/gui/paginator.html index 3b58a119..daa3310d 100644 --- a/app/themes/default/views/design/gui/paginator.html +++ b/app/themes/default/views/design/gui/paginator.html @@ -3,7 +3,23 @@