Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public function parseBorder($v)
 {
     $border = explode('|*|', $v);
     $style = 'border-width: ' . $border[0] . 'px';
     $style .= 'border-style: ' . $border[1] . ';';
     $rgba = N2Color::hex2rgba($border[2]);
     $style .= 'border-color: #' . substr($border[2], 0, 6) . "; border-color: RGBA(" . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
     return $style;
 }
Esempio n. 3
0
 /**
  * @param $slide N2SmartSliderSlide
  *
  * @return string
  */
 public function make($slide)
 {
     $dynamicHeight = intval($this->slider->params->get('dynamic-height', 0));
     $backgroundImageOpacity = min(100, max(0, $slide->parameters->get('backgroundImageOpacity', 100))) / 100;
     if ($slide->hasGenerator()) {
         $rawBackgroundImage = $slide->parameters->get('backgroundImage', '');
         $backgroundImage = $slide->fill($rawBackgroundImage);
         $imageData = N2ImageManager::getImageData($rawBackgroundImage);
         $imageData['desktop-retina']['image'] = $slide->fill($imageData['desktop-retina']['image']);
         $imageData['tablet']['image'] = $slide->fill($imageData['tablet']['image']);
         $imageData['tablet-retina']['image'] = $slide->fill($imageData['tablet-retina']['image']);
         $imageData['mobile']['image'] = $slide->fill($imageData['mobile']['image']);
         $imageData['mobile-retina']['image'] = $slide->fill($imageData['mobile-retina']['image']);
     } else {
         $backgroundImage = $slide->fill($slide->parameters->get('backgroundImage', ''));
         $imageData = N2ImageManager::getImageData($backgroundImage);
     }
     $sizes = $this->slider->assets->sizes;
     $backgroundColor = '';
     $color = $slide->parameters->get('backgroundColor', '');
     if (strlen($color) == 8 && substr($color, 6, 2) != '00') {
         $backgroundColor = 'background-color: #' . substr($color, 0, 6) . ';';
         if (!class_exists('N2Color')) {
             N2Loader::import("libraries.image.color");
         }
         $rgba = N2Color::hex2rgba($color);
         $rgba[3] = round($rgba[3] / 127, 2);
         $backgroundColor .= "background-color: RGBA({$rgba[0]}, {$rgba[1]}, {$rgba[2]}, {$rgba[3]});";
     }
     if (empty($backgroundImage)) {
         $src = N2Image::base64Transparent();
     } else {
         $src = $backgroundImage;
     }
     $alt = $slide->parameters->get('backgroundAlt', '');
     $title = $slide->parameters->get('backgroundTitle', '');
     $fillMode = $slide->parameters->get('backgroundMode', 'default');
     if ($fillMode == 'default') {
         $fillMode = $this->slider->params->get('backgroundMode', 'fill');
     }
     if ($dynamicHeight) {
         return $this->simple($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes);
     }
     switch ($fillMode) {
         case 'fit':
             return $this->fit($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes);
         case 'stretch':
             return $this->stretch($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title);
         case 'center':
             return $this->center($backgroundColor, $backgroundImageOpacity, $src, $imageData);
         case 'tile':
             return $this->tile($backgroundColor, $backgroundImageOpacity, $src, $imageData);
     }
     return $this->fill($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes);
 }
Esempio n. 4
0
 /**
  * @param $v
  *
  * @return string
  */
 public function parseTshadow($v)
 {
     $v = N2Parse::parse($v);
     $rgba = N2Color::hex2rgba($v[3]);
     if ($v[0] == 0 && $v[1] == 0 && $v[2] == 0) {
         return 'text-shadow: none;';
     }
     return 'text-shadow: ' . $v[0] . 'px ' . $v[1] . 'px ' . $v[2] . 'px RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ');';
 }