_itemConfig = $options['config']; } parent::__construct($options); } /** * @return array */ protected function _getSliderOptions() { $cfg = $this->_itemConfig; unset($cfg['id']); $this->_prepareSliderOptions($cfg); $options = array( 'containerId' => 'wideSlide-' . $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 View */ 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.active-class.js'); $this->_doc->addScript('js/royalslider/jquery.rs.autoplay.js'); $this->_doc->addCriticalStylesheet('css/modules/wideSlide.css'); $this->_doc->addScript('js/app/wideSlide/slide.js'); $options = $this->_getSliderOptions(); $this->_doc->addInitObject('app.wideSlide.Slide', array($options), 'wideSlide' . $this->getIdItem()); $item['containerId'] = $options['containerId']; $this->_addItem($item); } $this->_postList(); return $this; } }