You are here

function uniform_init in Uniform 7

Same name and namespace in other branches
  1. 6 uniform.module \uniform_init()
  2. 7.2 uniform.module \uniform_init()

Implements hook_init().

File

./uniform.module, line 109
Module for displaying sexy forms using jQuery. This module uses jQuery to theme html forms.

Code

function uniform_init() {
  $enabled = variable_get('uniform_elements', array());
  $go = current($enabled);
  if (!empty($go)) {
    $path = libraries_get_path('uniform');
    $modpath = drupal_get_path('module', 'uniform');

    // load theme css
    drupal_add_css($path . '/css/uniform.' . variable_get('uniform_theme', 'default') . '.css');
    drupal_add_css($modpath . '/uniform.css');

    // load uniform js file, chosing minified version if present.
    if (file_exists($path . '/jquery.uniform.min.js')) {
      drupal_add_js($path . '/jquery.uniform.min.js');
    }
    else {
      drupal_add_js($path . '/jquery.uniform.js');
    }

    //Only Show uniform in Admin section or on node add/edit forms if allowed
    if (variable_get('uniform_admin', 'su') != 'su' && arg(0) == 'admin' || variable_get('uniform_node', 'su') != 'su' && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == "edit") || variable_get('uniform_admin', 'su') != 'su' && arg(1) == 'ajax') {
    }
    else {

      // add script to enable theming of elements defined in settings
      $uniform_selectors = array(
        'selectors' => array_keys(array_filter($enabled)),
      );
      $not_selectors = variable_get('uniform_not_selectors', '');
      if (!empty($not_selectors)) {
        $uniform_selectors['not'] = filter_xss_admin($not_selectors);
      }
      drupal_add_js(array(
        'uniform' => $uniform_selectors,
      ), 'setting');
      drupal_add_js($modpath . '/uniform.js', array(
        'scope' => 'footer',
      ));
    }
  }
}