function clipboardjs_field_formatter_view in Clipboard.js 7
Implements hook_field_formatter_view().
File
- ./
clipboardjs.module, line 144 - Integrates the Clipboard.js library with Drupal.
Code
function clipboardjs_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, &$items, $display) {
$elements = array();
switch ($display['type']) {
case 'text_clipboardjs':
// Load clipboard.js library.
libraries_load('clipboard');
// Iterate over each text field and add clipboard.js.
foreach ($items as $delta => $item) {
$theme_variables = array(
'text' => _text_sanitize($instance, $langcode, $item, 'value'),
'alert_style' => $display['settings']['alert_style'],
'alert_text' => $display['settings']['alert_text'],
'button_label' => $display['settings']['button_label'],
);
$elements[$delta] = theme('clipboardjs', $theme_variables);
}
break;
}
return $elements;
}