Lightbox: Added auto-initialization when opening popup through JavaScript

Fixes #6020