root / drupal7 / sites / all / themes / bootstrap / templates / system / button.vars.php @ caf16a48
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* Stub file for "button" theme hook [pre]process functions.
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Pre-processes variables for the "button" theme hook.
|
9 |
*
|
10 |
* See theme function for list of available variables.
|
11 |
*
|
12 |
* @see bootstrap_button()
|
13 |
* @see theme_button()
|
14 |
*
|
15 |
* @ingroup theme_preprocess
|
16 |
*/
|
17 |
function bootstrap_preprocess_button(&$vars) { |
18 |
$element = &$vars['element']; |
19 |
|
20 |
// Drupal buttons should be of type 'submit'.
|
21 |
// @see https://www.drupal.org/node/2540452
|
22 |
$element['#attributes']['type'] = 'submit'; |
23 |
|
24 |
// Set the element's other attributes.
|
25 |
element_set_attributes($element, array('id', 'name', 'value')); |
26 |
|
27 |
// Add the base Bootstrap button class.
|
28 |
$element['#attributes']['class'][] = 'btn'; |
29 |
|
30 |
// Add button size, if necessary.
|
31 |
if ($size = bootstrap_setting('button_size')) { |
32 |
$element['#attributes']['class'][] = $size; |
33 |
} |
34 |
|
35 |
// Colorize button.
|
36 |
_bootstrap_colorize_button($element);
|
37 |
|
38 |
// Add in the button type class.
|
39 |
$element['#attributes']['class'][] = 'form-' . $element['#button_type']; |
40 |
|
41 |
// Ensure that all classes are unique, no need for duplicates.
|
42 |
$element['#attributes']['class'] = array_unique($element['#attributes']['class']); |
43 |
} |