-
Notifications
You must be signed in to change notification settings - Fork 0
/
nivo_slider_options.admin.inc
322 lines (307 loc) · 13.4 KB
/
nivo_slider_options.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
/**
* @file
* Generate configuration form and save settings.
*/
/**
* Configuration form for slider options.
*/
function nivo_slider_option_configuration_form($form, &$form_state) {
$config = config('nivo_slider.settings');
// Create a list of the currently available themes
$themes = module_invoke_all('nivo_slider_theme_info');
// Allow theme information to be altered
backdrop_alter('nivo_slider_theme_info', $themes);
$available_themes = array();
foreach ($themes as $theme => $properties) {
$available_themes[$theme] = $properties['name'];
}
// Theme
$form['nivo_slider_theme'] = array(
'#type' => 'select',
'#title' => t('Theme'),
'#options' => $available_themes,
'#default_value' => $config->get('nivo_slider_theme'),
'#description' => t('Select a slider theme. The slider theme determines the overall appearance of the slider.'),
);
// Display image style settings if the image module is available
if (module_exists('image') == TRUE) {
// Create a list of the currently available image styles
$image_styles = image_styles();
$available_themes = array();
foreach ($image_styles as $style => $properties) {
$available_image_styles[$style] = $properties['name'];
}
// Image Style
$form['nivo_slider_image_style'] = array(
'#type' => 'checkbox',
'#title' => t('Use image styles to generate slider images'),
'#default_value' => $config->get('nivo_slider_image_style'),
'#description' => t('Easily modify, scale, crop and apply various effects to slider images using <a href="@image-styles">Image styles</a>.', array('@image-styles' => '/admin/config/media/image-styles')),
);
$form['nivo_slider_image_style_slide'] = array(
'#type' => 'select',
'#title' => t('Slide image style'),
'#options' => $available_image_styles,
'#default_value' => $config->get('nivo_slider_image_style_slide'),
'#description' => t('Select an image style to apply to slide images.'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_image_style"]' => array('checked' => TRUE),
),
),
);
$form['nivo_slider_image_style_thumb'] = array(
'#type' => 'select',
'#title' => t('Tumbnail image style'),
'#options' => $available_image_styles,
'#default_value' => $config->get('nivo_slider_image_style_thumb'),
'#description' => t('Select an image style to apply to slide thumbnail images.'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_image_style"]' => array('checked' => TRUE),
),
),
);
}
// General
$form['general'] = array(
'#type' => 'fieldset',
'#title' => t('General'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['general']['nivo_slider_random_start'] = array(
'#type' => 'checkbox',
'#title' => t('Use a random starting slide'),
'#default_value' => $config->get('nivo_slider_random_start'),
'#description' => t('Randomly select a slide to begin the slideshow with.'),
);
$form['general']['nivo_slider_start_slide'] = array(
'#type' => 'textfield',
'#title' => t('Starting slide'),
'#maxlength' => 3,
'#size' => 3,
'#default_value' => $config->get('nivo_slider_start_slide'),
'#description' => t('Specify which slide the slideshow begins with.'),
'#field_prefix' => t('Slide #'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_random_start"]' => array('checked' => FALSE),
),
),
);
// Effects
$form['effects'] = array(
'#type' => 'fieldset',
'#title' => t('Effects'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['effects']['nivo_slider_effect'] = array(
'#type' => 'select',
'#title' => t('Effect'),
'#options' => array(
'sliceDown' => t('Slice Down'),
'sliceDownLeft' => t('Slice Down Left'),
'sliceUp' => t('Slice Up'),
'sliceUpLeft' => t('Slice Up Left'),
'sliceUpDown' => t('Slice Up Down'),
'sliceUpDownLeft' => t('Slice Up Down Left'),
'fold' => t('Fold'),
'fade' => t('Fade'),
'random' => t('Random'),
'slideInRight' => t('Slide In Right'),
'slideInLeft' => t('Slide in Left'),
'boxRandom' => t('Box Random'),
'boxRain' => t('Box Rain'),
'boxRainReverse' => t('Box Rain Reverse'),
'boxRainGrow' => t('Box Rain Grow'),
'boxRainGrowReverse' => t('Box Rain Grow Reverse'),
),
'#default_value' => $config->get('nivo_slider_effect'),
'#description' => t('Select an effect. The chosen effect will be used to transition between slides.'),
);
$form['effects']['effect_properties'] = array(
'#type' => 'fieldset',
'#title' => t('Effect properties'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['effects']['effect_properties']['nivo_slider_slices'] = array(
'#type' => 'textfield',
'#title' => t('Slices'),
'#maxlength' => 3,
'#size' => 3,
'#default_value' => $config->get('nivo_slider_slices'),
'#description' => t('Used for slice animations.'),
'#field_suffix' => t('Slices'),
'#states' => array(
'visible' => array(
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceDown')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceDownLeft')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceUp')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceUpLeft')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceUpDown')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'sliceUpDownLeft')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'fold')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'fade')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'random')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'slideInRight')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'slideInLeft')),
),
),
);
$form['effects']['effect_properties']['nivo_slider_box_columns'] = array(
'#type' => 'textfield',
'#title' => t('Box columns'),
'#maxlength' => 3,
'#size' => 3,
'#default_value' => $config->get('nivo_slider_box_columns'),
'#description' => t('Used for box animations.'),
'#field_suffix' => t('Columns'),
'#states' => array(
'visible' => array(
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRandom')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRain')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainReverse')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainGrow')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainGrowReverse')),
),
),
);
$form['effects']['effect_properties']['nivo_slider_box_rows'] = array(
'#type' => 'textfield',
'#title' => t('Box rows'),
'#maxlength' => 3,
'#size' => 3,
'#default_value' => $config->get('nivo_slider_box_rows'),
'#description' => t('Used for box animations.'),
'#field_suffix' => t('Rows'),
'#states' => array(
'visible' => array(
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRandom')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRain')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainReverse')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainGrow')),
array(':input[name="nivo_slider_effect"]' => array('value' => 'boxRainGrowReverse')),
),
),
);
$form['effects']['nivo_slider_animation_speed'] = array(
'#type' => 'textfield',
'#title' => t('Animation speed'),
'#maxlength' => 6,
'#size' => 6,
'#default_value' => $config->get('nivo_slider_animation_speed'),
'#description' => t('Enter a time in milliseconds. The animation speed determines how long it takes to transition from one slide to the next.'),
'#field_suffix' => t('ms'),
);
$form['effects']['nivo_slider_pause_on_hover'] = array(
'#type' => 'checkbox',
'#title' => t('Pause animation when hovering over the slide'),
'#default_value' => $config->get('nivo_slider_pause_on_hover'),
'#description' => t('Disable slide transitions while the user is hovering over the slide.'),
);
// Navigation
$form['navigation'] = array(
'#type' => 'fieldset',
'#title' => t('Navigation'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['navigation']['nivo_slider_directional_navigation'] = array(
'#type' => 'checkbox',
'#title' => t('Display directional navigation'),
'#default_value' => $config->get('nivo_slider_directional_navigation'),
'#description' => t('Display navigation buttons to go back to the previous slide and move forward to the next slide.'),
);
$form['navigation']['nivo_slider_next_text'] = array(
'#type' => 'textfield',
'#title' => t('Next button text'),
'#default_value' => $config->get('nivo_slider_next_text'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_directional_navigation"]' => array('checked' => TRUE),
),
),
);
$form['navigation']['nivo_slider_previous_text'] = array(
'#type' => 'textfield',
'#title' => t('Previous button text'),
'#default_value' => $config->get('nivo_slider_previous_text'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_directional_navigation"]' => array('checked' => TRUE),
),
),
);
$form['navigation']['nivo_slider_control_navigation'] = array(
'#type' => 'checkbox',
'#title' => t('Display control navigation'),
'#default_value' => $config->get('nivo_slider_control_navigation'),
'#description' => t('Display navigation buttons to select an individual slide.'),
);
$form['navigation']['nivo_slider_control_nav_thumbs'] = array(
'#type' => 'checkbox',
'#title' => t('Use thumbnails for control navigation'),
'#default_value' => $config->get('nivo_slider_control_nav_thumbs'),
'#description' => t('Use thumbnails of each slide as control navigation buttons. In order for thumbnails to be displayed, a compatible theme is required.'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_control_navigation"]' => array('checked' => TRUE),
),
),
);
$form['navigation']['nivo_slider_manual_advance'] = array(
'#type' => 'checkbox',
'#title' => t('Disable automatic slide transitions'),
'#default_value' => $config->get('nivo_slider_manual_advance'),
'#description' => t('For the use to manually navigate between slides.'),
);
$form['navigation']['nivo_slider_pause_time'] = array(
'#type' => 'textfield',
'#title' => t('Pause time'),
'#maxlength' => 6,
'#size' => 6,
'#default_value' => $config->get('nivo_slider_pause_time'),
'#description' => t('Enter a time in milliseconds. The pause time determines how long each slide is displayed before transitioning to the next slide.'),
'#field_suffix' => t('ms'),
'#states' => array(
'visible' => array(
':input[name="nivo_slider_manual_advance"]' => array('checked' => FALSE),
),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
/**
* Configuration form for slider options.
*/
function nivo_slider_option_configuration_form_submit($form, &$form_state) {
$config = config('nivo_slider.settings');
$config->set('nivo_slider_theme', $form_state['values']['nivo_slider_theme']);
$config->set('nivo_slider_image_style', $form_state['values']['nivo_slider_image_style']);
$config->set('nivo_slider_image_style_slide', $form_state['values']['nivo_slider_image_style_slide']);
$config->set('nivo_slider_image_style_thumb', $form_state['values']['nivo_slider_image_style_thumb']);
$config->set('nivo_slider_random_start', $form_state['values']['nivo_slider_random_start']);
$config->set('nivo_slider_start_slide', $form_state['values']['nivo_slider_start_slide']);
$config->set('nivo_slider_effect', $form_state['values']['nivo_slider_effect']);
$config->set('nivo_slider_slices', $form_state['values']['nivo_slider_slices']);
$config->set('nivo_slider_box_columns', $form_state['values']['nivo_slider_box_columns']);
$config->set('nivo_slider_box_rows', $form_state['values']['nivo_slider_box_rows']);
$config->set('nivo_slider_animation_speed', $form_state['values']['nivo_slider_animation_speed']);
$config->set('nivo_slider_pause_on_hover', $form_state['values']['nivo_slider_pause_on_hover']);
$config->set('nivo_slider_directional_navigation', $form_state['values']['nivo_slider_directional_navigation']);
$config->set('nivo_slider_next_text', $form_state['values']['nivo_slider_next_text']);
$config->set('nivo_slider_previous_text', $form_state['values']['nivo_slider_previous_text']);
$config->set('nivo_slider_control_navigation', $form_state['values']['nivo_slider_control_navigation']);
$config->set('nivo_slider_control_nav_thumbs', $form_state['values']['nivo_slider_control_nav_thumbs']);
$config->set('nivo_slider_manual_advance', $form_state['values']['nivo_slider_manual_advance']);
$config->set('nivo_slider_pause_time', $form_state['values']['nivo_slider_pause_time']);
$config->save();
}