function _select2_set_js_settings in Select 2 7
1 call to _select2_set_js_settings()
- _select2_post_load_library_callback in ./
select2.module - Sets the 'post-load callback' key.
File
- ./
select2.module, line 1276 - Main file for Select2 module.
Code
function _select2_set_js_settings($settings) {
$js =& drupal_static('drupal_add_js', array());
if (!isset($js['settings']) || !isset($js['settings']['data'])) {
drupal_add_js(array(
'select_2' => $settings['select_2'],
), 'setting');
return;
}
$js_setting_key =& drupal_static('select2_js_setting_key', -1);
if ($js_setting_key == -1) {
foreach ($js['settings']['data'] as $key => $data) {
foreach ($data as $scope_name => $scope_data) {
if ($scope_name == 'select_2') {
$js_setting_key = $key;
}
}
}
}
if ($js_setting_key == -1) {
drupal_add_js(array(
'select_2' => $settings['select_2'],
), 'setting');
return;
}
if (!isset($js['settings']['data'][$js_setting_key]['select_2'])) {
$js['settings']['data'][$js_setting_key]['select_2'] = $settings['select_2'];
}
else {
$js['settings']['data'][$js_setting_key]['select_2'] = array_replace_recursive($js['settings']['data'][$js_setting_key]['select_2'], $settings['select_2']);
}
}