/** * @file * Provides theme functions for all of Quick Edit's client-side HTML. */ (function ($, Drupal) { /** * Theme function for a "backstage" for the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.id * The id to apply to the backstage. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditBackstage = function (settings) { let html = ''; html += `
`; return html; }; /** * Theme function for a toolbar container of the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.id * the id to apply to the backstage. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditEntityToolbar = function (settings) { let html = ''; html += `
`; html += ''; html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; return html; }; /** * Theme function for a toolbar container of the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.entityLabel * The title of the active entity. * @param {string} settings.fieldLabel * The label of the highlighted or active field. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditEntityToolbarLabel = function (settings) { // @todo Add XSS regression test coverage in https://www.drupal.org/node/2547437 return `${Drupal.checkPlain( settings.fieldLabel, )}${Drupal.checkPlain(settings.entityLabel)}`; }; /** * Element defining a containing box for the placement of the entity toolbar. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditEntityToolbarFence = function () { return '
'; }; /** * Theme function for a toolbar container of the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.id * The id to apply to the toolbar container. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditFieldToolbar = function (settings) { return `
`; }; /** * Theme function for a toolbar toolgroup of the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} [settings.id] * The id of the toolgroup. * @param {string} settings.classes * The class of the toolgroup. * @param {Array} settings.buttons * See {@link Drupal.theme.quickeditButtons}. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditToolgroup = function (settings) { // Classes. const classes = settings.classes || []; classes.unshift('quickedit-toolgroup'); let html = ''; html += `
{ attributes.push(attr + (attrMap[attr] ? `="${attrMap[attr]}"` : '')); }); html += ``; } return html; }; /** * Theme function for a form container of the Quick Edit module. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.id * The id to apply to the toolbar container. * @param {string} settings.loadingMsg * The message to show while loading. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditFormContainer = function (settings) { let html = ''; html += `
`; html += '
'; html += '
'; html += settings.loadingMsg; html += '
'; html += '
'; html += '
'; return html; }; /** * Theme function for validation errors of the Image in-place editor. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.errors * Already escaped HTML representing error messages. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditImageErrors = function (settings) { return `
${settings.errors}
`; }; /** * Theme function for the dropzone element of the in-place editor. * * @param {object} settings * Settings object used to construct the markup. * @param {string} settings.state * State of the upload. * @param {string} settings.text * Text to display inline with the dropzone element. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditImageDropzone = function (settings) { return ( `
` + ' ' + ` ${settings.text}` + '
' ); }; /** * Theme function for the toolbar of the Image module's in-place editor. * * @param {object} settings * Settings object used to construct the markup. * @param {bool} settings.alt_field * Whether or not the "Alt" field is enabled for this field. * @param {bool} settings.alt_field_required * Whether or not the "Alt" field is required for this field. * @param {string} settings.alt * The current value for the "Alt" field. * @param {bool} settings.title_field * Whether or not the "Title" field is enabled for this field. * @param {bool} settings.title_field_required * Whether or not the "Title" field is required for this field. * @param {string} settings.title * The current value for the "Title" field. * * @return {string} * The corresponding HTML. */ Drupal.theme.quickeditImageToolbar = function (settings) { let html = '
'; if (settings.alt_field) { html += `
` + `` + '
'; } if (settings.title_field) { html += `
` + `` + '
'; } html += '
'; return html; }; })(jQuery, Drupal);