Author: andre Date: 2010-06-24 19:43:12 +0200 (Thu, 24 Jun 2010) New Revision: 42693
Modified: mmbase/branches/MMBase-1_9/applications/searchrelate/example-webapp/src/main/webapp/relate-my_editors.jspx Log: beautified it a bit, made example clearer Modified: mmbase/branches/MMBase-1_9/applications/searchrelate/example-webapp/src/main/webapp/relate-my_editors.jspx =================================================================== --- mmbase/branches/MMBase-1_9/applications/searchrelate/example-webapp/src/main/webapp/relate-my_editors.jspx 2010-06-24 15:26:50 UTC (rev 42692) +++ mmbase/branches/MMBase-1_9/applications/searchrelate/example-webapp/src/main/webapp/relate-my_editors.jspx 2010-06-24 17:43:12 UTC (rev 42693) @@ -8,70 +8,51 @@ xmlns:mm-sr="http://www.mmbase.org/tags/mm/searchrelate" xmlns:mm="http://www.mmbase.org/mmbase-taglib-2.0"> -<link href="${mm:link('/sr/css/searchrelate.css')}" rel="stylesheet" /> +<link href="${mm:link('/mmbase/searchrelate/styles/my_editors.css')}" rel="stylesheet" /> + <script type="text/javascript"> +// the edit icon links to the edit page in my_editors var editor = '<mm:link page="/mmbase/edit/my_editors/edit_object.jsp" />'; + $(document).ready(function() { - $("div.mm_related").bind("mmsrPaged", function (e, status, relater, obj, a) { - // [status, self.relater, self, anchor] - console.log("1. paged event: " + e + " st: " + status + " relater: " + relater + " self: " + obj + " a: " + a); - }); /* when ready */ $("div.mm_related").bind("mmsrRelaterReady", function (e, relater) { - - $(relater.div).find('tr.relation').hide(); - - if (relater.canEditrelations) { - - console.log("relater can edit"); - - /* edit node */ - $(relater.div).find('img.editnode').click(function(ev) { - ev.stopPropagation(); - var img = ev.target; - var href = $(img).parent('a').attr("href"); - var node = href.substring(href.lastIndexOf("_") + 1); // edit.jsp#node_348 - window.location = editor + "?nr=" + node; - }); - - /* edit relation */ - $(relater.div).find('img.editrelation').click(function(ev) { - ev.stopPropagation(); - ev.preventDefault(); - var img = ev.target; - var nr = $(img).parents('tr').find("td.node.number").text(); - //console.log('clicked: ' + nr); - $('div.mm_relate_current').find("tr.node_" + nr).toggle(); - }); - } - - + bind(relater); }); + + /* paging */ + $("div.mm_related").bind("mmsrPaged", function (e, status, relater, obj, a) { + bind(relater); + }); + +}); - - /* commit */ - $("div.mm_related").bind("mmsrCommitted", function (e, submitter, status, relater, related, unrelated, relations) { - - if (status == "failed") { - $(relater.div).find('div.mm_relate_repository').prepend('<div class="error">Some error!</div>'); - } +function bind(relater) { + if (relater.canEditrelations) { + $(relater.div).find('tr.relation').hide(); - if (status == "success") { - var msg = ""; - if (unrelated) msg += " Removed relation(s) with node #" + unrelated + ". "; - if (related) msg += " Saved new relation(s) with node #" + related + ". "; - //if (relations) msg += " Removed " + relations + " relation(s). "; - - $(relater.div).find('div.mm_relate_repository').prepend('<div class="message">' + msg + '</div>'); - - } + /* edit node */ + $(relater.div).find('img.editnode').click(function(ev) { + ev.stopPropagation(); + ev.preventDefault(); + var img = ev.target; + var href = $(img).parent('a').attr("href"); + var node = href.substring(href.lastIndexOf("_") + 1); // f.e. edit.jsp#node_348 + window.location = editor + "?nr=" + node; + }); - $(relater.div).find('tr.relation').hide(); - - }); - -}); + /* edit relation */ + $(relater.div).find('img.editrelation').click(function(ev) { + ev.stopPropagation(); + ev.preventDefault(); + var img = ev.target; + var nr = $(img).parents('tr').find("td.node.number").text(); + console.log('clicked: ' + nr); + $('div.mm_relate_current').find("tr.node_" + nr).toggle(); + }); + } +} </script> @@ -103,7 +84,7 @@ create="true" relations="true" select="true" - customizedir="/editors/sr/" + customizedir="/mmbase/searchrelate/styles/" submit="#save" extracreate=""> <jsp:attribute name="currentTitle"><b>News</b></jsp:attribute> _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs