Update of /var/cvs/applications/searchrelate/templates
In directory james.mmbase.org:/tmp/cvs-serv29442

Modified Files:
        Searcher.js.jsp 
Log Message:
added some ready() static function which can e.g. be used to add 
'relateCallBack' functions


See also: http://cvs.mmbase.org/viewcvs/applications/searchrelate/templates


Index: Searcher.js.jsp
===================================================================
RCS file: /var/cvs/applications/searchrelate/templates/Searcher.js.jsp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Searcher.js.jsp     15 Apr 2008 13:39:56 -0000      1.6
+++ Searcher.js.jsp     15 Apr 2008 14:03:37 -0000      1.7
@@ -11,7 +11,7 @@
 
  *
  * @author Michiel Meeuwissen
- * @version $Id: Searcher.js.jsp,v 1.6 2008/04/15 13:39:56 michiel Exp $
+ * @version $Id: Searcher.js.jsp,v 1.7 2008/04/15 14:03:37 michiel Exp $
  */
 
 $(document).ready(function(){
@@ -40,7 +40,6 @@
 }
 
 
-
 function MMBaseRelater(d) {
     this.div          = d;
     this.related       = {};
@@ -62,10 +61,22 @@
     this.logger.debug("setting up repository");
     this.repository    = $(d).find(".mm_relate_repository")[0];
     if (this.repository != null) this.addSearcher(this.repository, 
"repository");
+    this.relateCallBack = null;
+    for (var i = 0; i < MMBaseRelater.readyFunctions.length; i++) {
+       var fun =  MMBaseRelater.readyFunctions[i];
+       fun(this);
+    }
+}
+
+MMBaseRelater.readyFunctions = [];
+
 
+MMBaseRelater.ready = function(fun) {
+    MMBaseRelater.readyFunctions[MMBaseRelater.readyFunctions.length] = fun;
 }
 
 
+
 MMBaseRelater.prototype.addSearcher = function(el, type) {
     var relater = this;
     if ($(el).hasClass("searchable")) {
@@ -158,7 +169,7 @@
 
 MMBaseRelater.prototype.bindEvents = function(rep, type) {
     var self = this;
-    if (type == "repository" && self.current != null) {
+    if (type == "repository") {
        $(rep).find("tr.click").each(function() {
            $(this).click(function() {
                self.relate(this);
@@ -206,9 +217,10 @@
     this.unrelated[number] = null;
 
     // Set up HTML
-    var current =  $(this.div).find("div.mm_relate_current div.searchresult 
table tbody");
-    this.logger.debug(current[0]);
-    current.append(tr);
+    if (this.current != null) {
+       var currentList =  this.current.find("div.searchresult table tbody");
+       this.logger.debug(currentList[0]);
+       currentList.append(tr);
 
     // Classes
     if ($(tr).hasClass("removed")) {
@@ -220,10 +232,15 @@
 
     // Events
     $(tr).unbind();
+
     var self = this;
     $(tr).click(function() {
        self.unrelate(this);
     });
+    }
+    if (this.relateCallBack != null) {
+       this.relateCallBack(tr);
+    }
 }
 
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to