function _select2_post_load_library_callback in Select 2 7
Sets the 'post-load callback' key.
This function is used as a callback for the 'post-load' callback group.
See also
_libraries_test_callback()
1 string reference to '_select2_post_load_library_callback'
- select2_libraries_info in ./
select2.module - Implements hook_libraries_info().
File
- ./
select2.module, line 1052 - Main file for Select2 module.
Code
function _select2_post_load_library_callback(&$library, $version, $variant) {
global $language;
if ($excluded_paths = variable_get('select2_excluded_paths', '')) {
if (drupal_match_path($_GET['q'], $excluded_paths) || drupal_match_path(drupal_get_path_alias($_GET['q']), $excluded_paths)) {
return;
}
}
$branch_version = substr($library['version'], 0, 1);
drupal_add_js(SELECT2_MODULE_PATH . '/js/Drupal.select2.js', array(
'group' => JS_LIBRARY,
));
drupal_add_css(SELECT2_MODULE_PATH . '/css/select2_integration.css');
// Load and define exclude lists.
$process_all_selects = FALSE;
if (variable_get('select2_use_for_all_select_elements', FALSE)) {
if (!path_is_admin(current_path()) || path_is_admin(current_path()) && variable_get('select2_use_for_all_select_elements_for_admin_pages', FALSE)) {
$process_all_selects = TRUE;
}
}
$settings = _select2_set_exuled_for_settings();
$settings2 = array(
'select_2' => array(
'branch' => intval($branch_version),
'excludes' => array(
'by_id' => array(
'values' => array(),
'reg_exs' => array(),
),
'by_class' => array(),
'by_selectors' => array(),
),
'default_settings' => _select2_default_settings(),
'process_all_selects_on_page' => $process_all_selects,
'no_version_check' => variable_get('select2_disable_jq_version_check', FALSE) ? TRUE : FALSE,
'elements' => array(),
),
);
$settinings_updated_flag = !variable_get('select2_update_settings_by_ajax', FALSE);
$settings2['select_2']['settings_updated'] = $settinings_updated_flag;
$seeting_result = array_merge_recursive($settings, $settings2);
_select2_set_js_settings($seeting_result);
$lang = '';
if (isset($user->language) && $user->language) {
$lang = $user->language;
}
elseif (isset($language) && isset($language->language)) {
$lang = $language->language;
}
if ($lang) {
$translation_file = select2_get_plugin_path() . '/select2_locale_' . $lang . '.js';
if (file_exists($translation_file)) {
drupal_add_js($translation_file);
}
}
}