summaryrefslogtreecommitdiff
path: root/ext/js/display/structured-content-generator.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display/structured-content-generator.js')
-rw-r--r--ext/js/display/structured-content-generator.js43
1 files changed, 30 insertions, 13 deletions
diff --git a/ext/js/display/structured-content-generator.js b/ext/js/display/structured-content-generator.js
index cd4ea091..28f63f54 100644
--- a/ext/js/display/structured-content-generator.js
+++ b/ext/js/display/structured-content-generator.js
@@ -16,8 +16,7 @@
*/
class StructuredContentGenerator {
- constructor(templates, mediaLoader, document) {
- this._templates = templates;
+ constructor(mediaLoader, document) {
this._mediaLoader = mediaLoader;
this._document = document;
}
@@ -95,11 +94,29 @@ class StructuredContentGenerator {
(hasPreferredHeight ? preferredHeight * aspectRatio : width)
);
- const node = this._templates.instantiate('gloss-item-image');
- const imageContainer = node.querySelector('.gloss-image-container');
- const aspectRatioSizer = node.querySelector('.gloss-image-aspect-ratio-sizer');
- const image = node.querySelector('.gloss-image');
- const imageBackground = node.querySelector('.gloss-image-background');
+ const node = this._createElement('a', 'gloss-image-link');
+ node.target = '_blank';
+ node.rel = 'noreferrer noopener';
+
+ const imageContainer = this._createElement('span', 'gloss-image-container');
+ node.appendChild(imageContainer);
+
+ const aspectRatioSizer = this._createElement('span', 'gloss-image-aspect-ratio-sizer');
+ imageContainer.appendChild(aspectRatioSizer);
+
+ const imageBackground = this._createElement('span', 'gloss-image-background icon');
+ imageContainer.appendChild(imageBackground);
+
+ const image = this._createElement('img', 'gloss-image');
+ image.alt = '';
+ imageContainer.appendChild(image);
+
+ const overlay = this._createElement('span', 'gloss-image-container-overlay');
+ imageContainer.appendChild(overlay);
+
+ const linkText = this._createElement('span', 'gloss-image-link-text');
+ linkText.textContent = 'Image';
+ node.appendChild(linkText);
node.dataset.path = path;
node.dataset.dictionary = dictionary;
@@ -138,8 +155,10 @@ class StructuredContentGenerator {
// Private
- _createElement(tagName) {
- return this._document.createElement(tagName);
+ _createElement(tagName, className) {
+ const node = this._document.createElement(tagName);
+ node.className = className;
+ return node;
}
_createTextNode(data) {
@@ -165,16 +184,14 @@ class StructuredContentGenerator {
}
_createStructuredContentTableElement(tag, content, dictionary) {
- const container = this._createElement('div');
- container.classList = 'gloss-sc-table-container';
+ const container = this._createElement('div', 'gloss-sc-table-container');
const table = this._createStructuredContentElement(tag, content, dictionary, 'table', true, false);
container.appendChild(table);
return container;
}
_createStructuredContentElement(tag, content, dictionary, type, hasChildren, hasStyle) {
- const node = this._createElement(tag);
- node.className = `gloss-sc-${tag}`;
+ const node = this._createElement(tag, `gloss-sc-${tag}`);
switch (type) {
case 'table-cell':
{