findnode now creates crazy-wacky complicated jQuery selectors to find
authorMike Taylor <mike@indexdata.com>
Fri, 11 Apr 2014 10:56:20 +0000 (11:56 +0100)
committerMike Taylor <mike@indexdata.com>
Fri, 11 Apr 2014 10:56:20 +0000 (11:56 +0100)
nodes that either belong to the specified team, or in the case that
the team is "AUTO", no team at all. This makes it possible for us to
avoid decorating nodes with mkwsTeam_AUTO classes.

Down the line, we should be able to make this cleaner by having each
class know what widgets it contains, so we don't need to do this
findnode magic -- ideally so we don't need findnode at all.

src/mkws-team.js

index 9d9e34c..d6fc49f 100644 (file)
@@ -604,7 +604,12 @@ function team($, teamName) {
        teamName = teamName || m_teamName;
 
        selector = $.map(selector.split(','), function(s, i) {
-           return s + '.mkwsTeam_' + teamName;
+           if (teamName === 'AUTO') {
+               return (s + '.mkwsTeam_' + teamName + ',' +
+                       s + ':not([class^="mkwsTeam"],[class*=" mkwsTeam"])');
+           } else {
+               return s + '.mkwsTeam_' + teamName;
+           }
        }).join(',');
 
        var node = $(selector);