diff --git a/docs/en/index.md b/docs/en/index.md index d15ec3f..98cc878 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -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. @@ -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() { @@ -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 `clear_requirements` configuration: + +```yml +Dynamic\FlexSlider\ORM\FlexSlider: + clear_requirements: true +``` + ### 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. diff --git a/src/ORM/FlexSlider.php b/src/ORM/FlexSlider.php index 0617be6..c77c924 100644 --- a/src/ORM/FlexSlider.php +++ b/src/ORM/FlexSlider.php @@ -205,6 +205,11 @@ public function contentcontrollerInit() */ public function getCustomScript() { + + if ($this->owner->config('clear_requirements')) { + return; + } + // Flexslider options $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.fs-carousel:eq('+index+')'," : ''; @@ -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: '', @@ -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() . ", @@ -259,12 +264,13 @@ public function getCustomScript() }, before: " . $before . ', after: ' . $after . ', - slideshowSpeed: ' . $speed . ' + slideshowSpeed: ' . $speed . ' }); } }) }); - }(jQuery));' + }(jQuery));', + 'flexsliderjquery' ); }