2021-06-15 14:26:38 +02:00
|
|
|
const QuickPost = function (w) {
|
|
|
|
this.window = w
|
2021-03-29 13:58:05 +02:00
|
|
|
}
|
|
|
|
|
2021-06-15 14:26:38 +02:00
|
|
|
QuickPost.prototype.init = function () {
|
|
|
|
const doc = this.window.document
|
2021-03-29 13:58:05 +02:00
|
|
|
|
2021-06-15 14:26:38 +02:00
|
|
|
const images = doc.querySelectorAll('.quick-image img')
|
2021-03-29 13:58:05 +02:00
|
|
|
|
2021-06-15 14:26:38 +02:00
|
|
|
for (let i = 0, len = images.length; i < len; i++) {
|
|
|
|
(function (image) {
|
|
|
|
const source = image.getAttribute('data-src')
|
|
|
|
const loader = new Image()
|
2021-03-29 13:58:05 +02:00
|
|
|
|
2021-06-15 14:26:38 +02:00
|
|
|
loader.onload = function () {
|
|
|
|
image.style.backgroundImage = 'url(' + source + ')'
|
|
|
|
image.style.backgroundSize = 'cover'
|
|
|
|
}
|
2021-03-29 13:58:05 +02:00
|
|
|
|
2021-06-15 14:26:38 +02:00
|
|
|
loader.src = source
|
|
|
|
})(images[i])
|
|
|
|
}
|
2021-03-29 13:58:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = QuickPost
|