You are here

function encrypt_submissions_add_form_css_js in Encrypt Submissions 7

Same name and namespace in other branches
  1. 6 encrypt_submissions.module \encrypt_submissions_add_form_css_js()

We will use this function as an #after_build to ensure we always attach our CSS and JS to the page.

1 string reference to 'encrypt_submissions_add_form_css_js'
encrypt_submissions_form_alter in ./encrypt_submissions.module

File

./encrypt_submissions.module, line 277

Code

function encrypt_submissions_add_form_css_js($form_element, &$form_state) {
  $form_id = $form_state["complete form"]["#form_id"];
  $dom_form_id = $form_state["complete form"]["#id"];

  // Add the jCryption javascript and CSS to the page.
  drupal_add_css(drupal_get_path("module", "encrypt_submissions") . "/css/encrypt_submissions.css");

  // Add the jcryption library itself.
  $jcryption_location = variable_get("encrypt_submissions_jcryption_location", "");
  $js_file = "{$jcryption_location}/jquery.jcryption.js";
  if (!file_exists($js_file)) {
    encrypt_submissions_check_library_files_exist();
    $jcryption_location = variable_get("encrypt_submissions_jcryption_location", "");
    $js_file = "{$jcryption_location}/jquery.jcryption.js";
  }
  drupal_add_js($js_file);
  drupal_add_js(drupal_get_path("module", "encrypt_submissions") . "/js/encryption_submissions.js");

  // We need to add this form's ids to an array in javascript, so our js can attach
  // the jCryption later.
  drupal_add_js(array(
    'encrypt_submissions' => array(
      'encryptForms' => array(
        $form_id => $dom_form_id,
      ),
    ),
  ), 'setting');
  return $form_element;
}