perpage_default should work without select menu, MKWS-51
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 3c43d50..e3ca0e1 100644 (file)
@@ -108,6 +108,12 @@ Handlebars.registerHelper('json', function(obj) {
 });
 
 
+Handlebars.registerHelper('translate', function(s) {
+    debug("translating '" + s + "'");
+    return M(s);
+});
+
+
 // We need {{attr '@name'}} because Handlebars can't parse {{@name}}
 Handlebars.registerHelper('attr', function(attrName) {
     return this[attrName];
@@ -201,6 +207,7 @@ Handlebars.registerHelper('commaList', function(items, options) {
     }
 }
 
+
 mkws.sort = mkws_config.sort_default;
 debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to mkws.sort");
 
@@ -251,6 +258,10 @@ var SourceMax = 16;
 var SubjectMax = 10;
 var AuthorMax = 10;
 
+if ($.isNumeric(mkws_config.perpage_default)) {
+    recPerPage = parseInt(mkws_config.perpage_default);
+}
+
 //
 // pz2.js event handlers:
 //
@@ -495,8 +506,16 @@ function triggerSearch (query, sort, targets, windowid)
        }
     }
 
-    debug("triggerSearch(" + mkws.query + "): filters = " + $.toJSON(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
-    my_paz.search(mkws.query, recPerPage, mkws.sort, pp2filter, undefined, { limit: pp2limit });
+    var params = {};
+    if (pp2limit) {
+       params.limit = pp2limit;
+    }
+    if (windowid) {
+       params.windowid = windowid;
+    }
+    debug("triggerSearch(" + mkws.query + "): filters = " + $.toJSON(mkws.filters) + ", pp2filter = " + pp2filter + ", params = " + $.toJSON(params));
+
+    my_paz.search(mkws.query, recPerPage, mkws.sort, pp2filter, undefined, params);
 }
 
 function loadSelect ()
@@ -774,7 +793,7 @@ function defaultTemplate(name)
        return '\
       <table>\
        <tr>\
-         <th>Title</th>\
+         <th>{{translate "Title"}}</th>\
          <td>\
            {{md-title}}\
            {{#if md-title-remainder}}\
@@ -787,19 +806,19 @@ function defaultTemplate(name)
        </tr>\
        {{#if md-date}}\
        <tr>\
-         <th>Date</th>\
+         <th>{{translate "Date"}}</th>\
          <td>{{md-date}}</td>\
        </tr>\
        {{/if}}\
        {{#if md-author}}\
        <tr>\
-         <th>Author</th>\
+         <th>{{translate "Author"}}</th>\
          <td>{{md-author}}</td>\
        </tr>\
        {{/if}}\
        {{#if md-electronic-url}}\
        <tr>\
-         <th>URL</th>\
+         <th>{{translate "URL"}}</th>\
          <td>\
            {{#each md-electronic-url}}\
              <a href="{{this}}">{{this}}</a><br/>\
@@ -809,7 +828,7 @@ function defaultTemplate(name)
        {{/if}}\
        {{#if-any location having="md-subject"}}\
        <tr>\
-         <th>Subject</th>\
+         <th>{{translate "Subject"}}</th>\
          <td>\
            {{#first location having="md-subject"}}\
              {{#if md-subject}}\
@@ -820,7 +839,7 @@ function defaultTemplate(name)
        </tr>\
        {{/if-any}}\
        <tr>\
-         <th>Locations</th>\
+         <th>{{translate "Locations"}}</th>\
          <td>\
            {{#commaList location}}\
              {{attr "@name"}}{{/commaList}}\