| @@ -62,8 +62,14 @@ | ||
| 62 | 62 | */ |
| 63 | 63 | public $parallax; |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | + * @var Common\KenBurns|null | |
| 67 | + */ | |
| 68 | + public $kenBurns; | |
| 69 | + | |
| 70 | + | |
| 71 | + /** | |
| 66 | 72 | * @var Common\DataSourceOptions|null |
| 67 | 73 | */ |
| 68 | 74 | public $dataSource = null; |
| 69 | 75 | |
| @@ -81,9 +87,14 @@ | ||
| 81 | 87 | * @var array |
| 82 | 88 | */ |
| 83 | 89 | protected $styleList = []; |
| 84 | 90 | |
| 91 | + /** | |
| 92 | + * @var string | |
| 93 | + */ | |
| 94 | + protected $preloadTags = ''; | |
| 85 | 95 | |
| 96 | + | |
| 86 | 97 | /** |
| 87 | 98 | * get section ID |
| 88 | 99 | * |
| 89 | 100 | * @return string |
| @@ -157,9 +168,9 @@ | ||
| 157 | 168 | protected function renderDataSource() { |
| 158 | 169 | $sectionMarkup = ''; |
| 159 | 170 | $dataSourceInstance = \Depicter::dataSource()->getByType( $this->dataSource->type ); |
| 160 | 171 | if( $dataSourceInstance ){ |
| 161 | - $dataSheets = $dataSourceInstance->getRecordsWithTags( $this->dataSource->params ); | |
| 172 | + $dataSheets = $dataSourceInstance->getDataSheetArgs( $this->dataSource->params ); | |
| 162 | 173 | foreach( $dataSheets as $dataSheet ){ |
| 163 | 174 | $this->setDataSheet( $dataSheet ); |
| 164 | 175 | $sectionMarkup .= $this->renderStatic(); |
| 165 | 176 | } |
| @@ -183,12 +194,20 @@ | ||
| 183 | 194 | if ( !empty( $this->wrapperSize ) ) { |
| 184 | 195 | $sectionWidth = $this->wrapperSize->getResponsiveSizes( "width" ); |
| 185 | 196 | if ( ! $this->wrapperSize->hasNoResponsiveSize( $sectionWidth ) ) { |
| 186 | 197 | $args[ 'data-wrapper-width'] = implode( ',', $sectionWidth ); |
| 198 | + $args[ 'data-wrapper-width'] = str_replace( 'auto', '', $args[ 'data-wrapper-width'] ); | |
| 199 | + if ( $args[ 'data-wrapper-width'] == ',,' ) { | |
| 200 | + unset( $args[ 'data-wrapper-width'] ); | |
| 201 | + } | |
| 187 | 202 | } |
| 188 | 203 | $sectionHeight = $this->wrapperSize->getResponsiveSizes( "height" ); |
| 189 | 204 | if ( ! $this->wrapperSize->hasNoResponsiveSize( $sectionHeight ) ) { |
| 190 | 205 | $args['data-wrapper-height'] = implode( ',', $sectionHeight ); |
| 206 | + $args[ 'data-wrapper-height'] = str_replace( 'auto', '', $args[ 'data-wrapper-height'] ); | |
| 207 | + if ( $args[ 'data-wrapper-height'] == ',,' ) { | |
| 208 | + unset( $args[ 'data-wrapper-height'] ); | |
| 209 | + } | |
| 191 | 210 | } |
| 192 | 211 | } |
| 193 | 212 | |
| 194 | 213 | if ( !empty( $this->options ) ) { |
| @@ -230,8 +249,13 @@ | ||
| 230 | 249 | } |
| 231 | 250 | } |
| 232 | 251 | if( $sectionBackground = $this->background->render() ){ |
| 233 | 252 | $this->background->setDataSheet( $this->getDataSheet() ); |
| 253 | + | |
| 254 | + if ( $this->kenBurns && false !== $kenBurnsData = $this->kenBurns->getKenBurnsAttrs() ) { | |
| 255 | + $this->background->setKenBurnsData( $kenBurnsData ); | |
| 256 | + } | |
| 257 | + | |
| 234 | 258 | $div->nest( "\n" . $this->background->render() . "\n\n" ); |
| 235 | 259 | } |
| 236 | 260 | |
| 237 | 261 | $this->styleList = Arr::merge( $this->styleList, $this->getSelectorAndCssList() ); |
| @@ -244,9 +268,12 @@ | ||
| 244 | 268 | } |
| 245 | 269 | // Get element style |
| 246 | 270 | $this->styleList = Arr::merge( $this->styleList, $elementObject->prepare()->getSelectorAndCssList() ); |
| 247 | 271 | |
| 248 | - $div->nest( "\n" . $elementObject->prepare()->render() ) ; | |
| 272 | + $div->nest( "\n" . $elementObject->prepare()->render() ); | |
| 273 | + | |
| 274 | + // generate and retrieve media files of elements for preloading | |
| 275 | + $this->preloadTags .= $elementObject->prepare()->getPreloadTags(); | |
| 249 | 276 | } |
| 250 | 277 | } |
| 251 | 278 | |
| 252 | 279 | return "\n" . $div; |
| @@ -261,8 +288,17 @@ | ||
| 261 | 288 | return $this->isLinkedToDataSheet() || !empty( $this->options->url->enable ); |
| 262 | 289 | } |
| 263 | 290 | |
| 264 | 291 | /** |
| 292 | + * Retrieves markup for preloading media files belonging to this section | |
| 293 | + * | |
| 294 | + * @return string | |
| 295 | + */ | |
| 296 | + public function getPreloadTags(){ | |
| 297 | + return $this->preloadTags; | |
| 298 | + } | |
| 299 | + | |
| 300 | + /** | |
| 265 | 301 | * Retrieves section url if exists |
| 266 | 302 | * |
| 267 | 303 | * @return string |
| 268 | 304 | */ |
| @@ -388,11 +424,13 @@ | ||
| 388 | 424 | */ |
| 389 | 425 | protected function getSelectorAndCssList(){ |
| 390 | 426 | $styleList = []; |
| 391 | 427 | |
| 392 | - $styleList[ '.' . $this->getStyleSelector() ] = $this->background->getColor(); | |
| 428 | + $styleList[ '.' . $this->getStyleSelector() . ' .' . $this->background->getContainerClassName() ] = array_merge_recursive( | |
| 429 | + $this->background->getColor(), | |
| 430 | + $this->background->getSectionBackgroundFilter() | |
| 431 | + ); | |
| 393 | 432 | $styleList[ '.' . $this->getStyleSelector() . ' .' . $this->background->getContainerClassName() . '::after' ] = $this->background->getOverlayStyles(); |
| 394 | - $styleList[ '.' . $this->getStyleSelector() . ' .' . $this->background->getContainerClassName() ] = $this->background->getSectionBackgroundFilter(); | |
| 395 | 433 | |
| 396 | 434 | if ( $this->getCustomStyles() ) { |
| 397 | 435 | $styleList[ '.' . $this->getStyleSelector() ]['customStyle'] = $this->getCustomStyles(); |
| 398 | 436 | } |