function encrypt_submissions_add_form_css_js in Encrypt Submissions 6
Same name and namespace in other branches
- 7 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'
File
- ./
encrypt_submissions.module, line 279
Code
function encrypt_submissions_add_form_css_js($form_element, &$form_state) {
$form_id = $form_state["values"]["form_id"];
$dom_form_id = $form_element["#dom"];
// Add the jCryption javascript and CSS to the page.
drupal_add_css(drupal_get_path("module", "encrypt_submissions") . "/css/encrypt_submissions.css");
// figure out correct URL path to jCryption
$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";
}
// jQuery 1.4+, jCryption and encryption_submissions.js need necessarily load in sequence
// to ensure no interference with jQuery scripts that may require Drupal-supplied version.
// It seems that use of the $type parameter to drupal_add_js() guarantees just that (even
// with Javascript compression turned on).
// @todo check if jquery_update module is installed, and use that instead
if (!variable_get("encrypt_submissions_disable_jquery144", 0)) {
// Add in the 1.4.4 version of jQuery which is packaged with encrypt_submissions
drupal_add_js(drupal_get_path("module", "encrypt_submissions") . "/js/jq1.4.4/jquery.min.js", "encrypt_submissions");
}
// Add in the jCryption file.
drupal_add_js($js_file, "encrypt_submissions");
drupal_add_js(drupal_get_path("module", "encrypt_submissions") . "/js/encryption_submissions.js", "encrypt_submissions");
// 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;
}