Chris@0
|
1 /**
|
Chris@0
|
2 * @file
|
Chris@0
|
3 * Provides theme functions for image Quick Edit's client-side HTML.
|
Chris@0
|
4 */
|
Chris@0
|
5
|
Chris@17
|
6 (function(Drupal) {
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Theme function for validation errors of the Image in-place editor.
|
Chris@0
|
9 *
|
Chris@0
|
10 * @param {object} settings
|
Chris@0
|
11 * Settings object used to construct the markup.
|
Chris@0
|
12 * @param {string} settings.errors
|
Chris@0
|
13 * Already escaped HTML representing error messages.
|
Chris@0
|
14 *
|
Chris@0
|
15 * @return {string}
|
Chris@0
|
16 * The corresponding HTML.
|
Chris@0
|
17 */
|
Chris@17
|
18 Drupal.theme.quickeditImageErrors = function(settings) {
|
Chris@0
|
19 return `<div class="quickedit-image-errors">${settings.errors}</div>`;
|
Chris@0
|
20 };
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Theme function for the dropzone element of the Image module's in-place
|
Chris@0
|
24 * editor.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @param {object} settings
|
Chris@0
|
27 * Settings object used to construct the markup.
|
Chris@0
|
28 * @param {string} settings.state
|
Chris@0
|
29 * State of the upload.
|
Chris@0
|
30 * @param {string} settings.text
|
Chris@0
|
31 * Text to display inline with the dropzone element.
|
Chris@0
|
32 *
|
Chris@0
|
33 * @return {string}
|
Chris@0
|
34 * The corresponding HTML.
|
Chris@0
|
35 */
|
Chris@17
|
36 Drupal.theme.quickeditImageDropzone = function(settings) {
|
Chris@17
|
37 return (
|
Chris@17
|
38 `<div class="quickedit-image-dropzone ${settings.state}">` +
|
Chris@0
|
39 ' <i class="quickedit-image-icon"></i>' +
|
Chris@0
|
40 ` <span class="quickedit-image-text">${settings.text}</span>` +
|
Chris@17
|
41 '</div>'
|
Chris@17
|
42 );
|
Chris@0
|
43 };
|
Chris@0
|
44
|
Chris@0
|
45 /**
|
Chris@0
|
46 * Theme function for the toolbar of the Image module's in-place editor.
|
Chris@0
|
47 *
|
Chris@0
|
48 * @param {object} settings
|
Chris@0
|
49 * Settings object used to construct the markup.
|
Chris@0
|
50 * @param {bool} settings.alt_field
|
Chris@0
|
51 * Whether or not the "Alt" field is enabled for this field.
|
Chris@0
|
52 * @param {bool} settings.alt_field_required
|
Chris@0
|
53 * Whether or not the "Alt" field is required for this field.
|
Chris@0
|
54 * @param {string} settings.alt
|
Chris@0
|
55 * The current value for the "Alt" field.
|
Chris@0
|
56 * @param {bool} settings.title_field
|
Chris@0
|
57 * Whether or not the "Title" field is enabled for this field.
|
Chris@0
|
58 * @param {bool} settings.title_field_required
|
Chris@0
|
59 * Whether or not the "Title" field is required for this field.
|
Chris@0
|
60 * @param {string} settings.title
|
Chris@0
|
61 * The current value for the "Title" field.
|
Chris@0
|
62 *
|
Chris@0
|
63 * @return {string}
|
Chris@0
|
64 * The corresponding HTML.
|
Chris@0
|
65 */
|
Chris@17
|
66 Drupal.theme.quickeditImageToolbar = function(settings) {
|
Chris@0
|
67 let html = '<form class="quickedit-image-field-info">';
|
Chris@0
|
68 if (settings.alt_field) {
|
Chris@17
|
69 html +=
|
Chris@17
|
70 `<div><label for="alt" class="${
|
Chris@17
|
71 settings.alt_field_required ? 'required' : ''
|
Chris@17
|
72 }">${Drupal.t('Alternative text')}</label>` +
|
Chris@17
|
73 `<input type="text" placeholder="${settings.alt}" value="${
|
Chris@17
|
74 settings.alt
|
Chris@17
|
75 }" name="alt" ${settings.alt_field_required ? 'required' : ''}/>` +
|
Chris@0
|
76 ' </div>';
|
Chris@0
|
77 }
|
Chris@0
|
78 if (settings.title_field) {
|
Chris@17
|
79 html +=
|
Chris@17
|
80 `<div><label for="title" class="${
|
Chris@17
|
81 settings.title_field_required ? 'form-required' : ''
|
Chris@17
|
82 }">${Drupal.t('Title')}</label>` +
|
Chris@17
|
83 `<input type="text" placeholder="${settings.title}" value="${
|
Chris@17
|
84 settings.title
|
Chris@17
|
85 }" name="title" ${settings.title_field_required ? 'required' : ''}/>` +
|
Chris@17
|
86 '</div>';
|
Chris@0
|
87 }
|
Chris@0
|
88 html += '</form>';
|
Chris@0
|
89
|
Chris@0
|
90 return html;
|
Chris@0
|
91 };
|
Chris@17
|
92 })(Drupal);
|