Addressing notmasteryet's comments

This commit is contained in:
Saebekassebil 2011-12-22 11:29:27 +01:00
parent c714c782cc
commit 12e2dcd775
3 changed files with 32 additions and 41 deletions

View File

@ -379,7 +379,6 @@ var Page = (function PageClosure() {
item.textAlignment = getInheritableProperty(annotation, 'Q'); item.textAlignment = getInheritableProperty(annotation, 'Q');
item.flags = getInheritableProperty(annotation, 'Ff') || 0; item.flags = getInheritableProperty(annotation, 'Ff') || 0;
break; break;
case 'Text': case 'Text':
var content = annotation.get('Contents'); var content = annotation.get('Contents');
var title = annotation.get('T'); var title = annotation.get('T');
@ -387,7 +386,6 @@ var Page = (function PageClosure() {
item.title = stringToPDFString(title || ''); item.title = stringToPDFString(title || '');
item.name = annotation.get('Name').name; item.name = annotation.get('Name').name;
break; break;
default: default:
TODO('unimplemented annotation type: ' + subtype.name); TODO('unimplemented annotation type: ' + subtype.name);
break; break;

View File

@ -251,29 +251,25 @@ canvas {
position: absolute; position: absolute;
} }
.annotComment > .annotImageComment { .annotComment > img {
background: transparent url('./images/text.svg') no-repeat left top; position: absolute;
background-size: 75% 75%;
} }
.annotComment > .annotImageCheck { .annotComment > img:hover {
background: transparent url('./images/check.svg') no-repeat left top;
background-size: 75% 75%;
}
.annotComment > .annotImage:hover {
cursor: pointer; cursor: pointer;
opacity: 0.7; opacity: 0.7;
} }
.annotComment > .annotDetails { .annotComment > div {
display: none;
padding: 0.2em; padding: 0.2em;
max-width: 20em; max-width: 20em;
background-color: #F1E47B; background-color: #F1E47B;
box-shadow: 0px 2px 10px #333;
-moz-box-shadow: 0px 2px 10px #333;
-webkit-box-shadow: 0px 2px 10px #333;
} }
.annotComment > .annotDetails > h1 { .annotComment > div > h1 {
font-weight: normal; font-weight: normal;
font-size: 1.2em; font-size: 1.2em;
border-bottom: 1px solid #000000; border-bottom: 1px solid #000000;

View File

@ -476,40 +476,39 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
return element; return element;
} }
function createCommentAnnotation(type, item) { function createCommentAnnotation(type, item) {
var annotContainer = document.createElement('section'); var container = document.createElement('section');
annotContainer.className = 'annotComment'; container.className = 'annotComment';
var annotImage = createElementWithStyle('div', item);
annotImage.className = 'annotImage annotImage' + type;
var annotDetails = document.createElement('div');
annotDetails.className = 'annotDetails';
var annotTitle = document.createElement('h1');
var annotContent = document.createElement('p');
var image = createElementWithStyle('img', item);
image.src = './images/' + type.toLowerCase() + '.svg';
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); var offsetPos = Math.floor(item.x - view.x + item.width);
annotDetails.style.left = (offsetPos * scale) + 'px'; content.style.left = (offsetPos * scale) + 'px';
annotDetails.style.top = (Math.floor(item.y - view.y) * scale) + 'px'; content.style.top = (Math.floor(item.y - view.y) * scale) + 'px';
annotTitle.textContent = item.title; title.textContent = item.title;
if (!item.content) { if (!item.content) {
annotContent.style.display = 'none'; content.setAttribute('hidden', true);
} else { } else {
annotContent.innerHTML = item.content.replace('\n', '<br />'); text.innerHTML = item.content.replace('\n', '<br />');
annotImage.addEventListener('mouseover', function() { image.addEventListener('mouseover', function annotationImageOver() {
this.nextSibling.style.display = 'block'; this.nextSibling.removeAttribute('hidden');
}, true); }, false);
annotImage.addEventListener('mouseout', function() { image.addEventListener('mouseout', function annotationImageOut() {
this.nextSibling.style.display = 'none'; this.nextSibling.setAttribute('hidden', true);
}, true); }, false);
} }
annotDetails.appendChild(annotTitle); content.appendChild(title);
annotDetails.appendChild(annotContent); content.appendChild(text);
annotContainer.appendChild(annotImage); container.appendChild(image);
annotContainer.appendChild(annotDetails); container.appendChild(content);
return annotContainer; return container;
} }
var items = content.getAnnotations(); var items = content.getAnnotations();
@ -523,9 +522,7 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
bindLink(link, ('dest' in item) ? item.dest : null); bindLink(link, ('dest' in item) ? item.dest : null);
div.appendChild(link); div.appendChild(link);
break; break;
case 'Text': case 'Text':
case 'Check':
var comment = createCommentAnnotation(item.name, item); var comment = createCommentAnnotation(item.name, item);
if (comment) if (comment)
div.appendChild(comment); div.appendChild(comment);