You are here

function masonry_form_search_admin_settings_alter in Masonry API 7

Implements hook_form_FORM_ID_alter() for search_admin_settings.

File

masonry_search/masonry_search.module, line 10
Displays search results in a jQuery Masonry grid.

Code

function masonry_form_search_admin_settings_alter(&$form, &$form_state, $form_id) {
  $settings = variable_get('masonry_search', masonry_default_options());
  $form['masonry_search'] = array(
    '#type' => 'fieldset',
    '#title' => t('Masonry'),
    '#tree' => TRUE,
  );
  $form['masonry_search']['masonry'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Masonry'),
    '#description' => t("Display search results in a grid using the jQuery Masonry plugin."),
    '#default_value' => $settings['masonry'],
  );
  if (($library = libraries_detect('masonry')) && !empty($library['installed'])) {
    masonry_options_form($form['masonry_search'], $settings);
    $form['masonry_search']['masonry_width_unit']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_width_unit']['#prefix'] = '<div class="masonry-options" style="padding-left: 1.5em;">';
    $form['masonry_search']['masonry_width']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_animated']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_animated_duration']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
        'input.form-checkbox[name$="masonry_search[masonry_animated]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_animated_duration']['#prefix'] = '<div class="masonry-options animation" style="padding-left: 1.5em;">';
    $form['masonry_search']['masonry_animated_duration']['#suffix'] = '</div>';
    $form['masonry_search']['masonry_resizable']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_center']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_gutter']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_rtl']['#states'] = array(
      'visible' => array(
        'input.form-checkbox[name$="masonry_search[masonry]"]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['masonry_search']['masonry_rtl']['#suffix'] = '</div>';
  }
}