root / drupal7 / sites / all / themes / bootstrap / theme / system / button.func.php @ 87dbc3bf
1 |
<?php
|
---|---|
2 |
/**
|
3 |
* @file
|
4 |
* button.func.php
|
5 |
*/
|
6 |
|
7 |
/**
|
8 |
* Overrides theme_button().
|
9 |
*/
|
10 |
function bootstrap_button($variables) { |
11 |
$element = $variables['element']; |
12 |
$label = $element['#value']; |
13 |
element_set_attributes($element, array('id', 'name', 'value', 'type')); |
14 |
|
15 |
// If a button type class isn't present then add in default.
|
16 |
$button_classes = array( |
17 |
'btn-default',
|
18 |
'btn-primary',
|
19 |
'btn-success',
|
20 |
'btn-info',
|
21 |
'btn-warning',
|
22 |
'btn-danger',
|
23 |
'btn-link',
|
24 |
); |
25 |
$class_intersection = array_intersect($button_classes, $element['#attributes']['class']); |
26 |
if (empty($class_intersection)) { |
27 |
$element['#attributes']['class'][] = 'btn-default'; |
28 |
} |
29 |
|
30 |
// Add in the button type class.
|
31 |
$element['#attributes']['class'][] = 'form-' . $element['#button_type']; |
32 |
|
33 |
// This line break adds inherent margin between multiple buttons.
|
34 |
return '<button' . drupal_attributes($element['#attributes']) . '>' . $label . "</button>\n"; |
35 |
} |