From d4a1aae48f097d48e9fded67445ba20720c1d966 Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 31 Oct 2016 07:50:26 +0100 Subject: [PATCH] Fix disabled links in PagerPanel Disabled links in the PagerPanel (used on the LuceneSearchPage to page through search results) were only rendered as "disabled". The links themselves remained active, which gives strange effects when clicked. For instance it was possible to move to result pages -1, -2, and so on. Really disable the links. Add missing CSS rules to have correct styling as Wicket renders disabled links as spans, not anchors. Include the new CSS file in BasePage.html. And add the left/right arrows only if not on the first/last page. --- .../com/gitblit/wicket/pages/BasePage.html | 1 + .../com/gitblit/wicket/panels/PagerPanel.java | 5 ++-- src/main/resources/bootstrap-fixes.css | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/bootstrap-fixes.css diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.html b/src/main/java/com/gitblit/wicket/pages/BasePage.html index b998428c..4dbc2e57 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.html +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.html @@ -17,6 +17,7 @@ + diff --git a/src/main/java/com/gitblit/wicket/panels/PagerPanel.java b/src/main/java/com/gitblit/wicket/panels/PagerPanel.java index 2d774c41..d1214cae 100644 --- a/src/main/java/com/gitblit/wicket/panels/PagerPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/PagerPanel.java @@ -48,7 +48,7 @@ public class PagerPanel extends Panel { deltas = new int[] { -2, -1, 0, 1, 2 }; } - if (totalPages > 0) { + if (totalPages > 0 && currentPage > 1) { pages.add(new PageObject("\u2190", currentPage - 1)); } for (int delta : deltas) { @@ -57,7 +57,7 @@ public class PagerPanel extends Panel { pages.add(new PageObject("" + page, page)); } } - if (totalPages > 0) { + if (totalPages > 0 && currentPage < totalPages) { pages.add(new PageObject("\u2192", currentPage + 1)); } @@ -75,6 +75,7 @@ public class PagerPanel extends Panel { item.add(link); if (pageItem.page == currentPage || pageItem.page < 1 || pageItem.page > totalPages) { WicketUtils.setCssClass(item, "disabled"); + link.setEnabled(false); } } }; diff --git a/src/main/resources/bootstrap-fixes.css b/src/main/resources/bootstrap-fixes.css new file mode 100644 index 00000000..c9b6154b --- /dev/null +++ b/src/main/resources/bootstrap-fixes.css @@ -0,0 +1,25 @@ +/** + * Disabled links in a PagerPanel. Bootstrap 2.0.4 only handles , but not . Wicket renders disabled links as spans. + * The .pagination rules here are identical to the ones for in bootstrap.css, but for . + */ +.pagination span { + float: left; + padding: 0 14px; + line-height: 34px; + text-decoration: none; + border: 1px solid #ddd; + border-left-width: 0; +} + +.pagination li:first-child span { + border-left-width: 1px; + -webkit-border-radius: 3px 0 0 3px; + -moz-border-radius: 3px 0 0 3px; + border-radius: 3px 0 0 3px; +} + +.pagination li:last-child span { + -webkit-border-radius: 0 3px 3px 0; + -moz-border-radius: 0 3px 3px 0; + border-radius: 0 3px 3px 0; +} -- 2.39.5