system/modules/pct_theme_templates/templates/customelements/customelement_bgimage_start.html5 line 2

Open in your IDE?
  1. <?php 
  2. $GLOBALS['TL_CSS'][] = \Contao\Config::get('uploadPath').'/cto_layout/css/customelements/ce_bgimage.css|static';
  3. if($this->field('parallax')->value())
  4. {
  5.     $GLOBALS['SEO_SCRIPTS_FILE'][] = \Contao\Config::get('uploadPath').'/cto_layout/scripts/parallax/jquery.stellar.min.js|static';
  6. }
  7. ?>
  8. <!-- SEO-SCRIPT-START -->
  9. <script>
  10. <?php if($this->field('fullscreen-image')->value()): ?>
  11. function bgImageFullscreen_<?php echo $this->id?>() {
  12.     var windowHeight = jQuery(window).height();
  13.     var mobHeaderHeight = jQuery('.header.cloned').height();
  14.     if (jQuery(window).width() < 768)
  15.     {
  16.         var setNewHeightMobile = windowHeight - mobHeaderHeight;
  17.         jQuery('.ce_bgimage_<?php echo $this->id?>').height(setNewHeightMobile);
  18.     } else {
  19.         <?php if($this->field('offset')->value()): ?>
  20.             var offsetHeight_<?php echo $this->id?> = jQuery('<?php echo $this->field('offset')->value(); ?>').height();
  21.             var setNewHeight_<?php echo $this->id?> = windowHeight - offsetHeight_<?php echo $this->id?>;
  22.             jQuery('.ce_bgimage_<?php echo $this->id?>').height(setNewHeight_<?php echo $this->id?>);
  23.         <?php else: ?>
  24.             jQuery('.ce_bgimage_<?php echo $this->id?>').height(windowHeight);
  25.         <?php endif; ?>
  26.     }
  27. };
  28. jQuery(document).ready(function()
  29. {
  30.     if( jQuery('body').hasClass('mobile') )
  31.     {
  32.         setTimeout(function() 
  33.         { 
  34.             bgImageFullscreen_<?php echo $this->id?>() 
  35.         }, 100);    
  36.     }
  37.     else
  38.     {
  39.         bgImageFullscreen_<?php echo $this->id?>();
  40.     }        
  41.     
  42. });
  43. jQuery(window).on("resize", function(){
  44.     bgImageFullscreen_<?php echo $this->id?>();
  45. });
  46. <?php endif; ?>
  47. function oversize_<?php echo $this->id?>() {
  48.     var contentHeight_<?php echo $this->id?> = jQuery('.ce_bgimage_<?php echo $this->id?> .ce_bgimage-inside').height();
  49.     var availableHeight = jQuery(window).height() - 100;
  50.     if (contentHeight_<?php echo $this->id?> > availableHeight)
  51.     {
  52.         jQuery('.ce_bgimage_<?php echo $this->id?>').addClass('oversize');
  53.     } else {
  54.         jQuery('.ce_bgimage_<?php echo $this->id?>').removeClass('oversize');
  55.     }
  56. };
  57. jQuery(document).ready(function(){
  58.     oversize_<?php echo $this->id?>();
  59. });
  60. jQuery(window).on("resize", function(){
  61.     oversize_<?php echo $this->id?>();
  62. });
  63. </script>
  64. <!-- SEO-SCRIPT-STOP -->
  65. <?php
  66. if($this->field('mobile_height')->value())
  67. {
  68.     $GLOBALS['TL_HEAD'][] = "<style>@media only screen and (max-width: 767px) {.ce_bgimage_" $this->id  " {height:" $this->field('mobile_height')->value() . "px!important;}}</style>";
  69. }
  70. ?>
  71. <?php // responsive images
  72. $objFile \Contao\FilesModel::findByPk$this->field('image')->value() );
  73. if( $objFile !== null )
  74. {
  75.     $objPicture \Contao\Picture::create($objFile->path,\Contao\StringUtil::deserialize$this->field('image')->option('size') ) );
  76.     $arrMediaQueries = array();
  77.     if( $objPicture !== null )
  78.     {
  79.         $arrPicture $objPicture->getTemplateData();
  80.         foreach($arrPicture['sources'] ?: array() as $data)
  81.         {
  82.             if( strlen($data['media']) < )
  83.             {
  84.                 continue;
  85.             }
  86.             $arrMediaQueries[] = '@media '.$data['media'].' { .ce_bgimage_'.$this->id.' > .ce_bgimage-image { background-image:url('.$data['src'].') !important; } }';
  87.         }
  88.     }
  89.     if( count($arrMediaQueries) > )
  90.     {
  91.         $GLOBALS['TL_HEAD'][] = '<style>'.implode("\n",$arrMediaQueries).'</style>';
  92.     }
  93. }
  94. ?>
  95. <?php 
  96. $offset_color '';
  97. if( $this->field('offset_color')->value() )
  98. {
  99.     // compile color
  100.     $color $this->field('offset_color')->attribute()->compileColor$this->field('offset_color')->value() );
  101.     $offset_color $color->rgba;
  102. }
  103. $bg_owncolor '';
  104. if( $this->field('bg_owncolor')->value() )
  105. {
  106.     // compile color
  107.     $color $this->field('bg_owncolor')->attribute()->compileColor$this->field('bg_owncolor')->value() );
  108.     $bg_owncolor $color->rgba;
  109. }
  110. ?>
  111. <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 $bg_owncolor?>;<?php endif; ?><?php if ($this->style): ?><?php echo $this->style?><?php endif; ?>"<?php echo $this->cssID?>>
  112.     <?php if($this->field('image')->value()): ?>
  113.     <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>
  114.     <?php endif; ?>
  115.     <div class="ce_bgimage-outer">
  116.     <?php if($this->field('offset_layer')->value() != 'no-offset-layer'): ?><div class="offset_layer <?php echo $this->field('offset_layer')->value(); ?>" style="background-color:<?= $offset_color?>;height:<?php echo $this->field('offset_height')->value(); ?>%"></div><?php endif; ?>
  117.         <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; ?>">
  118.             <?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; ?>