Handle text direction when merging errietta/3970 errietta/merging
Errietta Kostala [Wed, 27 May 2015 15:35:04 +0000 (15:35 +0000)]
lib/stemmaweb/Controller/Relation.pm
root/js/relationship.js

index fd5a452..a8e63d0 100644 (file)
@@ -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,
index bf62e6b..f011bc6 100644 (file)
@@ -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();
     }
 }