protected function renderType(&$context) { $params = $this->slider->params; N2Loader::import('libraries.image.color'); $width = intval($context['width']); $height = intval($context['height']); $context['backgroundSize'] = $params->get('background-size'); $context['backgroundAttachment'] = $params->get('background-fixed') ? 'fixed' : 'scroll'; $borderWidth = $params->get('border-width'); $borderColor = $params->get('border-color'); $context['borderRadius'] = $params->get('border-radius') . 'px'; $padding = N2Parse::parse($params->get('padding')); $context['paddingt'] = $padding[0] . 'px'; $context['paddingr'] = $padding[1] . 'px'; $context['paddingb'] = $padding[2] . 'px'; $context['paddingl'] = $padding[3] . 'px'; if ($context['canvas']) { $width += 2 * $borderWidth + $padding[1] + $padding[3]; $height += 2 * $borderWidth + $padding[0] + $padding[2]; $context['width'] = $width . "px"; $context['height'] = $height . "px"; } $context['border'] = $borderWidth . 'px'; $rgba = N2Color::hex2rgba($borderColor); $context['borderrgba'] = 'RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ')'; $context['borderhex'] = '#' . substr($borderColor, 0, 6); $width = $width - ($padding[1] + $padding[3]) - $borderWidth * 2; $height = $height - ($padding[0] + $padding[2]) - $borderWidth * 2; $context['inner1height'] = $height . 'px'; $context['canvaswidth'] = $width . "px"; $context['canvasheight'] = $height . "px"; N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . NDS . 'style.less'), $this->slider->cacheId, $context, NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); }
static function render($slider, $id, $params) { $html = ''; $previous = $params->get(self::$key . 'previous-image'); $previousColor = $params->get(self::$key . 'previous-color'); $previousHover = $params->get(self::$key . 'previous-hover'); $previousHoverColor = $params->get(self::$key . 'previous-hover-color'); if (empty($previous)) { $previous = $params->get(self::$key . 'previous'); if ($previous == -1) { $previous = null; } elseif ($previous[0] != '$') { $previous = N2Uri::pathToUri(dirname(__FILE__) . '/image/previous/' . $previous); } } if ($params->get(self::$key . 'mirror')) { $next = str_replace('image/previous/', 'image/next/', $previous); $nextColor = $previousColor; $nextHover = $previousHover; $nextHoverColor = $previousHoverColor; } else { $next = $params->get(self::$key . 'next-image'); $nextColor = $params->get(self::$key . 'next-color'); $nextHover = $params->get(self::$key . 'next-hover'); $nextHoverColor = $params->get(self::$key . 'next-hover-color'); if (empty($next)) { $next = $params->get(self::$key . 'next'); if ($next == -1) { $next = null; } elseif ($next[0] != '$') { $next = N2Uri::pathToUri(dirname(__FILE__) . '/image/next/' . $next); } } } if ($previous || $next) { N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.less'), $slider->cacheId, array("sliderid" => $slider->elementId), NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/arrow.js'), $id); list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key); $animation = $params->get(self::$key . 'animation'); if ($animation == 'none' || $animation == 'fade') { $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' '); } else { $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading-active', $slider->elementId, 'div#' . $slider->elementId . ' '); } if ($previous) { $html .= self::getHTML($id, $params, $animation, 'previous', $previous, $displayClass, $displayAttributes, $styleClass, $previousColor, $previousHover, $previousHoverColor); } if ($next) { $html .= self::getHTML($id, $params, $animation, 'next', $next, $displayClass, $displayAttributes, $styleClass, $nextColor, $nextHover, $nextHoverColor); } N2JS::addInline('new NextendSmartSliderWidgetArrowImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');'); } return $html; }
public function render() { $slider = $this->slider; $params = $slider->params; $width = intval($params->get('width', 900)); $height = intval($params->get('height', 500)); if ($width < 10) { N2Message::error(n2_('Slider width is not valid number!')); } if ($height < 10) { N2Message::error(n2_('Slider height is not valid number!')); } $context = array('id' => "~'#{$slider->elementId}'", 'width' => $width . 'px', 'height' => $height . 'px', 'canvas' => 0, 'count' => count($slider->slides), 'margin' => '0px 0px 0px 0px', 'clear' => $params->get('weaker-selector', 0) ? 'clearv2.less' : 'clear.less'); $this->renderType($context); if ($params->get('imageload', 0)) { N2LESS::addFile(NEXTEND_SMARTSLIDER_ASSETS . '/less/spinner.less', $slider->cacheId, $context, NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); } $this->sizes['marginVertical'] = 0; $this->sizes['marginHorizontal'] = 0; $this->sizes['width'] = intval($context['width']); $this->sizes['height'] = intval($context['height']); $this->sizes['canvasWidth'] = intval($context['canvaswidth']); $this->sizes['canvasHeight'] = intval($context['canvasheight']); }
/** * @param $slider N2SmartSliderAbstract * @param $id * @param $params * * @return string */ static function render($slider, $id, $params) { $showImage = intval($params->get(self::$key . 'show-image')); $showTitle = intval($params->get(self::$key . 'title')); $showDescription = intval($params->get(self::$key . 'description')); if (!$showImage && !$showTitle && !$showDescription) { // Nothing to show return ''; } N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/default/thumbnail.js'), $id); N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'style.less'), $slider->cacheId, array("sliderid" => $slider->elementId), NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key); list($style, $attributes) = self::getPosition($params, self::$key); $attributes['data-offset'] = $params->get(self::$key . 'position-offset', 0); $barStyle = N2StyleRenderer::render($params->get(self::$key . 'style-bar'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); $slideStyle = N2StyleRenderer::render($params->get(self::$key . 'style-slides'), 'dot', $slider->elementId, 'div#' . $slider->elementId . ' '); $width = intval($slider->params->get(self::$key . 'width', 160)); $height = intval($slider->params->get(self::$key . 'height', 100)); $captionPlacement = $slider->params->get(self::$key . 'caption-placement', 'overlay'); if (!$showImage) { $captionPlacement = 'before'; } if (!$showTitle && !$showDescription) { $captionPlacement = 'overlay'; } $captionSize = intval($slider->params->get(self::$key . 'caption-size', 100)); $showCaption = $showTitle || $showDescription; if ($showCaption) { $captionStyle = N2StyleRenderer::render($params->get(self::$key . 'title-style'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); if ($showTitle) { $titleFont = N2FontRenderer::render($params->get(self::$key . 'title-font'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); } if ($showDescription) { $descriptionFont = N2FontRenderer::render($params->get(self::$key . 'description-font'), 'simple', $slider->elementId, 'div#' . $slider->elementId . ' '); } } $group = max(1, intval($params->get(self::$key . 'group'))); $orientation = self::getOrientationByPosition($params->get(self::$key . 'position-mode'), $params->get(self::$key . 'position-area'), $params->get(self::$key . 'orientation')); if ($orientation == 'auto') { $orientation = 'vertical'; } $slides = N2Html::openTag('table'); $containerStyle = ''; $captionClass = 'n2-caption-' . $captionPlacement; $captionExtraStyle = ''; switch ($captionPlacement) { case 'before': case 'after': switch ($orientation) { case 'vertical': if (!$showImage) { $width = 0; } $containerStyle = "width: " . ($width + $captionSize) . "px; height: {$height}px;"; $captionExtraStyle .= "width: {$captionSize}px"; break; default: if (!$showImage) { $height = 0; } $containerStyle = "width: {$width}px; height: " . ($height + $captionSize) . "px;"; $captionExtraStyle .= "height: {$captionSize}px"; } break; default: $containerStyle = "width: {$width}px; height: {$height}px;"; } $image = ''; $rows = array(); $i = 0; foreach ($slider->slides as $slide) { $active = ''; if ($slider->_activeSlide == $i) { $active = 'n2-active '; } if ($orientation == 'horizontal') { $row = $i % $group; } else { $row = intval($i / $group); } if (!isset($rows[$row])) { $rows[$row] = array(); } if ($showImage) { $image = N2Html::tag('div', array('class' => 'n2-ss-thumb-image', 'style' => "background-image: URL('" . $slide->getThumbnail() . "'); width: {$width}px; height: {$height}px;"), ''); } $inner = ''; if ($showCaption) { $html = ''; if ($showTitle) { $html .= N2Html::tag('div', array('class' => $titleFont), $slide->getTitle()); } $description = $slide->getDescription(); if ($showDescription && !empty($description)) { $html .= N2Html::tag('div', array('class' => $descriptionFont), $description); } $inner = N2Html::tag('div', array('class' => $captionStyle . 'n2-ss-caption ' . $captionClass, 'style' => $captionExtraStyle), $html); } switch ($captionPlacement) { case 'before': $inner .= $image; break; case 'after': default: $inner = $image . $inner; } $rows[$row][] = N2Html::tag('td', array(), N2Html::tag('div', array('class' => $slideStyle . $active, 'style' => $containerStyle), $inner)); $i++; } foreach ($rows as $row) { $slides .= N2Html::tag('tr', array(), implode('', $row)); } $slides .= N2Html::closeTag('table'); $parameters = array('overlay' => $params->get(self::$key . 'position-mode') != 'simple' || $params->get(self::$key . 'overlay'), 'area' => intval($params->get(self::$key . 'position-area')), 'orientation' => $orientation, 'group' => $group, 'action' => $params->get(self::$key . 'action')); N2JS::addInline('new NextendSmartSliderWidgetThumbnailDefault("' . $id . '", ' . json_encode($parameters) . ');'); $size = $params->get(self::$key . 'size'); if ($orientation == 'horizontal') { if (is_numeric($size) || substr($size, -1) == '%' || substr($size, -2) == 'px') { $style .= 'width:' . $size . ';'; } else { $attributes['data-sswidth'] = $size; } } else { if (is_numeric($size) || substr($size, -1) == '%' || substr($size, -2) == 'px') { $style .= 'height:' . $size . ';'; } else { $attributes['data-ssheight'] = $size; } } $previous = $next = ''; $showArrow = intval($slider->params->get(self::$key . 'arrow', 1)); if ($showArrow) { $previous = N2Html::image('data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed('$ss$/plugins/widgetthumbnail/default/default/thumbnail-up-arrow.svg', true))), '', array('class' => 'nextend-thumbnail-button nextend-thumbnail-previous')); $next = N2Html::image('data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2ImageHelper::fixed('$ss$/plugins/widgetthumbnail/default/default/thumbnail-down-arrow.svg', true))), '', array('class' => 'nextend-thumbnail-button nextend-thumbnail-next n2-active')); } if ($params->get(self::$key . 'position-mode') == 'simple' && $orientation == 'vertical') { $area = $params->get(self::$key . 'position-area'); switch ($area) { case '5': case '6': case '7': case '8': $attributes['data-sstop'] = '0'; break; } } return N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . 'nextend-thumbnail nextend-thumbnail-default nextend-thumbnail-' . $orientation, 'style' => $style), $previous . $next . N2Html::tag('div', array('class' => 'nextend-thumbnail-inner'), N2Html::tag('div', array('class' => $barStyle . 'nextend-thumbnail-scroller'), $slides))); }
protected function getFilesRaw() { N2GoogleFonts::build(); N2LESS::build(); return parent::getFilesRaw(); }