-
Notifications
You must be signed in to change notification settings - Fork 0
/
os2web_hjemmeside.module
49 lines (42 loc) · 1.32 KB
/
os2web_hjemmeside.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @file
* Os2web Hjemmeside module.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function os2web_hjemmeside_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['#attached']['library'][] = 'os2web_hjemmeside/chosen';
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function os2web_hjemmeside_form_editor_link_dialog_alter(&$form, FormStateInterface $form_state, $form_id) {
if (!empty($form['advanced'])) {
$form['advanced']['#open'] = TRUE;
// Adding ability to use link for email addresses.
if (isset($form_state->getUserInput()['editor_object'])) {
$input = $form_state->getUserInput()['editor_object'];
$form_state->set('link_element', $input);
$form_state->setCached(TRUE);
}
else {
// Retrieve the link element's attributes from form state.
$input = $form_state->get('link_element') ?: [];
}
$form['mailto'] = [
'#title' => t('Mailto'),
'#type' => 'checkbox',
'#default_value' => !empty($input['href']) && strpos($input['href'], 'mailto:') === 0,
'#group' => 'advanced',
'#attributes' => [
'class' => ['mailto-option'],
],
'#attached' => [
'library' => ['os2web_hjemmeside/mailto_editor_link_option'],
],
];
}
}