Vertical ws
[mkws-moved-to-github.git] / src / mkws-widgets.js
index 3901f67..cd9e45d 100644 (file)
@@ -22,6 +22,10 @@ function widget($, team, type, node) {
        return '[Widget ' + team.name() + ':' + type + ']';
     };
 
+    that.value = function() {
+        return node.value;
+    }
+
     for (var i = 0; i < node.attributes.length; i++) {
        var a = node.attributes[i];
        if (a.name === 'data-mkws-config') {
@@ -218,6 +222,13 @@ mkws.registerWidgetType('Pager', function() {
 });
 
 
+mkws.registerWidgetType('Results', function() {
+    // Nothing to do apart from act as an autosearch trigger
+    // Contained elements do all the real work
+    widget.autosearch(this);
+});
+
+
 mkws.registerWidgetType('Records', function() {
     var that = this;
     var team = this.team;
@@ -259,20 +270,18 @@ mkws.registerWidgetType('Navi', function() {
        var filters = that.team.filters();
        var text = "";
 
-       for (var i in filters) {
-           if (text) {
-               text += " | ";
-           }
-           var filter = filters[i];
-           if (filter.id) {
-               text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + teamName +
-                   "', '" + filter.id + "'" + ');return false;">' + filter.name + '</a>';
-           } else {
-               text += M(filter.field) + ': <a class="crossout" href="#" onclick="mkws.delimitQuery(\'' + teamName +
-                   "', '" + filter.field + "', '" + filter.value + "'" +
-                   ');return false;">' + filter.value + '</a>';
-           }
-       }
+       filters.visitTargets(function(id, name) {
+           if (text) text += " | ";
+           text += M('source') + ': <a class="crossout" href="#" onclick="mkws.delimitTarget(\'' + teamName +
+               "', '" + id + "'" + ');return false;">' + name + '</a>';
+       });
+
+       filters.visitFields(function(field, value) {
+           if (text) text += " | ";
+           text += M(field) + ': <a class="crossout" href="#" onclick="mkws.delimitQuery(\'' + teamName +
+               "', '" + field + "', '" + value + "'" +
+               ');return false;">' + value + '</a>';
+       });
 
        $(that.node).html(text);
     });