Fix slider max to match maximum attainable value.
[quanweb.git] / js / src / SearchController.js
index 0f131945bacbf56f2ac59cdcc1db7a96262590b7..a02d27bae05f905187ce3306fb9c928e627c72fe 100644 (file)
@@ -5,7 +5,7 @@ var SearchController = (function () {
     var my = {},
         booksModel = undefined;
 
-    const terms = ['aut', 'tit', 'ser'];
+    const terms = ['aut', 'lan', 'lst', 'ser', 'tit'];
 
     // ==============
     // Public methods
@@ -28,9 +28,13 @@ var SearchController = (function () {
                 booksModel.ids = jsonValue;
                 booksModel.count = booksModel.ids.length;
                 booksModel.first = (-1);
+
+                const max_pos = Math.max(0, booksModel.count - booksModel.pageSize);
         
                 var elem = Browser.getElementById('slider');
-                elem.max = booksModel.count;
+                elem.max = max_pos;
+                elem = Browser.getElementById('bottom_slider');
+                elem.max = max_pos;
         
                 PagingController.adjustPos(0);
             })
@@ -76,10 +80,14 @@ var SearchController = (function () {
                 else {
                     url += '&';
                 }
-                url += term + '=' + encodeURIComponent('%' + value + '%');
+                if (term === 'lst') {
+                  url += term + '=' + encodeURIComponent('' + value);
+                }
+                else {
+                  url += term + '=' + encodeURIComponent('%' + value + '%');
+                }
             }
         }
-
         return url;
     }