function _jquerymobile_button_settings in jQuery Mobile module 7.2
Generate the attributes array for the given button settings.
Parameters
array &$attributes: Reference to the attributes array
array &$settings: Reference to the settings array
string $prefix: (optional) Prefix character for options in the settings array Valid values are '' and '#'.
2 calls to _jquerymobile_button_settings()
- jquerymobile_preprocess_button in ./
jquerymobile.module - Implements template_preprocess_button().
- jquerymobile_preprocess_link in ./
jquerymobile.module - Implements template_preprocess_link().
File
- ./
jquerymobile.module, line 398
Code
function _jquerymobile_button_settings(&$attributes, &$settings, $prefix = '') {
// Assign the prefix the proper value if not blank.
if (!empty($prefix)) {
$prefix = '#';
}
// Add the button role.
if (isset($settings[$prefix . 'button']) && $settings[$prefix . 'button'] === TRUE) {
$attributes['data-role'] = 'button';
}
// Add the rounded corner option.
if (isset($settings[$prefix . 'corners'])) {
$attributes['data-corners'] = $settings[$prefix . 'corners'] ? 'true' : 'false';
}
// Add an icon and any supplementary options.
if (isset($settings[$prefix . 'icon'])) {
// Validate the icon option.
$icons = jquerymobile_icon_options();
if (isset($icons[$settings[$prefix . 'icon']])) {
// Assign the icon.
$attributes['data-icon'] = $icons[$settings[$prefix . 'icon']];
// Check for any other icon options.
// Set icon position.
if (isset($settings[$prefix . 'icon_position'])) {
// Validate the icon position.
$positions = jquerymobile_icon_position_options();
if (isset($positions[$settings[$prefix . 'icon_position']])) {
$attributes['data-iconpos'] = $settings[$prefix . 'icon_position'];
}
}
// Set icon shadow.
if (isset($settings[$prefix . 'icon_shadow'])) {
$attributes['data-iconshadow'] = $settings[$prefix . 'icon_shadow'] ? 'true' : 'false';
}
}
}
// Mark the button to be inline.
if (isset($settings[$prefix . 'inline'])) {
$attributes['data-inline'] = $settings[$prefix . 'inline'] ? 'true' : 'false';
}
// Add the shadow property.
if (isset($settings[$prefix . 'shadow'])) {
$attributes['data-shadow'] = $settings[$prefix . 'shadow'] ? 'true' : 'false';
}
if (isset($settings[$prefix . 'swatch'])) {
// Validate the option.
if (ctype_alpha($settings[$prefix . 'swatch']) && strlen($settings[$prefix . 'swatch']) == 1) {
$attributes['data-theme'] = drupal_strtolower($settings[$prefix . 'swatch']);
}
}
}