You are here

function browsersync_form_system_theme_settings_alter in Browsersync 7

Same name and namespace in other branches
  1. 8.2 browsersync.module \browsersync_form_system_theme_settings_alter()
  2. 8 browsersync.module \browsersync_form_system_theme_settings_alter()

Implements hook_form_system_theme_settings_alter().

Adds the Browsersync configuration options to the theme settings form.

See also

system_theme_settings()

File

./browsersync.module, line 77
Code for the Browsersync module.

Code

function browsersync_form_system_theme_settings_alter(&$form, &$form_state, $form_id) {

  // Extract the theme key from the form arguments. If not present, it means
  // that we are altering the global theme settings form.
  $args = $form_state['build_info']['args'];
  $theme_key = !empty($args[0]) ? $args[0] : NULL;
  $form['browsersync'] = array(
    '#type' => 'fieldset',
    '#title' => 'Browsersync settings',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['browsersync']['browsersync_enabled'] = array(
    '#title' => 'Enable Browsersync',
    '#type' => 'checkbox',
    '#default_value' => browsersync_get_setting('enabled', FALSE, $theme_key),
  );
  $form['browsersync']['settings'] = array(
    '#type' => 'container',
    '#states' => array(
      'visible' => array(
        'input[name="browsersync_enabled"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['browsersync']['settings']['browsersync_host'] = array(
    '#title' => 'Host',
    '#type' => 'textfield',
    '#description' => t('Override host detection if you know the correct IP to use.'),
    '#default_value' => browsersync_get_setting('host', '', $theme_key),
  );
  $form['browsersync']['settings']['browsersync_port'] = array(
    '#title' => 'Port',
    '#type' => 'textfield',
    '#description' => t('Use a specific port (instead of the one auto-detected by Browsersync).'),
    '#default_value' => browsersync_get_setting('port', '', $theme_key),
  );
}