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