form-01--form-container.php
3 years ago
form-02--form-fields.php
3 years ago
form-03--input.php
5 months ago
form-04--select2.php
5 months ago
form-05--select2-dropdown.php
3 years ago
form-06--timepicker-dropdown.php
3 years ago
form-07--radio.php
5 months ago
form-08--checkbox.php
5 months ago
form-09--calendar.php
3 years ago
form-10--submit.php
5 months ago
form-11--options-container.php
3 years ago
form-12--options-title.php
5 months ago
form-13--gdpr.php
5 months ago
form-14--error-message.php
5 months ago
form-15--success-message.php
2 years ago
form-16--recaptcha.php
5 months ago
general-01--module-container.php
3 years ago
general-02--main-layout.php
1 month ago
general-03--layout-header.php
3 years ago
general-04--layout-content.php
3 years ago
general-05--layout-footer.php
3 years ago
general-06--image-size.php
5 months ago
general-07--image-fitting.php
3 years ago
general-08--image-position.php
5 months ago
general-09--content-wrapper.php
3 years ago
general-10--title.php
5 months ago
general-11--subtitle.php
5 months ago
general-12--content.php
5 months ago
general-13--cta-container.php
3 years ago
general-14--cta-button.php
5 months ago
general-15--cta-alignment.php
3 years ago
general-16--nsa-link.php
5 months ago
general-17--close-button.php
3 years ago
general-18--popup-mask.php
3 years ago
general-19--cta-helper-text.php
5 months ago
module-size-embed.php
5 months ago
module-size-popup.php
5 months ago
module-size-slidein.php
3 years ago
general-08--image-position.php
359 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Feature Image Position. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.3.0 |
| 7 | */ |
| 8 | |
| 9 | global $wp_locale; |
| 10 | |
| 11 | $is_rtl = $wp_locale->is_rtl(); |
| 12 | |
| 13 | $container = '.hustle-layout .hustle-image'; |
| 14 | $component = $container . ' img'; |
| 15 | |
| 16 | // CONDITIONALS: Check if module has mobile appearance settings enabled. |
| 17 | $is_mobile_enabled = ( '1' === $design['enable_mobile_settings'] ); |
| 18 | $is_mobile_disabled = ( '1' !== $design['enable_mobile_settings'] ); |
| 19 | |
| 20 | // SETTINGS: Image. |
| 21 | $image = $content['feature_image']; |
| 22 | |
| 23 | // SETTINGS: Fitting. |
| 24 | $fitting = $design['feature_image_fit']; |
| 25 | $mobile_fitting = ( $is_mobile_enabled ) ? $design['feature_image_fit_mobile'] : $fitting; |
| 26 | |
| 27 | // SETTINGS: Horizontal Position. |
| 28 | $horizontal = $design['feature_image_horizontal_position']; |
| 29 | $horizontal_value = ( '' !== $design['feature_image_horizontal_value'] ) ? $design['feature_image_horizontal_value'] . $design['feature_image_horizontal_unit'] : '0'; |
| 30 | $horizontal_value = ( 'custom' === $horizontal ) ? $horizontal_value : $horizontal; |
| 31 | |
| 32 | $mobile_horizontal = $design['feature_image_horizontal_position_mobile']; |
| 33 | $mobile_horizontal_value = ( '' !== $design['feature_image_horizontal_value_mobile'] ) ? $design['feature_image_horizontal_value_mobile'] . $design['feature_image_horizontal_unit_mobile'] : '0'; |
| 34 | $mobile_horizontal_value = ( 'custom' === $mobile_horizontal ) ? $mobile_horizontal_value : $mobile_horizontal; |
| 35 | |
| 36 | // SETTINGS: Vertical Position. |
| 37 | $vertical = $design['feature_image_vertical_position']; |
| 38 | $vertical_value = ( '' !== $design['feature_image_vertical_value'] ) ? $design['feature_image_vertical_value'] . $design['feature_image_vertical_unit'] : '0'; |
| 39 | $vertical_value = ( 'custom' === $vertical ) ? $vertical_value : $vertical; |
| 40 | |
| 41 | $mobile_vertical = $design['feature_image_vertical_position_mobile']; |
| 42 | $mobile_vertical_value = ( '' !== $design['feature_image_vertical_value_mobile'] ) ? $design['feature_image_vertical_value_mobile'] . $design['feature_image_vertical_unit_mobile'] : '0'; |
| 43 | $mobile_vertical_value = ( 'custom' === $mobile_vertical ) ? $mobile_vertical_value : $mobile_vertical; |
| 44 | |
| 45 | // ================================================== |
| 46 | // Check if feature image exists. |
| 47 | if ( '' !== $image ) { |
| 48 | |
| 49 | if ( $is_mobile_enabled ) { |
| 50 | |
| 51 | // Mobile styles. |
| 52 | if ( 'cover' === $mobile_fitting || 'contain' === $mobile_fitting ) { |
| 53 | $style .= $prefix_mobile . $component . ' {'; |
| 54 | $style .= 'object-position: ' . $mobile_horizontal_value . ' ' . $mobile_vertical_value . ';'; |
| 55 | $style .= '-o-object-position: ' . $mobile_horizontal_value . ' ' . $mobile_vertical_value . ';'; |
| 56 | $style .= '}'; |
| 57 | |
| 58 | if ( 'left' === $mobile_horizontal ) { |
| 59 | $style .= $support_ie . ' {'; |
| 60 | $style .= $prefix_mobile . $component . ' {'; |
| 61 | $style .= 'left: 0;'; |
| 62 | $style .= '}'; |
| 63 | $style .= '}'; |
| 64 | } elseif ( 'right' === $mobile_horizontal ) { |
| 65 | $style .= $support_ie . ' {'; |
| 66 | $style .= $prefix_mobile . $component . ' {'; |
| 67 | $style .= 'right: 0;'; |
| 68 | $style .= '}'; |
| 69 | $style .= '}'; |
| 70 | } elseif ( 'center' === $mobile_horizontal ) { |
| 71 | $style .= $support_ie . ' {'; |
| 72 | $style .= $prefix_mobile . $component . ' {'; |
| 73 | $style .= 'left: 50%;'; |
| 74 | $style .= '}'; |
| 75 | $style .= '}'; |
| 76 | |
| 77 | if ( 'center' === $mobile_vertical ) { |
| 78 | $style .= $support_ie . ' {'; |
| 79 | $style .= $prefix_mobile . $component . ' {'; |
| 80 | $style .= 'transform: translate(-50%,-50%);'; |
| 81 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 82 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 83 | $style .= '}'; |
| 84 | $style .= '}'; |
| 85 | } else { |
| 86 | $style .= $support_ie . ' {'; |
| 87 | $style .= $prefix_mobile . $component . ' {'; |
| 88 | $style .= 'transform: translateX(-50%);'; |
| 89 | $style .= '-ms-transform: translateX(-50%);'; |
| 90 | $style .= '-webkit-transform: translateX(-50%);'; |
| 91 | $style .= '}'; |
| 92 | $style .= '}'; |
| 93 | } |
| 94 | } else { |
| 95 | $style .= $support_ie . ' {'; |
| 96 | $style .= $prefix_mobile . $component . ' {'; |
| 97 | $style .= 'left: ' . $mobile_vertical_value . ';'; |
| 98 | $style .= '}'; |
| 99 | $style .= '}'; |
| 100 | } |
| 101 | |
| 102 | if ( 'top' === $mobile_vertical ) { |
| 103 | $style .= $support_ie . ' {'; |
| 104 | $style .= $prefix_mobile . $component . ' {'; |
| 105 | $style .= 'top: 0;'; |
| 106 | $style .= '}'; |
| 107 | $style .= '}'; |
| 108 | } elseif ( 'bottom' === $mobile_vertical ) { |
| 109 | $style .= $support_ie . ' {'; |
| 110 | $style .= $prefix_mobile . $component . ' {'; |
| 111 | $style .= 'bottom: 0;'; |
| 112 | $style .= '}'; |
| 113 | $style .= '}'; |
| 114 | } elseif ( 'center' === $mobile_vertical ) { |
| 115 | $style .= $support_ie . ' {'; |
| 116 | $style .= $prefix_mobile . $component . ' {'; |
| 117 | $style .= 'top: 50%;'; |
| 118 | $style .= '}'; |
| 119 | $style .= '}'; |
| 120 | |
| 121 | if ( 'center' === $mobile_horizontal ) { |
| 122 | $style .= $support_ie . ' {'; |
| 123 | $style .= $prefix_mobile . $component . ' {'; |
| 124 | $style .= 'transform: translate(-50%,-50%);'; |
| 125 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 126 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 127 | $style .= '}'; |
| 128 | $style .= '}'; |
| 129 | } else { |
| 130 | $style .= $support_ie . ' {'; |
| 131 | $style .= $prefix_mobile . $component . ' {'; |
| 132 | $style .= 'transform: translateY(-50%);'; |
| 133 | $style .= '-ms-transform: translateY(-50%);'; |
| 134 | $style .= '-webkit-transform: translateY(-50%);'; |
| 135 | $style .= '}'; |
| 136 | $style .= '}'; |
| 137 | } |
| 138 | } else { |
| 139 | $style .= $support_ie . ' {'; |
| 140 | $style .= $prefix_mobile . $component . ' {'; |
| 141 | $style .= 'top: ' . $mobile_vertical_value . ';'; |
| 142 | $style .= '}'; |
| 143 | $style .= '}'; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Desktop styles. |
| 148 | if ( 'cover' === $fitting || 'contain' === $fitting ) { |
| 149 | $style .= $breakpoint . ' {'; |
| 150 | $style .= $prefix_desktop . $component . ' {'; |
| 151 | $style .= 'object-position: ' . $horizontal_value . ' ' . $vertical_value . ';'; |
| 152 | $style .= '-o-object-position: ' . $horizontal_value . ' ' . $vertical_value . ';'; |
| 153 | $style .= '}'; |
| 154 | $style .= '}'; |
| 155 | |
| 156 | if ( 'left' === $horizontal ) { |
| 157 | $style .= $breakpoint_ie . ' {'; |
| 158 | $style .= $prefix_desktop . $component . ' {'; |
| 159 | $style .= 'left: 0;'; |
| 160 | $style .= 'right: auto;'; |
| 161 | $style .= 'transform: unset;'; |
| 162 | $style .= '-ms-transform: unset;'; |
| 163 | $style .= '-webkit-transform: unset;'; |
| 164 | $style .= '}'; |
| 165 | $style .= '}'; |
| 166 | } elseif ( 'right' === $horizontal ) { |
| 167 | $style .= $breakpoint_ie . ' {'; |
| 168 | $style .= $prefix_desktop . $component . ' {'; |
| 169 | $style .= 'right: 0;'; |
| 170 | $style .= 'left: auto;'; |
| 171 | $style .= 'transform: unset;'; |
| 172 | $style .= '-ms-transform: unset;'; |
| 173 | $style .= '-webkit-transform: unset;'; |
| 174 | $style .= '}'; |
| 175 | $style .= '}'; |
| 176 | } elseif ( 'center' === $horizontal ) { |
| 177 | $style .= $breakpoint_ie . ' {'; |
| 178 | $style .= $prefix_desktop . $component . ' {'; |
| 179 | $style .= 'left: 50%;'; |
| 180 | $style .= 'right: auto;'; |
| 181 | $style .= '}'; |
| 182 | $style .= '}'; |
| 183 | |
| 184 | if ( 'center' === $vertical ) { |
| 185 | $style .= $breakpoint_ie . ' {'; |
| 186 | $style .= $prefix_desktop . $component . ' {'; |
| 187 | $style .= 'transform: translate(-50%,-50%);'; |
| 188 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 189 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 190 | $style .= '}'; |
| 191 | $style .= '}'; |
| 192 | } else { |
| 193 | $style .= $breakpoint_ie . ' {'; |
| 194 | $style .= $prefix_desktop . $component . ' {'; |
| 195 | $style .= 'transform: translateX(-50%);'; |
| 196 | $style .= '-ms-transform: translateX(-50%);'; |
| 197 | $style .= '-webkit-transform: translateX(-50%);'; |
| 198 | $style .= '}'; |
| 199 | $style .= '}'; |
| 200 | } |
| 201 | } else { |
| 202 | $style .= $breakpoint_ie . ' {'; |
| 203 | $style .= $prefix_desktop . $component . ' {'; |
| 204 | $style .= 'left: ' . $vertical_value . ';'; |
| 205 | $style .= 'right: auto;'; |
| 206 | $style .= '}'; |
| 207 | $style .= '}'; |
| 208 | } |
| 209 | |
| 210 | if ( 'top' === $vertical ) { |
| 211 | $style .= $breakpoint_ie . ' {'; |
| 212 | $style .= $prefix_desktop . $component . ' {'; |
| 213 | $style .= 'top: 0;'; |
| 214 | $style .= 'bottom: auto;'; |
| 215 | $style .= '}'; |
| 216 | $style .= '}'; |
| 217 | } elseif ( 'bottom' === $vertical ) { |
| 218 | $style .= $breakpoint_ie . ' {'; |
| 219 | $style .= $prefix_desktop . $component . ' {'; |
| 220 | $style .= 'top: auto;'; |
| 221 | $style .= 'bottom: 0;'; |
| 222 | $style .= '}'; |
| 223 | $style .= '}'; |
| 224 | } elseif ( 'center' === $vertical ) { |
| 225 | $style .= $breakpoint_ie . ' {'; |
| 226 | $style .= $prefix_desktop . $component . ' {'; |
| 227 | $style .= 'top: 50%;'; |
| 228 | $style .= 'bottom: auto;'; |
| 229 | $style .= '}'; |
| 230 | $style .= '}'; |
| 231 | |
| 232 | if ( 'center' === $horizontal ) { |
| 233 | $style .= $breakpoint_ie . ' {'; |
| 234 | $style .= $prefix_desktop . $component . ' {'; |
| 235 | $style .= 'transform: translate(-50%,-50%);'; |
| 236 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 237 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 238 | $style .= '}'; |
| 239 | $style .= '}'; |
| 240 | } else { |
| 241 | $style .= $breakpoint_ie . ' {'; |
| 242 | $style .= $prefix_desktop . $component . ' {'; |
| 243 | $style .= 'transform: translateY(-50%);'; |
| 244 | $style .= '-ms-transform: translateY(-50%);'; |
| 245 | $style .= '-webkit-transform: translateY(-50%);'; |
| 246 | $style .= '}'; |
| 247 | $style .= '}'; |
| 248 | } |
| 249 | } else { |
| 250 | $style .= $breakpoint_ie . ' {'; |
| 251 | $style .= $prefix_desktop . $component . ' {'; |
| 252 | $style .= 'top: ' . $vertical_value . ';'; |
| 253 | $style .= 'bottom: auto;'; |
| 254 | $style .= '}'; |
| 255 | $style .= '}'; |
| 256 | } |
| 257 | } |
| 258 | } elseif ( 'cover' === $fitting || 'contain' === $fitting ) { |
| 259 | |
| 260 | $style .= $prefix_mobile . $component . ' {'; |
| 261 | $style .= 'object-position: ' . $horizontal_value . ' ' . $vertical_value . ';'; |
| 262 | $style .= '-o-object-position: ' . $horizontal_value . ' ' . $vertical_value . ';'; |
| 263 | $style .= '}'; |
| 264 | |
| 265 | if ( 'left' === $horizontal ) { |
| 266 | $style .= $support_ie . ' {'; |
| 267 | $style .= $prefix_mobile . $component . ' {'; |
| 268 | $style .= 'left: 0;'; |
| 269 | $style .= '}'; |
| 270 | $style .= '}'; |
| 271 | } elseif ( 'right' === $horizontal ) { |
| 272 | $style .= $support_ie . ' {'; |
| 273 | $style .= $prefix_mobile . $component . ' {'; |
| 274 | $style .= 'right: 0;'; |
| 275 | $style .= '}'; |
| 276 | $style .= '}'; |
| 277 | } elseif ( 'center' === $horizontal ) { |
| 278 | $style .= $support_ie . ' {'; |
| 279 | $style .= $prefix_mobile . $component . ' {'; |
| 280 | $style .= 'left: 50%;'; |
| 281 | $style .= '}'; |
| 282 | $style .= '}'; |
| 283 | |
| 284 | if ( 'center' === $vertical ) { |
| 285 | $style .= $support_ie . ' {'; |
| 286 | $style .= $prefix_mobile . $component . ' {'; |
| 287 | $style .= 'transform: translate(-50%,-50%);'; |
| 288 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 289 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 290 | $style .= '}'; |
| 291 | $style .= '}'; |
| 292 | } else { |
| 293 | $style .= $support_ie . ' {'; |
| 294 | $style .= $prefix_mobile . $component . ' {'; |
| 295 | $style .= 'transform: translateX(-50%);'; |
| 296 | $style .= '-ms-transform: translateX(-50%);'; |
| 297 | $style .= '-webkit-transform: translateX(-50%);'; |
| 298 | $style .= '}'; |
| 299 | $style .= '}'; |
| 300 | } |
| 301 | } else { |
| 302 | $style .= $support_ie . ' {'; |
| 303 | $style .= $prefix_mobile . $component . ' {'; |
| 304 | $style .= 'left: ' . $vertical_value . ';'; |
| 305 | $style .= '}'; |
| 306 | $style .= '}'; |
| 307 | } |
| 308 | |
| 309 | if ( 'top' === $vertical ) { |
| 310 | $style .= $support_ie . ' {'; |
| 311 | $style .= $prefix_mobile . $component . ' {'; |
| 312 | $style .= 'top: 0;'; |
| 313 | $style .= '}'; |
| 314 | $style .= '}'; |
| 315 | } elseif ( 'bottom' === $vertical ) { |
| 316 | $style .= $support_ie . ' {'; |
| 317 | $style .= $prefix_mobile . $component . ' {'; |
| 318 | $style .= 'bottom: 0;'; |
| 319 | $style .= '}'; |
| 320 | $style .= '}'; |
| 321 | } elseif ( 'center' === $vertical ) { |
| 322 | $style .= $support_ie . ' {'; |
| 323 | $style .= $prefix_mobile . $component . ' {'; |
| 324 | $style .= 'top: 50%;'; |
| 325 | $style .= '}'; |
| 326 | $style .= '}'; |
| 327 | |
| 328 | if ( 'center' === $horizontal ) { |
| 329 | $style .= $support_ie . ' {'; |
| 330 | $style .= $prefix_mobile . $component . ' {'; |
| 331 | $style .= 'transform: translate(-50%,-50%);'; |
| 332 | $style .= '-ms-transform: translate(-50%,-50%);'; |
| 333 | $style .= '-webkit-transform: translate(-50%,-50%);'; |
| 334 | $style .= '}'; |
| 335 | $style .= '}'; |
| 336 | } else { |
| 337 | $style .= $support_ie . ' {'; |
| 338 | $style .= $prefix_mobile . $component . ' {'; |
| 339 | $style .= 'transform: translateY(-50%);'; |
| 340 | $style .= '-ms-transform: translateY(-50%);'; |
| 341 | $style .= '-webkit-transform: translateY(-50%);'; |
| 342 | $style .= '}'; |
| 343 | $style .= '}'; |
| 344 | } |
| 345 | } else { |
| 346 | $style .= $support_ie . ' {'; |
| 347 | $style .= $prefix_mobile . $component . ' {'; |
| 348 | $style .= 'top: ' . $vertical_value . ';'; |
| 349 | $style .= '}'; |
| 350 | $style .= '}'; |
| 351 | } |
| 352 | } |
| 353 | if ( $is_rtl ) { |
| 354 | $style .= $prefix_mobile . $component . ' {'; |
| 355 | $style .= 'transform: scaleX(-1);'; |
| 356 | $style .= '}'; |
| 357 | } |
| 358 | } |
| 359 |