From: Errietta Kostala Date: Wed, 27 May 2015 15:35:04 +0000 (+0000) Subject: Handle text direction when merging X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmaweb.git;a=commitdiff_plain;h=2a65f5c92fc04069b827194aa591a5795bc9b81b Handle text direction when merging --- diff --git a/lib/stemmaweb/Controller/Relation.pm b/lib/stemmaweb/Controller/Relation.pm index fd5a452..a8e63d0 100644 --- a/lib/stemmaweb/Controller/Relation.pm +++ b/lib/stemmaweb/Controller/Relation.pm @@ -531,6 +531,9 @@ sub compress :Chained('text') :PathPart :Args(0) { $m->save($collation); + if ($collation->direction eq 'RL') { + @nodes = reverse @nodes; + } $c->stash->{'result'} = { success => 1, diff --git a/root/js/relationship.js b/root/js/relationship.js index bf62e6b..f011bc6 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -875,16 +875,30 @@ function compress_nodes(readings) { //[].slice.call(s.getElementsByTagName('title')).find(function(elem){return elem.textContent=='r64.2->r66.2'}).parentNode.remove() - console.log(svg_root, svg_root_element); + var titles = svg_root.getElementsByTagName('title'); + var titlesArray = [].slice.call(titles); - console.log(rid); + if (titlesArray.length > 0) { + var title = titlesArray.find(function(elem){ + return elem.textContent === rid; + }); + + if (title && title.parentNode) { + title.parentNode.remove(); + } + } - [].slice.call(svg_root.getElementsByTagName('title')) - .find(function(elem){ - return elem.textContent==rid - }).parentNode.remove(); + var x = parseInt(first[0].getAttribute('cx'), 10); + + first[0].setAttribute('rx', 4.5 * first_title.textContent.length); + + if (text_direction !== "BI") { + first[0].setAttribute('cx', x + first_title.textContent.length + 20); + first_title.setAttribute('x', first[0].getAttribute('cx')); + } - node.parent().remove(); + merge_node(readings[i], readings[0]); + //node.parent().remove(); } }