function _hs_process_attach_css_js in Hierarchical Select 7.3
1 call to _hs_process_attach_css_js()
- form_hierarchical_select_process in ./
hierarchical_select.module - Hierarchical select form element type #process callback.
File
- ./
hierarchical_select.module, line 389 - This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
Code
function _hs_process_attach_css_js($element, $hsid, &$form_state, $complete_form) {
global $language;
// Set up Javascript and add settings specifically for the current
// hierarchical select.
$element['#attached']['library'][] = array(
'system',
'ui',
);
$element['#attached']['library'][] = array(
'system',
'drupal.ajax',
);
$element['#attached']['library'][] = array(
'system',
'jquery.form',
);
$element['#attached']['library'][] = array(
'system',
'effects',
);
$element['#attached']['library'][] = array(
'system',
'effects.drop',
);
$element['#attached']['css'][] = drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.css';
$element['#attached']['js'][] = drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.js';
if (variable_get('hierarchical_select_js_cache_system', 0) == 1) {
$element['#attached']['js'][] = drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select_cache.js';
}
if (!isset($form_state['storage']['hs']['js_settings_sent'])) {
$form_state['storage']['hs']['js_settings_sent'] = array();
}
// Form was submitted; this is a newly loaded page, thus ensure that all JS
// settings are resent.
if ($form_state['process_input'] === TRUE) {
$form_state['storage']['hs']['js_settings_sent'] = array();
}
if (!isset($form_state['storage']['hs']['js_settings_sent'][$hsid]) || isset($form_state['storage']['hs']['js_settings_sent'][$hsid]) && (isset($form_state['triggering_element']) && $form_state['triggering_element']['#type'] == 'submit')) {
$config = _hierarchical_select_inherit_default_config($element['#config']);
$settings = array(
'HierarchicalSelect' => array(
// Save language in settings so we can use the same language during the AJAX callback.
'hs_current_language' => $language->language,
'settings' => array(
"hs-{$hsid}" => array(
'animationDelay' => $config['animation_delay'] == 0 ? (int) variable_get('hierarchical_select_animation_delay', 400) : $config['animation_delay'],
'cacheId' => $config['module'] . '_' . md5(serialize($config['params'])),
'renderFlatSelect' => isset($config['render_flat_select']) ? (int) $config['render_flat_select'] : 0,
'createNewItems' => isset($config['editability']['status']) ? (int) $config['editability']['status'] : 0,
'createNewLevels' => isset($config['editability']['allow_new_levels']) ? (int) $config['editability']['allow_new_levels'] : 0,
'resizable' => isset($config['resizable']) ? (int) $config['resizable'] : 0,
'ajax_url' => url('hierarchical_select_ajax/' . implode('/', $element['#array_parents'])),
),
),
),
);
if (!isset($_POST['hsid'])) {
$element['#attached']['js'][] = array(
'type' => 'setting',
'data' => $settings,
);
}
else {
$element['#attached']['_hs_new_setting_ajax'][] = array(
$hsid,
$settings['HierarchicalSelect']['settings']["hs-{$hsid}"],
);
}
$form_state['storage']['hs']['js_settings_sent'][$hsid] = TRUE;
}
return $element;
}