Révision 7547bb19
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/themes/bootstrap/templates/system/button.func.php | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
function bootstrap_button($variables) { |
23 | 23 |
$element = $variables['element']; |
24 |
$text = $element['#value']; |
|
24 | 25 |
|
25 | 26 |
// Allow button text to be appear hidden. |
26 | 27 |
// @see https://www.drupal.org/node/2327437 |
27 |
$text = !empty($element['#hide_text']) ? '<span class="element-invisible">' . $element['#value'] . '</span>' : $element['#value']; |
|
28 |
if (!empty($element['#hide_text']) || $element['#icon_position'] === 'icon_only') { |
|
29 |
$text = '<span class="sr-only">' . $text . '</span>'; |
|
30 |
} |
|
28 | 31 |
|
29 | 32 |
// Add icons before or after the value. |
30 | 33 |
// @see https://www.drupal.org/node/2219965 |
31 |
if (!empty($element['#icon'])) { |
|
32 |
if ($element['#icon_position'] === 'before') { |
|
33 |
$text = $element['#icon'] . ' ' . $text; |
|
34 |
if (!empty($element['#icon']) && ($icon = render($element['#icon']))) { |
|
35 |
// Add icon position class. |
|
36 |
_bootstrap_add_class('icon-' . drupal_html_class($element['#icon_position'] === 'icon_only' ? 'only' : $element['#icon_position']), $element); |
|
37 |
|
|
38 |
if ($element['#icon_position'] === 'after') { |
|
39 |
$text .= ' ' . $icon; |
|
34 | 40 |
} |
35 |
elseif ($element['#icon_position'] === 'after') {
|
|
36 |
$text .= ' ' . $element['#icon'];
|
|
41 |
else { |
|
42 |
$text = $icon . ' ' . $text;
|
|
37 | 43 |
} |
38 | 44 |
} |
39 | 45 |
|
40 | 46 |
// This line break adds inherent margin between multiple buttons. |
41 |
return '<button' . drupal_attributes($element['#attributes']) . '>' . _bootstrap_filter_xss($text) . "</button>\n";
|
|
47 |
return '<button' . drupal_attributes($element['#attributes']) . '>' . filter_xss_admin($text) . "</button>\n";
|
|
42 | 48 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules