You are here

function lazy_configuration_form_submit in Lazy-load 7

Submit handler for lazy_configuration_form().

File

./lazy.admin.inc, line 156
Configuration form for Lazy-load.

Code

function lazy_configuration_form_submit($form, &$form_state) {
  $int_value = array(
    'lazy_filter_offset',
    'lazy_filter_saveViewportOffsetDelay',
    'lazy_filter_validateDelay',
  );
  $bool_value = array(
    'lazy_filter_loadInvisible',
    'lazy_prefer_native',
  );

  // Exclude unnecessary elements.
  form_state_values_clean($form_state);
  foreach ($form_state['values'] as $key => $value) {
    if (in_array($key, $int_value, TRUE)) {
      $value = (int) $value;
    }
    if (in_array($key, $bool_value, TRUE)) {
      $value = (bool) $value;
    }
    if (is_string($value)) {
      $value = trim($value);
    }
    variable_set($key, $value);
  }
  drupal_set_message(t('The configuration options have been saved.'));
}