Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to disable Requirements::customScript #200

Open
wants to merge 5 commits into
base: 4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Page:
After attaching the DataExtension to your page type or DataObject run a `dev/build`.

#### Adjust slider speed

Adding `FlexSliderSpeed` to the config will adjust the speed of the slider in milliseconds.
Sliders default to 7000 milliseconds, or 7 seconds to show each slide.

Expand All @@ -27,9 +28,10 @@ Page:
- Dynamic\FlexSlider\ORM\FlexSlider
```

The object that has FlexSlider applied can also have a method `setFlexSliderSpeed()`.
The object that has FlexSlider applied can also have a method `setFlexSliderSpeed()`.
This will allow for a field to be added to the cms to control speed, or more fine grained control over the speed of the slider.
If `setFlexSliderSpeed()` return 0 or false the slider will fall back to using the config value.

```php
public function setFlexSliderSpeed()
{
Expand All @@ -38,11 +40,19 @@ public function setFlexSliderSpeed()
```

Adjusting the defualt for all sliders can also be done in the config.

```yml
Dynamic\FlexSlider\ORM\FlexSlider:
FlexSliderSpeed: 3000
```

To disable including the custom JavaScript, use the `ClearRequirements` configuration:

```yml
Dynamic\FlexSlider\ORM\FlexSlider:
ClearRequirements: true
KINKCreative marked this conversation as resolved.
Show resolved Hide resolved
```

### User Guide

You should now see a "Slides" tab on the page type or DataObject to which you applied the DataExtension. Simply create Slides to be included in the slide show that link to other pages on your website.
Expand Down
16 changes: 11 additions & 5 deletions src/ORM/FlexSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public function contentcontrollerInit()
*/
public function getCustomScript()
{

if ($this->owner()->config('ClearRequirements')) {
KINKCreative marked this conversation as resolved.
Show resolved Hide resolved
return;
}

// Flexslider options
$sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : '';

Expand All @@ -222,13 +227,13 @@ public function getCustomScript()
"(function($) {
$(document).ready(function(){
jQuery('.flexslider').each(function(index){

if(jQuery('.fs-carousel').eq(index).length) {
jQuery('.fs-carousel').eq(index).flexslider({
slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ",
animation: 'slide',
animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ",
controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean() . ",
controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean() . ",
directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ",
prevText: '',
nextText: '',
Expand All @@ -241,7 +246,7 @@ public function getCustomScript()
itemMargin: 10
});
}

if(jQuery('.flexslider').eq(index).length){
jQuery('.flexslider').eq(index).flexslider({
slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ",
Expand All @@ -259,12 +264,13 @@ public function getCustomScript()
},
before: " . $before . ',
after: ' . $after . ',
slideshowSpeed: ' . $speed . '
slideshowSpeed: ' . $speed . '
});
}
})
});
}(jQuery));'
}(jQuery));',
'flexsliderjquery'
);
}

Expand Down