_itemConfig = $options['config']; } parent::__construct($options); } /** * @return array */ protected function _getSliderOptions() { $cfg = $this->_itemConfig; unset($cfg['id']); $this->_prepareSliderOptions($cfg); $options = array( 'containerId' => 'testimonialSlide-' . $this->getIdItem(), 'slider' => array( 'loop' => $cfg['cycle'], 'autoPlay' => array( 'enabled' => $cfg['autoPlay'], 'delay' => $cfg['autoPlayDelay'], 'pauseOnHover' => $cfg['pauseOnHover'], 'stopAtAction' => $cfg['stopAtAction'], ) ), ); return $options; } /** * @param array $options * @return $this */ protected function _prepareSliderOptions(array &$options) { foreach ($options as &$value) { if (is_array($value)) { $this->_prepareSliderOptions($value); } else { switch ($value) { case 'true': $value = true; break; case 'false': $value = false; break; default: if (is_numeric($value)) { if (preg_match('/^[0-9]+$/', $value)) { $value = (int) $value; } else { $value = (float) $value; } } break; } } } return $this; } protected function _doList() { $item = $this->_getListItem(); if ($item['list']) { $this->_doc->addCriticalStylesheet('css/thirdpart/royalslider.css'); $this->_doc->addCriticalStylesheet('css/thirdpart/royalslider-default.css'); $this->_doc->addScript('js/royalslider/jquery.royalslider.js'); $this->_doc->addScript('js/royalslider/jquery.rs.bullets.js'); $this->_doc->addScript('js/royalslider/jquery.rs.animated-blocks.js'); $this->_doc->addScript('js/royalslider/jquery.rs.autoplay.js'); $this->_doc->addScript('js/royalslider/jquery.rs.auto-height.js'); $this->_doc->addCriticalStylesheet('css/modules/testimonialSlide.css'); $this->_doc->addScript('js/app/testimonialSlide/slide.js'); $options = $this->_getSliderOptions(); $this->_doc->addInitObject( 'app.testimonialSlide.Slide', array($options), 'testimonialSlide' . $this->getIdItem()); $item['containerId'] = $options['containerId']; $this->_addItem($item); } $this->_postList(); return $this; } }