Unverified Commit 5b657b15 authored by alexpott's avatar alexpott
Browse files

Revert "Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core...

Revert "Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core JavaScript dependencies listed in package.json"

This reverts commit 2dadb738.
parent f791e767
......@@ -21,11 +21,6 @@
"Sortable": true,
"CKEDITOR": true
},
"settings": {
"react": {
"version": "latest"
}
},
"rules": {
"prettier/prettier": "error",
"consistent-return": ["off"],
......
......@@ -10,25 +10,26 @@
attach: function attach(context) {
var path = drupalSettings.path;
var queryString = JSON.stringify(path.currentQuery);
var querySelector = path.currentQuery ? "[data-drupal-link-query='".concat(queryString, "']") : ':not([data-drupal-link-query])';
var originalSelectors = ["[data-drupal-link-system-path=\"".concat(path.currentPath, "\"]")];
var selectors;
var querySelector = path.currentQuery ? '[data-drupal-link-query=\'' + queryString + '\']' : ':not([data-drupal-link-query])';
var originalSelectors = ['[data-drupal-link-system-path="' + path.currentPath + '"]'];
var selectors = void 0;
if (path.isFront) {
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
}
selectors = [].concat(originalSelectors.map(function (selector) {
return "".concat(selector, ":not([hreflang])");
return selector + ':not([hreflang])';
}), originalSelectors.map(function (selector) {
return "".concat(selector, "[hreflang=\"").concat(path.currentLanguage, "\"]");
return selector + '[hreflang="' + path.currentLanguage + '"]';
}));
selectors = selectors.map(function (current) {
return current + querySelector;
});
var activeLinks = context.querySelectorAll(selectors.join(','));
var il = activeLinks.length;
for (var i = 0; i < il; i++) {
activeLinks[i].classList.add('is-active');
}
......@@ -37,7 +38,6 @@
if (trigger === 'unload') {
var activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active');
var il = activeLinks.length;
for (var i = 0; i < il; i++) {
activeLinks[i].classList.remove('is-active');
}
......
......@@ -102,9 +102,7 @@
if (xmlhttp.status) {
statusCode = `\n${Drupal.t('An AJAX HTTP error occurred.')}\n${Drupal.t(
'HTTP Result Code: !status',
{
'!status': xmlhttp.status,
},
{ '!status': xmlhttp.status },
)}`;
} else {
statusCode = `\n${Drupal.t(
......@@ -1131,14 +1129,12 @@
(response.effect || ajax.effect) !== 'none' &&
$newContent.filter(
i =>
!(
// We can not consider HTML comments or whitespace text as separate
// roots, since they do not cause visual regression with effect.
(
$newContent[i].nodeName === '#comment' ||
($newContent[i].nodeName === '#text' &&
/^(\s|\n|\r)*$/.test($newContent[i].textContent))
)
!// We can not consider HTML comments or whitespace text as separate
// roots, since they do not cause visual regression with effect.
(
$newContent[i].nodeName === '#comment' ||
($newContent[i].nodeName === '#text' &&
/^(\s|\n|\r)*$/.test($newContent[i].textContent))
),
).length > 1
? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent)
......
......@@ -4,25 +4,16 @@
* https://www.drupal.org/node/2815083
* @preserve
**/
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
(function ($, window, Drupal, drupalSettings) {
Drupal.behaviors.AJAX = {
attach: function attach(context, settings) {
function loadAjaxBehavior(base) {
var elementSettings = settings.ajax[base];
if (typeof elementSettings.selector === 'undefined') {
elementSettings.selector = "#".concat(base);
elementSettings.selector = '#' + base;
}
$(elementSettings.selector).once('drupal-ajax').each(function () {
elementSettings.element = this;
elementSettings.base = base;
......@@ -33,17 +24,22 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Object.keys(settings.ajax || {}).forEach(function (base) {
return loadAjaxBehavior(base);
});
Drupal.ajax.bindAjaxLinks(document.body);
$('.use-ajax-submit').once('ajax').each(function () {
var elementSettings = {};
elementSettings.url = $(this.form).attr('action');
elementSettings.setClick = true;
elementSettings.event = 'click';
elementSettings.progress = {
type: 'throbber'
};
elementSettings.progress = { type: 'throbber' };
elementSettings.base = $(this).attr('id');
elementSettings.element = this;
Drupal.ajax(elementSettings);
});
},
......@@ -57,47 +53,45 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
var statusCode;
var statusText;
var responseText;
var statusCode = void 0;
var statusText = void 0;
var responseText = void 0;
if (xmlhttp.status) {
statusCode = "\n".concat(Drupal.t('An AJAX HTTP error occurred.'), "\n").concat(Drupal.t('HTTP Result Code: !status', {
'!status': xmlhttp.status
}));
statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status });
} else {
statusCode = "\n".concat(Drupal.t('An AJAX HTTP request terminated abnormally.'));
statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.');
}
statusCode += "\n".concat(Drupal.t('Debugging information follows.'));
var pathText = "\n".concat(Drupal.t('Path: !uri', {
'!uri': uri
}));
statusCode += '\n' + Drupal.t('Debugging information follows.');
var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri });
statusText = '';
try {
statusText = "\n".concat(Drupal.t('StatusText: !statusText', {
statusText = '\n' + Drupal.t('StatusText: !statusText', {
'!statusText': $.trim(xmlhttp.statusText)
}));
});
} catch (e) {}
responseText = '';
try {
responseText = "\n".concat(Drupal.t('ResponseText: !responseText', {
responseText = '\n' + Drupal.t('ResponseText: !responseText', {
'!responseText': $.trim(xmlhttp.responseText)
}));
});
} catch (e) {}
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, '');
responseText = responseText.replace(/[\n]+\s+/g, '\n');
var readyStateText = xmlhttp.status === 0 ? "\n".concat(Drupal.t('ReadyState: !readyState', {
var readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', {
'!readyState': xmlhttp.readyState
})) : '';
customMessage = customMessage ? "\n".concat(Drupal.t('CustomMessage: !customMessage', {
}) : '';
customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', {
'!customMessage': customMessage
})) : '';
}) : '';
this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
this.name = 'AjaxError';
};
......@@ -121,6 +115,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var ajax = new Drupal.Ajax(base, element, settings);
ajax.instanceIndex = Drupal.ajax.instances.length;
Drupal.ajax.instances.push(ajax);
return ajax;
};
......@@ -135,10 +130,9 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Drupal.ajax.bindAjaxLinks = function (element) {
$(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) {
var $linkElement = $(ajaxLink);
var elementSettings = {
progress: {
type: 'throbber'
},
progress: { type: 'throbber' },
dialogType: $linkElement.data('dialog-type'),
dialog: $linkElement.data('dialog-options'),
dialogRenderer: $linkElement.data('dialog-renderer'),
......@@ -151,7 +145,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
elementSettings.url = href;
elementSettings.event = 'click';
}
Drupal.ajax(elementSettings);
});
};
......@@ -160,7 +153,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var defaults = {
event: element ? 'mousedown' : null,
keypress: true,
selector: base ? "#".concat(base) : null,
selector: base ? '#' + base : null,
effect: 'none',
speed: 'none',
method: 'replaceWith',
......@@ -172,16 +165,21 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
js: true
}
};
$.extend(this, defaults, elementSettings);
this.commands = new Drupal.AjaxCommands();
this.instanceIndex = false;
if (this.wrapper) {
this.wrapper = "#".concat(this.wrapper);
this.wrapper = '#' + this.wrapper;
}
this.element = element;
this.element_settings = elementSettings;
this.elementSettings = elementSettings;
if (this.element && this.element.form) {
......@@ -190,7 +188,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
if (!this.url) {
var $element = $(this.element);
if ($element.is('a')) {
this.url = $element.attr('href');
} else if (this.element && element.form) {
......@@ -199,6 +196,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
var originalUrl = this.url;
this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1');
if (drupalSettings.ajaxTrustedUrl[originalUrl]) {
......@@ -206,6 +204,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
var ajax = this;
ajax.options = {
url: ajax.url,
data: ajax.submit,
......@@ -236,11 +235,11 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
},
complete: function complete(xmlhttprequest, status) {
ajax.ajaxing = false;
if (status === 'error' || status === 'parsererror') {
return ajax.error(xmlhttprequest, ajax.url);
}
},
dataType: 'json',
type: 'POST'
};
......@@ -255,20 +254,18 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
ajax.options.url += '&';
}
var wrapper = "drupal_".concat(elementSettings.dialogType || 'ajax');
var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax');
if (elementSettings.dialogRenderer) {
wrapper += ".".concat(elementSettings.dialogRenderer);
wrapper += '.' + elementSettings.dialogRenderer;
}
ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=' + wrapper;
ajax.options.url += "".concat(Drupal.ajax.WRAPPER_FORMAT, "=").concat(wrapper);
$(ajax.element).on(elementSettings.event, function (event) {
if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) {
throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', {
'!url': ajax.url
}));
}
return ajax.eventResponse(this, event);
});
......@@ -284,6 +281,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format';
Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax';
Drupal.Ajax.prototype.execute = function () {
......@@ -293,10 +291,12 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
try {
this.beforeSerialize(this.element, this.options);
return $.ajax(this.options);
} catch (e) {
this.ajaxing = false;
window.alert("An error occurred while attempting to process ".concat(this.options.url, ": ").concat(e.message));
window.alert('An error occurred while attempting to process ' + this.options.url + ': ' + e.message);
return $.Deferred().reject();
}
};
......@@ -314,6 +314,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Drupal.Ajax.prototype.eventResponse = function (element, event) {
event.preventDefault();
event.stopPropagation();
var ajax = this;
if (ajax.ajaxing) {
......@@ -333,7 +334,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
} catch (e) {
ajax.ajaxing = false;
window.alert("An error occurred while attempting to process ".concat(ajax.options.url, ": ").concat(e.message));
window.alert('An error occurred while attempting to process ' + ajax.options.url + ': ' + e.message);
}
};
......@@ -344,6 +345,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
options.data[Drupal.Ajax.AJAX_REQUEST_PARAMETER] = 1;
var pageState = drupalSettings.ajaxPageState;
options.data['ajax_page_state[theme]'] = pageState.theme;
options.data['ajax_page_state[theme_token]'] = pageState.theme_token;
......@@ -355,9 +357,10 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) {
if (this.$form) {
options.extraData = options.extraData || {};
options.extraData.ajax_iframe_upload = '1';
var v = $.fieldValue(this.element);
var v = $.fieldValue(this.element);
if (v !== null) {
options.extraData[this.element.name] = v;
}
......@@ -369,8 +372,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
return;
}
var progressIndicatorMethod = "setProgressIndicator".concat(this.progress.type.slice(0, 1).toUpperCase()).concat(this.progress.type.slice(1).toLowerCase());
var progressIndicatorMethod = 'setProgressIndicator' + this.progress.type.slice(0, 1).toUpperCase() + this.progress.type.slice(1).toLowerCase();
if (progressIndicatorMethod in this && typeof this[progressIndicatorMethod] === 'function') {
this[progressIndicatorMethod].call(this);
}
......@@ -379,7 +381,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Drupal.theme.ajaxProgressThrobber = function (message) {
var messageMarkup = typeof message === 'string' ? Drupal.theme('ajaxProgressMessage', message) : '';
var throbber = '<div class="throbber">&nbsp;</div>';
return "<div class=\"ajax-progress ajax-progress-throbber\">".concat(throbber).concat(messageMarkup, "</div>");
return '<div class="ajax-progress ajax-progress-throbber">' + throbber + messageMarkup + '</div>';
};
Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
......@@ -387,7 +390,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.theme.ajaxProgressMessage = function (message) {
return "<div class=\"message\">".concat(message, "</div>");
return '<div class="message">' + message + '</div>';
};
Drupal.theme.ajaxProgressBar = function ($element) {
......@@ -395,16 +398,13 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.Ajax.prototype.setProgressIndicatorBar = function () {
var progressBar = new Drupal.ProgressBar("ajax-progress-".concat(this.element.id), $.noop, this.progress.method, $.noop);
var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop);
if (this.progress.message) {
progressBar.setProgress(-1, this.progress.message);
}
if (this.progress.url) {
progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
}
this.progress.element = $(Drupal.theme('ajaxProgressBar', progressBar.element));
this.progress.object = progressBar;
$(this.element).after(this.progress.element);
......@@ -426,18 +426,17 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
if (this.progress.element) {
$(this.progress.element).remove();
}
if (this.progress.object) {
this.progress.object.stopMonitoring();
}
$(this.element).prop('disabled', false);
var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray();
var focusChanged = false;
Object.keys(response || {}).forEach(function (i) {
if (response[i].command && _this.commands[response[i].command]) {
_this.commands[response[i].command](_this, response[i], status);
if (response[i].command === 'invoke' && response[i].method === 'focus') {
focusChanged = true;
}
......@@ -448,7 +447,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var target = false;
for (var n = elementParents.length - 1; !target && n >= 0; n--) {
target = document.querySelector("[data-drupal-selector=\"".concat(elementParents[n].getAttribute('data-drupal-selector'), "\"]"));
target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]');
}
if (target) {
......@@ -467,8 +466,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
Drupal.Ajax.prototype.getEffect = function (response) {
var type = response.effect || this.effect;
var speed = response.speed || this.speed;
var effect = {};
var effect = {};
if (type === 'none') {
effect.showEffect = 'show';
effect.hideEffect = 'hide';
......@@ -478,8 +477,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
effect.hideEffect = 'fadeOut';
effect.showSpeed = speed;
} else {
effect.showEffect = "".concat(type, "Toggle");
effect.hideEffect = "".concat(type, "Toggle");
effect.showEffect = type + 'Toggle';
effect.hideEffect = type + 'Toggle';
effect.showSpeed = speed;
}
......@@ -490,19 +489,18 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
if (this.progress.element) {
$(this.progress.element).remove();
}
if (this.progress.object) {
this.progress.object.stopMonitoring();
}
$(this.wrapper).show();
$(this.element).prop('disabled', false);
if (this.$form && document.body.contains(this.$form.get(0))) {
var settings = this.settings || drupalSettings;
Drupal.attachBehaviors(this.$form.get(0), settings);
}
throw new Drupal.AjaxError(xmlhttprequest, uri, customMessage);
};
......@@ -517,14 +515,16 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.AjaxCommands = function () {};
Drupal.AjaxCommands.prototype = {
insert: function insert(ajax, response) {
var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
var method = response.method || ajax.method;
var effect = ajax.getEffect(response);
var settings = response.settings || ajax.settings || drupalSettings;
var $newContent = $($.parseHTML(response.data, document, true));
$newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response);
switch (method) {
......@@ -535,7 +535,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
case 'remove':
Drupal.detachBehaviors($wrapper.get(0), settings);
break;
default:
break;
}
......@@ -547,7 +546,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
var $ajaxNewContent = $newContent.find('.ajax-new-content');
if ($ajaxNewContent.length) {
$ajaxNewContent.hide();
$newContent.show();
......@@ -572,12 +570,10 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
},
changed: function changed(ajax, response, status) {
var $element = $(response.selector);
if (!$element.hasClass('ajax-changed')) {
$element.addClass('ajax-changed');
if (response.asterisk) {
$element.find(response.asterisk).append(" <abbr class=\"ajax-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr> "));
$element.find(response.asterisk).append(' <abbr class="ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr> ');
}
}
},
......@@ -602,9 +598,9 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
if (ajaxSettings) {
Drupal.ajax.expired().forEach(function (instance) {
if (instance.selector) {
var selector = instance.selector.replace('#', '');
if (selector in ajaxSettings) {
delete ajaxSettings[selector];
}
......@@ -629,18 +625,16 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
$(response.selector).find('> tbody > tr:visible, > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
},
update_build_id: function update_build_id(ajax, response, status) {
$("input[name=\"form_build_id\"][value=\"".concat(response.old, "\"]")).val(response["new"]);
$('input[name="form_build_id"][value="' + response.old + '"]').val(response.new);
},
add_css: function add_css(ajax, response, status) {
$('head').prepend(response.data);
},
message: function message(ajax, response) {
var messages = new Drupal.Message(document.querySelector(response.messageWrapperQuerySelector));
if (response.clearPrevious) {
messages.clear();
}
messages.add(response.message, response.messageOptions);
}
};
......
......@@ -6,8 +6,9 @@
**/
(function (Drupal, debounce) {
var liveElement;
var liveElement = void 0;
var announcements = [];
Drupal.behaviors.drupalAnnounce = {
attach: function attach(context) {
if (!liveElement) {
......@@ -24,9 +25,9 @@
function announce() {
var text = [];
var priority = 'polite';
var announcement;
var il = announcements.length;
var announcement = void 0;
var il = announcements.length;
for (var i = 0; i < il; i++) {
announcement = announcements.pop();
text.unshift(announcement.text);
......@@ -38,9 +39,13 @@
if (text.length) {
liveElement.innerHTML = '';
liveElement.setAttribute('aria-busy', 'true');
<