Compare commits

..

No commits in common. "367c33939cd2c59e934b0917ff3da28d310c2570" and "d955523d45fd7ffbfdcf0950cf7eda36c0776818" have entirely different histories.

4 changed files with 4 additions and 160 deletions

View File

@ -62,7 +62,3 @@ Dynamic\Elements\Image\Elements\ElementImage:
DNADesign\ElementalVirtual\Model\ElementVirtual:
controller_template: VirtualElementHolder
Dynamic\FlexSlider\Model\SlideImage:
extensions:
- A2nt\ElementalBasics\Extensions\SlideImageEx

View File

@ -8,11 +8,9 @@
namespace A2nt\ElementalBasics\Elements;
use Colymba\BulkUpload\BulkUploader;
use Dynamic\Elements\Flexslider\Elements\ElementSlideshow;
use Dynamic\FlexSlider\Model\SlideImage;
use Dynamic\FlexSlider\ORM\FlexSlider;
use SilverStripe\Assets\Image;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\LiteralField;
@ -35,8 +33,6 @@ class SliderElement extends ElementSlideshow
private static $db = [
'Interval' => 'Int',
'SlidesInRow' => 'Int',
'ImageOriginalSize' => 'Boolean(0)',
];
private static $extensions = [
@ -54,28 +50,14 @@ class SliderElement extends ElementSlideshow
return self::$singular_name;
}
protected function ratioSize($size)
{
$count = $this->SlidesInRow;
return ($count > 1) ? $size / $count : $size;
}
public function getSlideWidth()
{
if($this->getField('ImageOriginalSize')){
return null;
}
return $this->ratioSize(self::config()->get('slide_width'));
return self::config()->get('slide_width');
}
public function getSlideHeight()
{
if($this->getField('ImageOriginalSize')){
return null;
}
return $this->ratioSize(self::config()->get('slide_height'));
return self::config()->get('slide_height');
}
public function getCMSFields()
@ -97,22 +79,13 @@ class SliderElement extends ElementSlideshow
]);
$fields->addFieldsToTab('Root.Settings', [
CheckboxField::create('ImageOriginalSize', 'Use original image size'),
NumericField::create('Interval', 'Auto-play Interval (sec)'),
NumericField::create('SlidesInRow'),
NumericField::create('Interval', 'Auto-play Interval'),
]);
$grid = $fields->dataFieldByName('Slides');
if ($grid) {
$config = $grid->getConfig();
$bulk = new BulkUploader('Image', SlideImage::class, false);
$bulk
->setUfSetup('setFolderName', 'Uploads/SlideImages')
->setUfSetup('getValidator.setAllowedExtensions', ['jpg', 'jpeg', 'png', 'gif']);
$config->addComponent($bulk);
$columns = new GridFieldEditableColumns();
$columns->setDisplayFields([
'Hide' => [

View File

@ -1,112 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: tony
* Date: 6/23/18
* Time: 1:23 PM
*/
namespace A2nt\ElementalBasics\Extensions;
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DatetimeField;
use SilverStripe\Forms\ToggleCompositeField;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\ValidationResult;
class SlideImageEx extends DataExtension
{
private static $db = [
'Hide' => 'Boolean(0)',
'DateOn' => 'Datetime',
'DateOff' => 'Datetime',
];
private $_cache = [
'element' => [],
];
public function getElement()
{
if(!isset($this->_cache['element'][$this->owner->ID])) {
$this->_cache['element'][$this->owner->ID] = $this->owner->SlideshowElement();
}
return $this->_cache['element'][$this->owner->ID];
}
public function ImageURL()
{
$el = $this->getElement();
$img = $this->owner->Image();
if(!$img) {
return null;
}
if($el->getField('ImageOriginalSize')){
return $img->Link();
}
return $img->FocusFill($this->getSlideWidth(), $this->getSlideHeight())->Link();
}
public function getSlideWidth()
{
$element = $this->getElement();
if(!$element->ID) {
return SliderElement::config()->get('slide_width');
}
return $element->getSlideWidth();
}
public function getSlideHeight()
{
$element = $this->getElement();
if(!$element->ID) {
return SliderElement::config()->get('slide_height');
}
return $element->getSlideHeight();
}
public function updateCMSFields(FieldList $fields)
{
parent::updateCMSFields($fields);
$fields->removeByName([
'PageLinkID',
'Hide',
'DateOn',
'DateOff',
]);
$fields->dataFieldByName('Image')
->setTitle('Image ('.$this->getSlideWidth().' x '.$this->getSlideHeight().' px)');
$fields->addFieldToTab('Root.Main', ToggleCompositeField::create(
'ConfigHD',
'Slide Settings',
[
CheckboxField::create('Hide', 'Hide this slide? (That will hide the slide regardless of start/end fields)'),
DatetimeField::create('DateOn', 'When would you like to start showing the slide?'),
DatetimeField::create('DateOff', 'When would you like to stop showing the slide?'),
]
));
}
public function validate(ValidationResult $validationResult)
{
if (!$this->owner->Name) {
$this->owner->Name = rand();
}
}
}

View File

@ -9,20 +9,7 @@
<% if $SlideShow %>
<div class="element__content">
<div
id="Carousel{$ID}"
class="element__carousel carousel slide js-carousel
<% if $SlidesInRow > 1 %>
carousel-multislide
<% end_if %>"
<% if $SlidesInRow > 1 %>
data-length="{$SlidesInRow}"
<% end_if %>
<% if $SlideShow.count > 1 %>
<% if $Interval %> data-bs-interval="$Interval"<% end_if %>
data-bs-indicators="true" data-bs-arrows="true"
<% end_if %>
>
<div id="Carousel{$ID}" class="element__carousel carousel slide js-carousel"<% if $SlideShow.count > 1 %><% if $Interval %> data-bs-interval="$Interval"<% end_if %> data-bs-indicators="true" data-bs-arrows="true"<% end_if %>>
<div class="carousel-inner">
<% loop $SlideShow %>
<div class="carousel-item carousel-item-{$SlideType}<% if no $Controls %> carousel-item-nocontrols<% end_if %><% if $First %> active<% end_if %>">