Popup records now work for all result-lists, as the request is now
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 6245215..98fc11c 100644 (file)
@@ -230,6 +230,7 @@ function _make_mkws_team($, teamName) {
                      "usesessions" : mkws_config.use_service_proxy ? false : true,
                      "showResponseType": '', // or "json" (for debugging?)
                      "onrecord": my_onrecord });
+    that.m_paz = m_paz; // For access from non-member functions like mkws.showDetails
 
     if (!isNaN(parseInt(mkws_config.perpage_default))) {
        m_recPerPage = parseInt(mkws_config.perpage_default);
@@ -281,7 +282,7 @@ function _make_mkws_team($, teamName) {
     {
        var template = loadTemplate("Summary");
        hit._id = "mkwsRec_" + hit.recid;
-       hit._onclick = "mkws.showDetails(this.id);return false;"
+       hit._onclick = "mkws.showDetails(this.id, '" + m_teamName + "');return false;"
        return template(hit);
     }
 
@@ -404,7 +405,14 @@ function _make_mkws_team($, teamName) {
     // wait until the DOM is ready
     function domReady ()
     {
-       document.mkwsSearchForm.onsubmit = onFormSubmitEventHandler;
+       $('.mkwsSearchForm').each(function (i, obj) {
+           var node = this;
+           debug("adding class 'foo' to node " + node);
+           mkws.handle_node_with_team(node, function(tname) {
+               $(node).submit(onFormSubmitEventHandler);
+           });
+       });
+
        document.mkwsSearchForm.mkwsQuery.value = '';
        if (document.mkwsSelect) {
            if (document.mkwsSelect.mkwsSort)
@@ -722,7 +730,7 @@ function _make_mkws_team($, teamName) {
 
 
     // detailed record drawing
-    mkws.showDetails = function (prefixRecId) {
+    mkws.showDetails = function (prefixRecId, tname) {
        var recId = prefixRecId.replace('mkwsRec_', '');
        var oldRecId = m_curDetRecId;
        m_curDetRecId = recId;
@@ -740,7 +748,9 @@ function _make_mkws_team($, teamName) {
             return;
        }
        // request the record
-       m_paz.record(recId);
+       var team = mkws.teams[tname];
+       if (!team) alert("no team '" + tname + "'");
+       team.m_paz.record(recId);
     }
 
 
@@ -1302,7 +1312,7 @@ function _mkws_jquery_plugin ($) {
        // Find all nodes with class (NOT id) mkwsRecords, and
        // determine their team from the mkwsTeam_* class. So:
        //      <div class="mkwsRecords mkwsTeam_foo"/>
-       $('.mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () {
+       $('.mkwsSearch, .mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () {
            var node = this;
            mkws.handle_node_with_team(node, function(tname) {
                if (mkws.teams[tname]) {