PluginProbe
Depicter — Popup & Slider Builder / 1.2.0
Depicter — Popup & Slider Builder v1.2.0
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Options / General.php

General.php in Depicter — Popup & Slider Builder 1.2.0, at app/src/Document/Models/Options/General.php

123 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Options;
3
4 use Depicter\Document\CSS\Breakpoints;
5
6 class General
7 {
8 /**
9 * @var int
10 */
11 public $fullscreenMargin;
12
13 /**
14 * @var bool
15 */
16 public $autoHeight;
17
18 /**
19 * @var bool
20 */
21 public $keepAspect;
22
23 /**
24 * @var Unit
25 */
26 public $minHeight;
27
28 /**
29 * @var Unit
30 */
31 public $maxHeight;
32
33 /**
34 * @var States
35 */
36 public $visible;
37
38 /**
39 * @var string
40 */
41 public $backgroundColor = '';
42
43 /**
44 * @var All
45 */
46 protected $allOptions;
47
48
49 public function setAllOptions( $allOptions ){
50 $this->allOptions = $allOptions;
51 }
52
53 public function getAllOptions(){
54 return $this->allOptions;
55 }
56
57 public function getStylesList(){
58 $styles = [
59 'default' => []
60 ];
61
62 // ignore min and max height if autoHeight is enabled or keep aspect ratio is disable
63 if( $this->getAllOptions()->getLayout() !== 'fullscreen' && ! $this->autoHeight && $this->keepAspect ) {
64
65 $heightSizes = $this->getAllOptions()->getSizes('height', false );
66 foreach ( $heightSizes as $device => $height ){
67 // always add max-height for desktop size
68 // and add max-height for other breakpoints if max-height is less than breakpoint content height
69 if( $device === 'default' || $this->maxHeight < $height ){
70 $styles[ $device ][ 'max-height' ] = $height . 'px';
71 }
72 if( ! empty( $this->minHeight ) ){
73 $styles[ $device ]['min-height'] = $this->minHeight;
74 }
75 }
76 }
77
78 if( $this->backgroundColor ){
79 $styles['default']['background-color'] = $this->backgroundColor;
80 }
81
82 return $styles;
83 }
84
85
86 /**
87 * Get before init document styles
88 *
89 * @return array
90 */
91 public function getBeforeInitStyles(){
92 $styles = [
93 'default' => []
94 ];
95 $layout = $this->getAllOptions()->getLayout();
96
97 if( $layout == 'fullscreen' ){
98 if( $this->fullscreenMargin ){
99 $styles['default']['height'] = "calc( 100vh - {$this->fullscreenMargin}px )";
100 }
101 } elseif( $layout == 'boxed' ){
102 $responsiveSizes = $this->getAllOptions()->getSizes('width', true);
103 foreach ( $responsiveSizes as $device => $value ){
104 $styles[ $device ][ 'width' ] = $value;
105 }
106
107 $responsiveSizes = $this->getAllOptions()->getSizes('height', true);
108 foreach ( $responsiveSizes as $device => $value ){
109 $styles[ $device ][ 'height' ] = $value;
110 }
111 } elseif( $layout == 'fullwidth' ){
112 $responsiveSizes = $this->getAllOptions()->getSizes('height', true);
113 foreach ( $responsiveSizes as $device => $value ){
114 $styles[ $device ][ 'height' ] = $value;
115 }
116 }
117
118 return $styles;
119 }
120
121
122 }
123