function chosen_library in Chosen 7.2
Same name and namespace in other branches
- 7.3 chosen.module \chosen_library()
Implements hook_library().
File
- ./
chosen.module, line 108 - General functions and hook implementations.
Code
function chosen_library() {
global $theme;
$library_path = chosen_get_chosen_path();
$info['chosen'] = array(
'title' => 'Chosen',
'website' => CHOSEN_WEBSITE_URL,
'version' => '1.1.0',
'js' => array(
$library_path . '/chosen.jquery.min.js' => array(),
),
);
$css_disabled_themes = variable_get('chosen_disabled_themes', array());
// Only add the Chosen CSS if it is not disabled for the active theme.
if (!in_array($theme, $css_disabled_themes, TRUE)) {
$css = $library_path . '/chosen.css';
if (!file_exists($css)) {
$css = $library_path . '/chosen.min.css';
}
$info['chosen']['css'] = array(
$css => array(),
);
}
// All the settings that are actually passed through into the chosen()
// function are contained in this array.
$options = array(
'allow_single_deselect' => (bool) variable_get('chosen_allow_single_deselect', FALSE),
'disable_search' => (bool) variable_get('chosen_disable_search', FALSE),
'disable_search_threshold' => (int) variable_get('chosen_disable_search_threshold', 0),
'search_contains' => (bool) variable_get('chosen_search_contains', FALSE),
'placeholder_text_multiple' => variable_get('chosen_placeholder_text_multiple', t('Choose some options')),
'placeholder_text_single' => variable_get('chosen_placeholder_text_single', t('Choose an option')),
'no_results_text' => variable_get('chosen_no_results_text', t('No results match')),
'inherit_select_classes' => TRUE,
);
$module_path = drupal_get_path('module', 'chosen');
$info['drupal.chosen'] = array(
'title' => 'Drupal Chosen integration',
'website' => 'https://drupal.org/project/chosen',
'version' => '1.1.0',
'js' => array(
$module_path . '/chosen.js' => array(
'group' => JS_DEFAULT,
'weight' => 100,
),
array(
'data' => array(
'chosen' => array(
'selector' => variable_get('chosen_jquery_selector', 'select:visible'),
'minimum_single' => (int) variable_get('chosen_minimum_single', 20),
'minimum_multiple' => (int) variable_get('chosen_minimum_multiple', 20),
'minimum_width' => (int) variable_get('chosen_minimum_width', ''),
'options' => $options,
),
),
'type' => 'setting',
),
),
'css' => array(
$module_path . '/css/chosen-drupal.css' => array(),
),
'dependencies' => array(
array(
'system',
'jquery.once',
),
array(
'chosen',
'chosen',
),
),
);
return $info;
}