my_onterm() made team-aware
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index fe82c5c..0d5868e 100644 (file)
@@ -1,4 +1,7 @@
-/*! MKWS, the MasterKey Widget Set. Copyright (C) 2013-2014, Index Data */
+/*! MKWS, the MasterKey Widget Set. 
+ *  Copyright (C) 2013-2014 Index Data 
+ *  See the file LICENSE for details
+ */
 
 "use strict"; // HTML5: disable for debug_level >= 2
 
@@ -306,12 +309,12 @@ function team($, teamName) {
        debug("term for " + teamName);
        // no facets
        if (!mkws_config.facets || mkws_config.facets.length == 0) {
-           $("#mkwsTermlists").hide();
+           $(".mkwsTermlists.mkwsTeam_" + teamName).hide();
            return;
        }
 
        // display if we first got results
-       $("#mkwsTermlists").show();
+       $(".mkwsTermlists.mkwsTeam_" + teamName).show();
 
        var acc = [];
        acc.push('<div class="title">' + M('Termlists') + '</div>');
@@ -329,7 +332,7 @@ function team($, teamName) {
            }
        }
 
-       var termlist = $("#mkwsTermlists");
+       var termlist = $(".mkwsTermlists.mkwsTeam_" + teamName);
        if (termlist)
            termlist.html(acc.join(''));
     }
@@ -1290,17 +1293,16 @@ function _mkws_jquery_plugin ($) {
 
        // For all MKWS-classed nodes that don't have a team
        // specified, set the team to AUTO.
-       $('div[class^="mkws"],div[class*=" mkws"]').each(function () {
+       $('[class^="mkws"],[class*=" mkws"]').each(function () {
            if (!this.className.match(/mkwsTeam_/)) {
                log("adding AUTO team to node with class '" + this.className + "'");
                $(this).addClass('mkwsTeam_AUTO');
            }
        });
 
-       // Find all nodes with class (NOT id) mkwsRecords, and
-       // determine their team from the mkwsTeam_* class. So:
-       //      <div class="mkwsRecords mkwsTeam_foo"/>
-       $('.mkwsSearch, .mkwsResults, .mkwsRecords, .mkwsTermlists').each(function () {
+       // Find all nodes with an class, and determine their team from
+       // the mkwsTeam_* class. Make all team objects.
+       $('[class^="mkws"],[class*=" mkws"]').each(function () {
            var node = this;
            mkws.handle_node_with_team(node, function(tname) {
                if (mkws.teams[tname]) {
@@ -1338,11 +1340,10 @@ function _mkws_jquery_plugin ($) {
 
 
     mkws.resize_page = function () {
-       var list = ["mkwsSwitch"];
+       var list = ["mkwsSwitch", "mkwsLang"];
 
        var width = mkws_config.responsive_design_width;
        var parent = $(".mkwsTermlists").parent();
-       log("parent = " + parent + ", length = " + parent.length);
 
        if ($(window).width() <= width &&
            parent.hasClass("mkwsTermlistContainer1")) {