Don't show random page option for single page results
Change-Id: I2ec9177a9aa78cb0f0bc0f1cd8791191bdc29ce4
diff --git a/dev/js/src/panel/pagination.js b/dev/js/src/panel/pagination.js
index dd3331c..03c5258 100644
--- a/dev/js/src/panel/pagination.js
+++ b/dev/js/src/panel/pagination.js
@@ -16,7 +16,6 @@
// Localization values
const loc = KorAP.Locale;
loc.RANDOM_PAGE = loc.RANDOM_PAGE || 'Random page';
-
return {
type : 'pagination',
@@ -77,18 +76,23 @@
*/
addRandomPage : function () {
const pi = pageInfoClass.create();
-
+
+ if (pi.total() < 2)
+ return false;
+
const button = this.actions().add(
loc.RANDOM_PAGE,
{},
function () {
- if (pi.total() > 0) {
+ if (pi.total() > 1) {
const sp = new URLSearchParams(window.location.search);
sp.set("p", Math.floor(Math.random() * pi.total()) + 1);
window.location.search = sp.toString();
};
}
- )
+ );
+
+ return true;
}
}
});