Implemented Comment and Check annotation. Correcting some typos in last commit

This commit is contained in:
Saebekassebil 2011-12-21 23:22:07 +01:00
parent ca7d44c646
commit 4a661e1735
5 changed files with 96 additions and 3 deletions

View file

@ -475,6 +475,41 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
element.style.height = Math.ceil(item.height * scale) + 'px';
return element;
}
function createCommentAnnotation(type, item) {
var annotContainer = document.createElement('section');
annotContainer.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');
annotDetails.style.left = (Math.floor(item.x - view.x + item.width) * scale) + 'px';
annotDetails.style.top = (Math.floor(item.y - view.y) * scale) + 'px';
annotTitle.textContent = item.title;
if(!item.content) {
annotContent.style.display = 'none';
} else {
annotContent.innerHTML = item.content.replace('\n', '<br />');
annotImage.addEventListener('mouseover', function() {
this.nextSibling.style.display = 'block';
}, true);
annotImage.addEventListener('mouseout', function() {
this.nextSibling.style.display = 'none';
}, true);
}
annotDetails.appendChild(annotTitle);
annotDetails.appendChild(annotContent);
annotContainer.appendChild(annotImage);
annotContainer.appendChild(annotDetails);
return annotContainer;
}
var items = content.getAnnotations();
for (var i = 0; i < items.length; i++) {
@ -487,6 +522,13 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
bindLink(link, ('dest' in item) ? item.dest : null);
div.appendChild(link);
break;
case 'Text':
case 'Check':
var comment = createCommentAnnotation(item.name, item);
if(comment)
div.appendChild(comment);
break;
}
}
}