2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, Drupal) {
9 Drupal.quickedit.util = Drupal.quickedit.util || {};
11 Drupal.quickedit.util.constants = {};
13 Drupal.quickedit.util.constants.transitionEnd = 'transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit';
15 Drupal.quickedit.util.buildUrl = function (id, urlFormat) {
16 var parts = id.split('/');
17 return Drupal.formatString(decodeURIComponent(urlFormat), {
18 '!entity_type': parts[0],
20 '!field_name': parts[2],
21 '!langcode': parts[3],
22 '!view_mode': parts[4]
26 Drupal.quickedit.util.networkErrorModal = function (title, message) {
27 var $message = $('<div>' + message + '</div>');
28 var networkErrorModal = Drupal.dialog($message.get(0), {
30 dialogClass: 'quickedit-network-error',
33 click: function click() {
34 networkErrorModal.close();
39 create: function create() {
40 $(this).parent().find('.ui-dialog-titlebar-close').remove();
42 close: function close(event) {
43 $(event.target).remove();
46 networkErrorModal.showModal();
49 Drupal.quickedit.util.form = {
50 load: function load(options, callback) {
51 var fieldID = options.fieldID;
53 var formLoaderAjax = Drupal.ajax({
54 url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode')),
56 nocssjs: options.nocssjs,
59 error: function error(xhr, url) {
60 var fieldLabel = Drupal.quickedit.metadata.get(fieldID, 'label');
61 var 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 });
62 Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
64 var fieldModel = Drupal.quickedit.app.model.get('activeField');
65 fieldModel.set('state', 'candidate');
69 formLoaderAjax.commands.quickeditFieldForm = function (ajax, response, status) {
70 callback(response.data, ajax);
71 Drupal.ajax.instances[this.instanceIndex] = null;
74 formLoaderAjax.execute();
76 ajaxifySaving: function ajaxifySaving(options, $submit) {
78 url: $submit.closest('form').attr('action'),
80 event: 'click.quickedit',
83 nocssjs: options.nocssjs,
84 other_view_modes: options.other_view_modes
87 success: function success(response, status) {
88 for (var i in response) {
89 if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) {
90 this.commands[response[i].command](this, response[i], status);
95 base: $submit.attr('id'),
99 return Drupal.ajax(settings);
101 unajaxifySaving: function unajaxifySaving(ajax) {
102 $(ajax.element).off('click.quickedit');