From 602700561648d1be5e19ab7c9b91bca4597ece8c Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Mon, 24 Feb 2014 07:46:11 +0100 Subject: [PATCH] Use angular-ui pagination --- css/style.css | 4 ++++ index.html | 56 ++++++++++++++++++++++---------------------- js/ctrls/download.js | 36 +--------------------------- 3 files changed, 33 insertions(+), 63 deletions(-) diff --git a/css/style.css b/css/style.css index d88fd61..da05f92 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,7 @@ +.pagination ul > li:not(.disabled) { + cursor: pointer; +} + .pagination ul > li.active > a { color: #fff; background-color: #428bca; diff --git a/index.html b/index.html index 28513c6..b212960 100755 --- a/index.html +++ b/index.html @@ -276,6 +276,22 @@ + + + diff --git a/js/ctrls/download.js b/js/ctrls/download.js index 64ee1b8..5f201e2 100644 --- a/js/ctrls/download.js +++ b/js/ctrls/download.js @@ -1,5 +1,6 @@ angular .module('webui.ctrls.download', [ + "ui.bootstrap", 'webui.services.utils', 'webui.services.rpc', 'webui.services.alerts', 'webui.services.settings', 'webui.services.modals' ]) @@ -171,11 +172,6 @@ function( // current displayed page scope.currentPage = 1; - scope.pageControlRadius = 3; - - // total maximum pages - scope.totalPages = 0; - // total amount of downloads returned by aria2 scope.totalAria2Downloads = function() { return scope.active.length @@ -219,42 +215,12 @@ function( scope.totalDownloads = downloads.length; - scope.totalPages = Math.ceil(scope.totalDownloads / scope.pageSize) || 1; - - // fix the bug when downloads are deleted until no left on a specific page - if (scope.currentPage > scope.totalPages) - scope.currentPage = scope.totalPages; - downloads = downloads.slice( (scope.currentPage - 1) * scope.pageSize ); downloads.splice( scope.pageSize ); return downloads; } - scope.setPage = function(pageNumber) { - scope.currentPage = pageNumber; - scope.currentPage = Math.max(Math.min(scope.currentPage, scope.totalPages), 1); - return false; - }; - - scope.advancePage = function(num) { - return scope.setPage(scope.currentPage + num); - }; - - // get the pages to be displayed - scope.getPages = function() { - var minPage = scope.currentPage - scope.pageControlRadius; - - if (minPage < 1) minPage = 1; - - var maxPage = scope.currentPage + scope.pageControlRadius; - - if (maxPage > scope.totalPages) - maxPage = scope.totalPages; - - return _.range(minPage, maxPage + 1); - } - // convert the donwload form aria2 to once used by the view, // minor additions of some fields and checks scope.getCtx = function(d, ctx) {