Update of /var/cvs/speeltuin/mihxil/wiki/mmbase/searchrelate
In directory james.mmbase.org:/tmp/cvs-serv5150/mmbase/searchrelate

Modified Files:
        Searcher.js.jsp relate.jspx 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/speeltuin/mihxil/wiki/mmbase/searchrelate


Index: Searcher.js.jsp
===================================================================
RCS file: /var/cvs/speeltuin/mihxil/wiki/mmbase/searchrelate/Searcher.js.jsp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Searcher.js.jsp     1 Apr 2008 09:35:30 -0000       1.4
+++ Searcher.js.jsp     1 Apr 2008 11:38:13 -0000       1.5
@@ -11,15 +11,16 @@
 
  *
  * @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.4 2008/04/01 09:35:30 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.5 2008/04/01 11:38:13 michiel Exp $
  */
 
 
 function MMBaseSearcher(d) {
-    this.logEnabled   = true;
+    this.logEnabled   = false;
     this.traceEnabled = false;
     this.div = d;
     this.value = "";
+    this.canUnrelate = $(d).hasClass("can_unrelate");
     this.searchResults = {};
     this.related       = {};
     this.unrelated     = {};
@@ -66,15 +67,7 @@
                        $(rep).empty();
                        $(rep).append(r);
                        self.searchResults["" + offset] = r;
-                       $(rep).find("a.navigate").each(function() {
-                           $(this).click(function() {
-                               return self.search(this.name);
-                           })});
-                       $(rep).find("tr.click").each(function() {
-                           $(this).click(function() {
-                               self.relate(this);
-                               return false;
-                           })});
+                       self.bindEvents(rep);
                    }
                }
               });
@@ -82,13 +75,23 @@
        this.log("reusing " + offset);
        $(rep).empty();
        $(rep).append(result);
+       self.bindEvents(rep);
     }
-
-
-
     return false;
 }
 
+MMBaseSearcher.prototype.bindEvents = function(rep) {
+    var self = this;
+    $(rep).find("a.navigate").each(function() {
+       $(this).click(function() {
+           return self.search(this.name);
+       })});
+    $(rep).find("tr.click").each(function() {
+       $(this).click(function() {
+           self.relate(this);
+           return false;
+       })});
+}
 /**
  * Moves a node from the 'unrelated' repository to the list of related nodes.
  */
@@ -165,18 +168,18 @@
     $("body").find("div.mm_related")
     .each(function() {
        var parent = this;
-       console.log("found " + parent);
        var anchor = $(parent).find("> a.search")[0];
-       console.log(anchor);
        anchor.searcher = new MMBaseSearcher(parent);
        $(anchor).click(function() {
            return this.searcher.search(0);
        });
+       if (anchor.search.canUnrelate) {
        $(parent).find("tr.click").each(function() {
            $(this).click(function() {
                anchor.searcher.unrelate(this);
                return false;
            })});
+       }
     });
 
 });


Index: relate.jspx
===================================================================
RCS file: /var/cvs/speeltuin/mihxil/wiki/mmbase/searchrelate/relate.jspx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- relate.jspx 1 Apr 2008 09:35:30 -0000       1.2
+++ relate.jspx 1 Apr 2008 11:38:13 -0000       1.3
@@ -17,6 +17,14 @@
           Queries.addToResult(current, n);
         </jsp:scriptlet>
       </mm:listnodes>
+      <!--
+          Not yet supported
+      <mm:listnodes referid="unrelated" jspvar="n">
+        <jsp:scriptlet>
+          Queries.removeFromResult(current, n);
+        </jsp:scriptlet>
+      </mm:listnodes>
+      -->
     </mm:cloud>
   </mm:content>
 </div>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to