function theme_clipboardjs in Clipboard.js 7
Theme function for clipboardjs_theme
Parameters
string $variables['text']: Text to be copied.
string $variables['alert_style']: Alert style, either 'alert' or 'tooltip'.
string $variables['alert_text']: Text to display in alert or tooltip.
string $variables['button_label']: The label of the button that triggers the copy.
Return value
array An renderable array.
1 theme call to theme_clipboardjs()
- clipboardjs_field_formatter_view in ./
clipboardjs.module - Implements hook_field_formatter_view().
File
- ./
clipboardjs.module, line 203 - Integrates the Clipboard.js library with Drupal.
Code
function theme_clipboardjs($variables) {
$element = array();
$uniqid = uniqid('clipboardjs-');
$element['text'] = array(
'#type' => 'container',
'#attributes' => array(
'id' => $uniqid,
'class' => 'clipboardjs-text',
),
);
$element['text']['markup'] = array(
'#markup' => $variables['text'],
);
$element['button'] = array(
'#type' => 'button',
'#value' => check_plain($variables['button_label']),
'#attributes' => array(
'class' => array(
'clipboardjs-button',
),
'data-clipboard-alert' => $variables['alert_style'],
'data-clipboard-alert-text' => $variables['alert_text'],
'data-clipboard-target' => '#' . $uniqid,
'onClick' => 'return false;',
),
);
return $element;
}