]> git.parisson.com Git - pdf.js.git/commitdiff
Fix annotations; add text annotation icon
authorYury Delendik <ydelendik@mozilla.com>
Tue, 17 Apr 2012 20:33:15 +0000 (15:33 -0500)
committerYury Delendik <ydelendik@mozilla.com>
Tue, 17 Apr 2012 20:33:15 +0000 (15:33 -0500)
src/core.js
web/images/text.svg [new file with mode: 0644]
web/viewer.js

index 2734d0eef7c19a6d3df6cf23d3c48a2a72a366f3..90a2c9733a8d0b2bace38402ad9965f228a4ac96 100644 (file)
@@ -283,7 +283,8 @@ var Page = (function PageClosure() {
             var title = annotation.get('T');
             item.content = stringToPDFString(content || '');
             item.title = stringToPDFString(title || '');
-            item.name = annotation.get('Name').name;
+            item.name = !annotation.has('Name') ? 'Note' :
+              annotation.get('Name').name;
             break;
           default:
             TODO('unimplemented annotation type: ' + subtype.name);
diff --git a/web/images/text.svg b/web/images/text.svg
new file mode 100644 (file)
index 0000000..25df8f4
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<svg
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   height="40"
+   width="40"
+   id="svg2995"
+   version="1.1">
+  
+  <rect
+     style="fill:#f1e47b;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-opacity:1"
+     id="rect3009"
+     width="30.169491"
+     height="24.576269"
+     x="4.237288"
+     y="6.7796612" />
+  <rect
+     style="fill:#000000;fill-opacity:1;stroke:none"
+     id="rect3781"
+     width="23.38983"
+     height="1.1864407"
+     x="7.6271186"
+     y="11.389831" />
+  <rect
+     style="fill:#000000;fill-opacity:1;stroke:none"
+     id="rect3781-1"
+     width="23.38983"
+     height="0.67796612"
+     x="7.6271191"
+     y="21.61017" />
+  <rect
+     style="fill:#000000;fill-opacity:1;stroke:none"
+     id="rect3781-7"
+     width="23.38983"
+     height="0.67796612"
+     x="7.4576273"
+     y="26.152542" />
+  <rect
+     style="fill:#000000;fill-opacity:1;stroke:none"
+     id="rect3781-1-4"
+     width="23.38983"
+     height="0.67796612"
+     x="7.6271186"
+     y="17.033899" />
+</svg>
index 3233371cc25d85435777df0ad4eeb8155c0dd0b7..f5bb9552f70dffc58d2d6b5add635a4e80bb51ae 100644 (file)
@@ -805,17 +805,20 @@ var PageView = function pageView(container, pdfPage, id, scale,
       container.className = 'annotComment';
 
       var image = createElementWithStyle('img', item);
+      var type = item.type;
+      var rect = viewport.convertToViewportRectangle(item.rect);
+      rect = PDFJS.Util.normalizeRect(rect);
       image.src = kImageDirectory + type.toLowerCase() + '.svg';
+      image.alt = '[' + type + ' Annotation]';
       var content = document.createElement('div');
       content.setAttribute('hidden', true);
       var title = document.createElement('h1');
       var text = document.createElement('p');
-      var offsetPos = Math.floor(item.x - view.x + item.width);
-      content.style.left = (offsetPos * scale) + 'px';
-      content.style.top = (Math.floor(item.y - view.y) * scale) + 'px';
+      content.style.left = Math.floor(rect[2]) + 'px';
+      content.style.top = Math.floor(rect[1]) + 'px';
       title.textContent = item.title;
 
-      if (!item.content) {
+      if (!item.content && !item.title) {
         content.setAttribute('hidden', true);
       } else {
         var e = document.createElement('span');
@@ -828,11 +831,11 @@ var PageView = function pageView(container, pdfPage, id, scale,
         }
         text.appendChild(e);
         image.addEventListener('mouseover', function annotationImageOver() {
-           this.nextSibling.removeAttribute('hidden');
+           content.removeAttribute('hidden');
         }, false);
 
         image.addEventListener('mouseout', function annotationImageOut() {
-           this.nextSibling.setAttribute('hidden', true);
+           content.setAttribute('hidden', true);
         }, false);
       }