templates/layout/customelement_bgimage_start.html5 line 82

Open in your IDE?
  1. <script>
  2. /* <![CDATA[ */
  3. <?php if($this->field('fullscreen-image')->value()): ?>
  4. function bgImageFullscreen_<?php echo $this->id?>() {
  5.     var windowHeight = jQuery(window).height();
  6.     var mobHeaderHeight = jQuery('.header.cloned').height();
  7.     if (jQuery(window).width() < 768)
  8.     {
  9.         var setNewHeightMobile = windowHeight - mobHeaderHeight;
  10.         jQuery('.ce_bgimage_<?php echo $this->id?>').height(setNewHeightMobile);
  11.     } else {
  12.         <?php if($this->field('offset')->value()): ?>
  13.             var offsetHeight_<?php echo $this->id?> = jQuery('<?php echo $this->field('offset')->value(); ?>').height();
  14.             var setNewHeight_<?php echo $this->id?> = windowHeight - offsetHeight_<?php echo $this->id?>;
  15.             jQuery('.ce_bgimage_<?php echo $this->id?>').height(setNewHeight_<?php echo $this->id?>);
  16.         <?php else: ?>
  17.             jQuery('.ce_bgimage_<?php echo $this->id?>').height(windowHeight);
  18.         <?php endif; ?>
  19.     }
  20. };
  21. jQuery(document).ready(function()
  22. {
  23.     if( jQuery('body').hasClass('mobile') )
  24.     {
  25.         setTimeout(function() 
  26.         { 
  27.             bgImageFullscreen_<?php echo $this->id?>() 
  28.         }, 100);    
  29.     }
  30.     else
  31.     {
  32.         bgImageFullscreen_<?php echo $this->id?>();
  33.     }        
  34.     
  35. });
  36. jQuery(window).on("resize", function(){
  37.     bgImageFullscreen_<?php echo $this->id?>();
  38. });
  39. <?php endif; ?>
  40. function oversize_<?php echo $this->id?>() {
  41.     var contentHeight_<?php echo $this->id?> = jQuery('.ce_bgimage_<?php echo $this->id?> .ce_bgimage-inside').height();
  42.     var availableHeight = jQuery(window).height() - 100;
  43.     if (contentHeight_<?php echo $this->id?> > availableHeight)
  44.     {
  45.         jQuery('.ce_bgimage_<?php echo $this->id?>').addClass('oversize');
  46.     } else {
  47.         jQuery('.ce_bgimage_<?php echo $this->id?>').removeClass('oversize');
  48.     }
  49. };
  50. jQuery(document).ready(function(){
  51.     oversize_<?php echo $this->id?>();
  52. });
  53. jQuery(window).on("resize", function(){
  54.     oversize_<?php echo $this->id?>();
  55. });
  56. /* ]]> */
  57. </script>
  58. <?php
  59. if($this->field('mobile_height')->value())
  60. {
  61.     $GLOBALS['TL_HEAD'][] = "<style>@media only screen and (max-width: 767px) {.ce_bgimage_" $this->id  " {height:" $this->field('mobile_height')->value() . "px!important;}}</style>";
  62. }
  63. ?>
  64. <?php // responsive images
  65. $objFile \Contao\FilesModel::findByPk$this->field('image')->value() );
  66. if( $objFile !== null )
  67. {
  68.     $objPicture \Contao\Picture::create($objFile->path,deserialize$this->field('image')->option('size') ) );
  69.     $arrMediaQueries = array();
  70.     if( $objPicture !== null )
  71.     {
  72.         $arrPicture $objPicture->getTemplateData();
  73.         foreach($arrPicture['sources'] ?: array() as $data)
  74.         {
  75.             if( strlen($data['media']) < )
  76.             {
  77.                 continue;
  78.             }
  79.             $arrMediaQueries[] = '@media ('.$data['media'].') { .ce_bgimage_'.$this->id.' .ce_bgimage-image { background-image:url('.$data['src'].') !important; } }';
  80.         }
  81.     }
  82.     if( count($arrMediaQueries) > )
  83.     {
  84.         $GLOBALS['TL_HEAD'][] = '<style>'.implode("\n",$arrMediaQueries).'</style>';
  85.     }
  86. }
  87. ?>
  88. <div class="<?php echo $this->class?> block ce_bgimage_<?php echo $this->id?> boxed-content <?php echo $this->field('schema')->value(); ?> <?php echo $this->field('bg_color')->value(); ?><?php if($this->field('parallax')->value()): ?> parallax<?php endif; ?><?php if($this->field('invert')->value()): ?> color-white<?php endif; ?><?php if($this->field('fullscreen-image')->value()): ?> fullscreen-image<?php endif; ?><?php if($this->field('bg_contain')->value()): ?> bg_contain<?php endif; ?><?php if($this->field('vertical_centered')->value()): ?> vertical_centered<?php endif; ?><?php if($this->field('bg_position')->value()): ?> <?php echo $this->field('bg_position')->value(); ?><?php endif; ?><?php if($this->field('hide_mobile')->value()): ?> bg-hide-mobile<?php endif; ?><?php if($this->field('max_width')->value()): ?> <?php echo $this->field('max_width')->value(); ?><?php endif; ?>" style="<?php if($this->field('height')->value()): ?> height:<?php echo $this->field('height')->value(); ?>px;<?php endif; ?><?php if($this->field('bg_owncolor')->value()): ?>background-color:<?php echo $this->field('bg_owncolor')->html(); ?>;<?php endif; ?><?php if ($this->style): ?><?php echo $this->style?><?php endif; ?>"<?php echo $this->cssID?>>
  89. <div class="ce_bgimage-image" style="<?php if($this->field('image')->value()): ?>background-image: url(<?php echo $this->field('image')->generate(); ?>);<?php endif; ?>"<?php if($this->field('parallax')->value()): ?> data-stellar-background-ratio="0.1" data-stellar-offset-parent="true"<?php endif; ?>></div>
  90.     <div class="ce_bgimage-outer">
  91.     <?php if($this->field('offset_layer')->value() != 'no-offset-layer'): ?><div class="offset_layer <?php echo $this->field('offset_layer')->value(); ?>" style="background-color:<?php echo $this->field('offset_color')->html(); ?>;height:<?php echo $this->field('offset_height')->value(); ?>%"></div><?php endif; ?>
  92.         <div class="ce_bgimage-inside contentwrap<?php if($this->field('padding_top_class')->value()): ?> <?php echo $this->field('padding_top_class')->value(); ?><?php endif; ?><?php if($this->field('padding_bottom_class')->value()): ?> <?php echo $this->field('padding_bottom_class')->value(); ?><?php endif; ?>">
  93.             <?php if($this->field('schema')->value() != 'img-as-bg'): ?><div class="mobile_image" style="display: none"><?php echo $this->field('image')->html(); ?></div><?php endif; ?>