Add title attribue if table cell title is very long

Change-Id: Icfe1f3838fca2afa27b14d8077b636b7efb5cd3a
diff --git a/dev/demo/matchdemo.js b/dev/demo/matchdemo.js
index 4264783..e1f0488 100644
--- a/dev/demo/matchdemo.js
+++ b/dev/demo/matchdemo.js
@@ -438,6 +438,49 @@
   "<span class=\"context-right\">" +
   "</span>";
 
+  // with cut
+  snippet = "<span title=\"cnx/l:meist\">" +
+  "  <span title=\"cnx/p:ADV\">" +
+  "    <span title=\"cnx/syn:@PREMOD\">" +
+  "      <span title=\"mate/l:meist\">" +
+  "        <span title=\"mate/p:ADV\">" +
+  "          <span title=\"opennlp/p:ADV\">meist</span>" +
+  "        </span>" +
+  "      </span>" +
+  "    </span>" +
+  "  </span>" +
+  "</span>" +
+  "<span title=\"cnx/l:deutlich\">" +
+  "  <span title=\"cnx/p:A\">" +
+  "    <span title=\"cnx/syn:@PREMOD\">" +
+  "      <span title=\"mate/l:deutlich\">" +
+  "        <span title=\"mate/m:degree:pos\">" +
+  "          <span title=\"mate/p:ADJD\">" +
+  "            <span title=\"opennlp/p:ADJD\">deutlich</span>" +
+  "          </span>" +
+  "        </span>" +
+  "      </span>" +
+  "    </span>" +
+  "  </span>" +
+  "</span>" +
+  "<span title=\"cnx/l:fähig\">" +
+  "  <span title=\"cnx/l:leistung\">" +
+  "    <span title=\"cnx/p:A\">" +
+  "      <span title=\"cnx/syn:@NH\">" +
+  "        <span title=\"mate/l:leistungsfähig\">" +
+  "          <span title=\"mate/m:degree:comp\">" +
+  "            <span title=\"mate/p:ADJD\">" +
+  "              <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
+  "            </span>" +
+  "          </span>" +
+  "        </span>" +
+  "      </span>" +
+  "    </span>" +
+  "  </span>" +
+  " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können."
+  "<span class=\"cutted\"><\/span>"
+  "</span>";
+  
   var treeSnippet =
   "<span class=\"context-left\"></span>" +
   "<span class=\"match\">" +
diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index d10aced..2004d4f 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -97,7 +97,9 @@
   ];
 
 
-  var snippet = "<span title=\"cnx/l:meist\">" +
+  var snippet = "<span class=\"context-left\"><\/span>"+
+      "<span class=\"match\">" +
+      "<span title=\"cnx/l:meist\">" +
       "  <span title=\"cnx/p:ADV\">" +
       "    <span title=\"cnx/syn:@PREMOD\">" +
       "      <span title=\"mate/l:meist\">" +
@@ -141,6 +143,9 @@
       "      </span>" +
       "    </span>" +
       "  </span>" +
+      "</span>" +
+      " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können." +
+      "<span class=\"cutted\"><\/span>" +
       "</span>";
 
   var treeSnippet =
@@ -445,7 +450,9 @@
   describe('KorAP.TableView', function () {
     beforeAll(beforeAllFunc);
     afterAll(afterAllFunc);  
-   
+
+    let longString = " und robust sind auch die anderen Traktoren, die hier der Übersicht wegen keine Erwähnung finden können.";
+    
     var table;
 
     var matchObj = matchClass.create(match);
@@ -479,11 +486,12 @@
     it('should parse into a table (async)', function () {
       expect(table).toBeTruthy();
 
-      expect(table.length()).toBe(3);
+      expect(table.length()).toBe(4);
 
       expect(table.getToken(0)).toBe("meist");
       expect(table.getToken(1)).toBe("deutlich");
       expect(table.getToken(2)).toBe("leistungsfähiger");
+      expect(table.getToken(3)).toBe(longString);
 
       expect(table.getValue(0, "cnx", "p")[0]).toBe("ADV");
       expect(table.getValue(0, "cnx", "syn")[0]).toBe("@PREMOD");
@@ -510,6 +518,9 @@
       expect(tr.children[3].classList.contains('mark')).toBeTruthy();
       expect(tr.children[4].firstChild.nodeValue).toBe('leistungsfähiger');
       expect(tr.children[4].classList.contains('mark')).toBeFalsy();
+      expect(tr.children[4].hasAttribute("title").toBeFalsy();
+      expect(tr.children[5].firstChild.nodeValue).toBe(longString);
+      expect(tr.children[5].getAttribute("title")).toBe(longString);
 
       // first row
       tr = e.children[1].children[0];
diff --git a/dev/js/src/match/table.js b/dev/js/src/match/table.js
index 1544637..61c100a 100644
--- a/dev/js/src/match/table.js
+++ b/dev/js/src/match/table.js
@@ -244,13 +244,19 @@
 
       // Add tokens
       for (var i in this._token) {
-        var c = tr.addCell('th', undefined, this.getToken(i));
+        let surface = this.getToken(i);
+        var c = tr.addCell('th', undefined, surface);
         if (this._mark[i]) {
           c.classList.add('mark');
           if (this._markE === undefined) {
             this._markE = c;
           };
         };
+
+        // In case the title is very long - add a title attribute
+        if (surface.length > 20) {
+          c.setAttribute("title", surface)
+        }
       };
       
       var tbody = table.addE('tbody');