-
Notifications
You must be signed in to change notification settings - Fork 508
/
thumbnail.js
40 lines (36 loc) · 1.09 KB
/
thumbnail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Thumbnail {
static wrapImgInContainer(img, container_style_class) {
const container = document.createElement('div')
container.className = container_style_class
container.appendChild(img)
return container
}
static addSPButtonToContainer(
container,
button_id,
title,
callbackFunction,
param1
) {
const elem = document.getElementById(button_id)
const clone = elem.cloneNode(true)
const button = clone
button.style.display = null
button.removeAttribute('id')
button.setAttribute('title', title)
// Create button element
button.className = 'thumbnail-image-button'
if (callbackFunction.constructor.name === 'AsyncFunction') {
button.addEventListener(
'click',
async () => await callbackFunction(param1)
)
} else {
button.addEventListener('click', () => callbackFunction(param1))
}
container.appendChild(button)
}
}
module.exports = {
Thumbnail,
}