|
|
|
@ -45,26 +45,27 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
@@ -45,26 +45,27 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
|
|
|
style.fontFamily = fontFamily + fallbackName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO(mack): Remove this, it's not really that helpful.
|
|
|
|
|
function getEmptyContainer(tagName, rect, borderWidth) { |
|
|
|
|
var bWidth = borderWidth || 0; |
|
|
|
|
var element = document.createElement(tagName); |
|
|
|
|
element.style.borderWidth = bWidth + 'px'; |
|
|
|
|
var width = rect[2] - rect[0] - 2 * bWidth; |
|
|
|
|
var height = rect[3] - rect[1] - 2 * bWidth; |
|
|
|
|
element.style.width = width + 'px'; |
|
|
|
|
element.style.height = height + 'px'; |
|
|
|
|
return element; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function initContainer(item) { |
|
|
|
|
var container = getEmptyContainer('section', item.rect, item.borderWidth); |
|
|
|
|
container.style.backgroundColor = item.color; |
|
|
|
|
|
|
|
|
|
function initContainer(item, drawBorder) { |
|
|
|
|
var container = document.createElement('section'); |
|
|
|
|
var cstyle = container.style; |
|
|
|
|
var width = item.rect[2] - item.rect[0]; |
|
|
|
|
var height = item.rect[3] - item.rect[1]; |
|
|
|
|
|
|
|
|
|
var bWidth = item.borderWidth || 0; |
|
|
|
|
if (bWidth) { |
|
|
|
|
width = width - 2 * bWidth; |
|
|
|
|
height = height - 2 * bWidth; |
|
|
|
|
cstyle.borderWidth = bWidth + 'px'; |
|
|
|
|
var color = item.color; |
|
|
|
|
item.colorCssRgb = Util.makeCssRgb(Math.round(color[0] * 255), |
|
|
|
|
if (drawBorder && color) { |
|
|
|
|
cstyle.borderStyle = 'solid'; |
|
|
|
|
cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255), |
|
|
|
|
Math.round(color[1] * 255), |
|
|
|
|
Math.round(color[2] * 255)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
cstyle.width = width + 'px'; |
|
|
|
|
cstyle.height = height + 'px'; |
|
|
|
|
|
|
|
|
|
var highlight = document.createElement('div'); |
|
|
|
|
highlight.className = 'annotationHighlight'; |
|
|
|
@ -79,7 +80,11 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
@@ -79,7 +80,11 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) { |
|
|
|
|
var element = getEmptyContainer('div', item.rect, 0); |
|
|
|
|
var element = document.createElement('div'); |
|
|
|
|
var width = item.rect[2] - item.rect[0]; |
|
|
|
|
var height = item.rect[3] - item.rect[1]; |
|
|
|
|
element.style.width = width + 'px'; |
|
|
|
|
element.style.height = height + 'px'; |
|
|
|
|
element.style.display = 'table'; |
|
|
|
|
|
|
|
|
|
var content = document.createElement('div'); |
|
|
|
@ -109,7 +114,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
@@ -109,7 +114,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
|
|
|
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var container = initContainer(item); |
|
|
|
|
var container = initContainer(item, false); |
|
|
|
|
container.className = 'annotText'; |
|
|
|
|
|
|
|
|
|
var image = document.createElement('img'); |
|
|
|
@ -218,12 +223,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
@@ -218,12 +223,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getHtmlElementForLinkAnnotation(item) { |
|
|
|
|
var container = initContainer(item); |
|
|
|
|
var container = initContainer(item, true); |
|
|
|
|
container.className = 'annotLink'; |
|
|
|
|
|
|
|
|
|
container.style.borderColor = item.colorCssRgb; |
|
|
|
|
container.style.borderStyle = 'solid'; |
|
|
|
|
|
|
|
|
|
var link = document.createElement('a'); |
|
|
|
|
link.href = link.title = item.url || ''; |
|
|
|
|
|
|
|
|
|