1 | <?php |
||
3 | class FlexSlider extends DataExtension |
||
4 | { |
||
5 | /** |
||
6 | * @var array |
||
7 | */ |
||
8 | public static $db = array( |
||
9 | 'Animation' => "Enum('slide, fade', 'slide')", |
||
10 | 'Loop' => 'Boolean', |
||
11 | 'Animate' => 'Boolean', |
||
12 | 'ThumbnailNav' => 'Boolean', |
||
13 | 'SliderControlNav' => 'Boolean', |
||
14 | 'SliderDirectionNav' => 'Boolean', |
||
15 | 'CarouselControlNav' => 'Boolean', |
||
16 | 'CarouselDirectionNav' => 'Boolean', |
||
17 | 'CarouselThumbnailCt' => 'Int', |
||
18 | ); |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | public static $has_many = array( |
||
24 | 'Slides' => 'SlideImage', |
||
25 | ); |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | */ |
||
30 | 4 | public function populateDefaults() |
|
41 | |||
42 | /** |
||
43 | * @param FieldList $fields |
||
44 | */ |
||
45 | 2 | public function updateCMSFields(FieldList $fields) |
|
92 | |||
93 | /** |
||
94 | * @return DataList |
||
95 | */ |
||
96 | 2 | public function SlideShow() |
|
106 | |||
107 | /** |
||
108 | * add requirements to Page_Controller init() |
||
109 | */ |
||
110 | public function contentcontrollerInit() |
||
119 | |||
120 | /** |
||
121 | * |
||
122 | */ |
||
123 | public function getCustomScript() |
||
124 | { |
||
125 | // Flexslider options |
||
126 | $sync = ($this->owner->ThumbnailNav == true) ? "sync: '.carousel:eq('+index+')'," : ''; |
||
127 | |||
128 | $before = (method_exists($this->owner->ClassName, 'flexSliderBeforeAction')) |
||
129 | ? $this->owner->flexSliderBeforeAction() |
||
130 | : 'function(){}'; |
||
131 | |||
132 | $after = (method_exists($this->owner->ClassName, 'flexSliderAfterAction')) |
||
133 | ? $this->owner->flexSliderAfterAction() |
||
134 | : 'function(){}'; |
||
135 | |||
136 | $speed = (method_exists($this->owner->ClassName, 'setFlexSliderSpeed')) |
||
137 | ? $this->owner->setFlexSliderSpeed() |
||
138 | : 7000; |
||
139 | |||
140 | Requirements::customScript(" |
||
141 | (function($) { |
||
142 | $(document).ready(function(){ |
||
143 | jQuery('.flexslider').each(function(index){ |
||
144 | |||
145 | if(jQuery('.carousel').eq(index).length) { |
||
146 | jQuery('.carousel').eq(index).flexslider({ |
||
147 | slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
||
148 | animation: '" . $this->owner->Animation . "', |
||
149 | animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
||
150 | controlNav: " . $this->owner->obj('CarouselControlNav')->NiceAsBoolean() . ", |
||
151 | directionNav: " . $this->owner->obj('CarouselDirectionNav')->NiceAsBoolean() . ", |
||
152 | prevText: '', |
||
153 | nextText: '', |
||
154 | pausePlay: false, |
||
155 | asNavFor: '.flexslider:eq('+index+')', |
||
156 | minItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
||
157 | maxItems: " . $this->owner->obj('CarouselThumbnailCt') . ", |
||
158 | move: " . $this->owner->obj('CarouselThumbnailCt') . ", |
||
159 | itemWidth: 100, |
||
160 | itemMargin: 10 |
||
161 | }); |
||
162 | } |
||
163 | |||
164 | if(jQuery('.flexslider').eq(index).length){ |
||
165 | jQuery('.flexslider').eq(index).flexslider({ |
||
166 | slideshow: " . $this->owner->obj('Animate')->NiceAsBoolean() . ", |
||
167 | animation: '" . $this->owner->Animation . "', |
||
168 | animationLoop: " . $this->owner->obj('Loop')->NiceAsBoolean() . ", |
||
169 | controlNav: " . $this->owner->obj('SliderControlNav')->NiceAsBoolean() . ", |
||
170 | directionNav: " . $this->owner->obj('SliderDirectionNav')->NiceAsBoolean() . ", |
||
171 | prevText: '', |
||
172 | nextText: '', |
||
173 | pauseOnAction: true, |
||
174 | pauseOnHover: true, |
||
175 | " . $sync . " |
||
176 | start: function(slider){ |
||
177 | $('body').removeClass('loading'); |
||
178 | }, |
||
179 | before: " . $before . ', |
||
180 | after: ' . $after . ', |
||
181 | slideshowSpeed: ' . $speed . ' |
||
182 | }); |
||
183 | } |
||
184 | }) |
||
185 | }); |
||
186 | }(jQuery));', 'jqueryFlexSlider' |
||
187 | ); |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * |
||
192 | */ |
||
193 | 3 | public function onBeforeWrite() |
|
202 | } |
||
203 |