Unverified Commit 2dadb738 authored by alexpott's avatar alexpott
Browse files

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

Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core JavaScript dependencies listed in package.json
parent 09b78ffb
......@@ -21,6 +21,11 @@
"Sortable": true,
"CKEDITOR": true
},
"settings": {
"react": {
"version": "latest"
}
},
"rules": {
"prettier/prettier": "error",
"consistent-return": ["off"],
......
......@@ -10,26 +10,25 @@
attach: function attach(context) {
var path = drupalSettings.path;
var queryString = JSON.stringify(path.currentQuery);
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;
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;
if (path.isFront) {
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
}
selectors = [].concat(originalSelectors.map(function (selector) {
return selector + ':not([hreflang])';
return "".concat(selector, ":not([hreflang])");
}), originalSelectors.map(function (selector) {
return selector + '[hreflang="' + path.currentLanguage + '"]';
return "".concat(selector, "[hreflang=\"").concat(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');
}
......@@ -38,6 +37,7 @@
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,7 +102,9 @@
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(
......@@ -1129,12 +1131,14 @@
(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,16 +4,25 @@
* https://www.drupal.org/node/2815083
* @preserve
**/
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 _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 ($, 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 = '#' + base;
elementSettings.selector = "#".concat(base);
}
$(elementSettings.selector).once('drupal-ajax').each(function () {
elementSettings.element = this;
elementSettings.base = base;
......@@ -24,22 +33,17 @@ function _toConsumableArray(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);
});
},
......@@ -53,45 +57,47 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
var statusCode = void 0;
var statusText = void 0;
var responseText = void 0;
var statusCode;
var statusText;
var responseText;
if (xmlhttp.status) {
statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status });
statusCode = "\n".concat(Drupal.t('An AJAX HTTP error occurred.'), "\n").concat(Drupal.t('HTTP Result Code: !status', {
'!status': xmlhttp.status
}));
} else {
statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.');
statusCode = "\n".concat(Drupal.t('An AJAX HTTP request terminated abnormally.'));
}
statusCode += '\n' + Drupal.t('Debugging information follows.');
var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri });
statusCode += "\n".concat(Drupal.t('Debugging information follows.'));
var pathText = "\n".concat(Drupal.t('Path: !uri', {
'!uri': uri
}));
statusText = '';
try {
statusText = '\n' + Drupal.t('StatusText: !statusText', {
statusText = "\n".concat(Drupal.t('StatusText: !statusText', {
'!statusText': $.trim(xmlhttp.statusText)
});
}));
} catch (e) {}
responseText = '';
try {
responseText = '\n' + Drupal.t('ResponseText: !responseText', {
responseText = "\n".concat(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' + Drupal.t('ReadyState: !readyState', {
var readyStateText = xmlhttp.status === 0 ? "\n".concat(Drupal.t('ReadyState: !readyState', {
'!readyState': xmlhttp.readyState
}) : '';
customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', {
})) : '';
customMessage = customMessage ? "\n".concat(Drupal.t('CustomMessage: !customMessage', {
'!customMessage': customMessage
}) : '';
})) : '';
this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
this.name = 'AjaxError';
};
......@@ -115,7 +121,6 @@ function _toConsumableArray(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;
};
......@@ -130,9 +135,10 @@ function _toConsumableArray(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'),
......@@ -145,6 +151,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
elementSettings.url = href;
elementSettings.event = 'click';
}
Drupal.ajax(elementSettings);
});
};
......@@ -153,7 +160,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var defaults = {
event: element ? 'mousedown' : null,
keypress: true,
selector: base ? '#' + base : null,
selector: base ? "#".concat(base) : null,
effect: 'none',
speed: 'none',
method: 'replaceWith',
......@@ -165,21 +172,16 @@ function _toConsumableArray(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 = '#' + this.wrapper;
this.wrapper = "#".concat(this.wrapper);
}
this.element = element;
this.element_settings = elementSettings;
this.elementSettings = elementSettings;
if (this.element && this.element.form) {
......@@ -188,6 +190,7 @@ function _toConsumableArray(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) {
......@@ -196,7 +199,6 @@ function _toConsumableArray(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]) {
......@@ -204,7 +206,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
var ajax = this;
ajax.options = {
url: ajax.url,
data: ajax.submit,
......@@ -235,11 +236,11 @@ function _toConsumableArray(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'
};
......@@ -254,18 +255,20 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
ajax.options.url += '&';
}
var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax');
var wrapper = "drupal_".concat(elementSettings.dialogType || 'ajax');
if (elementSettings.dialogRenderer) {
wrapper += '.' + elementSettings.dialogRenderer;
wrapper += ".".concat(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);
});
......@@ -281,7 +284,6 @@ function _toConsumableArray(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 () {
......@@ -291,12 +293,10 @@ function _toConsumableArray(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 ' + this.options.url + ': ' + e.message);
window.alert("An error occurred while attempting to process ".concat(this.options.url, ": ").concat(e.message));
return $.Deferred().reject();
}
};
......@@ -314,7 +314,6 @@ function _toConsumableArray(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) {
......@@ -334,7 +333,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
} catch (e) {
ajax.ajaxing = false;
window.alert('An error occurred while attempting to process ' + ajax.options.url + ': ' + e.message);
window.alert("An error occurred while attempting to process ".concat(ajax.options.url, ": ").concat(e.message));
}
};
......@@ -345,7 +344,6 @@ function _toConsumableArray(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;
......@@ -357,10 +355,9 @@ function _toConsumableArray(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);
if (v !== null) {
options.extraData[this.element.name] = v;
}
......@@ -372,7 +369,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
return;
}
var progressIndicatorMethod = 'setProgressIndicator' + this.progress.type.slice(0, 1).toUpperCase() + this.progress.type.slice(1).toLowerCase();
var progressIndicatorMethod = "setProgressIndicator".concat(this.progress.type.slice(0, 1).toUpperCase()).concat(this.progress.type.slice(1).toLowerCase());
if (progressIndicatorMethod in this && typeof this[progressIndicatorMethod] === 'function') {
this[progressIndicatorMethod].call(this);
}
......@@ -381,8 +379,7 @@ function _toConsumableArray(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">' + throbber + messageMarkup + '</div>';
return "<div class=\"ajax-progress ajax-progress-throbber\">".concat(throbber).concat(messageMarkup, "</div>");
};
Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
......@@ -390,7 +387,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.theme.ajaxProgressMessage = function (message) {
return '<div class="message">' + message + '</div>';
return "<div class=\"message\">".concat(message, "</div>");
};
Drupal.theme.ajaxProgressBar = function ($element) {
......@@ -398,13 +395,16 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
};
Drupal.Ajax.prototype.setProgressIndicatorBar = function () {
var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop);
var progressBar = new Drupal.ProgressBar("ajax-progress-".concat(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,17 +426,18 @@ function _toConsumableArray(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);
$(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;
}
......@@ -447,7 +448,7 @@ function _toConsumableArray(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="' + elementParents[n].getAttribute('data-drupal-selector') + '"]');
target = document.querySelector("[data-drupal-selector=\"".concat(elementParents[n].getAttribute('data-drupal-selector'), "\"]"));
}
if (target) {
......@@ -466,8 +467,8 @@ function _toConsumableArray(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 = {};
if (type === 'none') {
effect.showEffect = 'show';
effect.hideEffect = 'hide';
......@@ -477,8 +478,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
effect.hideEffect = 'fadeOut';
effect.showSpeed = speed;
} else {
effect.showEffect = type + 'Toggle';
effect.hideEffect = type + 'Toggle';
effect.showEffect = "".concat(type, "Toggle");
effect.hideEffect = "".concat(type, "Toggle");
effect.showSpeed = speed;
}
......@@ -489,18 +490,19 @@ function _toConsumableArray(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);
};
......@@ -515,16 +517,14 @@ function _toConsumableArray(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,6 +535,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
case 'remove':
Drupal.detachBehaviors($wrapper.get(0), settings);
break;
default:
break;
}
......@@ -546,6 +547,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
}
var $ajaxNewContent = $newContent.find('.ajax-new-content');
if ($ajaxNewContent.length) {
$ajaxNewContent.hide();
$newContent.show();
......@@ -570,10 +572,12 @@ function _toConsumableArray(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="' + Drupal.t('Changed') + '">*</abbr> ');
$element.find(response.asterisk).append(" <abbr class=\"ajax-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr> "));
}
}
},
......@@ -598,9 +602,9 @@ function _toConsumableArray(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];
}
......@@ -625,16 +629,18 @@ function _toConsumableArray(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="' + response.old + '"]').val(response.new);
$("input[name=\"form_build_id\"][value=\"".concat(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,9 +6,8 @@
**/
(function (Drupal, debounce) {
var liveElement = void 0;
var liveElement;
var announcements = [];
Drupal.behaviors.drupalAnnounce = {
attach: function attach(context) {
if (!liveElement) {
......@@ -25,9 +24,9 @@
function announce() {
var text = [];
var priority = 'polite';
var announcement = void 0;
var announcement;
var il = announcements.length;
for (var i = 0; i < il; i++) {
announcement = announcements.pop();
text.unshift(announcement.text);
......@@ -39,13 +38,9 @@
if (text.length) {
liveElement.innerHTML = '';
liveElement.setAttribute('aria-busy', 'true');