--- flexslider.admin.inc 2012-05-17 13:59:14.000000000 -0700 +++ flexslider.admin.inc 2012-11-29 10:42:19.418731842 -0800 @@ -79,7 +79,7 @@ $optionset->name = $form_state['values']['name']; $optionset->title = $form_state['values']['title']; $optionset->options = array(); - + $saved = ctools_export_crud_save('flexslider_optionset', $optionset); drupal_set_message(t('Option set %name was created.', array('%name' => $optionset->name))); @@ -96,13 +96,13 @@ */ function flexslider_option_elements($options = array()) { $form = array(); - + // General Slideshow and Animiation Settings $form['animation_slideshow'] = array( '#type' => 'fieldset', '#title' => t('General Slideshow and Animation Settings'), ); - + $form['animation_slideshow']['animation'] = array( '#type' => 'select', '#title' => t('Animation'), @@ -112,18 +112,8 @@ 'slide' => t('Slide'), ), '#default_value' => isset($options['animation']) ? $options['animation'] : 'fade', - // @todo add states to enable/disable the direction ); - - $form['animation_slideshow']['animationDuration'] = array( - '#type' => 'textfield', - '#title' => t('Animation speed'), - '#description' => t('Set the speed of animations, in milliseconds'), - '#element_validate' => array('_flexslider_validate_positive_integer'), - '#default_value' => isset($options['animationDuration']) ? $options['animationDuration'] : 600, - '#size' => 30, - ); - + $form['animation_slideshow']['slideDirection'] = array( '#type' => 'select', '#title' => t('Slide Direction'), @@ -133,6 +123,23 @@ 'vertical' => t('Vertical'), ), '#default_value' => isset($options['slideDirection']) ? $options['slideDirection'] : 'horizontal', + '#states' => array( + 'visible' => array( + ':input[name="animation"]' => array('value' => 'slide'), + ), + 'invisible' => array( + ':input[name="animation"]' => array('value' => 'fade'), + ), + ), + ); + + $form['animation_slideshow']['animationDuration'] = array( + '#type' => 'textfield', + '#title' => t('Animation speed'), + '#description' => t('Set the speed of animations, in milliseconds'), + '#element_validate' => array('_flexslider_validate_positive_integer'), + '#default_value' => isset($options['animationDuration']) ? $options['animationDuration'] : 600, + '#size' => 30, ); $form['animation_slideshow']['slideshow'] = array( @@ -141,7 +148,7 @@ '#description' => t('Animate the slides automatically'), '#default_value' => isset($options['slideshow']) ? $options['slideshow'] : TRUE, ); - + $form['animation_slideshow']['slideshowSpeed'] = array( '#type' => 'textfield', '#title' => t('Slideshow speed'), @@ -171,9 +178,16 @@ '#element_validate' => array('_flexslider_validate_positive_integer'), '#default_value' => isset($options['slideToStart']) ? $options['slideToStart'] : 0, '#size' => 30, - // @todo add states to disable if randomize is set + '#states' => array( + 'visible' => array( + ':input[name="randomize"]' => array('checked' => FALSE), + ), + 'invisible' => array( + ':input[name="randomize"]' => array('checked' => TRUE), + ), + ), ); - + // Navigation and Control Settings $form['nav_controls'] = array( '#type' => 'fieldset', @@ -209,12 +223,28 @@ '#title' => t('Previous Link Text'), '#description' => t('Set the text for the "previous" control item. Text translation can be controlled using the String Overrides module.'), '#default_value' => isset($options['prevText']) ? $options['prevText'] : 'Previous', + '#states' => array( + 'visible' => array( + ':input[name="directionNav"]' => array('checked' => TRUE), + ), + 'invisible' => array( + ':input[name="directionNav"]' => array('checked' => FALSE), + ), + ), ); $form['nav_controls']['nextText'] = array( '#type' => 'textfield', '#title' => t('Next Link Text'), '#description' => t('Set the text for the "next" control item. Text translation can be controlled using the String Overrides module.'), '#default_value' => isset($options['nextText']) ? $options['nextText'] : 'Next', + '#states' => array( + 'visible' => array( + ':input[name="directionNav"]' => array('checked' => TRUE), + ), + 'invisible' => array( + ':input[name="directionNav"]' => array('checked' => FALSE), + ), + ), ); // Advanced Options @@ -222,58 +252,76 @@ '#type' => 'fieldset', '#title' => t('Advanced Options'), ); + $form['advanced']['pauseOnHover'] = array( + '#type' => 'checkbox', + '#title' => t('Pause on Hover'), + '#description' => t('Have FlexSlider pause the slideshow when user is hovering over the current slide, and resume when user moves mouse off current slide.'), + '#default_value' => isset($options['pauseOnHover']) ? $options['pauseOnHover'] : FALSE, + ); $form['advanced']['pausePlay'] = array( '#type' => 'checkbox', '#title' => t('Add Pause/Play Indicator'), '#description' => t('Have FlexSlider add an element indicating the current state of the slideshow (i.e. "pause" or "play").'), '#default_value' => isset($options['pausePlay']) ? $options['pausePlay'] : FALSE, - // @todo add states value for pause/play text ); - $form['advanced']['pauseText'] = array( + $form['advanced']['pauseTextWrapper'] = array( + '#type' => 'fieldset', + '#title' => t('Pause/Play options'), + '#tree' => FALSE, + '#states' => array( + 'visible' => array( + ':input[name="pausePlay"]' => array('checked' => TRUE), + ), + 'invisible' => array( + ':input[name="pausePlay"]' => array('checked' => FALSE), + ), + ), + ); + $form['advanced']['pauseTextWrapper']['pauseText'] = array( '#type' => 'textfield', '#title' => t('Pause State Text'), '#description' => t('Set the text for the "pause" state indicator. Text translation can be controlled using the String Overrides module.'), '#default_value' => isset($options['pauseText']) ? $options['pauseText'] : 'Pause', ); - $form['advanced']['playText'] = array( + $form['advanced']['pauseTextWrapper']['playText'] = array( '#type' => 'textfield', '#title' => t('Play State Text'), '#description' => t('Set the text for the "play" state indicator. Text translation can be controlled using the String Overrides module.'), '#default_value' => isset($options['playText']) ? $options['playText'] : 'Play', ); - $form['advanced']['pauseOnAction'] = array( + $form['advanced']['pauseTextWrapper']['pauseOnAction'] = array( '#type' => 'checkbox', '#title' => t('Pause On Controls'), '#description' => t('Pause the slideshow when interacting with control elements.'), '#default_value' => isset($options['pauseOnAction']) ? $options['pauseOnAction'] : TRUE, ); - $form['advanced']['controlsContainer'] = array( + $form['advanced']['pauseTextWrapper']['controlsContainer'] = array( '#type' => 'textfield', '#title' => t('Controls container (Advanced)'), '#description' => t('Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.'), '#default_value' => isset($options['controlsContainer']) ? $options['controlsContainer'] : '.flex-nav-container', ); - $form['advanced']['manualControls'] = array( + $form['advanced']['pauseTextWrapper']['manualControls'] = array( '#type' => 'textfield', '#title' => t('Manual controls (Advanced)'), '#description' => t('Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.'), '#default_value' => isset($options['manualControls']) ? $options['manualControls'] : '', ); - + if (module_exists('bulk_export')) { } else { - + } - + return $form; } /** * Form builder; Form to edit a given option set. */ -function flexslider_form_optionset_edit($form, &$form_state, $optionset) { +function flexslider_form_optionset_edit($form, &$form_state, $optionset) { if (empty($form_state['optionset'])) { $form_state['optionset'] = $optionset; @@ -321,7 +369,7 @@ // Map current settings to form elements // @todo - + // Add form actions $form['actions'] = array( '#type' => 'actions', @@ -389,6 +437,7 @@ $optionset->options['pausePlay'] = $form_state['values']['pausePlay']; $optionset->options['pauseText'] = $form_state['values']['pauseText']; $optionset->options['playText'] = $form_state['values']['playText']; + $optionset->options['pauseOnHover'] = $form_state['values']['pauseOnHover']; $optionset->options['pauseOnAction'] = $form_state['values']['pauseOnAction']; $optionset->options['controlsContainer'] = $form_state['values']['controlsContainer']; $optionset->options['manualControls'] = $form_state['values']['manualControls']; @@ -453,7 +502,7 @@ '#default_value' => variable_get('flexslider_debug', FALSE), '#access' => user_access('administer flexslider'), ); - + return system_settings_form($form); } @@ -477,7 +526,7 @@ */ function flexslider_form_optionset_export() { $output = ''; - + // Check for an appropriate export tool if (module_exists('bulk_export') || module_exists('features')) { $output .= 'Use any of the following to export your option sets.';