Author: andre
Date: 2010-02-24 16:50:49 +0100 (Wed, 24 Feb 2010)
New Revision: 41159

Modified:
   
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
   
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
Log:
porting from 1.9

Modified: 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
 2010-02-24 15:45:20 UTC (rev 41158)
+++ 
mmbase/trunk/applications/searchrelate/src/main/resources/META-INF/tags/mm/searchrelate/relate.tagx
 2010-02-24 15:50:49 UTC (rev 41159)
@@ -23,11 +23,8 @@
                            description="An mmbase Query describing which list 
is considered to represent already 'related' nodes" />
 
   <jsp:directive.attribute name="submit"            type="java.lang.String"
-                           description="A jquery selector. The 'commit' action 
will be binded to the 'onclick' of the elements that match."  />
+                           description="A jQuery selector, if relate/unrelate 
should happen inmediate (default is inmediate). The 'commit' action will be 
binded to the 'onclick' event of elements that match." />
 
-  <jsp:directive.attribute name="instant"           type="java.lang.Boolean"
-                           description="Relating or unrelating should happen 
inmediate after clicking an item or not. Defaults to both relating and 
unrelating true. When false confirmation is needed via submit." />
-
   <jsp:directive.attribute name="unrelate"          type="java.lang.Boolean"
                            description="Whether, or not, the tools should also 
allow deletion of relations" />
 
@@ -113,8 +110,7 @@
   </script>
   <script type="text/javascript">
     $(document).ready(function() {
-    <c:if test="${! empty submit}">
-      <!-- if a submit attribute is given, commit the search/relate on click 
of that element -->
+    <c:if test="${! empty submit}"><!-- submit attribute given: commit 
search/relate on click of that element -->
          $("#mm_related_${sid} ${submit}").click(function(el) {
             return $("#mm_related_${sid}")[0].relater.commit(el); });</c:if>
       $("#mm_related_${sid}").each(function() {
@@ -126,7 +122,7 @@
     <c:if test="${! empty context}"> this.relater.setContext('${context}'); 
</c:if>
     
this.relater.setSessionName('${mm:property('org.mmbase.cloud.sessionname')}');
     <c:if test="${! empty current}">
-      if (this.relater.current != null) 
this.relater.current.searcher.maxNumber = ${current.maxNumber};
+      if (this.relater.current != null) { 
this.relater.current.searcher.maxNumber = ${current.maxNumber}; }
     </c:if>
     }
       })
@@ -137,7 +133,7 @@
       xmlns:fmt="http://java.sun.com/jsp/jstl/fmt";
       basename="org.mmbase.searchrelate.resources.searchrelate">
     <div id="mm_related_${sid}"
-         class="mm_related ${empty unrelate or ! unrelate ? '' : 
'can_unrelate'} ${empty relations or ! relations ? '' : 'can_editrelations'} 
${empty instant or instant == true ? 'instant' : ''} ${styleClass}">
+         class="mm_related ${empty unrelate or ! unrelate ? '' : 
'can_unrelate'} ${empty relations or ! relations ? '' : 'can_editrelations'} 
${!empty submit ? 'instant' : ''} ${styleClass}">
       <c:if test="${! empty transaction}">
         <span class="transactionname" style="display: 
none;">${transaction}</span>
       </c:if>

Modified: 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
===================================================================
--- 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
  2010-02-24 15:45:20 UTC (rev 41158)
+++ 
mmbase/trunk/applications/searchrelate/src/main/webapp/mmbase/searchrelate/Searcher.js.jsp
  2010-02-24 15:50:49 UTC (rev 41159)
@@ -91,6 +91,7 @@
         fun(this);
     }
     this.sessionName = null;
+    this.bindCommit();
     var self = this;
     $(this.div).trigger("mmsrRelaterReady", [self]);
 }
@@ -111,8 +112,6 @@
     MMBaseRelater.readyFunctions[MMBaseRelater.readyFunctions.length] = fun;
 }
 
-
-
 MMBaseRelater.prototype.addSearcher = function(el, type) {
     var relater = this;
     if ($(el).hasClass("searchable")) {
@@ -145,6 +144,20 @@
     }
 }
 
+MMBaseRelater.prototype.bindCommit = function() {
+    if (this.instant) {
+        $(this.div).bind("mmsrRelate", function (e, tr, relater) {
+            if (e) {
+                self.commit(e);
+            }
+        });
+        $(this.div).bind("mmsrUnrelate", function (e, tr, relater) {
+            if (e) {
+                self.commit(e);
+            }
+        });
+    }
+}
 
 MMBaseRelater.prototype.needsCommit = function() {
     var relatedNumbers   = this.getNumbers(this.related);
@@ -152,7 +165,6 @@
     return relatedNumbers != "" || unrelatedNumbers != "";
 }
 
-
 /**
  * Commits makes changes to MMBase. Depends on a jsp 
/mmbase/searchrelate/relate.jsp to do the actual work.
  * This jsp, in turn, depends on the query in the user's session which defines 
precisely what must happen.
@@ -392,7 +404,7 @@
     $(tr).unbind();
     var self = this;
     $(tr).click(function() {
-        self.relateIt(this)
+        self.relate(this)
     });
     $(this.div).trigger("mmsrUnrelate", [tr, this]);
 }

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to