<?php
use Contao\Template;

// Add the colorbox style sheet
$GLOBALS['TL_CSS']['jbox'] = 'bundles/vonrotenbergjbox/jBox.min.css|static';
$GLOBALS['TL_CSS']['jbox_image'] = 'bundles/vonrotenbergjbox/plugins/jBox.Image.css|static';
$GLOBALS['TL_CSS']['jbox_custom'] = 'bundles/vonrotenbergjbox/jBox.custom.min.css|static';

echo Template::generateScriptTag('bundles/vonrotenbergjbox/jBox.all.min.js',false,null);
?>

<script>

 jQuery(function($) {
    $('a[data-jbox-iframe],nav a.modal-iframe').map(function() {
      new jBox('Modal', {
      	attach: $(this),
      	preventDefault: true,
        title: $(this).data('jbox-title') ? '<h3>' + $(this).data('jbox-title') + '</h3>' : ($(this).attr('title') ? '<h3>' + $(this).attr('title') + '</h3>' : ''),
        // content: '<iframe frameborder="0" class="jBox-iframe" src="' + $(this).attr('href') + '"></iframe>',
        closeButton: 'title',
        width: 1200,
        height: '90%',
        theme: 'Iframe',
        animation: {open: 'zoomIn', close: 'slide:top'},
        onOpen: function() {
      	  this.setContent('<iframe frameborder="0" class="jBox-iframe" src="' + this.source[0].getAttribute('href') + '"></iframe>');
        }
      });
    });

    $('a[data-jbox-imagemodal]').map(function() {
      var $self = $(this);
      new jBox('Modal', {
        attach: $(this),
        preventDefault: true,
        title: $(this).data('jbox-title') ? '<h3>' + $(this).data('jbox-title') + '</h3>' : ($(this).attr('title') ? '<h3>' + $(this).attr('title') + '</h3>' : ''),
        content: '<img src="' + $(this).attr('href') + '">',
        onInit: function() {
          var image = new Image();
          image.src = $self.attr('href');
        },
        onOpen: function() {
          this.position();
        },
        closeButton: 'title',
        width: 710,
        maxWidth: 710
      });
    });

    $lbImages = $('[data-lightbox]').filter(function(index) {
      if (!$(this).parents().eq(3).hasClass('slick-cloned'))
      {
        return true;
      }
    });

    new jBox('Image', {
      // Put custom options here
      gallery: 'data-lightbox',
      attach: $lbImages,
      imageCounter: true,
      imageSize: 'auto'
    });

    new jBox('Tooltip', {
      attach: '[data-tooltip-title]',
      // pointer: 'right:60',
      getContent: 'data-tooltip-title',
      maxWidth: 250,
      /*position: {
        x: 'right',
        y: 'bottom'
      },
      offset: {
        x: -5,
        y: 5
      },*/
      outside: 'x',
      zIndex: 4000,
      adjustPosition: true,
      adjustTracker: true,
      closeOnClick: true
    });

  });
</script>