function theme_gathercontent_checkboxcounter in GatherContent 7.3
Returns HTML markup for a checkbox counter.
Parameters
array $variables: An associative array containing:
- element: An associative array containing the properties and children of the checkboxcounter element. Properties used (every one is optional): #checkboxes_selector, #counter_message_js_template, #counter_message_default.
Return value
string The rendered markup.
1 theme call to theme_gathercontent_checkboxcounter()
- gathercontent_element_info in ./
gathercontent.theme.inc - Implements hook_element_info().
File
- ./
gathercontent.theme.inc, line 110 - Form elements and theme functions for GatherContent module.
Code
function theme_gathercontent_checkboxcounter(array $variables) {
$output = '';
$element = $variables['element'];
$gathercontent_module_path = drupal_get_path('module', 'gathercontent');
$gathercontent_counter_id = drupal_html_id('gathercontent-checkbox-counter');
$gathercontent_counter_id_js = lcfirst(implode('', array_map('ucfirst', explode('-', $gathercontent_counter_id))));
$element['#attributes']['class'][] = 'gathercontent-checkboxcounter';
$element['#attributes']['data-gathercontent-counter-id'] = $gathercontent_counter_id_js;
$element['#children'] .= !empty($element['#counter_message_default']) ? format_plural(0, '1 item selected', '@count item selected') : $element['#counter_message_default'];
$js_settings = array();
if (!empty($element['#checkboxes_selector'])) {
$js_settings['checkboxesSelector'] = $element['#checkboxes_selector'];
}
if (!empty($element['#counter_message_js_template']) && is_array($element['#counter_message_js_template'])) {
$js_settings['counterMessage'] = $element['#counter_message_js_template'];
}
drupal_add_js($gathercontent_module_path . '/js/gathercontent-checkboxcounter.js', 'file');
drupal_add_js(array(
$gathercontent_counter_id_js => $js_settings,
), 'setting');
$output .= theme('container', array(
'element' => $element,
));
return $output;
}