You are here

public function views_accordion_style_plugin::options_form in Views Accordion 7

Same name and namespace in other branches
  1. 6 views_accordion_style_plugin.inc \views_accordion_style_plugin::options_form()

Provide a form to edit options for this plugin.

Overrides views_plugin_style::options_form

File

./views_accordion_style_plugin.inc, line 65
Provide an accordion style plugin for Views. This file is autoloaded by views.

Class

views_accordion_style_plugin
Implements views_plugin_style().

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['grouping']['#prefix'] = '<div class="form-item">' . t('<strong>IMPORTANT:</strong> The <em>first field</em> in order of appearance <em>will</em> be the one used as the "header" or "trigger" of the accordion action.') . '</div>';

  // Available valid options for grouping (used for use-grouping-header
  // #dependency).
  $options = array();
  foreach ($this->display->handler
    ->get_handlers('field') as $field => $handler) {
    $options[] = $field;
  }

  // Find out how many items the display is currently configured to show
  // (row-start-open).
  $maxitems = $this->display->handler
    ->get_option('items_per_page');

  // If items_per_page is set to unlimitted (0), 10 rows will be what the user
  // gets to choose from.
  $maxitems = $maxitems == 0 ? 10 : $maxitems;

  // Setup our array of options for choosing which row should start opened
  // (row-start-open).
  $rsopen_options = array();
  for ($i = 1; $i <= $maxitems; $i++) {
    $rsopen_options[] = t('Row') . $i;
  }
  $rsopen_options['none'] = t('None');
  $rsopen_options['random'] = t('Random');

  // The easing effects from jQuery UI.
  $animated_options = array(
    'none' => t('None'),
    'slide' => t('Slide'),
    'swing' => t('Swing'),
    'linear' => t('Linear'),
    'bounceslide' => t('Bounceslide'),
    'easeInQuart' => t('easeInQuart'),
    'easeOutQuart' => t('easeOutQuart'),
    'easeInOutQuart' => t('easeInOutQuart'),
    'easeInExpo' => t('easeInExpo'),
    'easeOutExpo' => t('easeOutExpo'),
    'easeInOutExpo' => t('easeInOutExpo'),
    'easeInBack' => t('easeInBack'),
    'easeOutBack' => t('easeOutBack'),
    'easeInOutBack' => t('easeInOutBack'),
    'easeInQuad' => t('easeInQuad'),
    'easeOutQuad' => t('easeOutQuad'),
    'easeInOutQuad' => t('easeInOutQuad'),
    'easeInQuint' => t('easeInQuint'),
    'easeOutQuint' => t('easeOutQuint'),
    'easeInOutQuint' => t('easeInOutQuint'),
    'easeInCirc' => t('easeInCirc'),
    'easeOutCirc' => t('easeOutCirc'),
    'easeInOutCirc' => t('easeInOutCirc'),
    'easeInBounce' => t('easeInBounce'),
    'easeOutBounce' => t('easeOutBounce'),
    'easeInOutBounce' => t('easeInOutBounce'),
    'easeInCubic' => t('easeInCubic'),
    'easeOutCubic' => t('easeOutCubic'),
    'easeInOutCubic' => t('easeInOutCubic'),
    'easeInSine' => t('easeInSine'),
    'easeOutSine' => t('easeOutSine'),
    'easeInOutSine' => t('easeInOutSine'),
    'easeInElastic' => t('easeInElastic'),
    'easeOutElastic' => t('easeOutElastic'),
    'easeInOutElastic' => t('easeInOutElastic'),
  );
  if ($this->newoptions) {

    // Slide easing was removed from jQuery UI.
    unset($animated_options['slide']);
    unset($animated_options['bounceslide']);
  }
  $form['use-grouping-header'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use the group header as the Accordion header'),
    '#default_value' => $this->options['use-grouping-header'],
    '#description' => t("If checked, the Group's header will be used to open/close the accordion."),
    '#dependency' => array(
      'edit-style-options-grouping' => $options,
    ),
  );
  $form['row-start-open'] = array(
    '#type' => 'select',
    '#title' => t('Row to display opened on start'),
    '#default_value' => $this->options['row-start-open'],
    '#description' => t('Choose which row should start opened when the accordion first loads. If you want all to start closed, choose "None", and make sure to have "Allow for all rows to be closed" on below.'),
    '#options' => $rsopen_options,
  );
  $form['collapsible'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow for all rows to be closed'),
    '#default_value' => $this->options['collapsible'],
    '#description' => t('If you check this on, when the user clicks on an opened item, it will close.'),
  );
  $form['animated'] = array(
    '#type' => 'select',
    '#title' => t('Animation effect'),
    '#default_value' => $this->options['animated'],
    '#description' => t('Choose what animation effect you would like to see, or "None" to disable it.'),
    '#options' => $animated_options,
  );

  // Animate duration only available from jquery >= 1.9.
  if ($this->newoptions) {
    $form['animation_time'] = array(
      '#type' => 'textfield',
      '#title' => t('Animation time'),
      '#default_value' => $this->options['animation_time'],
      '#description' => t('The animation duration in milliseconds'),
      '#element_validate' => array(
        'views_element_validate_integer',
      ),
    );
  }
  $form['autoheight'] = array(
    '#type' => 'checkbox',
    '#title' => t('Autoheight'),
    '#default_value' => $this->options['autoheight'],
    '#description' => t('If set, the highest content part is used as height reference for all other parts. Provides more consistent animations.'),
  );
  $form['event'] = array(
    '#type' => 'select',
    '#title' => t('Event'),
    '#default_value' => $this->options['event'],
    '#description' => t('The event on which to trigger the accordion.'),
    '#options' => array(
      'click' => t('Click'),
      'mouseover' => t('Mouseover'),
    ),
  );
  $form['fillspace'] = array(
    '#type' => 'checkbox',
    '#title' => t('Fillspace'),
    '#default_value' => $this->options['fillspace'],
    '#description' => t('If set, the accordion completely fills the height of the parent element. Overrides autoheight.'),
  );
  $form['navigation'] = array(
    '#type' => 'checkbox',
    '#title' => t('Navigation'),
    '#default_value' => $this->options['navigation'],
    '#description' => t('If set, looks for the anchor that matches location.href and activates it. Great for href-based state-saving. Use navigationFilter to implement your own matcher.'),
  );
  $form['clearstyle'] = array(
    '#type' => 'checkbox',
    '#title' => t('Clearstyle'),
    '#default_value' => $this->options['clearstyle'],
    '#description' => t("If set, clears height and overflow styles after finishing animations. This enables accordions to work with dynamic content. Won't work together with autoHeight."),
  );
  $form['disableifone'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable if only one result'),
    '#default_value' => $this->options['disableifone'],
    '#description' => t("If set, the accordion will not be shown when there are less than 2 results."),
  );
}