Set venobox type (image, iframe etc) through option when initializing
Closed this issue · 1 comments
Hello,
I would like to suggest I think a useful enhacement. The data-vbtype should also be settable in the options when initializing venobox like :
new VenoBox({ selector: '.ifr-modal', vbtype: 'iframe' });
I didn't manage to find any perhaps undocumented option for it.
I think it would be useful for different scenarios. In my case, for example, I have a client and he has a content administration for managing the content of his site. He can add links via a rich text editor (CKEditor) and in the link creation dialog he can specify classes to be applied to the link but cannot add data attributes / values. I think this could be a common case for other rich text editors too. I cannot ask the client to open the source mode and add a data-vbtype on the link but I can tell him to add a class through the dialog named lets say 'veno-iframe' and then I have added in the website code waiting for link with this class to be opened as venobox iframes by using code like the sample above.
I think it would add an extra level of versatility.
Hi, you could assign the data-vbtype before initializing VenoBox with a small function.
Let's say we have a list of links, all of them with the class .venobox, but some link images and some iFrames:
<a href="#" class="venobox ifr-modal">iFrame</a>
<a href="#" class="venobox">image</a>
<a href="#" class="venobox ifr-modal">iFrame</a>
<script>
const iframelinks = document.queryselectorAll(".ifr-modal");
iframelinks.forEach(function(iframelink){
iframelink.dataset.vbtype = "iframe";
});
new VenoBox({ selector: ".venobox" });
</script>