| 1 |
import {Core} from "../Core"; |
| 2 |
import {Lightbox} from "./Lightbox"; |
| 3 |
|
| 4 |
export class PhotonicVenoBox extends Lightbox { |
| 5 |
constructor() { |
| 6 |
super(); |
| 7 |
} |
| 8 |
|
| 9 |
soloImages() { |
| 10 |
const solos = super.soloImages(); |
| 11 |
let idIndex = 1; |
| 12 |
solos.forEach(solo => { |
| 13 |
if (solo.getAttribute('id') == null) { |
| 14 |
solo.setAttribute('id', 'photonic-venobox-' + idIndex); |
| 15 |
idIndex++; |
| 16 |
} |
| 17 |
if (solo.getAttribute('data-gall') == null) { |
| 18 |
solo.setAttribute('data-gall', 'photonic-solo-gallery'); |
| 19 |
} |
| 20 |
}); |
| 21 |
}; |
| 22 |
|
| 23 |
hostedVideo(a) { |
| 24 |
const self = this; |
| 25 |
const html5 = a.getAttribute('href').match(new RegExp(/(\.mp4|\.webm|\.ogg)/i)), |
| 26 |
css = a.classList.contains('photonic-lb'); |
| 27 |
|
| 28 |
if (html5 !== null && !css) { |
| 29 |
a.classList.add(Photonic_JS.lightbox_library + "-html5-video"); |
| 30 |
self.modifyAdditionalVideoProperties(a); |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
changeVideoURL(element, regular, embed) { |
| 35 |
element.setAttribute('href', embed); // Don't need this for Venobox, but embeds are the only type that support "start" or "t" parameters |
| 36 |
}; |
| 37 |
|
| 38 |
modifyAdditionalVideoProperties(anchor) { |
| 39 |
if (anchor != null && anchor instanceof Element && anchor.tagName === 'A') { |
| 40 |
anchor.setAttribute('data-vbtype', 'video'); |
| 41 |
if (anchor.getAttribute('id') == null) { |
| 42 |
anchor.setAttribute('id', 'photonic-venobox-video-' + this.videoIndex); |
| 43 |
this.videoIndex++; |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
initialize(selector, destroy) { |
| 49 |
this.handleSolos(); |
| 50 |
const self = this; |
| 51 |
|
| 52 |
let selection; |
| 53 |
if (selector == null) { |
| 54 |
selection = document.querySelectorAll('.photonic-level-1-container'); |
| 55 |
} |
| 56 |
else if (selector instanceof NodeList) { |
| 57 |
selection = selector; |
| 58 |
} |
| 59 |
else if (selector instanceof Element) { |
| 60 |
selection = [selector]; |
| 61 |
} |
| 62 |
else { |
| 63 |
selection = document.querySelectorAll(selector); |
| 64 |
} |
| 65 |
|
| 66 |
selection.forEach(function (current) { |
| 67 |
const galleryId = current.getAttribute('id'); |
| 68 |
|
| 69 |
if (destroy) { |
| 70 |
} |
| 71 |
|
| 72 |
const lightbox = new VenoBox({ |
| 73 |
selector: '#' + galleryId + ' a.photonic-lb', |
| 74 |
titleattr: 'data-title', |
| 75 |
numeration: true, |
| 76 |
share: Photonic_JS.social_media, |
| 77 |
infinigall: Photonic_JS.lightbox_loop, |
| 78 |
customClass: Photonic_JS.vb_disable_vertical_scroll ? 'no-scroll' : '', |
| 79 |
titlePosition: Photonic_JS.vb_title_position, |
| 80 |
titleStyle: Photonic_JS.vb_title_style, |
| 81 |
onPreOpen: (a) => { |
| 82 |
self.setHash(a); |
| 83 |
}, |
| 84 |
onNavComplete: (obj, idx, theNext, thePrev) => { |
| 85 |
self.setHash(obj); |
| 86 |
}, |
| 87 |
onPreClose: () => { |
| 88 |
self.unsetHash(); |
| 89 |
}, |
| 90 |
}); |
| 91 |
|
| 92 |
let thumbs; |
| 93 |
thumbs = current.querySelectorAll('a.photonic-lb'); |
| 94 |
let rel = ''; |
| 95 |
if (thumbs.length > 0) { |
| 96 |
rel = thumbs[0].getAttribute('data-gall'); |
| 97 |
Core.addToLightboxList(rel, lightbox); |
| 98 |
} |
| 99 |
}); |
| 100 |
|
| 101 |
if (document.querySelector('.photonic-venobox-solo, .venobox-video, .venobox-html5-video') && !destroy) { |
| 102 |
new VenoBox({ |
| 103 |
selector: '.photonic-venobox-solo, .venobox-video, .venobox-html5-video', |
| 104 |
numeration: true, |
| 105 |
share: Photonic_JS.social_media, |
| 106 |
infinigall: Photonic_JS.lightbox_loop, |
| 107 |
customClass: Photonic_JS.vb_disable_vertical_scroll ? 'no-scroll' : '', |
| 108 |
titlePosition: Photonic_JS.vb_title_position, |
| 109 |
titleStyle: Photonic_JS.vb_title_style, |
| 110 |
}); |
| 111 |
} |
| 112 |
}; |
| 113 |
|
| 114 |
initializeForNewContainer(containerId) { |
| 115 |
this.initialize(containerId); |
| 116 |
} |
| 117 |
} |
| 118 |
|