Mercurial > hg > isophonics-drupal-site
comparison core/modules/quickedit/js/theme.es6.js @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 /** | 1 /** |
2 * @file | 2 * @file |
3 * Provides theme functions for all of Quick Edit's client-side HTML. | 3 * Provides theme functions for all of Quick Edit's client-side HTML. |
4 */ | 4 */ |
5 | 5 |
6 (function ($, Drupal) { | 6 (function($, Drupal) { |
7 /** | 7 /** |
8 * Theme function for a "backstage" for the Quick Edit module. | 8 * Theme function for a "backstage" for the Quick Edit module. |
9 * | 9 * |
10 * @param {object} settings | 10 * @param {object} settings |
11 * Settings object used to construct the markup. | 11 * Settings object used to construct the markup. |
13 * The id to apply to the backstage. | 13 * The id to apply to the backstage. |
14 * | 14 * |
15 * @return {string} | 15 * @return {string} |
16 * The corresponding HTML. | 16 * The corresponding HTML. |
17 */ | 17 */ |
18 Drupal.theme.quickeditBackstage = function (settings) { | 18 Drupal.theme.quickeditBackstage = function(settings) { |
19 let html = ''; | 19 let html = ''; |
20 html += `<div id="${settings.id}" />`; | 20 html += `<div id="${settings.id}" />`; |
21 return html; | 21 return html; |
22 }; | 22 }; |
23 | 23 |
30 * the id to apply to the backstage. | 30 * the id to apply to the backstage. |
31 * | 31 * |
32 * @return {string} | 32 * @return {string} |
33 * The corresponding HTML. | 33 * The corresponding HTML. |
34 */ | 34 */ |
35 Drupal.theme.quickeditEntityToolbar = function (settings) { | 35 Drupal.theme.quickeditEntityToolbar = function(settings) { |
36 let html = ''; | 36 let html = ''; |
37 html += `<div id="${settings.id}" class="quickedit quickedit-toolbar-container clearfix">`; | 37 html += `<div id="${ |
38 settings.id | |
39 }" class="quickedit quickedit-toolbar-container clearfix">`; | |
38 html += '<i class="quickedit-toolbar-pointer"></i>'; | 40 html += '<i class="quickedit-toolbar-pointer"></i>'; |
39 html += '<div class="quickedit-toolbar-content">'; | 41 html += '<div class="quickedit-toolbar-content">'; |
40 html += '<div class="quickedit-toolbar quickedit-toolbar-entity clearfix icon icon-pencil">'; | 42 html += |
43 '<div class="quickedit-toolbar quickedit-toolbar-entity clearfix icon icon-pencil">'; | |
41 html += '<div class="quickedit-toolbar-label" />'; | 44 html += '<div class="quickedit-toolbar-label" />'; |
42 html += '</div>'; | 45 html += '</div>'; |
43 html += '<div class="quickedit-toolbar quickedit-toolbar-field clearfix" />'; | 46 html += |
47 '<div class="quickedit-toolbar quickedit-toolbar-field clearfix" />'; | |
44 html += '</div><div class="quickedit-toolbar-lining"></div></div>'; | 48 html += '</div><div class="quickedit-toolbar-lining"></div></div>'; |
45 return html; | 49 return html; |
46 }; | 50 }; |
47 | 51 |
48 /** | 52 /** |
56 * The label of the highlighted or active field. | 60 * The label of the highlighted or active field. |
57 * | 61 * |
58 * @return {string} | 62 * @return {string} |
59 * The corresponding HTML. | 63 * The corresponding HTML. |
60 */ | 64 */ |
61 Drupal.theme.quickeditEntityToolbarLabel = function (settings) { | 65 Drupal.theme.quickeditEntityToolbarLabel = function(settings) { |
62 // @todo Add XSS regression test coverage in https://www.drupal.org/node/2547437 | 66 // @todo Add XSS regression test coverage in https://www.drupal.org/node/2547437 |
63 return `<span class="field">${Drupal.checkPlain(settings.fieldLabel)}</span>${Drupal.checkPlain(settings.entityLabel)}`; | 67 return `<span class="field">${Drupal.checkPlain( |
68 settings.fieldLabel, | |
69 )}</span>${Drupal.checkPlain(settings.entityLabel)}`; | |
64 }; | 70 }; |
65 | 71 |
66 /** | 72 /** |
67 * Element defining a containing box for the placement of the entity toolbar. | 73 * Element defining a containing box for the placement of the entity toolbar. |
68 * | 74 * |
69 * @return {string} | 75 * @return {string} |
70 * The corresponding HTML. | 76 * The corresponding HTML. |
71 */ | 77 */ |
72 Drupal.theme.quickeditEntityToolbarFence = function () { | 78 Drupal.theme.quickeditEntityToolbarFence = function() { |
73 return '<div id="quickedit-toolbar-fence" />'; | 79 return '<div id="quickedit-toolbar-fence" />'; |
74 }; | 80 }; |
75 | 81 |
76 /** | 82 /** |
77 * Theme function for a toolbar container of the Quick Edit module. | 83 * Theme function for a toolbar container of the Quick Edit module. |
82 * The id to apply to the toolbar container. | 88 * The id to apply to the toolbar container. |
83 * | 89 * |
84 * @return {string} | 90 * @return {string} |
85 * The corresponding HTML. | 91 * The corresponding HTML. |
86 */ | 92 */ |
87 Drupal.theme.quickeditFieldToolbar = function (settings) { | 93 Drupal.theme.quickeditFieldToolbar = function(settings) { |
88 return `<div id="${settings.id}" />`; | 94 return `<div id="${settings.id}" />`; |
89 }; | 95 }; |
90 | 96 |
91 /** | 97 /** |
92 * Theme function for a toolbar toolgroup of the Quick Edit module. | 98 * Theme function for a toolbar toolgroup of the Quick Edit module. |
101 * See {@link Drupal.theme.quickeditButtons}. | 107 * See {@link Drupal.theme.quickeditButtons}. |
102 * | 108 * |
103 * @return {string} | 109 * @return {string} |
104 * The corresponding HTML. | 110 * The corresponding HTML. |
105 */ | 111 */ |
106 Drupal.theme.quickeditToolgroup = function (settings) { | 112 Drupal.theme.quickeditToolgroup = function(settings) { |
107 // Classes. | 113 // Classes. |
108 const classes = (settings.classes || []); | 114 const classes = settings.classes || []; |
109 classes.unshift('quickedit-toolgroup'); | 115 classes.unshift('quickedit-toolgroup'); |
110 let html = ''; | 116 let html = ''; |
111 html += `<div class="${classes.join(' ')}"`; | 117 html += `<div class="${classes.join(' ')}"`; |
112 if (settings.id) { | 118 if (settings.id) { |
113 html += ` id="${settings.id}"`; | 119 html += ` id="${settings.id}"`; |
132 * - String label: the label of the button. | 138 * - String label: the label of the button. |
133 * | 139 * |
134 * @return {string} | 140 * @return {string} |
135 * The corresponding HTML. | 141 * The corresponding HTML. |
136 */ | 142 */ |
137 Drupal.theme.quickeditButtons = function (settings) { | 143 Drupal.theme.quickeditButtons = function(settings) { |
138 let html = ''; | 144 let html = ''; |
139 for (let i = 0; i < settings.buttons.length; i++) { | 145 for (let i = 0; i < settings.buttons.length; i++) { |
140 const button = settings.buttons[i]; | 146 const button = settings.buttons[i]; |
141 if (!button.hasOwnProperty('type')) { | 147 if (!button.hasOwnProperty('type')) { |
142 button.type = 'button'; | 148 button.type = 'button'; |
143 } | 149 } |
144 // Attributes. | 150 // Attributes. |
145 const attributes = []; | 151 const attributes = []; |
146 const attrMap = settings.buttons[i].attributes || {}; | 152 const attrMap = settings.buttons[i].attributes || {}; |
147 Object.keys(attrMap).forEach((attr) => { | 153 Object.keys(attrMap).forEach(attr => { |
148 attributes.push(attr + ((attrMap[attr]) ? `="${attrMap[attr]}"` : '')); | 154 attributes.push(attr + (attrMap[attr] ? `="${attrMap[attr]}"` : '')); |
149 }); | 155 }); |
150 html += `<button type="${button.type}" class="${button.classes}" ${attributes.join(' ')}>${button.label}</button>`; | 156 html += `<button type="${button.type}" class="${ |
157 button.classes | |
158 }" ${attributes.join(' ')}>${button.label}</button>`; | |
151 } | 159 } |
152 return html; | 160 return html; |
153 }; | 161 }; |
154 | 162 |
155 /** | 163 /** |
163 * The message to show while loading. | 171 * The message to show while loading. |
164 * | 172 * |
165 * @return {string} | 173 * @return {string} |
166 * The corresponding HTML. | 174 * The corresponding HTML. |
167 */ | 175 */ |
168 Drupal.theme.quickeditFormContainer = function (settings) { | 176 Drupal.theme.quickeditFormContainer = function(settings) { |
169 let html = ''; | 177 let html = ''; |
170 html += `<div id="${settings.id}" class="quickedit-form-container">`; | 178 html += `<div id="${settings.id}" class="quickedit-form-container">`; |
171 html += ' <div class="quickedit-form">'; | 179 html += ' <div class="quickedit-form">'; |
172 html += ' <div class="placeholder">'; | 180 html += ' <div class="placeholder">'; |
173 html += settings.loadingMsg; | 181 html += settings.loadingMsg; |
174 html += ' </div>'; | 182 html += ' </div>'; |
175 html += ' </div>'; | 183 html += ' </div>'; |
176 html += '</div>'; | 184 html += '</div>'; |
177 return html; | 185 return html; |
178 }; | 186 }; |
179 }(jQuery, Drupal)); | 187 })(jQuery, Drupal); |