* Provides utility functions for Quick Edit.
*/
-(function ($, Drupal) {
+(function($, Drupal) {
/**
* @namespace
*/
*
* @type {string}
*/
- Drupal.quickedit.util.constants.transitionEnd = 'transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit';
+ Drupal.quickedit.util.constants.transitionEnd =
+ 'transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit';
/**
* Converts a field id into a formatted url path.
* @return {string}
* The formatted URL.
*/
- Drupal.quickedit.util.buildUrl = function (id, urlFormat) {
+ Drupal.quickedit.util.buildUrl = function(id, urlFormat) {
const parts = id.split('/');
return Drupal.formatString(decodeURIComponent(urlFormat), {
'!entity_type': parts[0],
* @param {string} message
* The message to use in the modal dialog.
*/
- Drupal.quickedit.util.networkErrorModal = function (title, message) {
+ Drupal.quickedit.util.networkErrorModal = function(title, message) {
const $message = $(`<div>${message}</div>`);
const networkErrorModal = Drupal.dialog($message.get(0), {
title,
},
],
create() {
- $(this).parent().find('.ui-dialog-titlebar-close').remove();
+ $(this)
+ .parent()
+ .find('.ui-dialog-titlebar-close')
+ .remove();
},
close(event) {
// Automatically destroy the DOM element that was used for the dialog.
* @namespace
*/
Drupal.quickedit.util.form = {
-
/**
* Loads a form, calls a callback to insert.
*
// Create a Drupal.ajax instance to load the form.
const formLoaderAjax = Drupal.ajax({
- url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode')),
+ url: Drupal.quickedit.util.buildUrl(
+ fieldID,
+ Drupal.url(
+ 'quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode',
+ ),
+ ),
submit: {
nocssjs: options.nocssjs,
reset: options.reset,
error(xhr, url) {
// Show a modal to inform the user of the network error.
const fieldLabel = Drupal.quickedit.metadata.get(fieldID, 'label');
- const message = Drupal.t('Could not load the form for <q>@field-label</q>, either due to a website problem or a network connection problem.<br>Please try again.', { '@field-label': fieldLabel });
- Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
+ const message = Drupal.t(
+ 'Could not load the form for <q>@field-label</q>, either due to a website problem or a network connection problem.<br>Please try again.',
+ { '@field-label': fieldLabel },
+ );
+ Drupal.quickedit.util.networkErrorModal(
+ Drupal.t('Network problem!'),
+ message,
+ );
// Change the state back to "candidate", to allow the user to start
// in-place editing of the field again.
},
});
// Implement a scoped quickeditFieldForm AJAX command: calls the callback.
- formLoaderAjax.commands.quickeditFieldForm = function (ajax, response, status) {
+ formLoaderAjax.commands.quickeditFieldForm = function(
+ ajax,
+ response,
+ status,
+ ) {
callback(response.data, ajax);
Drupal.ajax.instances[this.instanceIndex] = null;
};
* The HTTP status code.
*/
success(response, status) {
- Object.keys(response || {}).forEach((i) => {
+ Object.keys(response || {}).forEach(i => {
if (response[i].command && this.commands[response[i].command]) {
this.commands[response[i].command](this, response[i], status);
}
unajaxifySaving(ajax) {
$(ajax.element).off('click.quickedit');
},
-
};
-}(jQuery, Drupal));
+})(jQuery, Drupal);