diff --git a/core/misc/active-link.js b/core/misc/active-link.js index caa29f87da62e7cfdbd892159d8591eaf04a2c0f..cd439b5c4d3aed937153a395e2a40ce267b86e86 100644 --- a/core/misc/active-link.js +++ b/core/misc/active-link.js @@ -18,17 +18,20 @@ originalSelectors.push('[data-drupal-link-system-path="<front>"]'); } - selectors = [].concat(originalSelectors.map(function (selector) { + selectors = [].concat( + originalSelectors.map(function (selector) { return "".concat(selector, ":not([hreflang])"); - }), originalSelectors.map(function (selector) { + }), + originalSelectors.map(function (selector) { 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'); } @@ -37,7 +40,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'); } diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 59c21a6acb6c8c9a3492d1c96e948df0b7229f0d..955f9c5ba4f8d312fd3f84ad12a424b876ecda75 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -4,31 +4,23 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function ($, window, Drupal, drupalSettings, loadjs, _ref) { var isFocusable = _ref.isFocusable, - tabbable = _ref.tabbable; + tabbable = _ref.tabbable; 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); } - once('drupal-ajax', $(elementSettings.selector)).forEach(function (el) { elementSettings.element = el; elementSettings.base = base; @@ -40,8 +32,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return loadAjaxBehavior(base); }); Drupal.ajax.bindAjaxLinks(document.body); + once('ajax', '.use-ajax-submit').forEach(function (el) { var elementSettings = {}; + elementSettings.url = $(el.form).attr('action'); elementSettings.setClick = true; elementSettings.event = 'click'; @@ -66,7 +60,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var statusCode; var statusText; var responseText; - if (xmlhttp.status) { statusCode = "\n".concat(Drupal.t('An AJAX HTTP error occurred.'), "\n").concat(Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status @@ -74,39 +67,40 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } else { statusCode = "\n".concat(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 })); statusText = ''; - try { statusText = "\n".concat(Drupal.t('StatusText: !statusText', { '!statusText': xmlhttp.statusText.trim() })); - } catch (e) {} + } catch (e) { + } responseText = ''; - try { responseText = "\n".concat(Drupal.t('ResponseText: !responseText', { '!responseText': xmlhttp.responseText.trim() })); - } catch (e) {} + } catch (e) { + } responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ''); responseText = responseText.replace(/[\n]+\s+/g, '\n'); + var readyStateText = xmlhttp.status === 0 ? "\n".concat(Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState })) : ''; customMessage = customMessage ? "\n".concat(Drupal.t('CustomMessage: !customMessage', { '!customMessage': customMessage })) : ''; + this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText; + this.name = 'AjaxError'; }; - Drupal.AjaxError.prototype = new Error(); Drupal.AjaxError.prototype.constructor = Drupal.AjaxError; @@ -114,7 +108,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (arguments.length !== 1) { throw new Error('Drupal.ajax() function must be called with one configuration object only'); } - var base = settings.base || false; var element = settings.element || false; delete settings.base; @@ -123,7 +116,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (!settings.progress && !element) { settings.progress = false; } - var ajax = new Drupal.Ajax(base, element, settings); ajax.instanceIndex = Drupal.ajax.instances.length; Drupal.ajax.instances.push(ajax); @@ -152,12 +144,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len element: ajaxLink }; var href = $linkElement.attr('href'); - if (href) { elementSettings.url = href; elementSettings.event = 'click'; } - Drupal.ajax(elementSettings); }); }; @@ -179,7 +169,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }; $.extend(this, defaults, elementSettings); + this.commands = new Drupal.AjaxCommands(); + this.instanceIndex = false; if (this.wrapper) { @@ -187,7 +179,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } this.element = element; + this.element_settings = elementSettings; + this.elementSettings = elementSettings; if (this.element && this.element.form) { @@ -196,7 +190,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (!this.url) { var $element = $(this.element); - if ($element.is('a')) { this.url = $element.attr('href'); } else if (this.element && element.form) { @@ -205,13 +198,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } var originalUrl = this.url; - this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1'); + this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1'); if (drupalSettings.ajaxTrustedUrl[originalUrl]) { drupalSettings.ajaxTrustedUrl[this.url] = true; } var ajax = this; + ajax.options = { url: ajax.url, data: ajax.submit, @@ -237,10 +231,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return ajax.error(xmlhttprequest, ajax.url, customMessage); } } - - return Promise.resolve(ajax.success(response, status)).then(function () { - ajax.ajaxing = false; - }); + return ( + Promise.resolve(ajax.success(response, status)) + .then(function () { + ajax.ajaxing = false; + }) + ); }, error: function error(xmlhttprequest, status, _error) { ajax.ajaxing = false; @@ -254,7 +250,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len jsonp: false, type: 'POST' }; - if (elementSettings.dialog) { ajax.options.data.dialogOptions = elementSettings.dialog; } @@ -264,21 +259,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } else { ajax.options.url += '&'; } - var wrapper = "drupal_".concat(elementSettings.dialogType || 'ajax'); - if (elementSettings.dialogRenderer) { wrapper += ".".concat(elementSettings.dialogRenderer); } - 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); }); @@ -294,13 +286,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }; Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; + Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax'; Drupal.Ajax.prototype.execute = function () { if (this.ajaxing) { return; } - try { this.beforeSerialize(this.element, this.options); return $.ajax(this.options); @@ -324,18 +316,17 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.Ajax.prototype.eventResponse = function (element, event) { event.preventDefault(); event.stopPropagation(); + var ajax = this; if (ajax.ajaxing) { return; } - try { if (ajax.$form) { if (ajax.setClick) { element.form.clk = element; } - ajax.$form.ajaxSubmit(ajax.options); } else { ajax.beforeSerialize(ajax.element, ajax.options); @@ -354,33 +345,35 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } 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; options.data['ajax_page_state[libraries]'] = pageState.libraries; }; - Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) {}; + Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) { + } + ; 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; } } $(this.element).prop('disabled', true); - if (!this.progress || !this.progress.type) { return; } 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); } @@ -406,15 +399,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.Ajax.prototype.setProgressIndicatorBar = function () { 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); @@ -432,12 +422,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.Ajax.prototype.commandExecutionQueue = function (response, status) { var _this = this; - var ajaxCommands = this.commands; - return Object.keys(response || {}).reduce(function (executionQueue, key) { + return Object.keys(response || {}).reduce( + function (executionQueue, key) { return executionQueue.then(function () { var command = response[key].command; - if (command && ajaxCommands[command]) { return ajaxCommands[command](_this, response[key], status); } @@ -447,46 +436,44 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.Ajax.prototype.success = function (response, status) { var _this2 = this; - 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 = Object.keys(response || {}).some(function (key) { var _response$key = response[key], - command = _response$key.command, - method = _response$key.method; + command = _response$key.command, + method = _response$key.method; return command === 'focusFirst' || command === 'invoke' && method === 'focus'; }); - return this.commandExecutionQueue(response, status).then(function () { + return this.commandExecutionQueue(response, status) + .then(function () { if (!focusChanged && _this2.element && !$(_this2.element).data('disable-refocus')) { 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'), "\"]")); } - if (target) { $(target).trigger('focus'); } } - if (_this2.$form && document.body.contains(_this2.$form.get(0))) { var settings = _this2.settings || drupalSettings; Drupal.attachBehaviors(_this2.$form.get(0), settings); } - _this2.settings = null; }).catch(function (error) { - return console.error(Drupal.t('An error occurred during the execution of the Ajax response: !error', { - '!error': error - })); + return ( + console.error(Drupal.t('An error occurred during the execution of the Ajax response: !error', { + '!error': error + })) + ); }); }; @@ -494,7 +481,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var type = response.effect || this.effect; var speed = response.speed || this.speed; var effect = {}; - if (type === 'none') { effect.showEffect = 'show'; effect.hideEffect = 'hide'; @@ -508,7 +494,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len effect.hideEffect = "".concat(type, "Toggle"); effect.showSpeed = speed; } - return effect; }; @@ -516,25 +501,23 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len 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); }; Drupal.theme.ajaxWrapperNewContent = function ($newContent, ajax, response) { return (response.effect || ajax.effect) !== 'none' && $newContent.filter(function (i) { - return !($newContent[i].nodeName === '#comment' || $newContent[i].nodeName === '#text' && /^(\s|\n|\r)*$/.test($newContent[i].textContent)); + return !( + + $newContent[i].nodeName === '#comment' || $newContent[i].nodeName === '#text' && /^(\s|\n|\r)*$/.test($newContent[i].textContent)); }).length > 1 ? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent) : $newContent; }; @@ -543,13 +526,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }; 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); @@ -561,7 +545,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len case 'remove': Drupal.detachBehaviors($wrapper.get(0), settings); break; - default: break; } @@ -573,7 +556,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } var $ajaxNewContent = $newContent.find('.ajax-new-content'); - if ($ajaxNewContent.length) { $ajaxNewContent.hide(); $newContent.show(); @@ -598,10 +580,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }, 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> ")); } @@ -628,16 +608,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (ajaxSettings) { Drupal.ajax.expired().forEach(function (instance) { + if (instance.selector) { var selector = instance.selector.replace('#', ''); - if (selector in ajaxSettings) { delete ajaxSettings[selector]; } } }); } - if (response.merge) { $.extend(true, drupalSettings, response.settings); } else { @@ -650,7 +629,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len focusFirst: function focusFirst(ajax, response, status) { var focusChanged = false; var container = document.querySelector(response.selector); - if (container) { var tabbableElements = tabbable(container); @@ -684,11 +662,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }, 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); }, add_js: function add_js(ajax, response, status) { @@ -702,6 +678,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Object.keys(script).forEach(function (attributeKey) { scriptEl.setAttribute(attributeKey, script[attributeKey]); }); + parentEl.appendChild(scriptEl); return false; } diff --git a/core/misc/announce.js b/core/misc/announce.js index eacf55b511eb9ed7cb9b8b3140f7b07232e1abab..7183ef66529a427b1906ffc3abfa0da950311f05 100644 --- a/core/misc/announce.js +++ b/core/misc/announce.js @@ -8,6 +8,7 @@ (function (Drupal, debounce) { var liveElement; var announcements = []; + Drupal.behaviors.drupalAnnounce = { attach: function attach(context) { if (!liveElement) { @@ -25,17 +26,15 @@ var text = []; var priority = 'polite'; var announcement; - var il = announcements.length; + var il = announcements.length; for (var i = 0; i < il; i++) { announcement = announcements.pop(); text.unshift(announcement.text); - if (announcement.priority === 'assertive') { priority = 'assertive'; } } - if (text.length) { liveElement.innerHTML = ''; liveElement.setAttribute('aria-busy', 'true'); diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js index 3b4a4a24251da0e1fa7d9b863ec5482b511ee5d9..444c4b6df970242604f7aba4e0d2eb1a991cd7eb 100644 --- a/core/misc/autocomplete.js +++ b/core/misc/autocomplete.js @@ -14,10 +14,8 @@ var current = ''; var valueLength = value.length; var character; - for (var i = 0; i < valueLength; i++) { character = value.charAt(i); - if (character === '"') { current += character; quote = !quote; @@ -28,11 +26,9 @@ current += character; } } - if (value.length > 0) { result.push(current.trim()); } - return result; } @@ -42,23 +38,18 @@ function searchHandler(event) { var options = autocomplete.options; - if (options.isComposing) { return false; } - var term = autocomplete.extractLastTerm(event.target.value); - if (term.length > 0 && options.firstCharacterBlacklist.indexOf(term[0]) !== -1) { return false; } - return term.length >= options.minLength; } function sourceData(request, response) { var elementId = this.element.attr('id'); - if (!(elementId in autocomplete.cache)) { autocomplete.cache[elementId] = {}; } @@ -66,15 +57,12 @@ function showSuggestions(suggestions) { var tagged = autocomplete.splitValues(request.term); var il = tagged.length; - for (var i = 0; i < il; i++) { var index = suggestions.indexOf(tagged[i]); - if (index >= 0) { suggestions.splice(index, 1); } } - response(suggestions); } @@ -82,6 +70,7 @@ function sourceCallbackHandler(data) { autocomplete.cache[elementId][term] = data; + showSuggestions(data); } @@ -117,7 +106,6 @@ Drupal.behaviors.autocomplete = { attach: function attach(context) { var $autocomplete = $(once('autocomplete', 'input.form-autocomplete', context)); - if ($autocomplete.length) { var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist'); $.extend(autocomplete.options, { @@ -126,6 +114,7 @@ $autocomplete.autocomplete(autocomplete.options).each(function () { $(this).data('ui-autocomplete')._renderItem = autocomplete.options.renderItem; }); + $autocomplete.on('compositionstart.autocomplete', function () { autocomplete.options.isComposing = true; }); @@ -140,10 +129,12 @@ } } }; + autocomplete = { cache: {}, splitValues: autocompleteSplitValues, extractLastTerm: extractLastTerm, + options: { source: sourceData, focus: focusHandler, diff --git a/core/misc/batch.js b/core/misc/batch.js index 2511bdbb7565cfa959288d14b7f6d43e2d3d4852..a46b2e4f234ede6fe35d563dc0e86d27240e178e 100644 --- a/core/misc/batch.js +++ b/core/misc/batch.js @@ -18,12 +18,10 @@ window.location = "".concat(batch.uri, "&op=finished"); } } - function errorCallback(pb) { $progress.prepend($('<p class="error"></p>').html(batch.errorMessage)); $('#wait').hide(); } - if ($progress.length) { progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback); progressBar.setProgress(-1, batch.initMessage); diff --git a/core/misc/collapse.js b/core/misc/collapse.js index 60bd05a067fd3d8fae5e12ae850425af226bb12c..11ea59eec23458d9797b4e7f13f3e73065da06c0 100644 --- a/core/misc/collapse.js +++ b/core/misc/collapse.js @@ -10,22 +10,21 @@ this.$node = $(node); this.$node.data('details', this); var anchor = window.location.hash && window.location.hash !== '#' ? ", ".concat(window.location.hash) : ''; - if (this.$node.find(".error".concat(anchor)).length) { this.$node.attr('open', true); } - this.setupSummaryPolyfill(); } - $.extend(CollapsibleDetails, { instances: [] }); $.extend(CollapsibleDetails.prototype, { setupSummaryPolyfill: function setupSummaryPolyfill() { var $summary = this.$node.find('> summary'); + $summary.attr('tabindex', '-1'); $('<span class="details-summary-prefix visually-hidden"></span>').append(this.$node.attr('open') ? Drupal.t('Hide') : Drupal.t('Show')).prependTo($summary).after(document.createTextNode(' ')); + $('<a class="details-title"></a>').attr('href', "#".concat(this.$node.attr('id'))).prepend($summary.contents()).appendTo($summary); $summary.append(this.$summary).on('click', $.proxy(this.onSummaryClick, this)); }, @@ -35,27 +34,24 @@ }, toggle: function toggle() { var _this = this; - var isOpen = !!this.$node.attr('open'); var $summaryPrefix = this.$node.find('> summary span.details-summary-prefix'); - if (isOpen) { $summaryPrefix.html(Drupal.t('Show')); } else { $summaryPrefix.html(Drupal.t('Hide')); } - setTimeout(function () { _this.$node.attr('open', !isOpen); }, 0); } }); + Drupal.behaviors.collapse = { attach: function attach(context) { if (Modernizr.details) { return; } - once('collapse', 'details', context).forEach(function (detail) { detail.classList.add('collapse-processed'); CollapsibleDetails.instances.push(new CollapsibleDetails(detail)); @@ -68,5 +64,6 @@ }; $('body').on('formFragmentLinkClickOrHashChange.details', handleFragmentLinkClickOrHashChange); + Drupal.CollapsibleDetails = CollapsibleDetails; })(jQuery, Modernizr, Drupal); \ No newline at end of file diff --git a/core/misc/date.js b/core/misc/date.js index d30fb1dbbca6818f66cf501bcdb6ef2842d51e1b..f920e1b05cd68ba4e328abc2914bdcbc9fd1f05a 100644 --- a/core/misc/date.js +++ b/core/misc/date.js @@ -4,11 +4,8 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } (function (Modernizr, Drupal, once) { @@ -35,8 +32,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var help = Drupal.theme.dateHelp({ dateDesc: dateInput.dataset.help }); + var id = "".concat(date.id, "--description"); dateInput.setAttribute('aria-describedby', id); + dateInput.setAttribute('type', 'text'); Drupal.DatepickerPolyfill.attachDescription(date, help, id); }); @@ -48,34 +47,32 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d function _class() { _classCallCheck(this, _class); } - _createClass(_class, null, [{ key: "attachDescription", - value: function attachDescription(element, help, id) { + value: + function attachDescription(element, help, id) { var description = element.nextElementSibling; if (!(description && description.getAttribute('data-drupal-field-elements') === 'description')) { description = Drupal.DatepickerPolyfill.descriptionWrapperElement(id); element.parentNode.insertBefore(description, element.nextSibling); } - description.insertAdjacentHTML('beforeend', help); } + }, { key: "descriptionWrapperElement", - value: function descriptionWrapperElement(id) { + value: + function descriptionWrapperElement(id) { var description = document.createElement('div'); description.classList.add('description'); description.setAttribute('data-drupal-field-elements', 'description'); - if (id) { description.setAttribute('id', id); } - return description; } }]); - return _class; }(); @@ -86,9 +83,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d Drupal.theme.dateTimeHelp = function (_ref2) { var dateId = _ref2.dateId, - timeId = _ref2.timeId, - dateDesc = _ref2.dateDesc, - timeDesc = _ref2.timeDesc; + timeId = _ref2.timeId, + dateDesc = _ref2.dateDesc, + timeDesc = _ref2.timeDesc; return "<div class=\"no-native-datepicker-help\">\n <span id=\"".concat(dateId, "\">").concat(dateDesc, "</span> <span id=\"").concat(timeId, "\">").concat(timeDesc, "</span>\n </div>"); }; })(Modernizr, Drupal, once); \ No newline at end of file diff --git a/core/misc/debounce.js b/core/misc/debounce.js index e33575670c09f14d771906b3000dd4044a82d0b2..3f726863e323e55b5357aba9f230cc8671c01391 100644 --- a/core/misc/debounce.js +++ b/core/misc/debounce.js @@ -12,25 +12,19 @@ Drupal.debounce = function (func, wait, immediate) { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - var context = this; - var later = function later() { timeout = null; - if (!immediate) { result = func.apply(context, args); } }; - var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); - if (callNow) { result = func.apply(context, args); } - return result; }; }; \ No newline at end of file diff --git a/core/misc/details-summarized-content.js b/core/misc/details-summarized-content.js index d1b2d8d694ce5f829a211477797363700f5a62fa..8e38526d43490f4780f68d40533902523b4b0dde 100644 --- a/core/misc/details-summarized-content.js +++ b/core/misc/details-summarized-content.js @@ -4,13 +4,11 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { function DetailsSummarizedContent(node) { this.$node = $(node); this.setupSummary(); } - $.extend(DetailsSummarizedContent, { instances: [] }); @@ -24,6 +22,7 @@ this.$detailsSummarizedContentWrapper.html(Drupal.theme('detailsSummarizedContentText', text)); } }); + Drupal.behaviors.detailsSummary = { attach: function attach(context) { DetailsSummarizedContent.instances = DetailsSummarizedContent.instances.concat(once('details', 'details', context).map(function (details) { diff --git a/core/misc/dialog/dialog.ajax.js b/core/misc/dialog/dialog.ajax.js index c470491abff77261b1b71343f32f5bc4a6c789c1..69f2af1ec149b012354838175517d33740c33a96 100644 --- a/core/misc/dialog/dialog.ajax.js +++ b/core/misc/dialog/dialog.ajax.js @@ -15,7 +15,6 @@ } var $dialog = $context.closest('.ui-dialog-content'); - if ($dialog.length) { if ($dialog.dialog('option', 'drupalAutoButtons')) { $dialog.trigger('dialogButtonsChange'); @@ -23,14 +22,11 @@ $dialog.dialog('widget').trigger('focus'); } - var originalClose = settings.dialog.close; - settings.dialog.close = function (event) { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } - originalClose.apply(settings.dialog, [event].concat(args)); $(event.target).remove(); }; @@ -63,13 +59,10 @@ if (!response.selector) { return false; } - var $dialog = $(response.selector); - if (!$dialog.length) { $dialog = $("<div id=\"".concat(response.selector.replace(/^#/, ''), "\" class=\"ui-front\"></div>")).appendTo('body'); } - if (!ajax.wrapper) { ajax.wrapper = $dialog.attr('id'); } @@ -87,9 +80,9 @@ var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog); $dialog.dialog('option', 'buttons', buttons); }); + response.dialogOptions = response.dialogOptions || {}; var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions); - if (response.dialogOptions.modal) { dialog.showModal(); } else { @@ -101,10 +94,8 @@ Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) { var $dialog = $(response.selector); - if ($dialog.length) { Drupal.dialog($dialog.get(0)).close(); - if (!response.persist) { $dialog.remove(); } @@ -115,7 +106,6 @@ Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) { var $dialog = $(response.selector); - if ($dialog.length) { $dialog.dialog('option', response.optionName, response.optionValue); } @@ -128,6 +118,7 @@ e.stopPropagation(); }); }); + $(window).on('dialog:beforeclose', function (e, dialog, $element) { $element.off('.dialog'); }); diff --git a/core/misc/dialog/dialog.jquery-ui.js b/core/misc/dialog/dialog.jquery-ui.js index 86f9455d99817eeae6a79f2f0cbc5faf5d01edb0..9e4b2d414f8e8f6a3d7d0e04777f5eaf8ad9fa18 100644 --- a/core/misc/dialog/dialog.jquery-ui.js +++ b/core/misc/dialog/dialog.jquery-ui.js @@ -7,7 +7,7 @@ (function ($, _ref) { var tabbable = _ref.tabbable, - isTabbable = _ref.isTabbable; + isTabbable = _ref.isTabbable; $.widget('ui.dialog', $.ui.dialog, { options: { buttonClass: 'button', @@ -18,7 +18,6 @@ var primaryIndex; var index; var il = opts.buttons.length; - for (index = 0; index < il; index++) { if (opts.buttons[index].primary && opts.buttons[index].primary === true) { primaryIndex = index; @@ -26,16 +25,14 @@ break; } } - this._super(); - var $buttons = this.uiButtonSet.children().addClass(opts.buttonClass); - if (typeof primaryIndex !== 'undefined') { $buttons.eq(index).addClass(opts.buttonPrimaryClass); } }, _focusTabbable: function _focusTabbable() { + var hasFocus = this._focusedElement ? this._focusedElement.get(0) : null; if (!hasFocus) { @@ -44,15 +41,12 @@ if (!hasFocus) { var $elements = [this.element, this.uiDialogButtonPane]; - for (var i = 0; i < $elements.length; i++) { var element = $elements[i].get(0); - if (element) { var elementTabbable = tabbable(element); hasFocus = elementTabbable.length ? elementTabbable[0] : null; } - if (hasFocus) { break; } @@ -67,7 +61,6 @@ if (!hasFocus) { hasFocus = this.uiDialog.get(0); } - $(hasFocus).eq(0).trigger('focus'); } }); diff --git a/core/misc/dialog/dialog.js b/core/misc/dialog/dialog.js index 979fdeff67de6dc82c2aa8c217a03bb311d91fbc..8ba4390a297c3c3a9c22aa7645731add5d0480f8 100644 --- a/core/misc/dialog/dialog.js +++ b/core/misc/dialog/dialog.js @@ -24,7 +24,6 @@ open: false, returnValue: undef }; - function openDialog(settings) { settings = $.extend({}, drupalSettings.dialog, options, settings); $(window).trigger('dialog:beforecreate', [dialog, $element, settings]); @@ -32,7 +31,6 @@ dialog.open = true; $(window).trigger('dialog:aftercreate', [dialog, $element, settings]); } - function closeDialog(value) { $(window).trigger('dialog:beforeclose', [dialog, $element]); $element.dialog('close'); @@ -40,19 +38,16 @@ dialog.open = false; $(window).trigger('dialog:afterclose', [dialog, $element]); } - dialog.show = function () { openDialog({ modal: false }); }; - dialog.showModal = function () { openDialog({ modal: true }); }; - dialog.close = closeDialog; return dialog; }; diff --git a/core/misc/dialog/dialog.position.js b/core/misc/dialog/dialog.position.js index 552e1c596f9fdb6dc0ffcd1469df98f4c5bcf431..59a813110f52a0a169fc28024dfbd1dba84d8449 100644 --- a/core/misc/dialog/dialog.position.js +++ b/core/misc/dialog/dialog.position.js @@ -31,32 +31,25 @@ var option; var optionValue; var adjustedValue; - for (var n = 0; n < positionOptions.length; n++) { option = positionOptions[n]; optionValue = event.data.settings[option]; - if (optionValue) { if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) { windowHeight -= displace.offsets.top + displace.offsets.bottom; adjustedValue = parseInt(0.01 * parseInt(optionValue, 10) * windowHeight, 10); - if (option === 'height' && event.data.$element.parent().outerHeight() < adjustedValue) { adjustedValue = 'auto'; } - adjustedOptions[option] = adjustedValue; } } } - if (!event.data.settings.modal) { adjustedOptions = resetPosition(adjustedOptions); } - event.data.$element.dialog('option', adjustedOptions).trigger('dialogContentResize'); } - $(window).on({ 'dialog:aftercreate': function dialogAftercreate(event, dialog, $element, settings) { var autoResize = debounce(resetSize, 20); @@ -64,7 +57,6 @@ settings: settings, $element: $element }; - if (settings.autoResize === true || settings.autoResize === 'true') { $element.dialog('option', { resizable: false, diff --git a/core/misc/dialog/off-canvas.js b/core/misc/dialog/off-canvas.js index 96369f40dc55d1c23e132bf6fbdeca5cfeb2672d..00fbd1907e352aa9b2f8dd9a4d722c05ecfe19e0 100644 --- a/core/misc/dialog/off-canvas.js +++ b/core/misc/dialog/off-canvas.js @@ -21,7 +21,7 @@ }, beforeCreate: function beforeCreate(_ref) { var settings = _ref.settings, - $element = _ref.$element; + $element = _ref.$element; Drupal.offCanvas.removeOffCanvasEvents($element); $('body').addClass('js-off-canvas-dialog-open'); settings.position = { @@ -29,6 +29,7 @@ at: "".concat(Drupal.offCanvas.getEdge(), " top"), of: window }; + var position = settings.drupalOffCanvasPosition; var height = position === 'side' ? $(window).height() : settings.height; var width = position === 'side' ? settings.width : '100%'; @@ -43,7 +44,7 @@ }, afterCreate: function afterCreate(_ref3) { var $element = _ref3.$element, - settings = _ref3.settings; + settings = _ref3.settings; var eventData = { settings: settings, $element: $element, @@ -62,6 +63,7 @@ var $container = Drupal.offCanvas.getContainer($element); var $offsets = $container.find('> :not(#drupal-off-canvas, .ui-resizable-handle)'); var offset = 0; + $element.css({ height: 'auto' }); @@ -69,6 +71,7 @@ $offsets.each(function (i, e) { offset += $(e).outerHeight(); }); + var scrollOffset = $element.outerHeight() - $element.height(); $element.height(modalHeight - offset - scrollOffset); }, @@ -80,11 +83,9 @@ if (Drupal.offCanvas.position && Drupal.offCanvas.position !== position) { container.removeAttr("data-offset-".concat(Drupal.offCanvas.position)); } - if (position === 'top') { $element.css('min-height', "".concat(Drupal.offCanvas.minimumHeight, "px")); } - displace(); var offsets = displace.offsets; var topPosition = position === 'side' && offsets.top !== 0 ? "+".concat(offsets.top) : ''; @@ -105,26 +106,21 @@ }, bodyPadding: function bodyPadding(event) { var position = event.data.settings.drupalOffCanvasPosition; - if (position === 'side' && $('body').outerWidth() < Drupal.offCanvas.minDisplaceWidth) { return; } - Drupal.offCanvas.resetPadding(); var $element = event.data.$element; var $container = Drupal.offCanvas.getContainer($element); var $mainCanvasWrapper = Drupal.offCanvas.$mainCanvasWrapper; var width = $container.outerWidth(); var mainCanvasPadding = $mainCanvasWrapper.css("padding-".concat(Drupal.offCanvas.getEdge())); - if (position === 'side' && width !== mainCanvasPadding) { $mainCanvasWrapper.css("padding-".concat(Drupal.offCanvas.getEdge()), "".concat(width, "px")); $container.attr("data-offset-".concat(Drupal.offCanvas.getEdge()), width); displace(); } - var height = $container.outerHeight(); - if (position === 'top') { $mainCanvasWrapper.css('padding-top', "".concat(height, "px")); $container.attr('data-offset-top', height); @@ -143,12 +139,12 @@ displace(); } }; + Drupal.behaviors.offCanvasEvents = { attach: function attach() { if (!once('off-canvas', 'html').length) { return; } - $(window).on({ 'dialog:beforecreate': function dialogBeforecreate(event, dialog, $element, settings) { if (Drupal.offCanvas.isOffCanvas($element)) { diff --git a/core/misc/displace.js b/core/misc/displace.js index e0cef041d81ebd916bfc2b083caf75990f1a5dff..906ea1e52cc42bd265f240380691d7d26a6786a6 100644 --- a/core/misc/displace.js +++ b/core/misc/displace.js @@ -20,12 +20,10 @@ var horizontal = edge === 'left' || edge === 'right'; var placement = $el.offset()[horizontal ? 'left' : 'top']; placement -= window["scroll".concat(horizontal ? 'X' : 'Y')] || document.documentElement["scroll".concat(horizontal ? 'Left' : 'Top')] || 0; - switch (edge) { case 'top': displacement = placement + $el.outerHeight(); break; - case 'left': displacement = placement + $el.outerWidth(); break; @@ -33,15 +31,12 @@ case 'bottom': displacement = documentElement.clientHeight - placement; break; - case 'right': displacement = documentElement.clientWidth - placement; break; - default: displacement = 0; } - return displacement; } @@ -49,23 +44,17 @@ var edgeOffset = 0; var displacingElements = document.querySelectorAll("[data-offset-".concat(edge, "]")); var n = displacingElements.length; - for (var i = 0; i < n; i++) { var el = displacingElements[i]; - if (el.style.display === 'none') { continue; } - var displacement = parseInt(el.getAttribute("data-offset-".concat(edge)), 10); - if (isNaN(displacement)) { displacement = getRawOffset(el, edge); } - edgeOffset = Math.max(edgeOffset, displacement); } - return edgeOffset; } @@ -81,11 +70,9 @@ function displace(broadcast) { offsets = calculateOffsets(); Drupal.displace.offsets = offsets; - if (typeof broadcast === 'undefined' || broadcast) { $(document).trigger('drupalViewportOffsetChange', offsets); } - return offsets; } @@ -94,11 +81,11 @@ if (this.displaceProcessed) { return; } - this.displaceProcessed = true; $(window).on('resize.drupalDisplace', debounce(displace, 200)); } }; + Drupal.displace = displace; $.extend(Drupal.displace, { offsets: offsets, diff --git a/core/misc/dropbutton/dropbutton.js b/core/misc/dropbutton/dropbutton.js index f7787d51cb60cd02bcaad1f3855b8ce5b81234ca..d6276739a97738a66100bc4989b9390c56497ecf 100644 --- a/core/misc/dropbutton/dropbutton.js +++ b/core/misc/dropbutton/dropbutton.js @@ -11,8 +11,11 @@ title: Drupal.t('List additional actions') }, settings); var $dropbutton = $(dropbutton); + this.$dropbutton = $dropbutton; + this.$list = $dropbutton.find('.dropbutton'); + this.$actions = this.$list.find('li').addClass('dropbutton-action'); if (this.$actions.length > 1) { @@ -39,23 +42,22 @@ Drupal.behaviors.dropButton = { attach: function attach(context, settings) { var dropbuttons = once('dropbutton', '.dropbutton-wrapper', context); - if (dropbuttons.length) { var body = once('dropbutton-click', 'body'); - if (body.length) { $(body).on('click', '.dropbutton-toggle', dropbuttonClickHandler); } - dropbuttons.forEach(function (dropbutton) { DropButton.dropbuttons.push(new DropButton(dropbutton, settings.dropbutton)); }); } } }; + $.extend(DropButton, { dropbuttons: [] }); + $.extend(DropButton.prototype, { toggle: function toggle(show) { var isBool = typeof show === 'boolean'; @@ -88,5 +90,6 @@ return "<li class=\"dropbutton-toggle\"><button type=\"button\"><span class=\"dropbutton-arrow\"><span class=\"visually-hidden\">".concat(options.title, "</span></span></button></li>"); } }); + Drupal.DropButton = DropButton; })(jQuery, Drupal); \ No newline at end of file diff --git a/core/misc/drupal.init.js b/core/misc/drupal.init.js index 81eb78e0209d4df4c604dde4fc4ab4a47a646128..414062e2fba96ba2a4edef52acb6269c9d5f20c8 100644 --- a/core/misc/drupal.init.js +++ b/core/misc/drupal.init.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (window.jQuery) { jQuery.noConflict(); } @@ -17,7 +16,6 @@ document.documentElement.className += ' js'; callback(); document.removeEventListener('DOMContentLoaded', listener); }; - if (document.readyState !== 'loading') { setTimeout(callback, 0); } else { diff --git a/core/misc/drupal.js b/core/misc/drupal.js index a1debf251d9bba385975f02ca3dbeee84e753672..42a54c27e4cb6bdb16b301684a2109ab1dbc813d 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -80,24 +80,22 @@ window.Drupal = { if (!Array.isArray(keys)) { keys = Object.keys(args || {}); + keys.sort(function (a, b) { return a.length - b.length; }); } - if (keys.length === 0) { return str; } var key = keys.pop(); var fragments = str.split(key); - if (keys.length) { for (var i = 0; i < fragments.length; i++) { fragments[i] = Drupal.stringReplace(fragments[i], args, keys.slice(0)); } } - return fragments.join(args[key]); }; @@ -108,11 +106,9 @@ window.Drupal = { if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) { str = drupalTranslations.strings[options.context][str]; } - if (args) { str = Drupal.formatString(str, args); } - return str; }; @@ -125,9 +121,11 @@ window.Drupal = { try { url = decodeURIComponent(url); - } catch (e) {} + } catch (e) { + } urlParsingNode.setAttribute('href', url); + return urlParsingNode.cloneNode(false).href; }; @@ -138,16 +136,17 @@ window.Drupal = { if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) { protocol = 'https:'; } - var baseUrl = "".concat(protocol, "//").concat(window.location.host).concat(drupalSettings.path.baseUrl.slice(0, -1)); try { absoluteUrl = decodeURIComponent(absoluteUrl); - } catch (e) {} + } catch (e) { + } try { baseUrl = decodeURIComponent(baseUrl); - } catch (e) {} + } catch (e) { + } return absoluteUrl === baseUrl || absoluteUrl.indexOf("".concat(baseUrl, "/")) === 0; }; @@ -164,7 +163,6 @@ window.Drupal = { } else if (args['@count'] !== 1) { index = 1; } - return translations[index]; }; @@ -174,7 +172,6 @@ window.Drupal = { Drupal.deprecationError = function (_ref) { var message = _ref.message; - if (drupalSettings.suppressDeprecationErrors === false && typeof console !== 'undefined' && console.warn) { console.warn("[Deprecation] ".concat(message)); } @@ -182,13 +179,11 @@ window.Drupal = { Drupal.deprecatedProperty = function (_ref2) { var target = _ref2.target, - deprecatedProperty = _ref2.deprecatedProperty, - message = _ref2.message; - + deprecatedProperty = _ref2.deprecatedProperty, + message = _ref2.message; if (!Proxy || !Reflect) { return target; } - return new Proxy(target, { get: function get(target, key) { if (key === deprecatedProperty) { @@ -196,11 +191,9 @@ window.Drupal = { message: message }); } - for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { rest[_key - 2] = arguments[_key]; } - return Reflect.get.apply(Reflect, [target, key].concat(rest)); } }); @@ -209,11 +202,9 @@ window.Drupal = { Drupal.theme = function (func) { if (func in Drupal.theme) { var _Drupal$theme; - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - return (_Drupal$theme = Drupal.theme)[func].apply(_Drupal$theme, args); } }; diff --git a/core/misc/drupalSettingsLoader.js b/core/misc/drupalSettingsLoader.js index 27450b84d91d7305aa2f5a76fcc13d68a51c7f26..969814b3443e6f7ed9831ab174902a48f7e91721 100644 --- a/core/misc/drupalSettingsLoader.js +++ b/core/misc/drupalSettingsLoader.js @@ -7,8 +7,8 @@ (function () { var settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]'); - window.drupalSettings = {}; + window.drupalSettings = {}; if (settingsElement !== null) { window.drupalSettings = JSON.parse(settingsElement.textContent); } diff --git a/core/misc/entity-form.js b/core/misc/entity-form.js index af450a020248fa0cf7395f6d4a0e5cf41c66f335..88e2630057a234a03c5dcd63b4cd55a706502d55 100644 --- a/core/misc/entity-form.js +++ b/core/misc/entity-form.js @@ -16,21 +16,18 @@ if (revisionCheckbox.is(':checked') || !revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length) { return Drupal.t('New revision'); } - return Drupal.t('No revision'); }); $context.find('details.entity-translation-options').drupalSetSummary(function (context) { var $translationContext = $(context); var translate; var $checkbox = $translationContext.find('.js-form-item-translation-translate input'); - if ($checkbox.length) { translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated'); } else { $checkbox = $translationContext.find('.js-form-item-translation-retranslate input'); translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated'); } - return translate; }); } diff --git a/core/misc/form.js b/core/misc/form.js index 30e20d9ecf189b70d86af36dacca9b088386af23..7f239eee29ee403b0ae7ffccde6d56c44b40b83c 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -16,15 +16,15 @@ if (typeof callback !== 'function') { var val = callback; - callback = function callback() { return val; }; } - - return this.data('summaryCallback', callback).off('formUpdated.summary').on('formUpdated.summary', function () { + return this.data('summaryCallback', callback) + .off('formUpdated.summary').on('formUpdated.summary', function () { self.trigger('summaryUpdated'); - }).trigger('summaryUpdated'); + }) + .trigger('summaryUpdated'); }; Drupal.behaviors.formSingleSubmit = { @@ -33,14 +33,12 @@ var $form = $(e.currentTarget); var formValues = $form.serialize(); var previousValues = $form.attr('data-drupal-form-submit-last'); - if (previousValues === formValues) { e.preventDefault(); } else { $form.attr('data-drupal-form-submit-last', formValues); } } - $(once('form-single-submit', 'body')).on('submit.singleSubmit', 'form:not([method~="GET"])', onFormSubmit); } }; @@ -61,7 +59,6 @@ var contextIsForm = $context.is('form'); var $forms = $(once('form-updated', contextIsForm ? $context : $context.find('form'))); var formFields; - if ($forms.length) { $.makeArray($forms).forEach(function (form) { var events = 'change.formUpdated input.formUpdated '; @@ -73,11 +70,9 @@ $(form).on(events, eventHandler); }); } - if (contextIsForm) { formFields = fieldsList(context).join(','); var currentFields = $(context).attr('data-drupal-form-fields'); - if (formFields !== currentFields) { triggerFormUpdated(context); } @@ -86,7 +81,6 @@ detach: function detach(context, settings, trigger) { var $context = $(context); var contextIsForm = $context.is('form'); - if (trigger === 'unload') { once.remove('form-updated', contextIsForm ? $context : $context.find('form')).forEach(function (form) { form.removeAttribute('data-drupal-form-fields'); @@ -95,23 +89,20 @@ } } }; + Drupal.behaviors.fillUserInfoFromBrowser = { attach: function attach(context, settings) { var userInfo = ['name', 'mail', 'homepage']; var $forms = $(once('user-info-from-browser', '[data-user-info-from-browser]')); - if ($forms.length) { userInfo.forEach(function (info) { var $element = $forms.find("[name=".concat(info, "]")); var browserData = localStorage.getItem("Drupal.visitor.".concat(info)); - if (!$element.length) { return; } - var emptyValue = $element[0].value === ''; var defaultValue = $element.attr('data-drupal-default-value') === $element[0].value; - if (browserData && (emptyValue || defaultValue)) { $element.each(function (index, item) { item.value = browserData; @@ -119,11 +110,9 @@ } }); } - $forms.on('submit', function () { userInfo.forEach(function (info) { var $element = $forms.find("[name=".concat(info, "]")); - if ($element.length) { localStorage.setItem("Drupal.visitor.".concat(info), $element[0].value); } @@ -134,25 +123,24 @@ var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e) { var url; - if (e.type === 'click') { url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget; } else { url = window.location; } - var hash = url.hash.substr(1); - if (hash) { var $target = $("#".concat(hash)); $('body').trigger('formFragmentLinkClickOrHashChange', [$target]); + setTimeout(function () { return $target.trigger('focus'); }, 300); } }; - var debouncedHandleFragmentLinkClickOrHashChange = debounce(handleFragmentLinkClickOrHashChange, 300, true); + $(window).on('hashchange.form-fragment', debouncedHandleFragmentLinkClickOrHashChange); + $(document).on('click.form-fragment', 'a[href*="#"]', debouncedHandleFragmentLinkClickOrHashChange); })(jQuery, Drupal, Drupal.debounce); \ No newline at end of file diff --git a/core/misc/jquery.cookie.shim.js b/core/misc/jquery.cookie.shim.js index b05715788daa1f26a7919a6912131df5bec0b6d2..2edcc4432eda87ee09323cc1c0417f1030bd882e 100644 --- a/core/misc/jquery.cookie.shim.js +++ b/core/misc/jquery.cookie.shim.js @@ -4,11 +4,8 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } - function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } (function ($, Drupal, cookies) { @@ -22,20 +19,18 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope if (value.indexOf('"') === 0) { value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } - try { value = decodeURIComponent(value.replace(/\+/g, ' ')); return parseJson ? JSON.parse(value) : value; - } catch (e) {} + } catch (e) { + } }; var reader = function reader(cookieValue, cookieName, converter, readUnsanitized, parseJson) { var value = readUnsanitized ? cookieValue : parseCookieValue(cookieValue, parseJson); - if (converter !== undefined && isFunction(converter)) { return converter(value, cookieName); } - return value; }; @@ -45,14 +40,11 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope Drupal.deprecationError({ message: "jQuery.cookie() ".concat(deprecatedMessageSuffix) }); - if (value !== undefined && !isFunction(value)) { var attributes = _objectSpread(_objectSpread({}, $.cookie.defaults), options); - if (typeof attributes.expires === 'string' && attributes.expires !== '') { attributes.expires = new Date(attributes.expires); } - var cookieSetter = cookies.withConverter({ write: function write(cookieValue) { return encodeURIComponent(cookieValue); @@ -68,11 +60,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope return reader(cookieValue, cookieName, userProvidedConverter, $.cookie.raw, $.cookie.json); } }); - if (key !== undefined) { return cookiesShim.get(key); } - var results = cookiesShim.get(); Object.keys(results).forEach(function (resultKey) { if (results[resultKey] === undefined) { @@ -85,7 +75,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope $.cookie.defaults = _objectSpread({ path: '' }, cookies.defaults); + $.cookie.json = false; + $.cookie.raw = false; $.removeCookie = function (key, options) { diff --git a/core/misc/jquery.once.bc.js b/core/misc/jquery.once.bc.js index 9b3c3d4c6ff956c77c96580f277ec8af61972982..d680b56972be8ed6bb4580586225f7b12fa94fb9 100644 --- a/core/misc/jquery.once.bc.js +++ b/core/misc/jquery.once.bc.js @@ -7,6 +7,7 @@ (function ($, once) { var deprecatedMessageSuffix = "is deprecated in Drupal 9.3.0 and will be removed in Drupal 10.0.0. Use the core/once library instead. See https://www.drupal.org/node/3158256"; + var originalJQOnce = $.fn.once; var originalJQRemoveOnce = $.fn.removeOnce; @@ -16,7 +17,6 @@ }); return originalJQOnce.apply(this, [id]); }; - $.fn.removeOnce = function jQueryRemoveOnce(id) { Drupal.deprecationError({ message: "jQuery.removeOnce() ".concat(deprecatedMessageSuffix) diff --git a/core/misc/jquery.tabbable.shim.js b/core/misc/jquery.tabbable.shim.js index 3fb82e4b3086534b32e923444ad8cdc5a7b70e10..9d2d188f79086bc885c0affe4b23632ade3b8fd1 100644 --- a/core/misc/jquery.tabbable.shim.js +++ b/core/misc/jquery.tabbable.shim.js @@ -15,12 +15,10 @@ if (element.tagName === 'SUMMARY' || element.tagName === 'DETAILS') { var tabIndex = element.getAttribute('tabIndex'); - if (tabIndex === null || tabIndex < 0) { return false; } } - return isTabbable(element); } }); diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index ece950c739363e0dd2f9ca7dcadf2494f74c3a82..07e8455ebec5fda6cbd05eb22546483629949bff 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -12,7 +12,6 @@ var $context = $(context); var timeout = null; var xhr = null; - function clickEditHandler(e) { var data = e.data; data.$wrapper.removeClass('visually-hidden'); @@ -20,7 +19,6 @@ data.$suffix.hide(); data.$source.off('.machineName'); } - function machineNameHandler(e) { var data = e.data; var options = data.options; @@ -37,7 +35,6 @@ clearTimeout(timeout); timeout = null; } - if (baseValue.toLowerCase() !== expected) { timeout = setTimeout(function () { xhr = self.transliterate(baseValue, options).done(function (machine) { @@ -48,38 +45,31 @@ self.showMachineName(expected, data); } } - Object.keys(settings.machineName).forEach(function (sourceId) { var options = settings.machineName[sourceId]; var $source = $(once('machine-name', $context.find(sourceId).addClass('machine-name-source'))); var $target = $context.find(options.target).addClass('machine-name-target'); var $suffix = $context.find(options.suffix); var $wrapper = $target.closest('.js-form-item'); - if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) { return; } - if ($target.hasClass('error')) { return; } - options.maxlength = $target.attr('maxlength'); $wrapper.addClass('visually-hidden'); var machine = $target[0].value; var $preview = $("<span class=\"machine-name-value\">".concat(options.field_prefix).concat(Drupal.checkPlain(machine)).concat(options.field_suffix, "</span>")); $suffix.empty(); - if (options.label) { $suffix.append("<span class=\"machine-name-label\">".concat(options.label, ": </span>")); } - $suffix.append($preview); if ($target.is(':disabled')) { return; } - var eventData = { $source: $source, $target: $target, @@ -99,7 +89,8 @@ $suffix.append($link); if ($target[0].value === '') { - $source.on('formUpdated.machineName', eventData, machineNameHandler).trigger('formUpdated.machineName'); + $source.on('formUpdated.machineName', eventData, machineNameHandler) + .trigger('formUpdated.machineName'); } $target.on('invalid', eventData, clickEditHandler); @@ -107,13 +98,11 @@ }, showMachineName: function showMachineName(machine, data) { var settings = data.options; - if (machine !== '') { if (machine !== settings.replace) { data.$target[0].value = machine; data.$preview.html(settings.field_prefix + Drupal.checkPlain(machine) + settings.field_suffix); } - data.$suffix.show(); } else { data.$suffix.hide(); diff --git a/core/misc/message.js b/core/misc/message.js index e08cbaa8b8f415cf62f7be792bdc72bf2e2d8645..49a62dc343e52e5c62ce89bfa62fd77ff45e9009 100644 --- a/core/misc/message.js +++ b/core/misc/message.js @@ -4,20 +4,15 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - (function (Drupal) { + Drupal.Message = function () { function _class() { var messageWrapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - _classCallCheck(this, _class); - if (!messageWrapper) { this.messageWrapper = Drupal.Message.defaultWrapper(); } else { @@ -27,13 +22,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d _createClass(_class, [{ key: "add", - value: function add(message) { + value: + function add(message) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (!options.hasOwnProperty('type')) { options.type = 'status'; } - if (typeof message !== 'string') { throw new Error('Message must be a string.'); } @@ -45,82 +39,90 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var type = options.type; throw new Error("The message type, ".concat(type, ", is not present in Drupal.Message.getMessageTypeLabels().")); } - this.messageWrapper.appendChild(Drupal.theme('message', { text: message }, options)); return options.id; } + }, { key: "select", - value: function select(id) { + value: + function select(id) { return this.messageWrapper.querySelector("[data-drupal-message-id^=\"".concat(id, "\"]")); } + }, { key: "remove", - value: function remove(id) { + value: + function remove(id) { return this.messageWrapper.removeChild(this.select(id)); } + }, { key: "clear", - value: function clear() { + value: + function clear() { var _this = this; - Array.prototype.forEach.call(this.messageWrapper.querySelectorAll('[data-drupal-message-id]'), function (message) { _this.messageWrapper.removeChild(message); }); } + }], [{ key: "defaultWrapper", - value: function defaultWrapper() { + value: + function defaultWrapper() { var wrapper = document.querySelector('[data-drupal-messages]'); - if (!wrapper) { wrapper = document.querySelector('[data-drupal-messages-fallback]'); wrapper.removeAttribute('data-drupal-messages-fallback'); wrapper.setAttribute('data-drupal-messages', ''); wrapper.classList.remove('hidden'); } - return wrapper.innerHTML === '' ? Drupal.Message.messageInternalWrapper(wrapper) : wrapper.firstElementChild; } + }, { key: "getMessageTypeLabels", - value: function getMessageTypeLabels() { + value: + function getMessageTypeLabels() { return { status: Drupal.t('Status message'), error: Drupal.t('Error message'), warning: Drupal.t('Warning message') }; } + }, { key: "announce", - value: function announce(message, options) { + value: + function announce(message, options) { if (!options.priority && (options.type === 'warning' || options.type === 'error')) { options.priority = 'assertive'; } - if (options.announce !== '') { Drupal.announce(options.announce || message, options.priority); } } + }, { key: "messageInternalWrapper", - value: function messageInternalWrapper(messageWrapper) { + value: + function messageInternalWrapper(messageWrapper) { var innerWrapper = document.createElement('div'); innerWrapper.setAttribute('class', 'messages__wrapper'); messageWrapper.insertAdjacentElement('afterbegin', innerWrapper); return innerWrapper; } }]); - return _class; }(); Drupal.theme.message = function (_ref, _ref2) { var text = _ref.text; var type = _ref2.type, - id = _ref2.id; + id = _ref2.id; var messagesTypes = Drupal.Message.getMessageTypeLabels(); var messageWrapper = document.createElement('div'); messageWrapper.setAttribute('class', "messages messages--".concat(type)); diff --git a/core/misc/modernizr-additional-tests.js b/core/misc/modernizr-additional-tests.js index 9510b95bf4ee2c8b4eba15257b25b956a032277b..831ea81f81b8b45c0c04ebe3fd190c19c0a3c034 100644 --- a/core/misc/modernizr-additional-tests.js +++ b/core/misc/modernizr-additional-tests.js @@ -4,11 +4,9 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (Modernizr) { var _deprecationErrorModernizrCopy = function _deprecationErrorModernizrCopy(_ref) { var message = _ref.message; - if (typeof console !== 'undefined' && console.warn) { console.warn("[Deprecation] ".concat(message)); } @@ -16,13 +14,11 @@ var _deprecatedPropertyModernizrCopy = function _deprecatedPropertyModernizrCopy(_ref2) { var target = _ref2.target, - deprecatedProperty = _ref2.deprecatedProperty, - message = _ref2.message; - + deprecatedProperty = _ref2.deprecatedProperty, + message = _ref2.message; if (!Proxy || !Reflect) { return target; } - return new Proxy(target, { get: function get(target, key) { if (key === deprecatedProperty) { @@ -30,22 +26,18 @@ message: message }); } - for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { rest[_key - 2] = arguments[_key]; } - return Reflect.get.apply(Reflect, [target, key].concat(rest)); } }); }; - window.Modernizr = _deprecatedPropertyModernizrCopy({ target: Modernizr, deprecatedProperty: 'touchevents', message: 'The touchevents property of Modernizr has been deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There will be no replacement for this feature. See https://www.drupal.org/node/3277381.' }); - if (document.documentElement.classList.contains('touchevents') || document.documentElement.classList.contains('no-touchevents')) { return; } @@ -54,9 +46,7 @@ _deprecationErrorModernizrCopy({ message: 'The Modernizr touch events test is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. See https://www.drupal.org/node/3277381 for information on its replacement and how it should be used.' }); - var bool; - if ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch) { bool = true; } else { @@ -65,7 +55,6 @@ bool = node.offsetTop === 9; }); } - return bool; }); })(Modernizr); \ No newline at end of file diff --git a/core/misc/polyfills/array.find.js b/core/misc/polyfills/array.find.js index 98341bf4cb76027e1f07a42b25490c607f1c5a0a..3e302ad1af2a587e590efa47cb83f0247d2fe130 100644 --- a/core/misc/polyfills/array.find.js +++ b/core/misc/polyfills/array.find.js @@ -4,15 +4,14 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (!Array.prototype.find) { Object.defineProperty(Array.prototype, 'find', { value: function value(predicate) { if (this == null) { throw TypeError('"this" is null or not defined'); } - var o = Object(this); + var len = o.length >>> 0; if (typeof predicate !== 'function') { @@ -20,15 +19,14 @@ if (!Array.prototype.find) { } var thisArg = arguments[1]; + var k = 0; while (k < len) { var kValue = o[k]; - if (predicate.call(thisArg, kValue, k, o)) { return kValue; } - k++; } diff --git a/core/misc/polyfills/array.includes.js b/core/misc/polyfills/array.includes.js index 019fd8a046033011745290dc00a0ea08a03325c1..418837e88cf98dede8ad311fbab4e308ed50a5e2 100644 --- a/core/misc/polyfills/array.includes.js +++ b/core/misc/polyfills/array.includes.js @@ -4,45 +4,35 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (!Array.prototype.includes) { Array.prototype.includes = function (searchElement) { if (this == null) { throw new TypeError('Array.prototype.includes called on null or undefined'); } - var O = Object(this); var len = parseInt(O.length, 10) || 0; - if (len === 0) { return false; } - var n = parseInt(arguments[1], 10) || 0; var k; - if (n >= 0) { k = n; } else { k = len + n; - if (k < 0) { k = 0; } } - var currentElement; - while (k < len) { currentElement = O[k]; - - if (searchElement === currentElement || searchElement !== searchElement && currentElement !== currentElement) { + if (searchElement === currentElement || + searchElement !== searchElement && currentElement !== currentElement) { return true; } - k += 1; } - return false; }; } \ No newline at end of file diff --git a/core/misc/polyfills/customevent.js b/core/misc/polyfills/customevent.js index 87e371ed1c52faff8613811c9f9d9470298ceeac..2f29cb34046fdc1a841efdfb083de5552748ba70 100644 --- a/core/misc/polyfills/customevent.js +++ b/core/misc/polyfills/customevent.js @@ -4,10 +4,8 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function () { if (typeof window.CustomEvent === 'function') return false; - function CustomEvent(event, params) { params = params || { bubbles: false, @@ -18,6 +16,5 @@ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } - window.CustomEvent = CustomEvent; })(); \ No newline at end of file diff --git a/core/misc/polyfills/element.closest.js b/core/misc/polyfills/element.closest.js index 3b4c0335032bb6690c18b83fe037d5af8a94cb23..6407eaa3ecdeba207a8b3a15e386767f7aeb4377 100644 --- a/core/misc/polyfills/element.closest.js +++ b/core/misc/polyfills/element.closest.js @@ -4,16 +4,13 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (!Element.prototype.closest) { Element.prototype.closest = function (s) { var el = this; - do { if (Element.prototype.matches.call(el, s)) return el; el = el.parentElement || el.parentNode; } while (el !== null && el.nodeType === 1); - return null; }; } \ No newline at end of file diff --git a/core/misc/polyfills/element.matches.js b/core/misc/polyfills/element.matches.js index 8fc544b4b647310501654ee301d049ebd0a374a7..1d52bbd283770dc319ba8ea57fa1c2fcdedda512 100644 --- a/core/misc/polyfills/element.matches.js +++ b/core/misc/polyfills/element.matches.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; } \ No newline at end of file diff --git a/core/misc/polyfills/nodelist.foreach.js b/core/misc/polyfills/nodelist.foreach.js index a0ecf7bbcdcc86e241c9e04a40383f146b6903b8..80a0caab551fbf40d874beaad11b4550d1e17d31 100644 --- a/core/misc/polyfills/nodelist.foreach.js +++ b/core/misc/polyfills/nodelist.foreach.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (window.NodeList && !NodeList.prototype.forEach) { NodeList.prototype.forEach = Array.prototype.forEach; } \ No newline at end of file diff --git a/core/misc/polyfills/object.assign.js b/core/misc/polyfills/object.assign.js index 265eb629a38c29703247a72d1127f518c11fc806..58f76f6cc356984d2b49e72737fde7ca3258973e 100644 --- a/core/misc/polyfills/object.assign.js +++ b/core/misc/polyfills/object.assign.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (typeof Object.assign !== 'function') { Object.defineProperty(Object, 'assign', { value: function assign(target, varArgs) { @@ -13,12 +12,9 @@ if (typeof Object.assign !== 'function') { if (target === null || target === undefined) { throw new TypeError('Cannot convert undefined or null to object'); } - var to = Object(target); - for (var index = 1; index < arguments.length; index++) { var nextSource = arguments[index]; - if (nextSource !== null && nextSource !== undefined) { for (var nextKey in nextSource) { if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { @@ -27,7 +23,6 @@ if (typeof Object.assign !== 'function') { } } } - return to; }, writable: true, diff --git a/core/misc/polyfills/string.includes.js b/core/misc/polyfills/string.includes.js index 1a1ea7cd04cb75fb2bff35e8c5bafaf13bfd2524..772c4c0c1f062cc4ac779245c64c5804beedd668 100644 --- a/core/misc/polyfills/string.includes.js +++ b/core/misc/polyfills/string.includes.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (!String.prototype.includes) { String.prototype.includes = function (search, start) { 'use strict'; @@ -12,11 +11,9 @@ if (!String.prototype.includes) { if (search instanceof RegExp) { throw TypeError('first argument must not be a RegExp'); } - if (start === undefined) { start = 0; } - return this.indexOf(search, start) !== -1; }; } \ No newline at end of file diff --git a/core/misc/position.js b/core/misc/position.js index 962def4ef1c8e67187a66d35f6e2484d25cb016e..9f222ddc4c0eabfd99ebfa117d2efd1b3c78f252 100644 --- a/core/misc/position.js +++ b/core/misc/position.js @@ -8,25 +8,21 @@ (function ($) { var cachedScrollbarWidth = null; var max = Math.max, - abs = Math.abs; + abs = Math.abs; var regexHorizontal = /left|center|right/; var regexVertical = /top|center|bottom/; var regexOffset = /[+-]\d+(\.[\d]+)?%?/; var regexPosition = /^\w+/; var regexPercent = /%$/; var _position = $.fn.position; - function getOffsets(offsets, width, height) { return [parseFloat(offsets[0]) * (regexPercent.test(offsets[0]) ? width / 100 : 1), parseFloat(offsets[1]) * (regexPercent.test(offsets[1]) ? height / 100 : 1)]; } - function parseCss(element, property) { return parseInt($.css(element, property), 10) || 0; } - function getDimensions(elem) { var raw = elem[0]; - if (raw.nodeType === 9) { return { width: elem.width(), @@ -37,7 +33,6 @@ } }; } - if ($.isWindow(raw)) { return { width: elem.width(), @@ -48,7 +43,6 @@ } }; } - if (raw.preventDefault) { return { width: 0, @@ -59,14 +53,12 @@ } }; } - return { width: elem.outerWidth(), height: elem.outerHeight(), offset: elem.offset() }; } - var collisions = { fit: { left: function left(position, data) { @@ -82,17 +74,22 @@ if (overLeft > 0 && overRight <= 0) { newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; position.left += overLeft - newOverRight; + } else if (overRight > 0 && overLeft <= 0) { position.left = withinOffset; + } else if (overLeft > overRight) { position.left = withinOffset + outerWidth - data.collisionWidth; } else { position.left = withinOffset; } + } else if (overLeft > 0) { position.left += overLeft; + } else if (overRight > 0) { position.left -= overRight; + } else { position.left = max(position.left - collisionPosLeft, position.left); } @@ -110,17 +107,22 @@ if (overTop > 0 && overBottom <= 0) { newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; position.top += overTop - newOverBottom; + } else if (overBottom > 0 && overTop <= 0) { position.top = withinOffset; + } else if (overTop > overBottom) { position.top = withinOffset + outerHeight - data.collisionHeight; } else { position.top = withinOffset; } + } else if (overTop > 0) { position.top += overTop; + } else if (overBottom > 0) { position.top -= overBottom; + } else { position.top = max(position.top - collisionPosTop, position.top); } @@ -135,21 +137,20 @@ var collisionPosLeft = position.left - data.collisionPosition.marginLeft; var overLeft = collisionPosLeft - offsetLeft; var overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft; - var myOffset = data.my[0] === 'left' ? -data.elemWidth : data.my[0] === 'right' ? data.elemWidth : 0; - var atOffset = data.at[0] === 'left' ? data.targetWidth : data.at[0] === 'right' ? -data.targetWidth : 0; + var myOffset = + data.my[0] === 'left' ? -data.elemWidth : data.my[0] === 'right' ? data.elemWidth : 0; + var atOffset = + data.at[0] === 'left' ? data.targetWidth : data.at[0] === 'right' ? -data.targetWidth : 0; var offset = -2 * data.offset[0]; var newOverRight; var newOverLeft; - if (overLeft < 0) { newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; - if (newOverRight < 0 || newOverRight < abs(overLeft)) { position.left += myOffset + atOffset + offset; } } else if (overRight > 0) { newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; - if (newOverLeft > 0 || abs(newOverLeft) < overRight) { position.left += myOffset + atOffset + offset; } @@ -165,20 +166,18 @@ var overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop; var top = data.my[1] === 'top'; var myOffset = top ? -data.elemHeight : data.my[1] === 'bottom' ? data.elemHeight : 0; - var atOffset = data.at[1] === 'top' ? data.targetHeight : data.at[1] === 'bottom' ? -data.targetHeight : 0; + var atOffset = + data.at[1] === 'top' ? data.targetHeight : data.at[1] === 'bottom' ? -data.targetHeight : 0; var offset = -2 * data.offset[1]; var newOverTop; var newOverBottom; - if (overTop < 0) { newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if (newOverBottom < 0 || newOverBottom < abs(overTop)) { position.top += myOffset + atOffset + offset; } } else if (overBottom > 0) { newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; - if (newOverTop > 0 || abs(newOverTop) < overBottom) { position.top += myOffset + atOffset + offset; } @@ -190,7 +189,6 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - collisions.flip.left.apply(this, args); collisions.fit.left.apply(this, args); }, @@ -198,7 +196,6 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } - collisions.flip.top.apply(this, args); collisions.fit.top.apply(this, args); } @@ -209,18 +206,15 @@ if (cachedScrollbarWidth !== undefined) { return cachedScrollbarWidth; } - var div = $('<div ' + "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" + "<div style='height:100px;width:auto;'></div></div>"); var innerDiv = div.children()[0]; $('body').append(div); var w1 = innerDiv.offsetWidth; div.css('overflow', 'scroll'); var w2 = innerDiv.offsetWidth; - if (w1 === w2) { w2 = div[0].clientWidth; } - div.remove(); cachedScrollbarWidth = w1 - w2; return cachedScrollbarWidth; @@ -266,51 +260,50 @@ var scrollInfo = $.position.getScrollInfo(within); var collision = (options.collision || 'flip').split(' '); var offsets = {}; + var target = typeof options.of === 'string' ? $(document).find(options.of) : $(options.of); var dimensions = getDimensions(target); var targetWidth = dimensions.width; var targetHeight = dimensions.height; var targetOffset = dimensions.offset; - if (target[0].preventDefault) { options.at = 'left top'; } var basePosition = $.extend({}, targetOffset); + $.each(['my', 'at'], function () { var pos = (options[this] || '').split(' '); - if (pos.length === 1) { pos = regexHorizontal.test(pos[0]) ? pos.concat(['center']) : regexVertical.test(pos[0]) ? ['center'].concat(pos) : ['center', 'center']; } - pos[0] = regexHorizontal.test(pos[0]) ? pos[0] : 'center'; pos[1] = regexVertical.test(pos[1]) ? pos[1] : 'center'; + var horizontalOffset = regexOffset.exec(pos[0]); var verticalOffset = regexOffset.exec(pos[1]); offsets[this] = [horizontalOffset ? horizontalOffset[0] : 0, verticalOffset ? verticalOffset[0] : 0]; + options[this] = [regexPosition.exec(pos[0])[0], regexPosition.exec(pos[1])[0]]; }); if (collision.length === 1) { collision[1] = collision[0]; } - if (options.at[0] === 'right') { basePosition.left += targetWidth; } else if (options.at[0] === 'center') { basePosition.left += targetWidth / 2; } - if (options.at[1] === 'bottom') { basePosition.top += targetHeight; } else if (options.at[1] === 'center') { basePosition.top += targetHeight / 2; } - var atOffset = getOffsets(offsets.at, targetWidth, targetHeight); basePosition.left += atOffset[0]; basePosition.top += atOffset[1]; + return this.each(function () { var using; var elem = $(this); @@ -322,25 +315,23 @@ var collisionHeight = elemHeight + marginTop + parseCss(this, 'marginBottom') + scrollInfo.height; var position = $.extend({}, basePosition); var myOffset = getOffsets(offsets.my, elem.outerWidth(), elem.outerHeight()); - if (options.my[0] === 'right') { position.left -= elemWidth; } else if (options.my[0] === 'center') { position.left -= elemWidth / 2; } - if (options.my[1] === 'bottom') { position.top -= elemHeight; } else if (options.my[1] === 'center') { position.top -= elemHeight / 2; } - position.left += myOffset[0]; position.top += myOffset[1]; var collisionPosition = { marginLeft: marginLeft, marginTop: marginTop }; + $.each(['left', 'top'], function (i, dir) { if (collisions[collision[i]]) { collisions[collision[i]][dir](position, { @@ -359,7 +350,6 @@ }); } }); - if (options.using) { using = function using(props) { var left = targetOffset.left - position.left; @@ -384,25 +374,20 @@ horizontal: right < 0 ? 'left' : left > 0 ? 'right' : 'center', vertical: bottom < 0 ? 'top' : top > 0 ? 'bottom' : 'middle' }; - if (targetWidth < elemWidth && abs(left + right) < targetWidth) { feedback.horizontal = 'center'; } - if (targetHeight < elemHeight && abs(top + bottom) < targetHeight) { feedback.vertical = 'middle'; } - if (max(abs(left), abs(right)) > max(abs(top), abs(bottom))) { feedback.important = 'horizontal'; } else { feedback.important = 'vertical'; } - options.using.call(this, props, feedback); }; } - elem.offset($.extend(position, { using: using })); @@ -412,6 +397,5 @@ if (!$.hasOwnProperty('ui')) { $.ui = {}; } - $.ui.position = collisions; })(jQuery); \ No newline at end of file diff --git a/core/misc/progress.js b/core/misc/progress.js index fc532a897d36b142e594fdd668dbcf1e696039e1..4f4a3ce23aade02b67b082c65c5a0c8a5eee3dac 100644 --- a/core/misc/progress.js +++ b/core/misc/progress.js @@ -15,19 +15,17 @@ this.method = method || 'GET'; this.updateCallback = updateCallback; this.errorCallback = errorCallback; + this.element = $(Drupal.theme('progressBar', id)); }; - $.extend(Drupal.ProgressBar.prototype, { setProgress: function setProgress(percentage, message, label) { if (percentage >= 0 && percentage <= 100) { $(this.element).find('div.progress__bar').css('width', "".concat(percentage, "%")); $(this.element).find('div.progress__percentage').html("".concat(percentage, "%")); } - $('div.progress__description', this.element).html(message); $('div.progress__label', this.element).html(label); - if (this.updateCallback) { this.updateCallback(percentage, message, this); } @@ -45,17 +43,14 @@ if (this.timer) { clearTimeout(this.timer); } - if (this.uri) { var pb = this; var uri = this.uri; - if (uri.indexOf('?') === -1) { uri += '?'; } else { uri += '&'; } - uri += '_format=json'; $.ajax({ type: this.method, @@ -67,7 +62,6 @@ pb.displayError(progress.data); return; } - pb.setProgress(progress.percentage, progress.message, progress.label); pb.timer = setTimeout(function () { pb.sendPing(); @@ -83,7 +77,6 @@ displayError: function displayError(string) { var error = $('<div class="messages messages--error"></div>').html(string); $(this.element).before(error).hide(); - if (this.errorCallback) { this.errorCallback(this); } diff --git a/core/misc/states.js b/core/misc/states.js index 8629f8da7d1784bc58c1d8c9bbe7a291ccc8e506..2a79ccbc4100d81a26eed9dd08f6b31e5d21528e 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -19,7 +19,6 @@ if (a === b) { return typeof a === 'undefined' ? a : true; } - return typeof a === 'undefined' || typeof b === 'undefined'; } @@ -27,11 +26,9 @@ if (typeof a === 'undefined') { return b; } - if (typeof b === 'undefined') { return a; } - return a && b; } @@ -39,7 +36,6 @@ attach: function attach(context, settings) { var $states = $(context).find('[data-drupal-states]'); var il = $states.length; - var _loop = function _loop(i) { var config = JSON.parse($states[i].getAttribute('data-drupal-states')); Object.keys(config || {}).forEach(function (state) { @@ -50,7 +46,6 @@ }); }); }; - for (var i = 0; i < il; i++) { _loop(i); } @@ -63,7 +58,6 @@ states.Dependent = function (args) { var _this = this; - $.extend(this, { values: {}, oldValue: null @@ -88,23 +82,23 @@ states.Dependent.prototype = { initializeDependee: function initializeDependee(selector, dependeeStates) { var _this2 = this; - this.values[selector] = {}; Object.keys(dependeeStates).forEach(function (i) { var state = dependeeStates[i]; - if ($.inArray(state, dependeeStates) === -1) { return; } - state = states.State.sanitize(state); + _this2.values[selector][state.name] = null; + $(selector).on("state:".concat(state), { selector: selector, state: state }, function (e) { _this2.update(e.data.selector, e.data.state, e.value); }); + new states.Trigger({ selector: selector, state: state @@ -113,7 +107,6 @@ }, compare: function compare(reference, selector, state) { var value = this.values[selector][state.name]; - if (reference.constructor.name in states.Dependent.comparisons) { return states.Dependent.comparisons[reference.constructor.name](reference, value); } @@ -131,7 +124,9 @@ if (value !== this.oldValue) { this.oldValue = value; + value = invert(value, this.state.invert); + this.element.trigger({ type: "state:".concat(this.state), value: value, @@ -141,34 +136,29 @@ }, verifyConstraints: function verifyConstraints(constraints, selector) { var result; - if ($.isArray(constraints)) { var hasXor = $.inArray('xor', constraints) === -1; var len = constraints.length; - for (var i = 0; i < len; i++) { if (constraints[i] !== 'xor') { var constraint = this.checkConstraints(constraints[i], selector, i); - if (constraint && (hasXor || result)) { return hasXor; } - result = result || constraint; } } - } else if ($.isPlainObject(constraints)) { + } + else if ($.isPlainObject(constraints)) { for (var n in constraints) { if (constraints.hasOwnProperty(n)) { result = ternary(result, this.checkConstraints(constraints[n], selector, n)); - if (result === false) { return false; } } } } - return result; }, checkConstraints: function checkConstraints(value, selector, state) { @@ -178,7 +168,6 @@ selector = state; state = null; } - if (state !== null) { state = states.State.sanitize(state); return invert(this.compare(value, selector, state), state.invert); @@ -189,7 +178,6 @@ getDependees: function getDependees() { var cache = {}; var _compare = this.compare; - this.compare = function (reference, selector, state) { (cache[selector] || (cache[selector] = [])).push(state.name); }; @@ -202,7 +190,6 @@ states.Trigger = function (args) { $.extend(this, args); - if (this.state in states.Trigger.states) { this.element = $(this.selector); @@ -211,13 +198,10 @@ } } }; - states.Trigger.prototype = { initialize: function initialize() { var _this3 = this; - var trigger = states.Trigger.states[this.state]; - if (typeof trigger === 'function') { trigger.call(window, this.element); } else { @@ -230,9 +214,9 @@ }, defaultTrigger: function defaultTrigger(event, valueFn) { var oldValue = valueFn.call(this.element); + this.element.on(event, $.proxy(function (e) { var value = valueFn.call(this.element, e); - if (oldValue !== value) { this.element.trigger({ type: "state:".concat(this.state), @@ -251,6 +235,7 @@ }, this)); } }; + states.Trigger.states = { empty: { keyup: function keyup() { @@ -272,14 +257,12 @@ if (this.length > 1) { return this.filter(':checked').val() || false; } - return this.val(); }, change: function change() { if (this.length > 1) { return this.filter(':checked').val() || false; } - return this.val(); } }, @@ -293,8 +276,8 @@ states.State = function (state) { this.pristine = state; this.name = state; - var process = true; + var process = true; do { while (this.name.charAt(0) === '!') { this.name = this.name.substring(1); @@ -313,7 +296,6 @@ if (state instanceof states.State) { return state; } - return new states.State(state); }; @@ -337,12 +319,15 @@ return this.name; } }; + var $document = $(document); $document.on('state:disabled', function (e) { if (e.trigger) { $(e.target).prop('disabled', e.value).closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggleClass('form-disabled', e.value).find('select, input, textarea').prop('disabled', e.value); + } }); + $document.on('state:required', function (e) { if (e.trigger) { if (e.value) { @@ -351,7 +336,6 @@ required: 'required', 'aria-required': 'true' }).closest('.js-form-item, .js-form-wrapper').find(label); - if (!$label.hasClass('js-form-required').length) { $label.addClass('js-form-required form-required'); } diff --git a/core/misc/tabbingmanager.js b/core/misc/tabbingmanager.js index 7fd4f9192d56ad2efafc0dbfdd6a6ea30fbe8a11..d64bfa532465e9be39446a6068770ee7e4807d21 100644 --- a/core/misc/tabbingmanager.js +++ b/core/misc/tabbingmanager.js @@ -4,23 +4,16 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function ($, Drupal, _ref) { var tabbable = _ref.tabbable, - isTabbable = _ref.isTabbable; - + isTabbable = _ref.isTabbable; function TabbingManager() { this.stack = []; } @@ -39,11 +32,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len $.extend(TabbingManager.prototype, { constrain: function constrain(elements) { var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref2$trapFocus = _ref2.trapFocus, - trapFocus = _ref2$trapFocus === void 0 ? false : _ref2$trapFocus; - + _ref2$trapFocus = _ref2.trapFocus, + trapFocus = _ref2$trapFocus === void 0 ? false : _ref2$trapFocus; var il = this.stack.length; - for (var i = 0; i < il; i++) { this.stack[i].deactivate(); } @@ -51,7 +42,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var tabbableElements = []; $(elements).each(function (index, rootElement) { tabbableElements = [].concat(_toConsumableArray(tabbableElements), _toConsumableArray(tabbable(rootElement))); - if (isTabbable(rootElement)) { tabbableElements = [].concat(_toConsumableArray(tabbableElements), [rootElement]); } @@ -62,13 +52,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len trapFocus: trapFocus }); this.stack.push(tabbingContext); + tabbingContext.activate(); + $(document).trigger('drupalTabbingConstrained', tabbingContext); return tabbingContext; }, release: function release() { var toActivate = this.stack.length - 1; - while (toActivate >= 0 && this.stack[toActivate].released) { toActivate--; } @@ -82,21 +73,19 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len activate: function activate(tabbingContext) { var $set = tabbingContext.$tabbableElements; var level = tabbingContext.level; - var $disabledSet = $(tabbable(document.body)).not($set); + var $disabledSet = $(tabbable(document.body)) + .not($set); tabbingContext.$disabledElements = $disabledSet; var il = $disabledSet.length; - for (var i = 0; i < il; i++) { this.recordTabindex($disabledSet.eq(i), level); } - $disabledSet.prop('tabindex', -1).prop('autofocus', false); - var $hasFocus = $set.filter('[autofocus]').eq(-1); + var $hasFocus = $set.filter('[autofocus]').eq(-1); if ($hasFocus.length === 0) { $hasFocus = $set.eq(0); } - $hasFocus.trigger('focus'); if ($set.length && tabbingContext.trapFocus) { @@ -120,7 +109,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var il = $set.length; tabbingContext.$tabbableElements.first().off('keydown.focus-trap'); tabbingContext.$tabbableElements.last().off('keydown.focus-trap'); - for (var i = 0; i < il; i++) { this.restoreTabindex($set.eq(i), level); } @@ -135,16 +123,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }, restoreTabindex: function restoreTabindex($el, level) { var tabInfo = $el.data('drupalOriginalTabIndices'); - if (tabInfo && tabInfo[level]) { var data = tabInfo[level]; - if (data.tabindex) { $el[0].setAttribute('tabindex', data.tabindex); - } else { + } + else { $el[0].removeAttribute('tabindex'); } - if (data.autofocus) { $el[0].setAttribute('autofocus', 'autofocus'); } @@ -153,17 +139,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len $el.removeData('drupalOriginalTabIndices'); } else { var levelToDelete = level; - while (tabInfo.hasOwnProperty(levelToDelete)) { delete tabInfo[levelToDelete]; levelToDelete++; } - $el.data('drupalOriginalTabIndices', tabInfo); } } } }); + $.extend(TabbingContext.prototype, { release: function release() { if (!this.released) { diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js index 3a046b375baeff12a6c41ff7c6342303b9541c68..a4c7cffa0cee31ce527c0ea5fe402fc2717b0384 100644 --- a/core/misc/tabledrag.js +++ b/core/misc/tabledrag.js @@ -4,11 +4,11 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } (function ($, Drupal, drupalSettings) { var showWeight = JSON.parse(localStorage.getItem('Drupal.tableDrag.showWeight')); + Drupal.behaviors.tableDrag = { attach: function attach(context, settings) { function initTableDrag(table, base) { @@ -16,7 +16,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag[base] = new Drupal.tableDrag(table[0], settings.tableDrag[base]); } } - Object.keys(settings.tableDrag || {}).forEach(function (base) { initTableDrag($(once('tabledrag', "#".concat(base), context)), base); }); @@ -25,48 +24,63 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag = function (table, tableSettings) { var _this = this; - var self = this; var $table = $(table); + this.$table = $(table); + this.table = table; + this.tableSettings = tableSettings; + this.dragObject = null; + this.rowObject = null; + this.oldRowElement = null; + this.oldY = null; + this.changed = false; + this.maxDepth = 0; + this.rtl = $(this.table).css('direction') === 'rtl' ? -1 : 1; + this.striping = $(this.table).data('striping') === 1; + this.scrollSettings = { amount: 4, interval: 50, trigger: 70 }; + this.scrollInterval = null; + this.scrollY = 0; + this.windowHeight = 0; + this.$toggleWeightButton = null; + this.indentEnabled = false; Object.keys(tableSettings || {}).forEach(function (group) { Object.keys(tableSettings[group] || {}).forEach(function (n) { if (tableSettings[group][n].relationship === 'parent') { _this.indentEnabled = true; } - if (tableSettings[group][n].limit > 0) { _this.maxDepth = tableSettings[group][n].limit; } }); }); - if (this.indentEnabled) { this.indentCount = 1; var indent = Drupal.theme('tableDragIndentation'); var testRow = $('<tr></tr>').addClass('draggable').appendTo(table); var testCell = $('<td></td>').appendTo(testRow).prepend(indent).prepend(indent); var $indentation = testCell.find('.js-indentation'); + this.indentAmount = $indentation.get(1).offsetLeft - $indentation.get(0).offsetLeft; testRow.remove(); } @@ -81,7 +95,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = this.toggleColumns(); }, this)); $table.before($toggleWeightWrapper); + self.initColumns(); + $(document).on('touchmove', function (event) { return self.dragRow(event.originalEvent.touches[0], self); }); @@ -94,6 +110,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = $(document).on('mouseup pointerup', function (event) { return self.dropRow(event, self); }); + $(window).on('storage', $.proxy(function (e) { if (e.originalEvent.key === 'Drupal.tableDrag.showWeight') { showWeight = JSON.parse(e.originalEvent.newValue); @@ -104,7 +121,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.initColumns = function () { var _this2 = this; - var $table = this.$table; var hidden; var cell; @@ -112,13 +128,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Object.keys(this.tableSettings || {}).forEach(function (group) { Object.keys(_this2.tableSettings[group]).some(function (tableSetting) { var field = $table.find(".".concat(_this2.tableSettings[group][tableSetting].target)).eq(0); - if (field.length && _this2.tableSettings[group][tableSetting].hidden) { hidden = _this2.tableSettings[group][tableSetting].hidden; cell = field.closest('td'); return true; } - return false; }); @@ -141,10 +155,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = index -= this.colSpan - 1; } }); - if (index > 0) { cell = cells.filter(":nth-child(".concat(index, ")")); - if (cell[0].colSpan && cell[0].colSpan > 1) { cell.addClass('tabledrag-has-colspan'); } else { @@ -157,18 +169,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.displayColumns = function (displayWeight) { if (displayWeight) { this.showColumns(); - } else { + } + else { this.hideColumns(); } - this.$toggleWeightButton.html(Drupal.theme('toggleButtonContent', displayWeight)); + $(once.filter('tabledrag', 'table')).trigger('columnschange', !!displayWeight); }; Drupal.tableDrag.prototype.toggleColumns = function () { showWeight = !showWeight; this.displayColumns(showWeight); - if (showWeight) { localStorage.setItem('Drupal.tableDrag.showWeight', showWeight); } else { @@ -200,14 +212,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = return Object.keys(tableSettingsGroup).map(function (delta) { var targetClass = tableSettingsGroup[delta].target; var rowSettings; - if (field.is(".".concat(targetClass))) { rowSettings = {}; Object.keys(tableSettingsGroup[delta]).forEach(function (n) { rowSettings[n] = tableSettingsGroup[delta][n]; }); } - return rowSettings; }).filter(function (rowSetting) { return rowSetting; @@ -220,39 +230,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = $item.find('td:first-of-type').find('a').addClass('menu-item__link'); var $handle = $(Drupal.theme('tableDragHandle')); var $indentationLast = $item.find('td:first-of-type').find('.js-indentation').eq(-1); - if ($indentationLast.length) { $indentationLast.after($handle); self.indentCount = Math.max($item.find('.js-indentation').length, self.indentCount); } else { $item.find('td').eq(0).prepend($handle); } - $handle.on('mousedown touchstart pointerdown', function (event) { event.preventDefault(); - if (event.originalEvent.type === 'touchstart') { event = event.originalEvent.touches[0]; } - self.dragStart(event, self, item); }); + $handle.on('click', function (e) { e.preventDefault(); }); + $handle.on('focus', function () { self.safeBlur = true; }); + $handle.on('blur', function (event) { if (self.rowObject && self.safeBlur) { self.dropRow(event, self); } }); + $handle.on('keydown', function (event) { if (event.keyCode !== 9 && !self.rowObject) { self.rowObject = new self.row(item, 'keyboard', self.indentEnabled, self.maxDepth, true); } - var keyChange = false; var groupHeight; @@ -268,26 +277,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = { var $previousRow = $(self.rowObject.element).prev('tr').eq(0); var previousRow = $previousRow.get(0); - while (previousRow && $previousRow.is(':hidden')) { $previousRow = $(previousRow).prev('tr').eq(0); previousRow = $previousRow.get(0); } - if (previousRow) { self.safeBlur = false; self.rowObject.direction = 'up'; keyChange = true; - if ($(item).is('.tabledrag-root')) { groupHeight = 0; - while (previousRow && $previousRow.find('.js-indentation').length) { $previousRow = $(previousRow).prev('tr').eq(0); previousRow = $previousRow.get(0); groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight; } - if (previousRow) { self.rowObject.swap('before', previousRow); window.scrollBy(0, -groupHeight); @@ -298,13 +302,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.rowObject.indent(0); window.scrollBy(0, -parseInt(item.offsetHeight, 10)); } - $handle.trigger('focus'); } - break; } - case 39: case 63235: keyChange = true; @@ -316,21 +317,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = { var $nextRow = $(self.rowObject.group).eq(-1).next('tr').eq(0); var nextRow = $nextRow.get(0); - while (nextRow && $nextRow.is(':hidden')) { $nextRow = $(nextRow).next('tr').eq(0); nextRow = $nextRow.get(0); } - if (nextRow) { self.safeBlur = false; self.rowObject.direction = 'down'; keyChange = true; - if ($(item).is('.tabledrag-root')) { groupHeight = 0; var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false); - if (nextGroup) { $(nextGroup.group).each(function () { groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight; @@ -345,27 +342,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.rowObject.indent(0); window.scrollBy(0, parseInt(item.offsetHeight, 10)); } - $handle.trigger('focus'); } - break; } } if (self.rowObject && self.rowObject.changed === true) { $(item).addClass('drag'); - if (self.oldRowElement) { $(self.oldRowElement).removeClass('drag-previous'); } - self.oldRowElement = item; - if (self.striping === true) { self.restripeTable(); } - self.onDrag(); } @@ -373,7 +364,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = return false; } }); + $handle.on('keypress', function (event) { + switch (event.keyCode) { case 37: case 38: @@ -381,6 +374,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = case 40: return false; } + }); }; @@ -388,7 +382,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.dragObject = {}; self.dragObject.initOffset = self.getPointerOffset(item, event); self.dragObject.initPointerCoords = self.pointerCoords(event); - if (self.indentEnabled) { self.dragObject.indentPointerPos = self.dragObject.initPointerCoords; } @@ -398,11 +391,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = } self.rowObject = new self.row(item, 'pointer', self.indentEnabled, self.maxDepth, true); + self.table.topY = $(self.table).offset().top; self.table.bottomY = self.table.topY + self.table.offsetHeight; + $(item).addClass('drag'); - $('body').addClass('drag'); + $('body').addClass('drag'); if (self.oldRowElement) { $(self.oldRowElement).removeClass('drag-previous'); } @@ -421,20 +416,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.oldY = y; var scrollAmount = self.checkScroll(self.currentPointerCoords.y); clearInterval(self.scrollInterval); - if (scrollAmount > 0 && self.rowObject.direction === 'down' || scrollAmount < 0 && self.rowObject.direction === 'up') { self.setScroll(scrollAmount); } var currentRow = self.findDropTargetRow(x, y); - if (currentRow) { if (self.rowObject.direction === 'down') { self.rowObject.swap('after', currentRow, self); } else { self.rowObject.swap('before', currentRow, self); } - if (self.striping === true) { self.restripeTable(); } @@ -448,7 +440,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.dragObject.indentPointerPos.x += self.indentAmount * indentChange * self.rtl; self.indentCount = Math.max(self.indentCount, self.rowObject.indents); } - return false; } }; @@ -460,12 +451,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = if (self.rowObject !== null) { droppedRow = self.rowObject.element; $droppedRow = $(droppedRow); - if (self.rowObject.changed === true) { self.updateFields(droppedRow); + Object.keys(self.tableSettings || {}).forEach(function (group) { var rowSettings = self.rowSettings(group, droppedRow); - if (rowSettings.relationship === 'group') { Object.keys(self.rowObject.children || {}).forEach(function (n) { self.updateField(self.rowObject.children[n], group); @@ -473,21 +463,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = } }); self.rowObject.markChanged(); - if (self.changed === false) { $(Drupal.theme('tableDragChangedWarning')).insertBefore(self.table).hide().fadeIn('slow'); self.changed = true; } } - if (self.indentEnabled) { self.rowObject.removeIndentClasses(); } - if (self.oldRowElement) { $(self.oldRowElement).removeClass('drag-previous'); } - $droppedRow.removeClass('drag').addClass('drag-previous'); self.oldRowElement = droppedRow; self.onDrop(); @@ -508,7 +494,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = y: event.pageY }; } - return { x: event.clientX + document.body.scrollLeft - document.body.clientLeft, y: event.clientY + document.body.scrollTop - document.body.clientTop @@ -526,18 +511,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) { var _this3 = this; - var rows = $(this.table.tBodies[0].rows).not(':hidden'); - var _loop = function _loop(n) { var row = rows[n]; var $row = $(row); var rowY = $row.offset().top; var rowHeight = void 0; - if (row.offsetHeight === 0) { rowHeight = parseInt(row.firstChild.offsetHeight, 10) / 2; - } else { + } + else { rowHeight = parseInt(row.offsetHeight, 10) / 2; } @@ -550,7 +533,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = v: null }; } - } else if (row === _this3.rowObject.element) { + } + else if (row === _this3.rowObject.element) { return { v: null }; @@ -566,25 +550,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = $row = $row.prev('tr:first-of-type'); row = $row.get(0); } - return { v: row }; } }; - for (var n = 0; n < rows.length; n++) { var _ret = _loop(n); - if (_typeof(_ret) === "object") return _ret.v; } - return null; }; Drupal.tableDrag.prototype.updateFields = function (changedRow) { var _this4 = this; - Object.keys(this.tableSettings || {}).forEach(function (group) { _this4.updateField(changedRow, group); }); @@ -597,16 +576,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var $previousRow; var previousRow; var useSibling; - if (rowSettings.relationship === 'self' || rowSettings.relationship === 'group') { sourceRow = changedRow; - } else if (rowSettings.relationship === 'sibling') { + } + else if (rowSettings.relationship === 'sibling') { $previousRow = $changedRow.prev('tr:first-of-type'); previousRow = $previousRow.get(0); var $nextRow = $changedRow.next('tr:first-of-type'); var nextRow = $nextRow.get(0); sourceRow = changedRow; - if ($previousRow.is('.draggable') && $previousRow.find(".".concat(group)).length) { if (this.indentEnabled) { if ($previousRow.find('.js-indentations').length === $changedRow.find('.js-indentations').length) { @@ -624,24 +602,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = sourceRow = nextRow; } } - } else if (rowSettings.relationship === 'parent') { + } + else if (rowSettings.relationship === 'parent') { $previousRow = $changedRow.prev('tr'); previousRow = $previousRow; - while ($previousRow.length && $previousRow.find('.js-indentation').length >= this.rowObject.indents) { $previousRow = $previousRow.prev('tr'); previousRow = $previousRow; } - if ($previousRow.length) { sourceRow = $previousRow.get(0); - } else { + } + else { sourceRow = $(this.table).find('tr.draggable:first-of-type').get(0); - if (sourceRow === this.rowObject.element) { sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0); } - useSibling = true; } } @@ -653,27 +629,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = rowSettings.relationship = 'sibling'; rowSettings.source = rowSettings.target; } - var targetClass = ".".concat(rowSettings.target); var targetElement = $changedRow.find(targetClass).get(0); if (targetElement) { var sourceClass = ".".concat(rowSettings.source); var sourceElement = $(sourceClass, sourceRow).get(0); - switch (rowSettings.action) { case 'depth': targetElement.value = $(sourceElement).closest('tr').find('.js-indentation').length; break; - case 'match': targetElement.value = sourceElement.value; break; - case 'order': { var siblings = this.rowObject.findSiblings(rowSettings); - if ($(targetElement).is('select')) { var values = []; $(targetElement).find('option').each(function () { @@ -690,17 +661,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = } else { var weight = 0; var $siblingTarget = $(siblings[0]).find(targetClass); - if ($siblingTarget.length) { weight = parseInt($siblingTarget[0].value, 10) || 0; } - $(siblings).find(targetClass).each(function () { this.value = weight; weight++; }); } - break; } } @@ -710,7 +678,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.copyDragClasses = function (sourceRow, targetRow, group) { var sourceElement = $(sourceRow).find(".".concat(group)); var targetElement = $(targetRow).find(".".concat(group)); - if (sourceElement.length && targetElement.length) { targetElement[0].className = sourceElement[0].className; } @@ -722,13 +689,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight); this.windowHeight = windowHeight; var scrollY; - if (document.all) { scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop; } else { scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY; } - this.scrollY = scrollY; var trigger = this.scrollSettings.trigger; var delta = 0; @@ -738,7 +703,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = delta = delta > 0 && delta < trigger ? delta : trigger; return delta * this.scrollSettings.amount; } - if (cursorY - scrollY < trigger) { delta = trigger / (cursorY - scrollY); delta = delta > 0 && delta < trigger ? delta : trigger; @@ -752,7 +716,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = self.checkScroll(self.currentPointerCoords.y); var aboveTable = self.scrollY > self.table.topY; var belowTable = self.scrollY + self.windowHeight < self.table.bottomY; - if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) { window.scrollBy(0, scrollAmount); } @@ -782,12 +745,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = this.indentEnabled = indentEnabled; this.maxDepth = maxDepth; this.direction = ''; - if (this.indentEnabled) { this.indents = $tableRow.find('.js-indentation').length; this.children = this.findChildren(addClasses); this.group = this.group.concat(this.children); - for (var n = 0; n < this.group.length; n++) { this.groupDepth = Math.max($(this.group[n]).find('.js-indentation').length, this.groupDepth); } @@ -799,50 +760,40 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var currentRow = $(this.element, this.table).next('tr.draggable'); var rows = []; var child = 0; - function rowIndentation(indentNum, el) { var self = $(el); - if (child === 1 && indentNum === parentIndentation) { self.addClass('tree-child-first'); } - if (indentNum === parentIndentation) { self.addClass('tree-child'); } else if (indentNum > parentIndentation) { self.addClass('tree-child-horizontal'); } } - while (currentRow.length) { if (currentRow.find('.js-indentation').length > parentIndentation) { child++; rows.push(currentRow[0]); - if (addClasses) { currentRow.find('.js-indentation').each(rowIndentation); } } else { break; } - currentRow = currentRow.next('tr.draggable'); } - if (addClasses && rows.length) { $(rows[rows.length - 1]).find(".js-indentation:nth-child(".concat(parentIndentation + 1, ")")).addClass('tree-child-last'); } - return rows; }; Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) { var $row = $(row); - if (this.indentEnabled) { var prevRow; var nextRow; - if (this.direction === 'down') { prevRow = row; nextRow = $row.next('tr').get(0); @@ -850,7 +801,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = prevRow = $row.prev('tr').get(0); nextRow = row; } - this.interval = this.validIndentInterval(prevRow, nextRow); if (this.interval.min > this.interval.max) { @@ -861,7 +811,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = if (this.table.tBodies[0].rows[0] === row && $row.is(':not(.draggable)')) { return false; } - return true; }; @@ -880,18 +829,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) { var $prevRow = $(prevRow); var maxIndent; + var minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0; if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) { maxIndent = 0; } else { maxIndent = $prevRow.find('.js-indentation').length + ($prevRow.is('.tabledrag-leaf') ? 0 : 1); - if (this.maxDepth) { maxIndent = Math.min(maxIndent, this.maxDepth - (this.groupDepth - this.indents)); } } - return { min: minIndent, max: maxIndent @@ -900,7 +848,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) { var $group = $(this.group); - if (!this.interval) { var prevRow = $(this.element).prev('tr').get(0); var nextRow = $group.eq(-1).next('tr').get(0); @@ -911,7 +858,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = indent = Math.max(indent, this.interval.min); indent = Math.min(indent, this.interval.max); indentDiff = indent - this.indents; - for (var n = 1; n <= Math.abs(indentDiff); n++) { if (indentDiff < 0) { $group.find('.js-indentation:first-of-type').remove(); @@ -921,13 +867,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = this.indents++; } } - if (indentDiff) { this.changed = true; this.groupDepth += indentDiff; this.onIndent(); } - return indentDiff; }; @@ -936,16 +880,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = var directions = ['prev', 'next']; var rowIndentation = this.indents; var checkRowIndentation; - for (var d = 0; d < directions.length; d++) { var checkRow = $(this.element)[directions[d]](); - while (checkRow.length) { if (checkRow.find(".".concat(rowSettings.target))) { if (this.indentEnabled) { checkRowIndentation = checkRow.find('.js-indentation').length; } - if (!this.indentEnabled || checkRowIndentation === rowIndentation) { siblings.push(checkRow[0]); } else if (checkRowIndentation < rowIndentation) { @@ -954,22 +895,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = } else { break; } - checkRow = checkRow[directions[d]](); } - if (directions[d] === 'prev') { siblings.reverse(); siblings.push(this.element); } } - return siblings; }; Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () { var _this5 = this; - Object.keys(this.children || {}).forEach(function (n) { $(_this5.children[n]).find('.js-indentation').removeClass('tree-child').removeClass('tree-child-first').removeClass('tree-child-last').removeClass('tree-child-horizontal'); }); @@ -978,7 +915,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.row.prototype.markChanged = function () { var marker = Drupal.theme('tableDragChangedMarker'); var cell = $(this.element).find('td:first-of-type'); - if (cell.find('abbr.tabledrag-changed').length === 0) { cell.append(marker); } @@ -991,7 +927,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = Drupal.tableDrag.prototype.row.prototype.onSwap = function (swappedRow) { return null; }; - $.extend(Drupal.theme, { tableDragChangedMarker: function tableDragChangedMarker() { return "<abbr class=\"warning tabledrag-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr>"); diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js index 110d30fee0ed77936d23b08bc1701ebf30db265b..65e5962460684f403b7d39eff98bba9c80fd4308 100644 --- a/core/misc/tableheader.js +++ b/core/misc/tableheader.js @@ -8,31 +8,34 @@ (function ($, Drupal, displace) { function TableHeader(table) { var $table = $(table); + this.$originalTable = $table; + this.$originalHeader = $table.children('thead'); + this.$originalHeaderCells = this.$originalHeader.find('> tr > th'); + this.displayWeight = null; this.$originalTable.addClass('sticky-table'); this.tableHeight = $table[0].clientHeight; this.tableOffset = this.$originalTable.offset(); + this.$originalTable.on('columnschange', { tableHeader: this }, function (e, display) { var tableHeader = e.data.tableHeader; - if (tableHeader.displayWeight === null || tableHeader.displayWeight !== display) { tableHeader.recalculateSticky(); } - tableHeader.displayWeight = display; }); + this.createSticky(); } function forTables(method, arg) { var tables = TableHeader.tables; var il = tables.length; - for (var i = 0; i < il; i++) { tables[i][method](arg); } @@ -52,19 +55,15 @@ }, tableHeaderInitHandler); } }; - function scrollValue(position) { return document.documentElement[position] || document.body[position]; } - function tableHeaderResizeHandler(e) { forTables('recalculateSticky'); } - function tableHeaderOnScrollHandler(e) { forTables('onScroll'); } - function tableHeaderOffsetChangeHandler(e, offsets) { forTables('stickyPosition', offsets.top); } @@ -77,9 +76,11 @@ 'columnschange.TableHeader drupalToolbarTrayChange': tableHeaderResizeHandler, 'drupalViewportOffsetChange.TableHeader': tableHeaderOffsetChangeHandler }); + $.extend(TableHeader, { tables: [] }); + $.extend(TableHeader.prototype, { minHeight: 100, tableOffset: null, @@ -94,19 +95,17 @@ top: '0px' }).append($stickyHeader).insertBefore(this.$originalTable); this.$stickyHeaderCells = $stickyHeader.find('> tr > th'); + this.recalculateSticky(); }, stickyPosition: function stickyPosition(offsetTop, offsetLeft) { var css = {}; - if (typeof offsetTop === 'number') { css.top = "".concat(offsetTop, "px"); } - if (typeof offsetLeft === 'number') { css.left = "".concat(this.tableOffset.left - offsetLeft, "px"); } - this.$html.css('scroll-padding-top', displace.offsets.top + (this.stickyVisible ? this.$stickyTable.height() : 0)); return this.$stickyTable.css(css); }, @@ -115,11 +114,9 @@ var tableTop = this.tableOffset.top - displace.offsets.top; var tableBottom = tableTop + this.tableHeight; var visible = false; - if (tableTop < scrollTop && scrollTop < tableBottom - this.minHeight) { visible = true; } - this.stickyVisible = visible; return visible; }, @@ -130,19 +127,19 @@ }, recalculateSticky: function recalculateSticky(event) { this.tableHeight = this.$originalTable[0].clientHeight; + displace.offsets.top = displace.calculateOffset('top'); this.tableOffset = this.$originalTable.offset(); this.stickyPosition(displace.offsets.top, scrollValue('scrollLeft')); + var $that = null; var $stickyCell = null; var display = null; var il = this.$originalHeaderCells.length; - for (var i = 0; i < il; i++) { $that = $(this.$originalHeaderCells[i]); $stickyCell = this.$stickyHeaderCells.eq($that.index()); display = $that.css('display'); - if (display !== 'none') { $stickyCell.css({ width: $that.css('width'), @@ -152,9 +149,9 @@ $stickyCell.css('display', 'none'); } } - this.$stickyTable.css('width', this.$originalTable.outerWidth()); } }); + Drupal.TableHeader = TableHeader; })(jQuery, Drupal, window.Drupal.displace); \ No newline at end of file diff --git a/core/misc/tableresponsive.js b/core/misc/tableresponsive.js index 192536d49db440d8f3ac7c67a8d3438499b1e9d2..5b8e859a71fd016629a9c9d63008ccdc76d10151 100644 --- a/core/misc/tableresponsive.js +++ b/core/misc/tableresponsive.js @@ -14,6 +14,7 @@ this.$headers = this.$table.find('th'); this.$link = $('<button type="button" class="link tableresponsive-toggle"></button>').attr('title', Drupal.t('Show table cells that were hidden to make the table fit within a small screen.')).on('click', $.proxy(this, 'eventhandlerToggleColumns')); this.$table.before($('<div class="tableresponsive-toggle-columns"></div>').append(this.$link)); + $(window).on('resize.tableresponsive', $.proxy(this, 'eventhandlerEvaluateColumnVisibility')).trigger('resize.tableresponsive'); } @@ -24,19 +25,19 @@ }); } }; + $.extend(TableResponsive, { tables: [] }); + $.extend(TableResponsive.prototype, { eventhandlerEvaluateColumnVisibility: function eventhandlerEvaluateColumnVisibility(e) { var pegged = parseInt(this.$link.data('pegged'), 10); var hiddenLength = this.$headers.filter('.priority-medium:hidden, .priority-low:hidden').length; - if (hiddenLength > 0) { this.$link.show(); this.$link[0].textContent = this.showText; } - if (!pegged && hiddenLength === 0) { this.$link.hide(); this.$link[0].textContent = this.hideText; @@ -47,7 +48,6 @@ var self = this; var $hiddenHeaders = this.$headers.filter('.priority-medium:hidden, .priority-low:hidden'); this.$revealedCells = this.$revealedCells || $(); - if ($hiddenHeaders.length > 0) { $hiddenHeaders.each(function (index, element) { var $header = $(this); @@ -62,26 +62,23 @@ }); this.$link[0].textContent = this.hideText; this.$link.data('pegged', 1); - } else { + } + else { this.$revealedCells.hide(); this.$revealedCells.each(function (index, element) { var $cell = $(this); var properties = $cell.attr('style').split(';'); var newProps = []; var match = /^display\s*:\s*none$/; - for (var i = 0; i < properties.length; i++) { var prop = properties[i]; prop.trim(); var isDisplayNone = match.exec(prop); - if (isDisplayNone) { continue; } - newProps.push(prop); } - $cell.attr('style', newProps.join(';')); }); this.$link[0].textContent = this.showText; @@ -90,5 +87,6 @@ } } }); + Drupal.TableResponsive = TableResponsive; })(jQuery, Drupal, window); \ No newline at end of file diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js index efd029f7ce174647719b8d0917d24ae97437615c..fa14c21ab43523d01f4057400b736c8091626027 100644 --- a/core/misc/tableselect.js +++ b/core/misc/tableselect.js @@ -27,7 +27,6 @@ selectAll: Drupal.t('Select all rows in this table'), selectNone: Drupal.t('Deselect all rows in this table') }; - var updateSelectAll = function updateSelectAll(state) { $table.prev('table.sticky-header').addBack().find('th.select-all input[type="checkbox"]').each(function () { var $checkbox = $(this); @@ -55,7 +54,9 @@ updateSelectAll(event.target.checked); } }); + checkboxes = $table.find('td input[type="checkbox"]:enabled').on('click', function (e) { + $(this).closest('tr').toggleClass('selected', this.checked); if (e.shiftKey && lastChecked && lastChecked !== e.target) { @@ -63,8 +64,10 @@ } updateSelectAll(checkboxes.length === checkboxes.filter(':checked').length); + lastChecked = e.target; }); + updateSelectAll(checkboxes.length === checkboxes.filter(':checked').length); }; @@ -73,19 +76,17 @@ for (var i = from[mode]; i; i = i[mode]) { var $i = $(i); - if (i.nodeType !== 1) { continue; } - $i.toggleClass('selected', state); $i.find('input[type="checkbox"]').prop('checked', state); - if (to.nodeType) { if (i === to) { break; } - } else if ($.filter(to, [i]).r.length) { + } + else if ($.filter(to, [i]).r.length) { break; } } diff --git a/core/misc/timezone.js b/core/misc/timezone.js index ea252a113d2dca64d09aeaaec669eb2e204ed122..7b31c63e45f78e6737cf41186063d7bb516ab51d 100644 --- a/core/misc/timezone.js +++ b/core/misc/timezone.js @@ -9,33 +9,33 @@ Drupal.behaviors.setTimezone = { attach: function attach(context, settings) { var timezone = once('timezone', '.timezone-detect', context); - if (timezone.length) { var tz = new Intl.DateTimeFormat().resolvedOptions().timeZone; - if (tz && $(timezone).find("option[value=\"".concat(tz, "\"]")).length) { timezone.forEach(function (item) { item.value = tz; }); return; } - var dateString = Date(); var matches = dateString.match(/\(([A-Z]{3,5})\)/); var abbreviation = matches ? matches[1] : 0; + var dateNow = new Date(); var offsetNow = dateNow.getTimezoneOffset() * -60; + var dateJan = new Date(dateNow.getFullYear(), 0, 1, 12, 0, 0, 0); var dateJul = new Date(dateNow.getFullYear(), 6, 1, 12, 0, 0, 0); var offsetJan = dateJan.getTimezoneOffset() * -60; var offsetJul = dateJul.getTimezoneOffset() * -60; var isDaylightSavingTime; - if (offsetJan === offsetJul) { isDaylightSavingTime = ''; - } else if (Math.max(offsetJan, offsetJul) === offsetNow) { + } + else if (Math.max(offsetJan, offsetJul) === offsetNow) { isDaylightSavingTime = 1; - } else { + } + else { isDaylightSavingTime = 0; } diff --git a/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js index cac5d36b2e784fce3dd2a57ab1f8285d5c7b3f14..a6c83bdd8e97a46db1452469e09c74caeecc6039 100644 --- a/core/misc/vertical-tabs.js +++ b/core/misc/vertical-tabs.js @@ -16,7 +16,6 @@ attach: function attach(context) { var width = drupalSettings.widthBreakpoint || 640; var mq = "(max-width: ".concat(width, "px)"); - if (window.matchMedia(mq).matches) { return; } @@ -26,14 +25,15 @@ var $this = $(verticalTab).addClass('vertical-tabs__panes'); var focusID = $this.find(':hidden.vertical-tabs__active-tab')[0].value; var tabFocus; - var $details = $this.find('> details'); + var $details = $this.find('> details'); if ($details.length === 0) { return; } var tabList = $('<ul class="vertical-tabs__menu"></ul>'); $this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList); + $details.each(function () { var $that = $(this); var $summary = $that.find('> summary'); @@ -43,24 +43,20 @@ }); tabList.append(verticalTab.item); $that.removeClass('collapsed').removeAttr('open').addClass('vertical-tabs__pane').data('verticalTab', verticalTab); - if (this.id === focusID) { tabFocus = $that; } }); $(tabList).find('> li').eq(0).addClass('first'); $(tabList).find('> li').eq(-1).addClass('last'); - if (!tabFocus) { var $locationHash = $this.find(window.location.hash); - if (window.location.hash && $locationHash.length) { tabFocus = $locationHash.closest('.vertical-tabs__pane'); } else { tabFocus = $this.find('> .vertical-tabs__pane').eq(0); } } - if (tabFocus.length) { tabFocus.data('verticalTab').focus(); } @@ -76,6 +72,7 @@ e.preventDefault(); self.focus(); }); + this.link.on('keydown', function (event) { if (event.keyCode === 13) { event.preventDefault(); @@ -87,7 +84,6 @@ self.updateSummary(); }).trigger('summaryUpdated'); }; - Drupal.verticalTab.prototype = { focus: function focus() { this.details.siblings('.vertical-tabs__pane').each(function () { @@ -117,13 +113,12 @@ this.item.parent().children('.vertical-tabs__menu-item').removeClass('first').filter(':visible').eq(0).addClass('first'); this.details.addClass('vertical-tab--hidden').hide().removeAttr('open'); var $firstTab = this.details.siblings('.vertical-tabs__pane:not(.vertical-tab--hidden)').eq(0); - if ($firstTab.length) { $firstTab.data('verticalTab').focus(); - } else { + } + else { this.item.closest('.js-form-type-vertical-tabs').hide(); } - return this; } }; diff --git a/core/modules/big_pipe/js/big_pipe.js b/core/modules/big_pipe/js/big_pipe.js index dbc36f002f48952610677d61519408356a5fe0ea..ac4a476fec20bb871783e3e43ed57082175b76f5 100644 --- a/core/modules/big_pipe/js/big_pipe.js +++ b/core/modules/big_pipe/js/big_pipe.js @@ -10,7 +10,6 @@ if (content === '') { return false; } - try { return JSON.parse(content); } catch (e) { @@ -21,10 +20,8 @@ function bigPipeProcessPlaceholderReplacement(placeholderReplacement) { var placeholderId = placeholderReplacement.getAttribute('data-big-pipe-replacement-for-placeholder-with-id'); var content = placeholderReplacement.textContent.trim(); - if (typeof drupalSettings.bigPipePlaceholderIds[placeholderId] !== 'undefined') { var response = mapTextContentToAjaxResponse(content); - if (response === false) { once.remove('big-pipe', placeholderReplacement); } else { @@ -40,6 +37,7 @@ } var interval = drupalSettings.bigPipeInterval || 50; + var timeoutID; function bigPipeProcessDocument(context) { @@ -56,13 +54,10 @@ if (timeoutID) { clearTimeout(timeoutID); } - return true; } - return false; } - function bigPipeProcess() { timeoutID = setTimeout(function () { if (!bigPipeProcessDocument(document)) { @@ -70,13 +65,12 @@ } }, interval); } - bigPipeProcess(); + window.addEventListener('load', function () { if (timeoutID) { clearTimeout(timeoutID); } - bigPipeProcessDocument(document); }); })(Drupal, drupalSettings); \ No newline at end of file diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 99777640ff9bcc0a31ff85bab8200b18f5ae69bb..a7f355fd3a01e2dfcb32bc514a5454e259ae49a5 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -30,13 +30,13 @@ }); } } - if ($table.length) { $filterRows = $table.find('div.block-filter-text-source'); $input.on('keyup', debounce(filterBlockList, 200)); } } }; + Drupal.behaviors.blockHighlightPlacement = { attach: function attach(context, settings) { if (settings.blockPlacement && $('.js-block-placed').length) { diff --git a/core/modules/block/js/block.js b/core/modules/block/js/block.js index 427efdf61131e807f0cd58f3dfedf73448d9568c..78aa4cbac633b4ca7fb7060278ea41d045804e37 100644 --- a/core/modules/block/js/block.js +++ b/core/modules/block/js/block.js @@ -16,30 +16,25 @@ var vals = []; var $checkboxes = $(context).find('input[type="checkbox"]:checked + label'); var il = $checkboxes.length; - for (var i = 0; i < il; i++) { vals.push($($checkboxes[i]).html()); } - if (!vals.length) { vals.push(Drupal.t('Not restricted')); } - return vals.join(', '); } - $('[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-entity-bundlenode"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"]').drupalSetSummary(checkboxesSummary); $('[data-drupal-selector="edit-visibility-request-path"]').drupalSetSummary(function (context) { var $pages = $(context).find('textarea[name="visibility[request_path][pages]"]'); - if (!$pages.length || !$pages[0].value) { return Drupal.t('Not restricted'); } - return Drupal.t('Restricted to certain pages'); }); } }; + Drupal.behaviors.blockDrag = { attach: function attach(context, settings) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag.blocks === 'undefined') { @@ -49,16 +44,15 @@ function checkEmptyRegions(table, rowObject) { table.find('tr.region-message').each(function () { var $this = $(this); - if ($this.prev('tr').get(0) === rowObject.element) { if (rowObject.method !== 'keyboard' || rowObject.direction === 'down') { rowObject.swap('after', this); } } - if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length === 0) { $this.removeClass('region-populated').addClass('region-empty'); - } else if ($this.is('.region-empty')) { + } + else if ($this.is('.region-empty')) { $this.removeClass('region-empty').addClass('region-populated'); } }); @@ -67,7 +61,6 @@ function updateLastPlaced(table, rowObject) { table.find('.color-success').removeClass('color-success'); var $rowObject = $(rowObject); - if (!$rowObject.is('.drag-previous')) { table.find('.drag-previous').removeClass('drag-previous'); $rowObject.addClass('drag-previous'); @@ -80,10 +73,8 @@ this.value = ++weight; }); } - var table = $('#blocks'); var tableDrag = Drupal.tableDrag.blocks; - tableDrag.row.prototype.onSwap = function (swappedRow) { checkEmptyRegions(table, this); updateLastPlaced(table, this); @@ -95,7 +86,6 @@ var regionRow = $rowElement.prevAll('tr.region-message').get(0); var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); var regionField = $rowElement.find('select.block-region-select'); - if (regionField.find("option[value=".concat(regionName, "]")).length === 0) { window.alert(Drupal.t('The block cannot be placed in this region.')); regionField.trigger('change'); @@ -108,7 +98,6 @@ weightField.removeClass("block-weight-".concat(oldRegionName)).addClass("block-weight-".concat(regionName)); regionField[0].value = regionName; } - updateBlockWeights(table, regionName); }; @@ -118,22 +107,19 @@ tableDrag.rowObject = new tableDrag.row(row[0]); var regionMessage = table.find(".region-".concat(select[0].value, "-message")); var regionItems = regionMessage.nextUntil('.region-message, .region-title'); - if (regionItems.length) { regionItems.last().after(row); - } else { + } + else { regionMessage.after(row); } - updateBlockWeights(table, select[0].value); checkEmptyRegions(table, tableDrag.rowObject); updateLastPlaced(table, row); - if (!tableDrag.changed) { $(Drupal.theme('tableDragChangedWarning')).insertBefore(tableDrag.table).hide().fadeIn('slow'); tableDrag.changed = true; } - select.trigger('blur'); }); } diff --git a/core/modules/book/book.js b/core/modules/book/book.js index 8b320fc0b88961a2754589ad6d1481cd2a4d984f..1eddc821ee9943b9691c6f9d8315e30c13f8fcf0 100644 --- a/core/modules/book/book.js +++ b/core/modules/book/book.js @@ -11,15 +11,12 @@ $(context).find('.book-outline-form').drupalSetSummary(function (context) { var $select = $(context).find('.book-title-select'); var val = $select[0].value; - if (val === '0') { return Drupal.t('Not in book'); } - if (val === 'new') { return Drupal.t('New book'); } - return Drupal.checkPlain($select.find(':selected')[0].textContent); }); } diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js index a1a0d1a64158fda04cf1bc993cdd7ab3c3b40f80..1429d0ac7749fb1ca04037789b6c2979a72122ce 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.js +++ b/core/modules/ckeditor/js/ckeditor.admin.js @@ -7,19 +7,24 @@ (function ($, Drupal, drupalSettings, _) { Drupal.ckeditor = Drupal.ckeditor || {}; + Drupal.behaviors.ckeditorAdmin = { attach: function attach(context) { var configurationForm = once('ckeditor-configuration', '.ckeditor-toolbar-configuration', context); - if (configurationForm.length) { var $configurationForm = $(configurationForm); - var $textarea = $configurationForm.find('.js-form-item-editor-settings-toolbar-button-groups').hide().find('textarea'); + var $textarea = $configurationForm + .find('.js-form-item-editor-settings-toolbar-button-groups').hide() + .find('textarea'); + $configurationForm.append(drupalSettings.ckeditor.toolbarAdmin); + Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({ $textarea: $textarea, activeEditorConfig: JSON.parse($textarea[0].value), hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig }); + var viewDefaults = { model: Drupal.ckeditor.models.Model, el: $('.ckeditor-toolbar-configuration') @@ -38,18 +43,17 @@ } var configurationForm = once.filter('ckeditor-configuration', '.ckeditor-toolbar-configuration', context); - if (configurationForm.length && Drupal.ckeditor.models && Drupal.ckeditor.models.Model) { var config = Drupal.ckeditor.models.Model.toJSON().activeEditorConfig; var buttons = Drupal.ckeditor.views.controller.getButtonList(config); var $activeToolbar = $('.ckeditor-toolbar-configuration').find('.ckeditor-toolbar-active'); - for (var i = 0; i < buttons.length; i++) { $activeToolbar.trigger('CKEditorToolbarChanged', ['removed', buttons[i]]); } } } }; + Drupal.ckeditor = { views: {}, models: {}, @@ -60,7 +64,6 @@ if (view.isProcessing) { return; } - view.isProcessing = true; Drupal.ckeditor.openGroupNameDialog(view, $group, callback); } else { @@ -70,14 +73,11 @@ }, registerGroupMove: function registerGroupMove(view, $group) { var $row = $group.closest('.ckeditor-row'); - if ($row.hasClass('placeholder')) { $row.removeClass('placeholder'); } - $row.parent().children().each(function () { $row = $(this); - if ($row.find('.ckeditor-toolbar-group').not('.placeholder').length === 0) { $row.addClass('placeholder'); } @@ -90,30 +90,30 @@ function validateForm(form) { if (form.elements[0].value.length === 0) { var $form = $(form); - if (!$form.hasClass('errors')) { $form.addClass('errors').find('input').addClass('error').attr('aria-invalid', 'true'); $("<div class=\"description\" >".concat(Drupal.t('Please provide a name for the button group.'), "</div>")).insertAfter(form.elements[0]); } - return true; } - return false; } function closeDialog(action, form) { function shutdown() { dialog.close(action); + delete view.isProcessing; } function namePlaceholderGroup($group, name) { if ($group.hasClass('placeholder')) { var groupID = "ckeditor-toolbar-group-aria-label-for-".concat(Drupal.checkPlain(name.toLowerCase().replace(/\s/g, '-'))); - $group.removeAttr('aria-label').attr('data-drupal-ckeditor-type', 'group').attr('tabindex', 0).children('.ckeditor-toolbar-group-name').attr('id', groupID).end().children('.ckeditor-toolbar-group-buttons').attr('aria-labelledby', groupID); + $group + .removeAttr('aria-label').attr('data-drupal-ckeditor-type', 'group').attr('tabindex', 0) + .children('.ckeditor-toolbar-group-name').attr('id', groupID).end() + .children('.ckeditor-toolbar-group-buttons').attr('aria-labelledby', groupID); } - $group.attr('data-drupal-ckeditor-toolbar-group-name', name).children('.ckeditor-toolbar-group-name').each(function () { this.textContent = name; }); @@ -133,7 +133,9 @@ shutdown(); namePlaceholderGroup($group, Drupal.checkPlain(form.elements[0].value)); $group.closest('.ckeditor-row.placeholder').addBack().removeClass('placeholder'); + callback(true, $group); + view.model.set('isDirty', true); } } @@ -165,11 +167,9 @@ var $target = $(event.currentTarget); var data = $target.data('ui-button'); var action = 'apply'; - if (data && data.options && data.options.label) { action = data.options.label.toLowerCase(); } - closeDialog(action, form); event.stopPropagation(); event.stopImmediatePropagation(); @@ -177,54 +177,51 @@ } }); var text = Drupal.t('Editing the name of the new button group in a dialog.'); - if (typeof $group.attr('data-drupal-ckeditor-toolbar-group-name') !== 'undefined') { text = Drupal.t('Editing the name of the "@groupName" button group in a dialog.', { '@groupName': $group.attr('data-drupal-ckeditor-toolbar-group-name') }); } - Drupal.announce(text); }, close: function close(event) { $(event.target).remove(); } }); + dialog.showModal(); - $(document.querySelector('.ckeditor-name-toolbar-group').querySelector('input')).attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name')).trigger('focus'); + $(document.querySelector('.ckeditor-name-toolbar-group').querySelector('input')) + .attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name')) + .trigger('focus'); } }; + Drupal.behaviors.ckeditorAdminButtonPluginSettings = { attach: function attach(context) { var $context = $(context); var ckeditorPluginSettings = once('ckeditor-plugin-settings', '#ckeditor-plugin-settings', context); - if (ckeditorPluginSettings.length) { var $ckeditorPluginSettings = $(ckeditorPluginSettings); $ckeditorPluginSettings.find('[data-ckeditor-buttons]').each(function () { var $this = $(this); - if ($this.data('verticalTab')) { $this.data('verticalTab').tabHide(); } else { $this.hide(); } - $this.data('ckeditorButtonPluginSettingsActiveButtons', []); }); + $context.find('.ckeditor-toolbar-active').off('CKEditorToolbarChanged.ckeditorAdminPluginSettings').on('CKEditorToolbarChanged.ckeditorAdminPluginSettings', function (event, action, button) { var $pluginSettings = $ckeditorPluginSettings.find("[data-ckeditor-buttons~=".concat(button, "]")); if ($pluginSettings.length === 0) { return; } - var verticalTab = $pluginSettings.data('verticalTab'); var activeButtons = $pluginSettings.data('ckeditorButtonPluginSettingsActiveButtons'); - if (action === 'added') { activeButtons.push(button); - if (verticalTab) { verticalTab.tabShow(); } else { @@ -232,7 +229,6 @@ } } else { activeButtons.splice(activeButtons.indexOf(button), 1); - if (activeButtons.length === 0) { if (verticalTab) { verticalTab.tabHide(); @@ -241,7 +237,6 @@ } } } - $pluginSettings.data('ckeditorButtonPluginSettingsActiveButtons', activeButtons); }); } diff --git a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js index 5ea1cd8cd40319261f75c7b9ac466f390df0987a..04b8d394b4b96e82a4137a72254de0e78dc383c1 100644 --- a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js +++ b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js @@ -17,21 +17,17 @@ var $scheme = $("".concat(root, "[scheme]\"]:checked")); var maxFileSize = maxFileSizeElement.value ? maxFileSizeElement.value : maxFileSizeElement.getAttribute('placeholder'); var maxDimensions = maxWidth.value && maxHeight.value ? "(".concat(maxWidth.value, "x").concat(maxHeight.value, ")") : ''; - if (!$status.is(':checked')) { return Drupal.t('Uploads disabled'); } - var output = ''; output += Drupal.t('Uploads enabled, max size: @size @dimensions', { '@size': maxFileSize, '@dimensions': maxDimensions }); - if ($scheme.length) { output += "<br />".concat($scheme.attr('data-label')); } - return output; }); } diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js index be798f0e05385d8f295715f3e1471965acccf3e3..8c8999052ea486835edf67303e069afc9b914507 100644 --- a/core/modules/ckeditor/js/ckeditor.js +++ b/core/modules/ckeditor/js/ckeditor.js @@ -9,10 +9,10 @@ Drupal.editors.ckeditor = { attach: function attach(element, format) { this._loadExternalPlugins(format); - format.editorSettings.drupal = { format: format.format }; + var label = $("label[for=".concat(element.getAttribute('id'), "]")).html(); format.editorSettings.title = Drupal.t('Rich Text Editor, !label field', { '!label': label @@ -21,7 +21,6 @@ }, detach: function detach(element, format, trigger) { var editor = CKEDITOR.dom.element.get(element).getEditor(); - if (editor) { if (trigger === 'serialize') { editor.updateElement(); @@ -30,24 +29,21 @@ element.removeAttribute('contentEditable'); } } - return !!editor; }, onChange: function onChange(element, callback) { var editor = CKEDITOR.dom.element.get(element).getEditor(); - if (editor) { editor.on('change', debounce(function () { callback(editor.getData()); }, 400)); + editor.on('mode', function () { var editable = editor.editable(); - if (!editable.isInline()) { editor.on('autoGrow', function (evt) { var doc = evt.editor.document; var scrollable = CKEDITOR.env.quirks ? doc.getBody() : doc.getDocumentElement(); - if (scrollable.$.scrollHeight < scrollable.$.clientHeight) { scrollable.setStyle('overflow-y', 'hidden'); } else { @@ -57,12 +53,10 @@ } }); } - return !!editor; }, attachInlineEditor: function attachInlineEditor(element, format, mainToolbarId, floatedToolbarId) { this._loadExternalPlugins(format); - format.editorSettings.drupal = { format: format.format }; @@ -76,8 +70,8 @@ top: mainToolbarId } }; - var sourceButtonFound = false; + var sourceButtonFound = false; for (var i = 0; !sourceButtonFound && i < settings.toolbar.length; i++) { if (settings.toolbar[i] !== '/') { for (var j = 0; !sourceButtonFound && j < settings.toolbar[i].items.length; j++) { @@ -90,7 +84,6 @@ } } } - settings.extraPlugins += ",".concat(settingsOverride.extraPlugins); settings.removePlugins += ",".concat(settingsOverride.removePlugins); settings.sharedSpaces = settingsOverride.sharedSpaces; @@ -101,7 +94,6 @@ }, _loadExternalPlugins: function _loadExternalPlugins(format) { var externalPlugins = format.editorSettings.drupalExternalPlugins; - if (externalPlugins) { Object.keys(externalPlugins || {}).forEach(function (pluginName) { CKEDITOR.plugins.addExternal(pluginName, externalPlugins[pluginName], ''); @@ -114,17 +106,18 @@ saveCallback: null, openDialog: function openDialog(editor, url, existingValues, saveCallback, dialogSettings) { var $target = $(editor.container.$); - if (editor.elementMode === CKEDITOR.ELEMENT_MODE_REPLACE) { $target = $target.find('.cke_contents'); } $target.css('position', 'relative').find('.ckeditor-dialog-loading').remove(); + var classes = dialogSettings.dialogClass ? dialogSettings.dialogClass.split(' ') : []; classes.push('ui-dialog--narrow'); dialogSettings.dialogClass = classes.join(' '); dialogSettings.autoResize = window.matchMedia('(min-width: 600px)').matches; dialogSettings.width = 'auto'; + var $content = $("<div class=\"ckeditor-dialog-loading\"><span style=\"top: -40px;\" class=\"ckeditor-dialog-loading-link\">".concat(Drupal.t('Loading...'), "</span></div>")); $content.appendTo($target); var ckeditorAjaxDialog = Drupal.ajax({ @@ -140,17 +133,21 @@ } }); ckeditorAjaxDialog.execute(); + window.setTimeout(function () { $content.find('span').animate({ top: '0px' }); }, 1000); + Drupal.ckeditor.saveCallback = saveCallback; } }; + $(window).on('dialogcreate', function (e, dialog, $element, settings) { $('.ui-dialog--narrow').css('zIndex', CKEDITOR.config.baseFloatZIndex + 1); }); + $(window).on('dialog:beforecreate', function (e, dialog, $element, settings) { $('.ckeditor-dialog-loading').animate({ top: '-40px' @@ -158,16 +155,19 @@ $(this).remove(); }); }); + $(window).on('editor:dialogsave', function (e, values) { if (Drupal.ckeditor.saveCallback) { Drupal.ckeditor.saveCallback(values); } }); + $(window).on('dialog:afterclose', function (e, dialog, $element) { if (Drupal.ckeditor.saveCallback) { Drupal.ckeditor.saveCallback = null; } }); + $(document).on('drupalViewportOffsetChange', function () { CKEDITOR.config.autoGrow_maxHeight = 0.7 * (window.innerHeight - displace.offsets.top - displace.offsets.bottom); }); @@ -175,26 +175,24 @@ function redirectTextareaFragmentToCKEditorInstance() { var hash = window.location.hash.substr(1); var element = document.getElementById(hash); - if (element) { var editor = CKEDITOR.dom.element.get(element).getEditor(); - if (editor) { var id = editor.container.getAttribute('id'); window.location.replace("#".concat(id)); } } } - $(window).on('hashchange.ckeditor', redirectTextareaFragmentToCKEditorInstance); + CKEDITOR.config.autoGrow_onStartup = true; + CKEDITOR.config.autoGrow_maxHeight = 0.7 * window.innerHeight; - CKEDITOR.timestamp = drupalSettings.ckeditor.timestamp; + CKEDITOR.timestamp = drupalSettings.ckeditor.timestamp; if (AjaxCommands) { AjaxCommands.prototype.ckeditor_add_stylesheet = function (ajax, response, status) { var editor = CKEDITOR.instances[response.editor_id]; - if (editor) { response.stylesheets.forEach(function (url) { editor.document.appendStyleSheet(url); diff --git a/core/modules/ckeditor/js/ckeditor.language.admin.js b/core/modules/ckeditor/js/ckeditor.language.admin.js index df9b5d794476fbf1d5e24b7e831f9210d5751921..fcb091d10be9c15106497abcde2f0920ad2429a9 100644 --- a/core/modules/ckeditor/js/ckeditor.language.admin.js +++ b/core/modules/ckeditor/js/ckeditor.language.admin.js @@ -4,17 +4,14 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { Drupal.behaviors.ckeditorLanguageSettingsSummary = { attach: function attach() { $('#edit-editor-settings-plugins-language').drupalSetSummary(function (context) { var $selected = $('#edit-editor-settings-plugins-language-language-list-type option:selected'); - if ($selected.length) { return $selected[0].textContent; } - return ''; }); } diff --git a/core/modules/ckeditor/js/ckeditor.off-canvas-css-reset.js b/core/modules/ckeditor/js/ckeditor.off-canvas-css-reset.js index e278cd634cc30be9818e6e19987285574232933f..5f7ff92c55521840e985b4ab0f9c1f64bfb85d7c 100644 --- a/core/modules/ckeditor/js/ckeditor.off-canvas-css-reset.js +++ b/core/modules/ckeditor/js/ckeditor.off-canvas-css-reset.js @@ -24,10 +24,11 @@ if (document.getElementById('ckeditor-off-canvas-reset')) { return; } - CKEDITOR.skinName = CKEDITOR.skin.name; + var editorCssPath = CKEDITOR.skin.getPath('editor'); var dialogCssPath = CKEDITOR.skin.getPath('dialog'); + var storedOffCanvasCss = window.localStorage.getItem("Drupal.off-canvas.css.".concat(editorCssPath).concat(dialogCssPath)); if (storedOffCanvasCss) { @@ -51,6 +52,5 @@ } }); }; - addCkeditorOffCanvasCss(); })(jQuery, CKEDITOR); \ No newline at end of file diff --git a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js index 3eb9cbb1e1000bc76b5905cd2f4ff91a35c4e9b0..8acc642a82cc0d4222189448a828aa29a73d078a 100644 --- a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js +++ b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js @@ -9,14 +9,13 @@ Drupal.behaviors.ckeditorStylesComboSettings = { attach: function attach(context) { var $context = $(context); + var $ckeditorActiveToolbar = $context.find('.ckeditor-toolbar-configuration').find('.ckeditor-toolbar-active'); var previousStylesSet = drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet; var that = this; $context.find('[name="editor[settings][plugins][stylescombo][styles]"]').on('blur.ckeditorStylesComboSettings', function () { var styles = this.value.trim(); - var stylesSet = that._generateStylesSetSetting(styles); - if (!_.isEqual(previousStylesSet, stylesSet)) { previousStylesSet = stylesSet; $ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [{ @@ -29,7 +28,6 @@ var stylesSet = []; styles = styles.replace(/\r/g, '\n'); var lines = styles.split('\n'); - for (var i = 0; i < lines.length; i++) { var style = lines[i].trim(); @@ -46,6 +44,7 @@ var label = parts[1]; var classes = selector.split('.'); var element = classes.shift(); + stylesSet.push({ attributes: { class: classes.join(' ') @@ -54,20 +53,18 @@ name: label }); } - return stylesSet; } }; + Drupal.behaviors.ckeditorStylesComboSettingsSummary = { attach: function attach() { $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary(function (context) { var stylesElement = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]'); var styles = stylesElement ? stylesElement.value.trim() : ''; - if (styles.length === 0) { return Drupal.t('No styles configured'); } - var count = styles.split('\n').length; return Drupal.t('@count styles configured', { '@count': count diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 34b0cc05197c3e5a75dd91ef85be315367098b9b..17cc93d22ffa6013f6d05980b37672396a521481 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -8,11 +8,9 @@ (function ($, Drupal, CKEDITOR) { function getFocusedWidget(editor) { var widget = editor.widgets.focused; - if (widget && widget.name === 'image') { return widget; } - return null; } @@ -20,22 +18,22 @@ if (!editor.plugins.drupallink) { return; } - CKEDITOR.plugins.drupallink.registerLinkableWidget('image'); + editor.getCommand('drupalunlink').on('exec', function (evt) { var widget = getFocusedWidget(editor); if (!widget || !widget.parts.link) { return; } - widget.setData('link', null); + this.refresh(editor, editor.elementPath()); evt.cancel(); }); + editor.getCommand('drupalunlink').on('refresh', function (evt) { var widget = getFocusedWidget(editor); - if (!widget) { return; } @@ -44,7 +42,6 @@ evt.cancel(); }); } - CKEDITOR.plugins.add('drupalimage', { requires: 'image2', icons: 'drupalimage', @@ -52,7 +49,6 @@ beforeInit: function beforeInit(editor) { editor.on('widgetDefinition', function (event) { var widgetDefinition = event.data; - if (widgetDefinition.name !== 'image') { return; } @@ -75,6 +71,7 @@ alt: '' } }); + var requiredContent = widgetDefinition.requiredContent.getDefinition(); requiredContent.attributes['data-entity-type'] = ''; requiredContent.attributes['data-entity-uuid'] = ''; @@ -91,7 +88,6 @@ if (element.name !== 'img') { return; } - if (element.attributes['data-cke-realelement']) { return; } @@ -102,11 +98,9 @@ }; var originalGetClasses = widgetDefinition.getClasses; - widgetDefinition.getClasses = function () { var classes = originalGetClasses.call(this); var captionedClasses = (this.editor.config.image2_captionedClass || '').split(/\s+/); - if (captionedClasses.length && classes) { for (var i = 0; i < captionedClasses.length; i++) { if (captionedClasses[i] in classes) { @@ -114,7 +108,6 @@ } } } - return classes; }; @@ -154,20 +147,19 @@ if (!firstEdit) { widget.focus(); } - editor.fire('saveSnapshot'); + var container = widget.wrapper.getParent(true); var image = widget.parts.image; var data = widgetDefinition._dialogValuesToData(dialogReturnValues.attributes); - widget.setData(data); + widget = editor.widgets.getByElement(image); if (firstEdit) { editor.widgets.finalizeCreation(container); } - setTimeout(function () { widget.focus(); editor.fire('saveSnapshot'); @@ -175,9 +167,7 @@ return widget; }; }; - var originalInit = widgetDefinition.init; - widgetDefinition.init = function () { originalInit.call(this); @@ -186,15 +176,15 @@ } }; }); + editor.widgets.on('instanceCreated', function (event) { var widget = event.data; - if (widget.name !== 'image') { return; } - widget.on('edit', function (event) { event.cancel(); + editor.execCommand('editdrupalimage', { existingValues: widget.definition._dataToDialogValues(widget.data), saveCallback: widget.definition._createDialogSaveCallback(editor, widget), @@ -202,6 +192,7 @@ }); }); }); + editor.addCommand('editdrupalimage', { allowedContent: 'img[alt,!src,width,height,!data-entity-type,!data-entity-uuid]', requiredContent: 'img[alt,src,data-entity-type,data-entity-uuid]', @@ -233,7 +224,6 @@ CKEDITOR.plugins.image2.getLinkAttributesParser = function () { return CKEDITOR.plugins.drupallink.parseLinkAttributes; }; - CKEDITOR.plugins.image2.getLinkAttributesGetter = function () { return CKEDITOR.plugins.drupallink.getLinkAttributes; }; diff --git a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js index 292f7b85b6e462a0a53e2cabcc0e460c428d500e..342dbd9d05fdc32bb3a5696a7ee227097803335c 100644 --- a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js @@ -10,7 +10,6 @@ if (element.name === name) { return element; } - var found = null; element.forEach(function (el) { if (el.name === name) { @@ -20,21 +19,22 @@ }, CKEDITOR.NODE_ELEMENT); return found; } - CKEDITOR.plugins.add('drupalimagecaption', { requires: 'drupalimage', beforeInit: function beforeInit(editor) { editor.lang.image2.captionPlaceholder = ''; + var placeholderText = editor.config.drupalImageCaption_captionPlaceholderText; + editor.on('widgetDefinition', function (event) { var widgetDefinition = event.data; - if (widgetDefinition.name !== 'image') { return; } var captionFilterEnabled = editor.config.drupalImageCaption_captionFilterEnabled; var alignFilterEnabled = editor.config.drupalImageCaption_alignFilterEnabled; + CKEDITOR.tools.extend(widgetDefinition.features, { caption: { requiredContent: 'img[data-caption]' @@ -43,28 +43,28 @@ requiredContent: 'img[data-align]' } }, true); + var requiredContent = widgetDefinition.requiredContent.getDefinition(); requiredContent.attributes['data-align'] = ''; requiredContent.attributes['data-caption'] = ''; widgetDefinition.requiredContent = new CKEDITOR.style(requiredContent); widgetDefinition.allowedContent.img.attributes['!data-align'] = true; widgetDefinition.allowedContent.img.attributes['!data-caption'] = true; + widgetDefinition.editables.caption.allowedContent = 'a[!href]; em strong cite code br'; - var originalDowncast = widgetDefinition.downcast; + var originalDowncast = widgetDefinition.downcast; widgetDefinition.downcast = function (element) { var img = findElementByName(element, 'img'); originalDowncast.call(this, img); var caption = this.editables.caption; var captionHtml = caption && caption.getData(); var attrs = img.attributes; - if (captionFilterEnabled) { if (captionHtml) { attrs['data-caption'] = captionHtml; } } - if (alignFilterEnabled) { if (this.data.align !== 'none') { attrs['data-align'] = this.data.align; @@ -74,28 +74,22 @@ if (img.parent.name === 'a') { return img.parent; } - return img; }; var originalUpcast = widgetDefinition.upcast; - widgetDefinition.upcast = function (element, data) { if (element.name !== 'img' || !element.attributes['data-entity-type'] || !element.attributes['data-entity-uuid']) { return; } - if (element.attributes['data-cke-realelement']) { return; } - element = originalUpcast.call(this, element, data); var attrs = element.attributes; - if (element.parent.name === 'a') { element = element.parent; } - var retElement = element; var caption; @@ -103,33 +97,26 @@ caption = attrs['data-caption']; delete attrs['data-caption']; } - if (alignFilterEnabled) { data.align = attrs['data-align']; delete attrs['data-align']; } - data['data-entity-type'] = attrs['data-entity-type']; delete attrs['data-entity-type']; data['data-entity-uuid'] = attrs['data-entity-uuid']; delete attrs['data-entity-uuid']; - if (captionFilterEnabled) { if (element.parent.name === 'p' && caption) { var index = element.getIndex(); var splitBefore = index > 0; var splitAfter = index + 1 < element.parent.children.length; - if (splitBefore) { element.parent.split(index); } - index = element.getIndex(); - if (splitAfter) { element.parent.split(index + 1); } - element.parent.replaceWith(element); retElement = element; } @@ -139,6 +126,7 @@ caption = new CKEDITOR.htmlParser.fragment.fromHtml(caption, 'figcaption'); var captionFilter = new CKEDITOR.filter(widgetDefinition.editables.caption.allowedContent); captionFilter.applyTo(caption); + caption.attributes['data-placeholder'] = placeholderText; element.replaceWith(figure); figure.add(element); @@ -147,7 +135,6 @@ retElement = figure; } } - if (alignFilterEnabled) { if (data.align === 'center' && (!captionFilterEnabled || !caption)) { var p = new CKEDITOR.htmlParser.element('p'); @@ -166,8 +153,8 @@ 'data-caption': 'data-caption', hasCaption: 'hasCaption' }); - var originalCreateDialogSaveCallback = widgetDefinition._createDialogSaveCallback; + var originalCreateDialogSaveCallback = widgetDefinition._createDialogSaveCallback; widgetDefinition._createDialogSaveCallback = function (editor, widget) { var saveCallback = originalCreateDialogSaveCallback.call(this, editor, widget); return function (dialogReturnValues) { @@ -176,8 +163,8 @@ if (dialogReturnValues.attributes.hasCaption) { actualWidget.editables.caption.setAttribute('data-placeholder', placeholderText); - var captionElement = actualWidget.editables.caption.$; + var captionElement = actualWidget.editables.caption.$; if (captionElement.childNodes.length === 1 && captionElement.childNodes.item(0).nodeName === 'BR') { captionElement.removeChild(captionElement.childNodes.item(0)); } @@ -189,7 +176,6 @@ afterInit: function afterInit(editor) { var disableButtonIfOnWidget = function disableButtonIfOnWidget(evt) { var widget = editor.widgets.focused; - if (widget && widget.name === 'image') { this.setState(CKEDITOR.TRISTATE_DISABLED); evt.cancel(); @@ -199,7 +185,6 @@ if (editor.plugins.justify && !editor.config.drupalImageCaption_alignFilterEnabled) { var cmd; var commands = ['justifyleft', 'justifycenter', 'justifyright', 'justifyblock']; - for (var n = 0; n < commands.length; n++) { cmd = editor.getCommand(commands[n]); cmd.contextSensitive = 1; diff --git a/core/modules/ckeditor/js/plugins/drupallink/plugin.js b/core/modules/ckeditor/js/plugins/drupallink/plugin.js index b06b276757ee09bcba0ff121730c3aa70c892808..3e535e6eafb4031055755af177329fc793ca1701 100644 --- a/core/modules/ckeditor/js/plugins/drupallink/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupallink/plugin.js @@ -11,31 +11,28 @@ var domElement = element.$; var attribute; var attributeName; - for (var attrIndex = 0; attrIndex < domElement.attributes.length; attrIndex++) { attribute = domElement.attributes.item(attrIndex); attributeName = attribute.nodeName.toLowerCase(); - if (attributeName.indexOf('data-cke-') === 0) { continue; } - parsedAttributes[attributeName] = element.data("cke-saved-".concat(attributeName)) || attribute.nodeValue; } if (parsedAttributes.class) { parsedAttributes.class = CKEDITOR.tools.trim(parsedAttributes.class.replace(/cke_\S+/, '')); } - return parsedAttributes; } - function getAttributes(editor, data) { var set = {}; Object.keys(data || {}).forEach(function (attributeName) { set[attributeName] = data[attributeName]; }); + set['data-cke-saved-href'] = set.href; + var removed = {}; Object.keys(set).forEach(function (s) { delete removed[s]; @@ -45,7 +42,6 @@ removed: CKEDITOR.tools.objectKeys(removed) }; } - var registeredLinkableWidgets = []; function registerLinkableWidget(widgetName) { @@ -54,32 +50,25 @@ function getFocusedLinkableWidget(editor) { var widget = editor.widgets.focused; - if (widget && registeredLinkableWidgets.indexOf(widget.name) !== -1) { return widget; } - return null; } function getSelectedLink(editor) { var selection = editor.getSelection(); var selectedElement = selection.getSelectedElement(); - if (selectedElement && selectedElement.is('a')) { return selectedElement; } - var range = selection.getRanges(true)[0]; - if (range) { range.shrink(CKEDITOR.SHRINK_TEXT); return editor.elementPath(range.getCommonAncestor()).contains('a', 1); } - return null; } - CKEDITOR.plugins.add('drupallink', { icons: 'drupallink,drupalunlink', hidpi: true, @@ -106,11 +95,12 @@ exec: function exec(editor) { var focusedLinkableWidget = getFocusedLinkableWidget(editor); var linkElement = getSelectedLink(editor); - var existingValues = {}; + var existingValues = {}; if (linkElement && linkElement.$) { existingValues = parseAttributes(editor, linkElement); - } else if (focusedLinkableWidget && focusedLinkableWidget.data.link) { + } + else if (focusedLinkableWidget && focusedLinkableWidget.data.link) { existingValues = CKEDITOR.tools.clone(focusedLinkableWidget.data.link); } @@ -120,7 +110,6 @@ editor.fire('saveSnapshot'); return; } - editor.fire('saveSnapshot'); if (!linkElement && returnValues.attributes.href) { @@ -140,14 +129,17 @@ style.type = CKEDITOR.STYLE_INLINE; style.applyToRange(range); range.select(); + linkElement = getSelectedLink(editor); - } else if (linkElement) { + } + else if (linkElement) { Object.keys(returnValues.attributes || {}).forEach(function (attrName) { if (returnValues.attributes[attrName].length > 0) { var value = returnValues.attributes[attrName]; linkElement.data("cke-saved-".concat(attrName), value); linkElement.setAttribute(attrName, value); - } else { + } + else { linkElement.removeAttribute(attrName); } }); @@ -155,11 +147,11 @@ editor.fire('saveSnapshot'); }; - var dialogSettings = { title: linkElement ? editor.config.drupalLink_dialogTitleEdit : editor.config.drupalLink_dialogTitleAdd, dialogClass: 'editor-link-dialog' }; + Drupal.ckeditor.openDialog(editor, Drupal.url("editor/dialog/link/".concat(editor.config.drupal.format)), existingValues, saveCallback, dialogSettings); } }); @@ -182,7 +174,6 @@ }, refresh: function refresh(editor, path) { var element = path.lastElement && path.lastElement.getAscendant('a', true); - if (element && element.getName() === 'a' && element.getAttribute('href') && element.getChildCount()) { this.setState(CKEDITOR.TRISTATE_OFF); } else { @@ -190,6 +181,7 @@ } } }); + editor.setKeystroke(CKEDITOR.CTRL + 75, 'drupallink'); if (editor.ui.addButton) { @@ -202,10 +194,8 @@ command: 'drupalunlink' }); } - editor.on('doubleclick', function (evt) { var element = getSelectedLink(editor) || evt.data.element; - if (!element.isReadOnly()) { if (element.is('a')) { editor.getSelection().selectElement(element); @@ -236,27 +226,23 @@ if (!element || element.isReadOnly()) { return null; } - var anchor = getSelectedLink(editor); - if (!anchor) { return null; } - var menu = {}; - if (anchor.getAttribute('href') && anchor.getChildCount()) { menu = { link: CKEDITOR.TRISTATE_OFF, unlink: CKEDITOR.TRISTATE_OFF }; } - return menu; }); } } }); + CKEDITOR.plugins.drupallink = { parseLinkAttributes: parseAttributes, getLinkAttributes: getAttributes, diff --git a/core/modules/ckeditor/js/plugins/drupalmedia/plugin.js b/core/modules/ckeditor/js/plugins/drupalmedia/plugin.js index 626931693ca1b104af71eb034c8f98c0b0c3da03..f7197acc5b157d2eea4f46ba21bdc981407f8477 100644 --- a/core/modules/ckeditor/js/plugins/drupalmedia/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalmedia/plugin.js @@ -8,11 +8,9 @@ (function (jQuery, Drupal, CKEDITOR) { function getFocusedWidget(editor) { var widget = editor.widgets.focused; - if (widget && widget.name === 'drupalmedia') { return widget; } - return null; } @@ -20,26 +18,21 @@ if (!editor.plugins.drupallink) { return; } - CKEDITOR.plugins.drupallink.registerLinkableWidget('drupalmedia'); editor.getCommand('drupalunlink').on('exec', function (evt) { var widget = getFocusedWidget(editor); - if (!widget) { return; } - widget.setData('link', null); this.refresh(editor, editor.elementPath()); evt.cancel(); }); editor.getCommand('drupalunlink').on('refresh', function (evt) { var widget = getFocusedWidget(editor); - if (!widget) { return; } - this.setState(widget.data.link ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED); evt.cancel(); }); @@ -47,23 +40,19 @@ if (editor.contextMenu) { editor.contextMenu.addListener(function () { var widget = getFocusedWidget(editor); - if (!widget) { return; } - if (widget.data.link) { return { link: CKEDITOR.TRISTATE_OFF, unlink: CKEDITOR.TRISTATE_OFF }; } - return {}; }); } } - CKEDITOR.plugins.add('drupalmedia', { requires: 'widget', beforeInit: function beforeInit(editor) { @@ -110,26 +99,20 @@ if (this.data.label) { return this.data.label; } - return Drupal.t('Embedded media'); }, upcast: function upcast(element, data) { var attributes = element.attributes; - if (element.name !== 'drupal-media' || attributes['data-entity-type'] !== 'media' || attributes['data-entity-uuid'] === undefined) { return; } - data.attributes = CKEDITOR.tools.copy(attributes); data.hasCaption = data.attributes.hasOwnProperty('data-caption'); - if (data.hasCaption && data.attributes['data-caption'] === '') { data.attributes['data-caption'] = ' '; } - data.label = null; data.link = null; - if (element.parent.name === 'a') { data.link = CKEDITOR.tools.copy(element.parent.attributes); Object.keys(element.parent.attributes).forEach(function (attrName) { @@ -138,13 +121,10 @@ } }); } - var hostEntityLangcode = document.getElementById(editor.name).getAttribute('data-media-embed-host-entity-langcode'); - if (hostEntityLangcode) { data.hostEntityLangcode = hostEntityLangcode; } - return element; }, destroy: function destroy() { @@ -152,7 +132,6 @@ }, data: function data(event) { var _this = this; - if (this.oldData) { if (!this.data.hasCaption && this.oldData.hasCaption) { delete this.data.attributes['data-caption']; @@ -160,17 +139,12 @@ this.data.attributes['data-caption'] = ' '; } } - if (this._previewNeedsServerSideUpdate()) { editor.fire('lockSnapshot'); - this._tearDownDynamicEditables(); - this._loadPreview(function (widget) { widget._setUpDynamicEditables(); - widget._setUpEditButton(); - editor.fire('unlockSnapshot'); }); } @@ -180,31 +154,27 @@ _this.element.removeAttribute(attrName); }); } - this.element.setAttributes(this.data.attributes); + this.oldData = CKEDITOR.tools.clone(this.data); }, downcast: function downcast() { var downcastElement = new CKEDITOR.htmlParser.element('drupal-media', this.data.attributes); - if (this.data.link) { var link = new CKEDITOR.htmlParser.element('a', this.data.link); link.add(downcastElement); return link; } - return downcastElement; }, _setUpDynamicEditables: function _setUpDynamicEditables() { var _this2 = this; - if (this.initEditable('caption', this.definition.editables.caption)) { var captionEditable = this.editables.caption; captionEditable.setAttribute('data-placeholder', Drupal.t('Enter caption here')); this.captionObserver = new MutationObserver(function () { var mediaAttributes = CKEDITOR.tools.clone(_this2.data.attributes); mediaAttributes['data-caption'] = captionEditable.getData(); - _this2.setData('attributes', mediaAttributes); }); this.captionObserver.observe(captionEditable.$, { @@ -213,7 +183,6 @@ childList: true, subtree: true }); - if (captionEditable.$.childNodes.length === 1 && captionEditable.$.childNodes.item(0).nodeName === 'BR') { captionEditable.$.removeChild(captionEditable.$.childNodes.item(0)); } @@ -230,20 +199,18 @@ var embeddedMediaContainer = this.data.hasCaption ? this.element.findOne('figure') : this.element; var embeddedMedia = embeddedMediaContainer.getFirst(isElementNode); - if (this.data.link) { embeddedMedia = embeddedMedia.getFirst(isElementNode); } - embeddedMedia.setStyle('position', 'relative'); var editButton = CKEDITOR.dom.element.createFromHtml(Drupal.theme('mediaEmbedEditButton')); embeddedMedia.getFirst().insertBeforeMe(editButton); + var widget = this; this.element.findOne('.media-library-item__edit').on('click', function (event) { var saveCallback = function saveCallback(values) { event.cancel(); editor.fire('saveSnapshot'); - if (values.hasOwnProperty('attributes')) { CKEDITOR.tools.extend(values.attributes, widget.data.attributes); Object.keys(values.attributes).forEach(function (prop) { @@ -252,27 +219,23 @@ } }); } - widget.setData({ attributes: values.attributes, hasCaption: !!values.hasCaption }); editor.fire('saveSnapshot'); }; - Drupal.ckeditor.openDialog(editor, Drupal.url("editor/dialog/media/".concat(editor.config.drupal.format)), widget.data, saveCallback, {}); }); + this.element.findOne('.media-library-item__edit').on('keydown', function (event) { var returnKey = 13; var spaceBar = 32; - if (typeof event.data !== 'undefined') { var keypress = event.data.getKey(); - if (keypress === returnKey || keypress === spaceBar) { event.sender.$.click(); } - event.data.$.stopPropagation(); event.data.$.stopImmediatePropagation(); } @@ -287,23 +250,19 @@ if (!this.ready) { return true; } - return this._hashData(this.oldData) !== this._hashData(this.data); }, _hashData: function _hashData(data) { var dataToHash = CKEDITOR.tools.clone(data); delete dataToHash.attributes['data-caption']; delete dataToHash.label; - if (dataToHash.link) { delete dataToHash.link.href; } - return JSON.stringify(dataToHash); }, _loadPreview: function _loadPreview(callback) { var _this3 = this; - jQuery.get({ url: Drupal.url("media/".concat(editor.config.drupal.format, "/preview")), data: { @@ -316,9 +275,7 @@ }, success: function success(previewHtml, textStatus, jqXhr) { _this3.element.setHtml(previewHtml); - _this3.setData('label', jqXhr.getResponseHeader('Drupal-Media-Label')); - callback(_this3); }, error: function error() { diff --git a/core/modules/ckeditor/js/plugins/drupalmedialibrary/plugin.js b/core/modules/ckeditor/js/plugins/drupalmedialibrary/plugin.js index bfb1e19529a27b8fb78893d5e2037ba566b8c2c1..5ef5386dcc554af782a76d65e7eb3e3a3a7abb80 100644 --- a/core/modules/ckeditor/js/plugins/drupalmedialibrary/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalmedialibrary/plugin.js @@ -52,7 +52,6 @@ Drupal.ckeditor.openDialog(editor, editor.config.DrupalMediaLibrary_url, {}, saveCallback, editor.config.DrupalMediaLibrary_dialogOptions); } }); - if (editor.ui.addButton) { editor.ui.addButton('DrupalMediaLibrary', { label: Drupal.t('Insert from Media Library'), diff --git a/core/modules/ckeditor/js/views/AuralView.js b/core/modules/ckeditor/js/views/AuralView.js index 6ffd0e324090ed1297766298a76a6fe31e5cde7d..6fdf6fba410ed1ec5f50b9dd3e89d41c92997d35 100644 --- a/core/modules/ckeditor/js/views/AuralView.js +++ b/core/modules/ckeditor/js/views/AuralView.js @@ -20,10 +20,8 @@ announceMove: function announceMove(model, isDirty) { if (!isDirty) { var item = document.activeElement || null; - if (item) { var $item = $(item); - if ($item.hasClass('ckeditor-toolbar-group')) { this.announceButtonGroupPosition($item); } else if ($item.parent().hasClass('ckeditor-button')) { @@ -37,7 +35,6 @@ var $originalTarget = $(event.target); var $currentTarget = $(event.currentTarget); var $parent = $currentTarget.parent(); - if ($parent.hasClass('ckeditor-button') || $parent.hasClass('ckeditor-button-separator')) { this.announceButtonPosition($currentTarget.parent()); } else if ($originalTarget.attr('role') !== 'button' && $currentTarget.hasClass('ckeditor-toolbar-group')) { @@ -59,12 +56,10 @@ '@row': row, '@rowCount': rowCount }); - if (position === 1 && row === rowCount) { text += '\n'; text += Drupal.t('Press the down arrow key to create a new row.'); } - Drupal.announce(text, 'assertive'); }, announceButtonPosition: function announceButtonPosition($button) { @@ -81,7 +76,6 @@ var rowCount = $rows.not('.placeholder').length; var type = $button.attr('data-drupal-ckeditor-type') === 'separator' ? '' : Drupal.t('button'); var text; - if ($button.closest('.ckeditor-toolbar-disabled').length > 0) { text = Drupal.t('@name @type.', { '@name': $button.children().attr('aria-label'), @@ -89,7 +83,8 @@ }); text += "\n".concat(Drupal.t('Press the down arrow key to activate.')); Drupal.announce(text, 'assertive'); - } else if ($group.not('.placeholder').length === 1) { + } + else if ($group.not('.placeholder').length === 1) { text = Drupal.t('@name @type in position @position of @positionCount in @groupName button group in row @row of @rowCount.', { '@name': $button.children().attr('aria-label'), '@type': type, @@ -99,17 +94,14 @@ '@row': row, '@rowCount': rowCount }); - if (groupPosition === 1 && position === 1 && row === rowCount) { text += '\n'; text += Drupal.t('Press the down arrow key to create a new button group in a new row.'); } - if (groupPosition === groupPositionCount && position === positionCount) { text += '\n'; text += Drupal.t('This is the last group. Move the button forward to create a new group.'); } - Drupal.announce(text, 'assertive'); } }, @@ -118,7 +110,6 @@ var $button = $link.parent(); var enabled = $button.closest('.ckeditor-toolbar-active').length > 0; var message; - if (enabled) { message = Drupal.t('The "@name" button is currently enabled.', { '@name': $link.attr('aria-label') @@ -131,7 +122,6 @@ }); message += "\n".concat(Drupal.t('Use the down arrow key to move this button into the active toolbar.')); } - Drupal.announce(message); event.preventDefault(); }, @@ -140,7 +130,6 @@ var $button = $link.parent(); var enabled = $button.closest('.ckeditor-toolbar-active').length > 0; var message; - if (enabled) { message = Drupal.t('This @name is currently enabled.', { '@name': $link.attr('aria-label') @@ -154,7 +143,6 @@ message += "\n".concat(Drupal.t('Use the down arrow key to move this separator into the active toolbar.')); message += "\n".concat(Drupal.t('You may add multiple separators to each button group.')); } - Drupal.announce(message); event.preventDefault(); } diff --git a/core/modules/ckeditor/js/views/ControllerView.js b/core/modules/ckeditor/js/views/ControllerView.js index 3194d62f65619a05a8968f507aa88ff95cd33a4c..e0cbb99dc1c24e10db3081557bc8026c53d2c2f4 100644 --- a/core/modules/ckeditor/js/views/ControllerView.js +++ b/core/modules/ckeditor/js/views/ControllerView.js @@ -10,19 +10,20 @@ events: {}, initialize: function initialize() { this.getCKEditorFeatures(this.model.get('hiddenEditorConfig'), this.disableFeaturesDisallowedByFilters.bind(this)); + this.model.listenTo(this.model, 'change:activeEditorConfig', this.model.sync); this.listenTo(this.model, 'change:isDirty', this.parseEditorDOM); }, parseEditorDOM: function parseEditorDOM(model, isDirty, options) { if (isDirty) { var currentConfig = this.model.get('activeEditorConfig'); + var rows = []; this.$el.find('.ckeditor-active-toolbar-configuration').children('.ckeditor-row').each(function () { var groups = []; $(this).find('.ckeditor-toolbar-group').each(function () { var $group = $(this); var $buttons = $group.find('.ckeditor-button'); - if ($buttons.length) { var group = { name: $group.attr('data-drupal-ckeditor-toolbar-group-name'), @@ -34,7 +35,6 @@ groups.push(group); } }); - if (groups.length) { rows.push(groups); } @@ -45,7 +45,6 @@ if (options.broadcast !== false) { var prev = this.getButtonList(currentConfig); var next = this.getButtonList(rows); - if (prev.length !== next.length) { this.$el.find('.ckeditor-toolbar-active').trigger('CKEditorToolbarChanged', [prev.length < next.length ? 'added' : 'removed', _.difference(_.union(prev, next), _.intersection(prev, next))[0]]); } @@ -56,11 +55,11 @@ var getProperties = function getProperties(CKEPropertiesList) { return _.isObject(CKEPropertiesList) ? _.keys(CKEPropertiesList) : []; }; - var convertCKERulesToEditorFeature = function convertCKERulesToEditorFeature(feature, CKEFeatureRules) { for (var i = 0; i < CKEFeatureRules.length; i++) { var CKERule = CKEFeatureRules[i]; var rule = new Drupal.EditorFeatureHTMLRule(); + var tags = getProperties(CKERule.elements); rule.required.tags = CKERule.propertiesOnly ? [] : tags; rule.allowed.tags = tags; @@ -76,36 +75,30 @@ }; var hiddenCKEditorID = 'ckeditor-hidden'; - if (CKEDITOR.instances[hiddenCKEditorID]) { CKEDITOR.instances[hiddenCKEditorID].destroy(true); } - var hiddenEditorConfig = this.model.get('hiddenEditorConfig'); - if (hiddenEditorConfig.drupalExternalPlugins) { var externalPlugins = hiddenEditorConfig.drupalExternalPlugins; Object.keys(externalPlugins || {}).forEach(function (pluginName) { CKEDITOR.plugins.addExternal(pluginName, externalPlugins[pluginName], ''); }); } - CKEDITOR.inline($("#".concat(hiddenCKEditorID)).get(0), CKEditorConfig); + CKEDITOR.once('instanceReady', function (e) { if (e.editor.name === hiddenCKEditorID) { var CKEFeatureRulesMap = {}; var rules = e.editor.filter.allowedContent; var rule; var name; - for (var i = 0; i < rules.length; i++) { rule = rules[i]; name = rule.featureName || ':('; - if (!CKEFeatureRulesMap[name]) { CKEFeatureRulesMap[name] = []; } - CKEFeatureRulesMap[name].push(rule); } @@ -116,7 +109,6 @@ convertCKERulesToEditorFeature(feature, CKEFeatureRulesMap[featureName]); features[featureName] = feature; var command = e.editor.getCommand(featureName); - if (command) { buttonsToFeatures[command.uiItems[0].name] = featureName; } @@ -131,46 +123,37 @@ } var featureName = this.model.get('buttonsToFeatures')[button.toLowerCase()]; - if (!featureName) { featureName = button.toLowerCase(); } - var featuresMetadata = this.model.get('featuresMetadata'); - if (!featuresMetadata[featureName]) { featuresMetadata[featureName] = new Drupal.EditorFeature(featureName); this.model.set('featuresMetadata', featuresMetadata); } - return featuresMetadata[featureName]; }, disableFeaturesDisallowedByFilters: function disableFeaturesDisallowedByFilters(features, buttonsToFeatures) { this.model.set('featuresMetadata', features); this.model.set('buttonsToFeatures', buttonsToFeatures); + this.broadcastConfigurationChanges(this.$el); - var existingButtons = []; + var existingButtons = []; var buttonGroups = _.flatten(this.model.get('activeEditorConfig')); - for (var i = 0; i < buttonGroups.length; i++) { var buttons = buttonGroups[i].items; - for (var k = 0; k < buttons.length; k++) { existingButtons.push(buttons[k]); } } - existingButtons = _.unique(existingButtons); - for (var n = 0; n < existingButtons.length; n++) { var button = existingButtons[n]; var feature = this.getFeatureForButton(button); - if (feature === false) { continue; } - if (Drupal.editorConfiguration.featureIsAllowedByFilters(feature)) { this.$el.find('.ckeditor-toolbar-active').trigger('CKEditorToolbarChanged', ['added', existingButtons[n]]); } else { @@ -188,7 +171,8 @@ var hiddenEditorConfig = this.model.get('hiddenEditorConfig'); var getFeatureForButton = this.getFeatureForButton.bind(this); var getCKEditorFeatures = this.getCKEditorFeatures.bind(this); - $ckeditorToolbar.find('.ckeditor-toolbar-active').on('CKEditorToolbarChanged.ckeditorAdmin', function (event, action, button) { + $ckeditorToolbar.find('.ckeditor-toolbar-active') + .on('CKEditorToolbarChanged.ckeditorAdmin', function (event, action, button) { var feature = getFeatureForButton(button); if (feature === false) { @@ -197,15 +181,16 @@ var configEvent = action === 'added' ? 'addedFeature' : 'removedFeature'; Drupal.editorConfiguration[configEvent](feature); - }).on('CKEditorPluginSettingsChanged.ckeditorAdmin', function (event, settingsChanges) { + }) + .on('CKEditorPluginSettingsChanged.ckeditorAdmin', function (event, settingsChanges) { Object.keys(settingsChanges || {}).forEach(function (key) { hiddenEditorConfig[key] = settingsChanges[key]; }); + getCKEditorFeatures(hiddenEditorConfig, function (features) { var featuresMetadata = view.model.get('featuresMetadata'); Object.keys(features || {}).forEach(function (name) { var feature = features[name]; - if (featuresMetadata.hasOwnProperty(name) && !_.isEqual(featuresMetadata[name], feature)) { Drupal.editorConfiguration.modifiedFeature(feature); } @@ -217,11 +202,13 @@ getButtonList: function getButtonList(config) { var buttons = []; config = _.flatten(config); + config.forEach(function (group) { group.items.forEach(function (button) { buttons.push(button); }); }); + return _.without(buttons, '-'); } }); diff --git a/core/modules/ckeditor/js/views/KeyboardView.js b/core/modules/ckeditor/js/views/KeyboardView.js index c1761ac626f79282638f3128fabc413fa4e49a3d..2154bf6b53ea2bd90d6c73ae48578b2c7fbdcb12 100644 --- a/core/modules/ckeditor/js/views/KeyboardView.js +++ b/core/modules/ckeditor/js/views/KeyboardView.js @@ -13,8 +13,15 @@ }, render: function render() {}, onPressButton: function onPressButton(event) { - var upDownKeys = [38, 63232, 40, 63233]; - var leftRightKeys = [37, 63234, 39, 63235]; + var upDownKeys = [38, + 63232, + 40, + 63233]; + + var leftRightKeys = [37, + 63234, + 39, + 63235]; if (event.keyCode === 13) { event.stopPropagation(); @@ -41,55 +48,57 @@ if (_.indexOf(leftRightKeys, event.keyCode) > -1) { var $siblings = $container.children(); var index = $siblings.index($button); - if (_.indexOf([37, 63234], event.keyCode) > -1) { if (index > 0) { $button.insertBefore($container.children().eq(index - 1)); - } else { + } + else { $group = $container.parent().prev(); - if ($group.length > 0) { $group.find('.ckeditor-toolbar-group-buttons').append($button); - } else { + } + else { $container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-group').not('.placeholder').find('.ckeditor-toolbar-group-buttons').eq(-1).append($button); } } - } else if (_.indexOf([39, 63235], event.keyCode) > -1) { + } + else if (_.indexOf([39, 63235], event.keyCode) > -1) { if (index < $siblings.length - 1) { $button.insertAfter($container.children().eq(index + 1)); - } else { + } + else { $container.parent().next().find('.ckeditor-toolbar-group-buttons').prepend($button); } } - } else if (_.indexOf(upDownKeys, event.keyCode) > -1) { + } + else if (_.indexOf(upDownKeys, event.keyCode) > -1) { dir = _.indexOf([38, 63232], event.keyCode) > -1 ? 'prev' : 'next'; $row = $container.closest('.ckeditor-row')[dir](); - if (dir === 'prev' && $row.length === 0) { if ($button.data('drupal-ckeditor-type') === 'separator') { $button.off().remove(); $activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).children().eq(0).children().trigger('focus'); - } else { + } + else { $availableButtons.prepend($button); } } else { $row.find('.ckeditor-toolbar-group-buttons').eq(0).prepend($button); } } - } else if (containerType === 'dividers') { + } + else if (containerType === 'dividers') { if (_.indexOf([40, 63233], event.keyCode) > -1) { $button = $button.clone(true); $activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).prepend($button); $target = $button.children(); } } - view = this; Drupal.ckeditor.registerButtonMove(this, $button, function (result) { if (!result && $originalGroup) { $originalGroup.find('.ckeditor-buttons').append($button); } - $target.trigger('focus'); }); event.preventDefault(); @@ -97,8 +106,15 @@ } }, onPressGroup: function onPressGroup(event) { - var upDownKeys = [38, 63232, 40, 63233]; - var leftRightKeys = [37, 63234, 39, 63235]; + var upDownKeys = [38, + 63232, + 40, + 63233]; + + var leftRightKeys = [37, + 63234, + 39, + 63235]; if (event.keyCode === 13) { var view = this; @@ -115,29 +131,30 @@ var $siblings = $container.children(); var index; var dir; - if (_.indexOf(leftRightKeys, event.keyCode) > -1) { index = $siblings.index($group); - if (_.indexOf([37, 63234], event.keyCode) > -1) { if (index > 0) { $group.insertBefore($siblings.eq(index - 1)); - } else { + } + else { var $rowChildElement = $container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-groups').children().eq(-1); $group.insertBefore($rowChildElement); } - } else if (_.indexOf([39, 63235], event.keyCode) > -1) { + } + else if (_.indexOf([39, 63235], event.keyCode) > -1) { if (!$siblings.eq(index + 1).hasClass('placeholder')) { $group.insertAfter($container.children().eq(index + 1)); - } else { + } + else { $container.closest('.ckeditor-row').next().find('.ckeditor-toolbar-groups').prepend($group); } } - } else if (_.indexOf(upDownKeys, event.keyCode) > -1) { + } + else if (_.indexOf(upDownKeys, event.keyCode) > -1) { dir = _.indexOf([38, 63232], event.keyCode) > -1 ? 'prev' : 'next'; $group.closest('.ckeditor-row')[dir]().find('.ckeditor-toolbar-groups').eq(0).prepend($group); } - Drupal.ckeditor.registerGroupMove(this, $group); $group.trigger('focus'); event.preventDefault(); diff --git a/core/modules/ckeditor/js/views/VisualView.js b/core/modules/ckeditor/js/views/VisualView.js index e7125d9ac7f2ea69757835524fbbdb4c4ac72d7a..d36a843d3c539a2c7a632b4c174c5025766d4c1b 100644 --- a/core/modules/ckeditor/js/views/VisualView.js +++ b/core/modules/ckeditor/js/views/VisualView.js @@ -14,14 +14,15 @@ }, initialize: function initialize() { this.listenTo(this.model, 'change:isDirty change:groupNamesVisible', this.render); + $(Drupal.theme('ckeditorButtonGroupNamesToggle')).prependTo(this.$el.find('#ckeditor-active-toolbar').parent()); this.render(); }, render: function render(model, value, changedAttributes) { this.insertPlaceholders(); this.applySorting(); - var groupNamesVisible = this.model.get('groupNamesVisible'); + var groupNamesVisible = this.model.get('groupNamesVisible'); if (changedAttributes && changedAttributes.changes && changedAttributes.changes.isDirty) { this.model.set({ groupNamesVisible: true @@ -30,7 +31,6 @@ }); groupNamesVisible = true; } - this.$el.find('[data-toolbar="active"]').toggleClass('ckeditor-group-names-are-visible', groupNamesVisible); var $toggle = this.$el.find('.ckeditor-groupnames-toggle'); $toggle.each(function (index, element) { @@ -65,6 +65,7 @@ }, startButtonDrag: function startButtonDrag(event) { this.$el.find('a:focus').trigger('blur'); + this.model.set('groupNamesVisible', true); }, endButtonDrag: function endButtonDrag(event) { @@ -75,7 +76,6 @@ }, applySorting: function applySorting() { var _this = this; - Array.prototype.forEach.call(this.el.querySelectorAll('.ckeditor-buttons:not(.js-sortable)'), function (buttons) { buttons.classList.add('js-sortable'); Sortable.create(buttons, { @@ -109,30 +109,28 @@ }, insertPlaceholderRow: function insertPlaceholderRow() { var $rows = this.$el.find('.ckeditor-row'); - if (!$rows.eq(-1).hasClass('placeholder')) { this.$el.find('.ckeditor-toolbar-active').children('.ckeditor-active-toolbar-configuration').append(Drupal.theme('ckeditorRow')); } - $rows = this.$el.find('.ckeditor-row'); var len = $rows.length; $rows.filter(function (index, row) { if (index + 1 === len) { return false; } - return $(row).find('.ckeditor-toolbar-group').not('.placeholder').length === 0; - }).remove(); + }) + .remove(); }, insertNewGroupButtons: function insertNewGroupButtons() { this.$el.find('.ckeditor-row').each(function () { var $row = $(this); var $groups = $row.find('.ckeditor-toolbar-group'); var $button = $row.find('.ckeditor-add-new-group'); - if ($button.length === 0) { $row.children('.ckeditor-toolbar-groups').append(Drupal.theme('ckeditorNewButtonGroup')); - } else if (!$groups.eq(-1).hasClass('ckeditor-add-new-group')) { + } + else if (!$groups.eq(-1).hasClass('ckeditor-add-new-group')) { $button.appendTo($row.children('.ckeditor-toolbar-groups')); } }); diff --git a/core/modules/ckeditor5/js/ckeditor5.admin.js b/core/modules/ckeditor5/js/ckeditor5.admin.js index bff2bc1c025cedf66855eb947635fb5ebc37520f..32a6cd1cf46a675248df93ff883625392f27c223 100644 --- a/core/modules/ckeditor5/js/ckeditor5.admin.js +++ b/core/modules/ckeditor5/js/ckeditor5.admin.js @@ -4,37 +4,21 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } - function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } - function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } (function (Drupal, drupalSettings, $, JSON, once, Sortable, _ref) { @@ -56,38 +40,43 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var Observable = function () { function Observable(value) { _classCallCheck(this, Observable); - this._listeners = []; this._value = value; } _createClass(Observable, [{ key: "notify", - value: function notify() { + value: + function notify() { var _this = this; - this._listeners.forEach(function (listener) { return listener(_this._value); }); } + }, { key: "subscribe", - value: function subscribe(listener) { + value: + function subscribe(listener) { this._listeners.push(listener); } + }, { key: "value", - get: function get() { + get: + function get() { return this._value; - }, - set: function set(val) { + } + + , + set: + function set(val) { if (val !== this._value) { this._value = val; this.notify(); } } }]); - return Observable; }(); @@ -104,6 +93,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var priorValue = textarea.innerHTML; textarea.value = newValue; textarea.innerHTML = newValue; + textarea.dispatchEvent(new CustomEvent('change', { detail: { priorValue: priorValue @@ -113,10 +103,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var addToSelectedButtons = function addToSelectedButtons(selection, element, announceChange) { var list = _toConsumableArray(selection.value); - list.push(element.dataset.id); selection.value = list; - if (announceChange) { setTimeout(function () { announceChange(element.dataset.label); @@ -126,13 +114,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var removeFromSelectedButtons = function removeFromSelectedButtons(selection, element, announceChange) { var list = _toConsumableArray(selection.value); - var index = Array.from(element.parentElement.children).findIndex(function (child) { return child === element; }); list.splice(index, 1); selection.value = list; - if (announceChange) { setTimeout(function () { announceChange(element.dataset.label); @@ -142,12 +128,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var moveWithinSelectedButtons = function moveWithinSelectedButtons(selection, element, dir) { var list = _toConsumableArray(selection.value); - var index = Array.from(element.parentElement.children).findIndex(function (child) { return child === element; }); var condition = dir < 0 ? index > 0 : index < list.length - 1; - if (condition) { list.splice(index + dir, 0, list.splice(index, 1)[0]); selection.value = list; @@ -156,7 +140,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var copyToActiveButtons = function copyToActiveButtons(selection, element, announceChange) { var list = _toConsumableArray(selection.value); - list.push(element.dataset.id); selection.value = list; setTimeout(function () { @@ -172,12 +155,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }).map(function (helpItem) { return helpItem.message; }); + var existingToolbarHelpText = document.querySelector('[data-drupal-selector="ckeditor5-admin-help-message"]'); if (existingToolbarHelpText && toolbarHelpText.join('').trim() !== existingToolbarHelpText.textContent.trim()) { Drupal.announce(toolbarHelpText.join(' ')); } - root.innerHTML = Drupal.theme.ckeditor5Admin({ availableButtons: Drupal.theme.ckeditor5AvailableButtons({ buttons: availableButtons.filter(function (button) { @@ -192,6 +175,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }), helpMessage: toolbarHelpText }); + new Sortable(root.querySelector('[data-button-list="ckeditor5-toolbar-active-buttons"]'), { group: { name: 'toolbar', @@ -235,13 +219,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d buttonElement.setAttribute('data-expanded', true); }); }; - var retractButton = function retractButton(event) { event.currentTarget.querySelectorAll('.ckeditor5-toolbar-button').forEach(function (buttonElement) { buttonElement.setAttribute('data-expanded', false); }); }; - element.addEventListener('mouseenter', expandButton); element.addEventListener('focus', expandButton); element.addEventListener('mouseleave', retractButton); @@ -249,7 +231,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d element.addEventListener('keyup', function (event) { var supportedKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; var dir = document.documentElement.dir; - if (supportedKeys.includes(event.key)) { if (event.currentTarget.dataset.divider.toLowerCase() === 'true') { switch (event.key) { @@ -260,7 +241,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d '@name': name })); }; - copyToActiveButtons(selectedButtons, event.currentTarget, announceChange); root.querySelector('[data-button-list="ckeditor5-toolbar-active-buttons"] li:last-child').focus(); break; @@ -270,7 +250,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var index = Array.from(element.parentElement.children).findIndex(function (child) { return child === element; }); - switch (event.key) { case 'ArrowLeft': { @@ -279,7 +258,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d root.querySelectorAll('[data-button-list="ckeditor5-toolbar-active-buttons"] li')[index + leftOffset].focus(); break; } - case 'ArrowRight': { var rightOffset = dir === 'ltr' ? 1 : -1; @@ -287,7 +265,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d root.querySelectorAll('[data-button-list="ckeditor5-toolbar-active-buttons"] li')[index + rightOffset].focus(); break; } - case 'ArrowUp': { var _announceChange = function _announceChange(name) { @@ -295,15 +272,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d '@name': name })); }; - removeFromSelectedButtons(selectedButtons, event.currentTarget, _announceChange); - if (!dividerButtons.find(function (dividerButton) { return event.currentTarget.dataset.id === dividerButton.id; })) { root.querySelector("[data-button-list=\"ckeditor5-toolbar-available-buttons\"] [data-id=\"".concat(event.currentTarget.dataset.id, "\"]")).focus(); } - break; } } @@ -316,7 +290,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d '@name': name })); }; - addToSelectedButtons(selectedButtons, event.currentTarget, _announceChange2); root.querySelector('[data-button-list="ckeditor5-toolbar-active-buttons"] li:last-child').focus(); break; @@ -334,9 +307,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var selectedTextarea = context.querySelector('#ckeditor5-toolbar-buttons-selected'); var available = Object.entries(JSON.parse(context.querySelector('#ckeditor5-toolbar-buttons-available').innerHTML)).map(function (_ref2) { var _ref3 = _slicedToArray(_ref2, 2), - name = _ref3[0], - attrs = _ref3[1]; - + name = _ref3[0], + attrs = _ref3[1]; return _objectSpread({ name: name, id: name @@ -351,12 +323,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d name: '-', label: Drupal.t('Wrapping') }]; + var selected = new Observable(JSON.parse(selectedTextarea.innerHTML).map(function (name) { return [].concat(dividers, _toConsumableArray(available)).find(function (button) { return button.name === name; }).id; })); - var mapSelection = function mapSelection(selection) { return selection.map(function (id) { return [].concat(dividers, _toConsumableArray(available)).find(function (button) { @@ -364,7 +336,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }).name; }); }; - selected.subscribe(function (selection) { updateSelectedButtons(mapSelection(selection), selectedTextarea); render(container, selected, available, dividers); @@ -385,11 +356,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d 39: 'right', 40: 'down' }; - if (['tab', 'left', 'up', 'right', 'down'].includes(keyCodeDirections[e.keyCode])) { var hideTip = false; var isActive = e.target.closest('[data-button-list="ckeditor5-toolbar-active__buttons"]'); - if (isActive) { if (['tab', 'left', 'up', 'right'].includes(keyCodeDirections[e.keyCode])) { hideTip = true; @@ -397,7 +366,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d } else if (['tab', 'down'].includes(keyCodeDirections[e.keyCode])) { hideTip = true; } - if (hideTip) { e.target.querySelector('[data-expanded]').setAttribute('data-expanded', 'false'); } @@ -407,13 +375,14 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var updateUiStateStorage = function updateUiStateStorage(states) { var form = document.querySelector('#filter-format-edit-form, #filter-format-add-form'); + var currentStates = form.hasAttribute('data-drupal-ui-state') ? JSON.parse(form.getAttribute('data-drupal-ui-state')) : {}; + form.setAttribute('data-drupal-ui-state', JSON.stringify(_objectSpread(_objectSpread({}, currentStates), states))); }; var getUiStateStorage = function getUiStateStorage(property) { var form = document.querySelector('#filter-format-edit-form, #filter-format-add-form'); - if (form === null) { return; } @@ -427,8 +396,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d var maintainActiveVerticalTab = function maintainActiveVerticalTab(verticalTabs) { var id = verticalTabs.id; - var activeTab = getUiStateStorage("".concat(id, "-active-tab")); + var activeTab = getUiStateStorage("".concat(id, "-active-tab")); if (activeTab) { setTimeout(function () { var activeTabLink = document.querySelector(activeTab); @@ -437,16 +406,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d if (id !== 'plugin-settings-wrapper') { return; } - if (document.activeElement !== document.body) { return; } - var targetTabPane = document.querySelector(activeTabLink.getAttribute('href')); - if (targetTabPane) { var tabbableElements = tabbable(targetTabPane); - if (tabbableElements.length) { tabbableElements[0].focus(); } @@ -463,17 +428,15 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }); }); }; - once('maintainActiveVerticalTab', '#plugin-settings-wrapper, #filter-settings-wrapper').forEach(maintainActiveVerticalTab); + var selectedButtons = document.querySelector('#ckeditor5-toolbar-buttons-selected'); once('textarea-listener', selectedButtons).forEach(function (textarea) { textarea.addEventListener('change', function (e) { var buttonName = document.activeElement.getAttribute('data-id'); - if (!buttonName) { return; } - var focusSelector = ''; if (['divider', 'wrapping'].includes(buttonName)) { @@ -506,14 +469,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }); textarea.addEventListener('focus', function () { var focusSelector = getUiStateStorage('focusSelector'); - if (focusSelector) { if (focusSelector.includes('|')) { var _focusSelector$split = focusSelector.split('|'), - _focusSelector$split2 = _slicedToArray(_focusSelector$split, 2), - buttonName = _focusSelector$split2[0], - count = _focusSelector$split2[1]; - + _focusSelector$split2 = _slicedToArray(_focusSelector$split, 2), + buttonName = _focusSelector$split2[0], + count = _focusSelector$split2[1]; document.querySelectorAll("[data-button-list=\"ckeditor5-toolbar-active-buttons\"] [data-id='".concat(buttonName, "']")).forEach(function (item, index) { if (index === parseInt(count, 10)) { item.focus(); @@ -521,7 +482,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d }); } else { var toFocus = document.querySelector(focusSelector); - if (toFocus) { toFocus.focus(); } @@ -564,9 +524,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d Drupal.theme.ckeditor5Button = function (_ref7) { var _ref7$button = _ref7.button, - label = _ref7$button.label, - id = _ref7$button.id, - listType = _ref7.listType; + label = _ref7$button.label, + id = _ref7$button.id, + listType = _ref7.listType; var buttonInstructions = { divider: Drupal.t('Press the down arrow key to use this divider in the active button list'), available: Drupal.t('Press the down arrow key to activate'), @@ -581,9 +541,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d Drupal.theme.ckeditor5Admin = function (_ref8) { var availableButtons = _ref8.availableButtons, - dividerButtons = _ref8.dividerButtons, - activeToolbar = _ref8.activeToolbar, - helpMessage = _ref8.helpMessage; + dividerButtons = _ref8.dividerButtons, + activeToolbar = _ref8.activeToolbar, + helpMessage = _ref8.helpMessage; return "\n <div data-drupal-selector=\"ckeditor5-admin-help-message\">\n <p>".concat(helpMessage.join('</p><p>'), "</p>\n </div>\n <div class=\"ckeditor5-toolbar-disabled\">\n <div class=\"ckeditor5-toolbar-available\">\n <label id=\"ckeditor5-toolbar-available-buttons-label\">").concat(Drupal.t('Available buttons'), "</label>\n ").concat(availableButtons, "\n </div>\n <div class=\"ckeditor5-toolbar-divider\">\n <label id=\"ckeditor5-toolbar-divider-buttons-label\">").concat(Drupal.t('Button divider'), "</label>\n ").concat(dividerButtons, "\n </div>\n </div>\n <div class=\"ckeditor5-toolbar-active\">\n <label id=\"ckeditor5-toolbar-active-buttons-label\">").concat(Drupal.t('Active toolbar'), "</label>\n ").concat(activeToolbar, "\n </div>\n "); }; @@ -591,8 +551,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d Drupal.behaviors.filterStatus.attach = function (context, settings) { var filterStatusCheckboxes = document.querySelectorAll('#filters-status-wrapper input.form-checkbox'); + once.remove('filter-status', filterStatusCheckboxes); + $(filterStatusCheckboxes).off('click.filterUpdate'); + originalFilterStatusAttach(context, settings); }; @@ -600,10 +563,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d attach: function attach(context) { context.querySelectorAll('details .form-item .error').forEach(function (item) { var details = item.closest('details'); - if (details.style.display === 'none') { var tabSelect = document.querySelector("[href='#".concat(details.id, "']")); - if (tabSelect) { tabSelect.click(); } diff --git a/core/modules/ckeditor5/js/ckeditor5.filter.admin.js b/core/modules/ckeditor5/js/ckeditor5.filter.admin.js index 98a6ecd2ec3659b8ca0e3b219be6ebdd9e732a57..3c3582072a4dbf2b9e75a90094afa7456cfde515 100644 --- a/core/modules/ckeditor5/js/ckeditor5.filter.admin.js +++ b/core/modules/ckeditor5/js/ckeditor5.filter.admin.js @@ -4,19 +4,20 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (Drupal, once) { Drupal.behaviors.allowedTagsListener = { attach: function attach(context) { once('ajax-conflict-prevention', '[data-drupal-selector="filter-format-edit-form"], [data-drupal-selector="filter-format-add-form"]', context).forEach(function (form) { form.addEventListener('submit', function () { - once.filter('drupal-ajax', '[data-drupal-selector="filter-format-edit-form"] [disabled], [data-drupal-selector="filter-format-add-form"] [disabled]').forEach(function (disabledElement) { + once.filter('drupal-ajax', '[data-drupal-selector="filter-format-edit-form"] [disabled], [data-drupal-selector="filter-format-add-form"] [disabled]') + .forEach(function (disabledElement) { disabledElement.removeAttribute('disabled'); }); }); }); } }; + var originalAjaxEventResponse = Drupal.Ajax.prototype.eventResponse; Drupal.Ajax.prototype.eventResponse = function ckeditor5AjaxEventResponse() { @@ -25,11 +26,9 @@ return; } } - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - originalAjaxEventResponse.apply(this, args); }; })(Drupal, once); \ No newline at end of file diff --git a/core/modules/ckeditor5/js/ckeditor5.js b/core/modules/ckeditor5/js/ckeditor5.js index 96657006a45e12664b3d3c279681487a10a47d8b..f234702a6058d92239bf1a94cb848bd00b14fca1 100644 --- a/core/modules/ckeditor5/js/ckeditor5.js +++ b/core/modules/ckeditor5/js/ckeditor5.js @@ -4,33 +4,19 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } - function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } - function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } - function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function (Drupal, debounce, CKEditor5, $, once) { @@ -39,32 +25,29 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } Drupal.CKEditor5Instances = new Map(); + var callbacks = new Map(); + var required = new Set(); function findFunc(scope, name) { if (!scope) { return null; } - var parts = name.includes('.') ? name.split('.') : name; - if (parts.length > 1) { return findFunc(scope[parts.shift()], parts); } - return typeof scope[parts[0]] === 'function' ? scope[parts[0]] : null; } function buildFunc(config) { var func = config.func; var fn = findFunc(window, func.name); - if (typeof fn === 'function') { var result = func.invoke ? fn.apply(void 0, _toConsumableArray(func.args)) : fn; return result; } - return null; } @@ -81,21 +64,17 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (_typeof(item) === 'object') { return processConfig(item); } - return item; }); } - return Object.entries(config).reduce(function (processed, _ref) { var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - value = _ref2[1]; - + key = _ref2[0], + value = _ref2[1]; if (_typeof(value) === 'object') { if (!value) { return processed; } - if (value.hasOwnProperty('func')) { processed[key] = buildFunc(value); } else if (value.hasOwnProperty('regexp')) { @@ -108,7 +87,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } else { processed[key] = value; } - return processed; }, {}); } @@ -126,10 +104,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len function selectPlugins(plugins) { return plugins.map(function (pluginDefinition) { var _pluginDefinition$spl = pluginDefinition.split('.'), - _pluginDefinition$spl2 = _slicedToArray(_pluginDefinition$spl, 2), - build = _pluginDefinition$spl2[0], - name = _pluginDefinition$spl2[1]; - + _pluginDefinition$spl2 = _slicedToArray(_pluginDefinition$spl, 2), + build = _pluginDefinition$spl2[0], + name = _pluginDefinition$spl2[1]; if (CKEditor5[build] && CKEditor5[build][name]) { return CKEditor5[build][name]; } @@ -151,25 +128,20 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (rule.cssRules) { processRules(rule); } - if (!rule.selectorText) { return; } - var offCanvasId = '#drupal-off-canvas'; var CKEditorClass = '.ck'; var styleFence = '[data-drupal-ck-style-fence]'; - if (rule.selectorText.includes(offCanvasId) || rule.selectorText.includes(CKEditorClass)) { rule.selectorText = rule.selectorText.split(/,/g).map(function (selector) { if (selector.includes(offCanvasId)) { return "".concat(selector.trim(), ":not(").concat(styleFence, " *)"); } - if (selector.includes(CKEditorClass)) { return [selector.trim(), selector.trim().replace(CKEditorClass, "".concat(offCanvasId, " ").concat(styleFence, " ").concat(CKEditorClass))]; } - return selector; }).flat().join(', '); } @@ -179,10 +151,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var fenceName = 'data-drupal-ck-style-fence'; var editor = Drupal.CKEditor5Instances.get(element.getAttribute('data-ckeditor5-id')); editor.ui.view.element.setAttribute(fenceName, ''); - if (once('ckeditor5-off-canvas-reset', 'body').length) { _toConsumableArray(document.styleSheets).forEach(processRules); - var prefix = "#drupal-off-canvas [".concat(fenceName, "]"); var addedCss = ["".concat(prefix, " .ck.ck-content {display:block;min-height:5rem;}"), "".concat(prefix, " .ck.ck-content * {display:initial;background:initial;color:initial;padding:initial;}"), "".concat(prefix, " .ck.ck-content li {display:list-item}"), "".concat(prefix, " .ck.ck-content ol li {list-style-type: decimal}"), "".concat(prefix, " .ck[contenteditable], ").concat(prefix, " .ck[contenteditable] * {-webkit-user-modify: read-write;-moz-user-modify: read-write;}")]; var blockSelectors = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'ol', 'ul', 'address', 'article', 'aside', 'blockquote', 'body', 'dd', 'div', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'header', 'hgroup', 'hr', 'html', 'legend', 'main', 'menu', 'pre', 'section', 'xmp'].map(function (blockElement) { @@ -190,6 +160,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }).join(', \n'); var blockCss = "".concat(blockSelectors, " { display: block; }"); var prefixedCss = [].concat(addedCss, [blockCss]).join('\n'); + var offCanvasCssStyle = document.createElement('style'); offCanvasCssStyle.textContent = prefixedCss; offCanvasCssStyle.setAttribute('id', 'ckeditor5-off-canvas-reset'); @@ -201,20 +172,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len attach: function attach(element, format) { var editorClassic = CKEditor5.editorClassic; var _format$editorSetting = format.editorSettings, - toolbar = _format$editorSetting.toolbar, - plugins = _format$editorSetting.plugins, - config = _format$editorSetting.config, - language = _format$editorSetting.language; + toolbar = _format$editorSetting.toolbar, + plugins = _format$editorSetting.plugins, + config = _format$editorSetting.config, + language = _format$editorSetting.language; var extraPlugins = selectPlugins(plugins); var pluginConfig = processConfig(config); - var editorConfig = _objectSpread(_objectSpread({ extraPlugins: extraPlugins, toolbar: toolbar }, pluginConfig), {}, { language: _objectSpread(_objectSpread({}, pluginConfig.language), language) }); - var id = setElementId(element); var ClassicEditor = editorClassic.ClassicEditor; ClassicEditor.create(element, editorConfig).then(function (editor) { @@ -230,7 +199,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }); editor.model.document.on('change:data', function () { var callback = callbacks.get(id); - if (callback) { if (editor.plugins.has('SourceEditing')) { if (editor.plugins.get('SourceEditing').isSourceEditingMode) { @@ -243,7 +211,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }); var isOffCanvas = element.closest('#drupal-off-canvas'); - if (isOffCanvas) { offCanvasCss(element); } @@ -254,13 +221,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len detach: function detach(element, format, trigger) { var id = getElementId(element); var editor = Drupal.CKEditor5Instances.get(id); - if (!editor) { return; } - $(document).off("drupalViewportOffsetChange.ckeditor5.".concat(id)); - if (trigger === 'serialize') { editor.updateSourceElement(); } else { @@ -268,7 +232,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len return editor.destroy().then(function () { Drupal.CKEditor5Instances.delete(id); callbacks.delete(id); - if (required.has(id)) { element.setAttribute('required', 'required'); required.delete(id); @@ -284,18 +247,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len attachInlineEditor: function attachInlineEditor(element, format, mainToolbarId) { var editorDecoupled = CKEditor5.editorDecoupled; var _format$editorSetting2 = format.editorSettings, - toolbar = _format$editorSetting2.toolbar, - plugins = _format$editorSetting2.plugins, - pluginConfig = _format$editorSetting2.config, - language = _format$editorSetting2.language; + toolbar = _format$editorSetting2.toolbar, + plugins = _format$editorSetting2.plugins, + pluginConfig = _format$editorSetting2.config, + language = _format$editorSetting2.language; var extraPlugins = selectPlugins(plugins); - var config = _objectSpread({ extraPlugins: extraPlugins, toolbar: toolbar, language: language }, processConfig(pluginConfig)); - var id = setElementId(element); var DecoupledEditor = editorDecoupled.DecoupledEditor; DecoupledEditor.create(element, config).then(function (editor) { @@ -304,7 +265,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len toolbar.appendChild(editor.ui.view.toolbar.element); editor.model.document.on('change:data', function () { var callback = callbacks.get(id); - if (callback) { debounce(callback, 400)(editor.getData()); } @@ -314,6 +274,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }); } }; + Drupal.ckeditor5 = { saveCallback: null, openDialog: function openDialog(url, saveCallback, dialogSettings) { @@ -335,6 +296,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } }); ckeditorAjaxDialog.execute(); + Drupal.ckeditor5.saveCallback = saveCallback; } }; @@ -342,19 +304,17 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len function redirectTextareaFragmentToCKEditor5Instance() { var hash = window.location.hash.substr(1); var element = document.getElementById(hash); - if (element) { var editorID = getElementId(element); var editor = Drupal.CKEditor5Instances.get(editorID); - if (editor) { editor.sourceElement.nextElementSibling.setAttribute('id', "cke_".concat(hash)); window.location.replace("#cke_".concat(hash)); } } } - $(window).on('hashchange.ckeditor', redirectTextareaFragmentToCKEditor5Instance); + $(window).on('dialog:beforecreate', function () { $('.ckeditor5-dialog-loading').animate({ top: '-40px' @@ -362,11 +322,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len $(this).remove(); }); }); + $(window).on('editor:dialogsave', function (e, values) { if (Drupal.ckeditor5.saveCallback) { Drupal.ckeditor5.saveCallback(values); } }); + $(window).on('dialog:afterclose', function () { if (Drupal.ckeditor5.saveCallback) { Drupal.ckeditor5.saveCallback = null; diff --git a/core/modules/ckeditor5/js/ckeditor5.style.admin.js b/core/modules/ckeditor5/js/ckeditor5.style.admin.js index d9baa199dedb613ace53866b29268d66777bafab..cdc010495e9b9323bad66944ec45eff805f3fbaf 100644 --- a/core/modules/ckeditor5/js/ckeditor5.style.admin.js +++ b/core/modules/ckeditor5/js/ckeditor5.style.admin.js @@ -10,14 +10,13 @@ attach: function attach() { $('[data-ckeditor5-plugin-id="ckeditor5_style"]').drupalSetSummary(function (context) { var stylesElement = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-style-styles"]'); - var styleCount = stylesElement.value.split('\n').filter(function (line) { + var styleCount = stylesElement.value.split('\n') + .filter(function (line) { return line.trim().length >= 5; }).length; - if (styleCount === 0) { return Drupal.t('No styles configured'); } - return Drupal.formatPlural(styleCount, 'One style configured', '@count styles configured'); }); } diff --git a/core/modules/ckeditor5/js/ie11.filter.warnings.js b/core/modules/ckeditor5/js/ie11.filter.warnings.js index 61ca106cefb5fbc77f2c735810d8e91ada698337..bd1d963d000b03c75741343941bc8b8658401894 100644 --- a/core/modules/ckeditor5/js/ie11.filter.warnings.js +++ b/core/modules/ckeditor5/js/ie11.filter.warnings.js @@ -10,9 +10,9 @@ attach: function attach() { var isIE11 = !!document.documentMode; var editorSelect = once('editor-ie11-warning', '[data-drupal-selector="filter-format-edit-form"] [data-drupal-selector="edit-editor-editor"], [data-drupal-selector="filter-format-add-form"] [data-drupal-selector="edit-editor-editor"]'); - if (typeof editorSelect[0] !== 'undefined') { var select = editorSelect[0]; + var selectMessageContainer = document.createElement('div'); select.parentNode.after(selectMessageContainer, select); var selectMessages = new Drupal.Message(selectMessageContainer); @@ -23,7 +23,6 @@ type: 'warning', id: 'ie_11_warning' }); - if (isIE11) { selectMessages.add(Drupal.t('Text editor toolbar settings are not available in Internet Explorer. They will be available in other <a href="@supported-browsers">supported browsers</a>.', { '@supported-browsers': 'https://www.drupal.org/docs/system-requirements/browser-requirements' @@ -42,19 +41,17 @@ if (selectMessages.select('ie_11_warning')) { selectMessages.remove('ie_11_warning'); } - if (selectMessages.select('ie_11_error')) { selectMessages.remove('ie_11_error'); } } }; - updateWarningStatus(); + var editorSelectObserver = new MutationObserver(function (mutations) { for (var i = 0; i < mutations.length; i++) { var switchToCKEditor5Complete = mutations[i].type === 'attributes' && mutations[i].attributeName === 'disabled' && !select.disabled; var fixedErrorsPreventingSwitchToCKEditor5 = mutations[i].type === 'attributes' && mutations[i].attributeName === 'data-error-switching-to-ckeditor5' && !select.hasAttribute('data-error-switching-to-ckeditor5'); - if (switchToCKEditor5Complete || fixedErrorsPreventingSwitchToCKEditor5) { updateWarningStatus(); } diff --git a/core/modules/ckeditor5/js/ie11.user.warnings.js b/core/modules/ckeditor5/js/ie11.user.warnings.js index 0356cc95ccccc0c86d1f0bae44d3c577e60b79de..76e97fd170cfbcb85579f8ce6431f6b8964b84a0 100644 --- a/core/modules/ckeditor5/js/ie11.user.warnings.js +++ b/core/modules/ckeditor5/js/ie11.user.warnings.js @@ -10,7 +10,9 @@ if (isIE11) { window.CKEditor5 = null; + var quickEditLabelObserver = null; + Drupal.editors.ckeditor5 = { attach: function attach(element) { var editorMessageContainer = document.createElement('div'); @@ -24,14 +26,16 @@ }, detach: function detach() { var quickEditToolbar = document.querySelector('#quickedit-entity-toolbar .quickedit-toolbar'); - if (quickEditToolbar) { quickEditToolbar.classList.remove('ck5-ie11'); quickEditToolbar.classList.add('icon-pencil'); + quickEditLabelObserver.disconnect(); } }, - onChange: function onChange() {}, + onChange: function onChange() { + }, + attachInlineEditor: function attachInlineEditor(element) { var quickEditToolbar = document.querySelector('#quickedit-entity-toolbar .quickedit-toolbar'); var notEditableAlert = Drupal.t('Field Not Editable'); @@ -39,17 +43,19 @@ function quickEditLabelWarnIE11(toolbarLabel) { quickEditLabelObserver.disconnect(); + toolbarLabel.innerHTML = "<div><b>".concat(notEditableAlert, "</b><div>").concat(notEditableMessage, "</div></div>"); quickEditLabelObserver.observe(toolbarLabel, { childList: true }); } - if (quickEditToolbar) { quickEditToolbar.classList.add('ck5-ie11'); quickEditToolbar.classList.remove('icon-pencil'); element.classList.add('ck5-ie11'); + var toolbarLabel = quickEditToolbar.querySelector('.quickedit-toolbar-label'); + quickEditLabelObserver = new MutationObserver(function (mutations) { for (var i = 0; i < mutations.length; i++) { if (mutations[i].type === 'childList') { diff --git a/core/modules/ckeditor5/tests/src/Nightwatch/Tests/drupalHtmlBuilderTest.js b/core/modules/ckeditor5/tests/src/Nightwatch/Tests/drupalHtmlBuilderTest.js index 8d416758b5177b21ab3fc8b35042987aa5b607ba..6a628ff7e57f78635ec17c35b61db056c2cf68f4 100644 --- a/core/modules/ckeditor5/tests/src/Nightwatch/Tests/drupalHtmlBuilderTest.js +++ b/core/modules/ckeditor5/tests/src/Nightwatch/Tests/drupalHtmlBuilderTest.js @@ -4,20 +4,16 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - var assert = require('assert'); - var fs = require('fs'); - var path = require('path'); - var _require = require('jsdom'), - JSDOM = _require.JSDOM; + JSDOM = _require.JSDOM; var DrupalHtmlBuilder = eval("(".concat(fs.readFileSync(path.resolve(__dirname, '../../../../js/ckeditor5_plugins/drupalHtmlEngine/src/drupalhtmlbuilder.js')).toString(), ")").replace('export default', '')); var _JSDOM$window = new JSDOM("<!DOCTYPE html>").window, - document = _JSDOM$window.document, - Node = _JSDOM$window.Node; + document = _JSDOM$window.document, + Node = _JSDOM$window.Node; module.exports = { '@tags': ['ckeditor5'], '@unitTest': true, diff --git a/core/modules/color/color.js b/core/modules/color/color.js index 2b73fcf00110968d7924337208865cc2ade4ee8c..8272f06bb909aa993f128853ccf9d1ffae85e05c 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -12,21 +12,22 @@ var j; var colors; var form = $(once('color', '#system-theme-settings .color-form', context)); - if (form.length === 0) { return; } - var inputs = []; var hooks = []; var locks = []; var focused = null; + $(once('color', $('<div class="color-placeholder"></div>'))).prependTo(form); var farb = $.farbtastic('.color-placeholder'); + var reference = settings.color.reference; Object.keys(reference || {}).forEach(function (color) { reference[color] = farb.RGBToHSL(farb.unpack(reference[color])); }); + var height = []; var width = []; @@ -43,13 +44,13 @@ function shiftColor(given, ref1, ref2) { var d; given = farb.RGBToHSL(farb.unpack(given)); + given[0] += ref2[0] - ref1[0]; if (ref1[1] === 0 || ref2[1] === 0) { given[1] = ref2[1]; } else { d = ref1[1] / ref2[1]; - if (d > 1) { given[1] /= d; } else { @@ -61,14 +62,12 @@ given[2] = ref2[2]; } else { d = ref1[2] / ref2[2]; - if (d > 1) { given[2] /= d; } else { given[2] = 1 - (1 - given[2]) * d; } } - return farb.pack(farb.HSLToRGB(given)); } @@ -84,21 +83,17 @@ if (propagate) { i = input.i; - for (j = i + 1;; ++j) { if (!locks[j - 1] || $(locks[j - 1]).is('.is-unlocked')) { break; } - matched = shiftColor(color, reference[input.key], reference[inputs[j].key]); callback(inputs[j], matched, false); } - for (j = i - 1;; --j) { if (!locks[j] || $(locks[j]).is('.is-unlocked')) { break; } - matched = shiftColor(color, reference[input.key], reference[inputs[j].key]); callback(inputs[j], matched, false); } @@ -117,15 +112,14 @@ var gradient = $(".color-preview #gradient-".concat(i)); height.push(parseInt(gradient.css('height'), 10) / 10); width.push(parseInt(gradient.css('width'), 10) / 10); - for (j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) { gradient.append('<div class="gradient-line"></div>'); } }); + form.find('#edit-scheme').on('change', function () { var schemes = settings.color.schemes; var colorScheme = this.options[this.selectedIndex].value; - if (colorScheme !== '' && schemes[colorScheme]) { colors = schemes[colorScheme]; Object.keys(colors || {}).forEach(function (fieldName) { @@ -137,7 +131,6 @@ function focus(e) { var input = e.target; - if (focused) { $(focused).off('keyup', farb.updateValue).off('keyup', preview).off('keyup', resetScheme).parent().removeClass('item-selected'); } @@ -152,14 +145,14 @@ form.find('.js-color-palette input.form-text').each(function () { this.key = this.id.substring(13); + farb.linkTo(function () {}).setColor('#000').linkTo(this); - var i = inputs.length; + var i = inputs.length; if (inputs.length) { var toggleClick = true; var lock = $("<button class=\"color-palette__lock\">".concat(Drupal.t('Unlock'), "</button>")).on('click', function (e) { e.preventDefault(); - if (toggleClick) { $(this).addClass('is-unlocked').html(Drupal.t('Lock')); $(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-up' : 'color-palette__hook'); @@ -169,7 +162,6 @@ $(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-down'); $(hooks[i]).attr('class', locks[i] && $(locks[i]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-up'); } - toggleClick = !toggleClick; }); $(this).after(lock); @@ -184,7 +176,9 @@ inputs.push(this); }).on('focus', focus); form.find('.js-color-palette label'); + inputs[0].focus(); + preview(); } }; diff --git a/core/modules/color/preview.js b/core/modules/color/preview.js index a65d0ea175b4d9245f128e7a9c5189bcc91c4e23..2dcfeb20e34df870a7d51cf08be407dd525f5c24 100644 --- a/core/modules/color/preview.js +++ b/core/modules/color/preview.js @@ -11,9 +11,9 @@ var accum; var delta; form.find('.color-preview').css('backgroundColor', form.find('.color-palette input[name="palette[base]"]').val()); + form.find('#text').css('color', form.find('.color-palette input[name="palette[text]"]').val()); form.find('#text a, #text h2').css('color', form.find('.color-palette input[name="palette[link]"]').val()); - function gradientLineColor(i, element) { Object.keys(accum || {}).forEach(function (k) { accum[k] += delta[k]; @@ -26,7 +26,6 @@ Object.keys(settings.gradients || {}).forEach(function (i) { colorStart = farb.unpack(form.find(".color-palette input[name=\"palette[".concat(settings.gradients[i].colors[0], "]\"]")).val()); colorEnd = farb.unpack(form.find(".color-palette input[name=\"palette[".concat(settings.gradients[i].colors[1], "]\"]")).val()); - if (colorStart && colorEnd) { delta = []; Object.keys(colorStart || {}).forEach(function (colorStartKey) { diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js b/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js index 546127de3f51cf869228bf2a5314e5eaf39ed302..cea8a35ef2640e37bd84d70f7bb183596900e5ad 100644 --- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($) { $(document).ready(function () {}); })(jQuery); \ No newline at end of file diff --git a/core/modules/comment/js/comment-new-indicator.js b/core/modules/comment/js/comment-new-indicator.js index ffa24817631422fbf5214601148ef30b2c7e098b..cc5268df0d6507b59eef1162cb39d929f78c7373 100644 --- a/core/modules/comment/js/comment-new-indicator.js +++ b/core/modules/comment/js/comment-new-indicator.js @@ -16,15 +16,14 @@ var $node = $placeholder.closest('[data-history-node-id]'); var nodeID = $node.attr('data-history-node-id'); var lastViewTimestamp = Drupal.history.getLastRead(nodeID); - if (timestamp > lastViewTimestamp) { placeholder.textContent = newCommentString; - $placeholder.removeClass('hidden').closest('.js-comment').addClass('new'); + $placeholder.removeClass('hidden').closest('.js-comment') + .addClass('new'); if (isFirstNewComment) { isFirstNewComment = false; $placeholder.prev().before('<a id="new"></a>'); - if (window.location.hash === '#new') { window.scrollTo(0, $placeholder.offset().top - Drupal.displace.offsets.top); } @@ -40,15 +39,12 @@ var $placeholder = $(placeholder); var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); - if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { nodeIDs.push(nodeID); return true; } - return false; }); - if (placeholders.length === 0) { return; } diff --git a/core/modules/comment/js/node-new-comments-link.js b/core/modules/comment/js/node-new-comments-link.js index 9285a60ada4d4d8938ca6c1935e9c3381343c8b6..7a82b3f85b19101c8d69b447b6f0a96bfaf17a71 100644 --- a/core/modules/comment/js/node-new-comments-link.js +++ b/core/modules/comment/js/node-new-comments-link.js @@ -7,7 +7,10 @@ (function ($, Drupal, drupalSettings) { function hide($placeholder) { - return $placeholder.closest('.comment-new-comments').prev().addClass('last').end().hide(); + return $placeholder + .closest('.comment-new-comments') + .prev().addClass('last') + .end().hide(); } function remove($placeholder) { @@ -15,7 +18,10 @@ } function show($placeholder) { - return $placeholder.closest('.comment-new-comments').prev().removeClass('last').end().show(); + return $placeholder + .closest('.comment-new-comments') + .prev().removeClass('last') + .end().show(); } function processNodeNewCommentLinks(placeholders) { @@ -31,12 +37,13 @@ if (timestamp > lastViewTimestamp) { $placeholdersToUpdate[nodeID] = $placeholder; - } else { + } + else { remove($placeholder); } }); - var nodeIDs = Object.keys($placeholdersToUpdate); + var nodeIDs = Object.keys($placeholdersToUpdate); if (nodeIDs.length === 0) { return; } @@ -52,7 +59,6 @@ } }); } - if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) { render(drupalSettings.comment.newCommentsLinks.node[fieldName]); } else { @@ -76,7 +82,6 @@ var $placeholder = $(placeholder); var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10); var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); - if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) { nodeIDs.push(nodeID); hide($placeholder); @@ -86,7 +91,6 @@ remove($placeholder); return false; }); - if (placeholders.length === 0) { return; } diff --git a/core/modules/content_translation/content_translation.admin.js b/core/modules/content_translation/content_translation.admin.js index 8a30f68618852475fe3cfc92d15584add8c79f07..1233417fe360b05d602bf15eca54b00b366528d7 100644 --- a/core/modules/content_translation/content_translation.admin.js +++ b/core/modules/content_translation/content_translation.admin.js @@ -11,7 +11,6 @@ var $context = $(context); var options = drupalSettings.contentTranslationDependentOptions; var $fields; - function fieldsChangeHandler($fields, dependentColumns) { return function (e) { Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target)); @@ -30,18 +29,15 @@ check: function check($fields, dependentColumns, $changed) { var $element = $changed; var column; - function filterFieldsList(index, field) { return field.value === column; } Object.keys(dependentColumns || {}).forEach(function (index) { column = dependentColumns[index]; - if (!$changed) { $element = $fields.filter(filterFieldsList); } - if ($element.is("input[value=\"".concat(column, "\"]:checked"))) { $fields.prop('checked', true).not($element).prop('disabled', true); } else { @@ -50,24 +46,25 @@ }); } }; + Drupal.behaviors.contentTranslation = { attach: function attach(context) { - once('translation-entity-admin-hide', $(context).find('table .bundle-settings .translatable :input')).forEach(function (input) { + once('translation-entity-admin-hide', + $(context).find('table .bundle-settings .translatable :input')).forEach(function (input) { var $input = $(input); var $bundleSettings = $input.closest('.bundle-settings'); - if (!$input.is(':checked')) { $bundleSettings.nextUntil('.bundle-settings').hide(); } else { $bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide(); } }); + $(once('translation-entity-admin-bind', 'body')).on('click', 'table .bundle-settings .translatable :input', function (e) { var $target = $(e.target); var $bundleSettings = $target.closest('.bundle-settings'); var $settings = $bundleSettings.nextUntil('.bundle-settings'); var $fieldSettings = $settings.filter('.field-settings'); - if ($target.is(':checked')) { $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true); $fieldSettings.find('.translatable :input').prop('checked', true); @@ -79,7 +76,6 @@ var $target = $(e.target); var $fieldSettings = $target.closest('.field-settings'); var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings'); - if ($target.is(':checked')) { $columnSettings.show(); } else { diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js index 878f0d38bc5f5da58830782bb9f3650680e4dde8..c2b656290060cfa30926fe5162237e4ab8a6ca9d 100644 --- a/core/modules/contextual/js/contextual.js +++ b/core/modules/contextual/js/contextual.js @@ -6,15 +6,16 @@ **/ (function ($, Drupal, drupalSettings, _, Backbone, JSON, storage) { - var options = $.extend(drupalSettings.contextual, { + var options = $.extend(drupalSettings.contextual, + { strings: { open: Drupal.t('Open'), close: Drupal.t('Close') } }); + var cachedPermissionsHash = storage.getItem('Drupal.contextual.permissionsHash'); var permissionsHash = drupalSettings.user.permissionsHash; - if (cachedPermissionsHash !== permissionsHash) { if (typeof permissionsHash === 'string') { _.chain(storage).keys().each(function (key) { @@ -23,12 +24,12 @@ } }); } - storage.setItem('Drupal.contextual.permissionsHash', permissionsHash); } function adjustIfNestedAndOverlapping($contextual) { - var $contextuals = $contextual.parents('.contextual-region').eq(-1).find('.contextual'); + var $contextuals = $contextual + .parents('.contextual-region').eq(-1).find('.contextual'); if ($contextuals.length <= 1) { return; @@ -36,14 +37,15 @@ var firstTop = $contextuals.eq(0).offset().top; var secondTop = $contextuals.eq(1).offset().top; - if (firstTop === secondTop) { var $nestedContextual = $contextuals.eq(1); + var height = 0; var $trigger = $nestedContextual.find('.trigger'); $trigger.removeClass('visually-hidden'); height = $nestedContextual.height(); $trigger.addClass('visually-hidden'); + $nestedContextual.css({ top: $nestedContextual.position().top + height }); @@ -53,7 +55,11 @@ function initContextual($contextual, html) { var $region = $contextual.closest('.contextual-region'); var contextual = Drupal.contextual; - $contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger')); + $contextual + .html(html) + .addClass('contextual') + .prepend(Drupal.theme('contextualTrigger')); + var destination = "destination=".concat(Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath))); $contextual.find('.contextual-links a').each(function () { var url = this.getAttribute('href'); @@ -62,11 +68,9 @@ }); var title = ''; var $regionHeading = $region.find('h2'); - if ($regionHeading.length) { title = $regionHeading[0].textContent.trim(); } - var model = new contextual.StateModel({ title: title }); @@ -83,7 +87,9 @@ el: $region, model: model }, options))); + contextual.collection.add(model); + $(document).trigger('drupalContextualLinkAdded', Drupal.deprecatedProperty({ target: { $el: $contextual, @@ -93,14 +99,15 @@ deprecatedProperty: 'model', message: 'The model property is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. There is no replacement.' })); + adjustIfNestedAndOverlapping($contextual); } Drupal.behaviors.contextual = { attach: function attach(context) { var $context = $(context); - var $placeholders = $(once('contextual-render', '[data-contextual-id]', context)); + var $placeholders = $(once('contextual-render', '[data-contextual-id]', context)); if ($placeholders.length === 0) { return; } @@ -116,14 +123,12 @@ var uncachedTokens = []; ids.forEach(function (contextualID) { var html = storage.getItem("Drupal.contextual.".concat(contextualID.id)); - if (html && html.length) { window.setTimeout(function () { initContextual($context.find("[data-contextual-id=\"".concat(contextualID.id, "\"]:empty")).eq(0), html); }); return; } - uncachedIDs.push(contextualID.id); uncachedTokens.push(contextualID.token); }); @@ -140,7 +145,6 @@ success: function success(results) { _.each(results, function (html, contextualID) { storage.setItem("Drupal.contextual.".concat(contextualID), html); - if (html.length > 0) { $placeholders = $context.find("[data-contextual-id=\"".concat(contextualID, "\"]")); @@ -154,10 +158,12 @@ } } }; + Drupal.contextual = { views: [], regionViews: [] }; + Drupal.contextual.collection = new Backbone.Collection([], { model: Drupal.contextual.StateModel }); diff --git a/core/modules/contextual/js/contextual.toolbar.js b/core/modules/contextual/js/contextual.toolbar.js index bbd8792d06903dbf5d51ebe8c62607ce44b07095..86a1e9ffb2f0b79771c3facfd4a15786f70be86a 100644 --- a/core/modules/contextual/js/contextual.toolbar.js +++ b/core/modules/contextual/js/contextual.toolbar.js @@ -16,7 +16,6 @@ if (!Drupal.contextual || !Drupal.contextual.collection) { return; } - var contextualToolbar = Drupal.contextualToolbar; contextualToolbar.model = new contextualToolbar.StateModel({ isViewing: localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false' @@ -39,6 +38,7 @@ } } }; + Drupal.contextualToolbar = { model: null }; diff --git a/core/modules/contextual/js/models/StateModel.js b/core/modules/contextual/js/models/StateModel.js index 8be38641b8fd8e2e97f0a710f610d4250a4707f1..92c445769b5c315d98ddb1e912ef122125824c35 100644 --- a/core/modules/contextual/js/models/StateModel.js +++ b/core/modules/contextual/js/models/StateModel.js @@ -17,11 +17,9 @@ toggleOpen: function toggleOpen() { var newIsOpen = !this.get('isOpen'); this.set('isOpen', newIsOpen); - if (newIsOpen) { this.focus(); } - return this; }, close: function close() { @@ -42,7 +40,6 @@ if (!this.get('isOpen')) { this.set('hasFocus', false); } - return this; } }); diff --git a/core/modules/contextual/js/toolbar/models/StateModel.js b/core/modules/contextual/js/toolbar/models/StateModel.js index e9780c8f8094ea855b41bcc62ea2e4eab7290098..93a00ff3223ed30413c884d1510be334b7b5a685 100644 --- a/core/modules/contextual/js/toolbar/models/StateModel.js +++ b/core/modules/contextual/js/toolbar/models/StateModel.js @@ -16,7 +16,9 @@ initialize: function initialize(attrs, options) { this.listenTo(options.contextualCollection, 'reset remove add', this.countContextualLinks); this.listenTo(options.contextualCollection, 'add', this.lockNewContextualLinks); + this.listenTo(this, 'change:contextualCount', this.updateVisibility); + this.listenTo(this, 'change:isViewing', function (model, isViewing) { options.contextualCollection.each(function (contextualModel) { contextualModel.set('isLocked', !isViewing); diff --git a/core/modules/contextual/js/toolbar/views/AuralView.js b/core/modules/contextual/js/toolbar/views/AuralView.js index 1de1d173f3a368d7221c00a43e6f9afeff3484a4..df4dd5f7f1600bd4b0e69272d80276b41eaa5fc7 100644 --- a/core/modules/contextual/js/toolbar/views/AuralView.js +++ b/core/modules/contextual/js/toolbar/views/AuralView.js @@ -21,15 +21,12 @@ }, manageTabbing: function manageTabbing() { var tabbingContext = this.model.get('tabbingContext'); - if (tabbingContext) { if (tabbingContext.active) { Drupal.announce(this.options.strings.tabbingReleased); } - tabbingContext.release(); } - if (!this.model.get('isViewing')) { tabbingContext = Drupal.tabbingManager.constrain($('.contextual-toolbar-tab, .contextual')); this.model.set('tabbingContext', tabbingContext); @@ -49,7 +46,6 @@ this.announceTabbingConstraint(); this.announcedOnce = true; } - if (event.keyCode === 27) { this.model.set('isViewing', true); } diff --git a/core/modules/contextual/js/toolbar/views/VisualView.js b/core/modules/contextual/js/toolbar/views/VisualView.js index fb8ecd3c5cb4a6f1caa60adc546baf929bee4313..9a85fd8ca3fc234e049bb8ad81358b7119e2ac7c 100644 --- a/core/modules/contextual/js/toolbar/views/VisualView.js +++ b/core/modules/contextual/js/toolbar/views/VisualView.js @@ -12,7 +12,6 @@ event.preventDefault(); event.target.click(); }; - return { click: function click() { this.model.set('isViewing', !this.model.get('isViewing')); diff --git a/core/modules/contextual/js/views/AuralView.js b/core/modules/contextual/js/views/AuralView.js index 7da888713f1f7a1a302e75d88160bf6697490f02..af94b7ec148ddd775dc3879a7edd00e0ff63075d 100644 --- a/core/modules/contextual/js/views/AuralView.js +++ b/core/modules/contextual/js/views/AuralView.js @@ -10,13 +10,15 @@ initialize: function initialize(options) { this.options = options; this.listenTo(this.model, 'change', this.render); + this.render(); }, render: function render() { var _this = this; - var isOpen = this.model.get('isOpen'); + this.$el.find('.contextual-links').prop('hidden', !isOpen); + var $trigger = this.$el.find('.trigger'); $trigger.each(function (index, element) { element.textContent = Drupal.t('@action @title configuration options', { diff --git a/core/modules/contextual/js/views/VisualView.js b/core/modules/contextual/js/views/VisualView.js index 7487eb620064f348f262754408a71adcc8561487..5082bb5ed6ab3f14214a2eff6a9373d32f3f9a11 100644 --- a/core/modules/contextual/js/views/VisualView.js +++ b/core/modules/contextual/js/views/VisualView.js @@ -42,12 +42,13 @@ render: function render() { var isOpen = this.model.get('isOpen'); var isVisible = this.model.get('isLocked') || this.model.get('regionIsHovered') || isOpen; - this.$el.toggleClass('open', isOpen).find('.trigger').toggleClass('visually-hidden', !isVisible); + this.$el + .toggleClass('open', isOpen) + .find('.trigger').toggleClass('visually-hidden', !isVisible); if ('isOpen' in this.model.changed) { this.$el.closest('.contextual-region').find('.contextual .trigger:not(:first)').toggle(!isOpen); } - return this; } }); diff --git a/core/modules/editor/js/editor.admin.js b/core/modules/editor/js/editor.admin.js index a1175e85d298648833bed0a594ef46400fb85e10..d265ed215a1bc07c057c74030dd17c724e07f15c 100644 --- a/core/modules/editor/js/editor.admin.js +++ b/core/modules/editor/js/editor.admin.js @@ -24,11 +24,10 @@ function generateUniverseFromFeatureRequirements(feature) { var properties = ['attributes', 'styles', 'classes']; var universe = {}; - for (var r = 0; r < feature.rules.length; r++) { var featureRule = feature.rules[r]; - var requiredTags = featureRule.required.tags; + var requiredTags = featureRule.required.tags; for (var t = 0; t < requiredTags.length; t++) { universe[requiredTags[t]] = { tag: false, @@ -42,14 +41,12 @@ for (var p = 0; p < properties.length; p++) { var property = properties[p]; - for (var pv = 0; pv < featureRule.required[property].length; pv++) { var propertyValue = featureRule.required[property]; universe[requiredTags]["".concat(property, ":").concat(propertyValue)] = false; } } } - return universe; } @@ -57,7 +54,6 @@ if (!universe.hasOwnProperty(tag)) { return false; } - var key = "".concat(property, ":").concat(propertyValue); if (allowing) { @@ -69,10 +65,8 @@ if (allowing) { universe[tag][key] = true; } - return true; } - return false; } @@ -81,7 +75,6 @@ Object.keys(universe[tag]).forEach(function (key) { if (key.match(regex)) { atLeastOneFound = true; - if (allowing) { universe[tag][key] = true; } @@ -93,7 +86,8 @@ function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) { var atLeastOneFound = false; Object.keys(universe).forEach(function (tag) { - if (findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing)) { + if ( + findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing)) { atLeastOneFound = true; } }); @@ -104,7 +98,6 @@ if (tag === '*') { return findPropertyValuesOnAllTags(universe, property, propertyValues, allowing); } - var atLeastOneFound = false; propertyValues.forEach(function (propertyValue) { if (findPropertyValueOnTag(universe, tag, property, propertyValue, allowing)) { @@ -128,7 +121,6 @@ if (tag === '*') { return deleteAllTagsFromUniverseIfAllowed(universe); } - if (universe.hasOwnProperty(tag) && Object.keys(universe[tag]).filter(function (key) { return key !== 'touchedByAllowedPropertyRule'; }).every(function (key) { @@ -137,23 +129,20 @@ delete universe[tag]; return true; } - return false; } function anyForbiddenFilterRuleMatches(universe, filterStatus) { var properties = ['attributes', 'styles', 'classes']; + var allRequiredTags = Object.keys(universe); var filterRule; - for (var i = 0; i < filterStatus.rules.length; i++) { filterRule = filterStatus.rules[i]; - if (filterRule.allow === false) { var intersection = filterRule.tags.filter(function (tag) { return allRequiredTags.includes(tag); }); - if (intersection.length > 0) { return true; } @@ -162,14 +151,11 @@ for (var n = 0; n < filterStatus.rules.length; n++) { filterRule = filterStatus.rules[n]; - if (filterRule.restrictedTags.tags.length && !emptyProperties(filterRule.restrictedTags.forbidden)) { for (var j = 0; j < filterRule.restrictedTags.tags.length; j++) { var tag = filterRule.restrictedTags.tags[j]; - for (var k = 0; k < properties.length; k++) { var property = properties[k]; - if (findPropertyValuesOnTag(universe, tag, property, filterRule.restrictedTags.forbidden[property], false)) { return true; } @@ -177,22 +163,19 @@ } } } - return false; } function markAllowedTagsAndPropertyValues(universe, filterStatus) { var properties = ['attributes', 'styles', 'classes']; + var filterRule; var tag; - for (var l = 0; Object.keys(universe).length > 0 && l < filterStatus.rules.length; l++) { filterRule = filterStatus.rules[l]; - if (filterRule.allow === true) { for (var m = 0; Object.keys(universe).length > 0 && m < filterRule.tags.length; m++) { tag = filterRule.tags[m]; - if (universe.hasOwnProperty(tag)) { universe[tag].tag = true; deleteFromUniverseIfAllowed(universe, tag); @@ -203,14 +186,11 @@ for (var i = 0; Object.keys(universe).length > 0 && i < filterStatus.rules.length; i++) { filterRule = filterStatus.rules[i]; - if (filterRule.restrictedTags.tags.length && !emptyProperties(filterRule.restrictedTags.allowed)) { for (var j = 0; Object.keys(universe).length > 0 && j < filterRule.restrictedTags.tags.length; j++) { tag = filterRule.restrictedTags.tags[j]; - for (var k = 0; k < properties.length; k++) { var property = properties[k]; - if (findPropertyValuesOnTag(universe, tag, property, filterRule.restrictedTags.allowed[property], true)) { deleteFromUniverseIfAllowed(universe, tag); } @@ -256,17 +236,14 @@ } var tags = Object.keys(universe); - for (var i = 0; i < tags.length; i++) { var tag = tags[i]; - if (universe.hasOwnProperty(tag)) { if (universe[tag].touchedByAllowedPropertyRule === false) { delete universe[tag]; } } } - return Object.keys(universe).length === 0; } @@ -287,12 +264,14 @@ styles: [], classes: [] }; + this.allowed = { tags: [], attributes: [], styles: [], classes: [] }; + this.raw = null; }; @@ -307,7 +286,9 @@ Drupal.FilterStatus = function (name) { this.name = name; + this.active = false; + this.rules = []; }; @@ -318,6 +299,7 @@ Drupal.FilterHTMLRule = function () { this.tags = []; this.allow = null; + this.restrictedTags = { tags: [], allowed: { @@ -333,7 +315,6 @@ }; return this; }; - Drupal.FilterHTMLRule.prototype.clone = function () { var clone = new Drupal.FilterHTMLRule(); clone.tags = this.tags.slice(0); @@ -361,12 +342,15 @@ }); } }; + Drupal.behaviors.initializeFilterConfiguration = { attach: function attach(context, settings) { once('filter-editor-status', '#filters-status-wrapper input.form-checkbox', context).forEach(function (checkbox) { var $checkbox = $(checkbox); var nameAttribute = $checkbox.attr('name'); + var filterID = nameAttribute.substring(8, nameAttribute.indexOf(']')); + Drupal.filterConfiguration.statuses[filterID] = new Drupal.FilterStatus(filterID); }); } diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index 70ae57a6799b32accd902e1a931c6c603fc5e360..222df985fef589aa3a80cfae32aa606ced066574 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -14,7 +14,8 @@ function filterXssWhenSwitching(field, format, originalFormatID, callback) { if (format.editor.isXssSafe) { callback(field, format); - } else { + } + else { $.ajax({ url: Drupal.url("editor/filter_xss/".concat(format.format)), type: 'POST', @@ -27,7 +28,6 @@ if (xssFilteredValue !== false) { field.value = xssFilteredValue; } - callback(field, format); } }); @@ -39,7 +39,8 @@ if (drupalSettings.editor.formats[previousFormatID]) { Drupal.editorDetach(field, drupalSettings.editor.formats[previousFormatID]); - } else { + } + else { $(field).off('.editor'); } @@ -63,7 +64,6 @@ var supportContentFiltering = drupalSettings.editor.formats[newFormatID] && drupalSettings.editor.formats[newFormatID].editorSupportsContentFiltering; var hasContent = field.value !== ''; - if (hasContent && supportContentFiltering) { var message = Drupal.t('Changing the text format to %text_format will permanently remove content that is not allowed in that text format.<br><br>Save your changes before switching the text format to avoid losing data.', { '%text_format': $(select).find('option:selected')[0].textContent @@ -103,12 +103,12 @@ } Drupal.editors = {}; + Drupal.behaviors.editor = { attach: function attach(context, settings) { if (!settings.editor) { return; } - once('editor', '[data-editor-for]', context).forEach(function (editor) { var $this = $(editor); var field = findFieldForFormatSelector($this); @@ -123,7 +123,6 @@ if (settings.editor.formats[activeFormatID]) { Drupal.editorAttach(field, settings.editor.formats[activeFormatID]); } - $(field).on('change.editor keypress.editor', function () { field.setAttribute('data-editor-value-is-changed', 'true'); $(field).off('.editor'); @@ -134,12 +133,10 @@ field: field }, onTextFormatChange); } - $this.parents('form').on('submit', function (event) { if (event.isDefaultPrevented()) { return; } - if (settings.editor.formats[activeFormatID]) { Drupal.editorDetach(field, settings.editor.formats[activeFormatID], 'serialize'); } @@ -148,18 +145,15 @@ }, detach: function detach(context, settings, trigger) { var editors; - if (trigger === 'serialize') { editors = once.filter('editor', '[data-editor-for]', context); } else { editors = once.remove('editor', '[data-editor-for]', context); } - editors.forEach(function (editor) { var $this = $(editor); var activeFormatID = editor.value; var field = findFieldForFormatSelector($this); - if (field && activeFormatID in settings.editor.formats) { Drupal.editorDetach(field, settings.editor.formats[activeFormatID], trigger); } @@ -170,8 +164,10 @@ Drupal.editorAttach = function (field, format) { if (format.editor) { Drupal.editors[format.editor].attach(field, format); + Drupal.editors[format.editor].onChange(field, function () { $(field).trigger('formUpdated'); + field.setAttribute('data-editor-value-is-changed', 'true'); }); } diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js index 30bdf9af8c1b47e4e075c513a5efd9906dd2610a..320ab6f7c44c8e74f99691be6f175fba46ee2aa9 100644 --- a/core/modules/field_ui/field_ui.js +++ b/core/modules/field_ui/field_ui.js @@ -9,13 +9,13 @@ Drupal.behaviors.fieldUIFieldStorageAddForm = { attach: function attach(context) { var form = once('field_ui_add', '[data-drupal-selector="field-ui-field-storage-add-form"]', context); - if (form.length) { var $form = $(form); $form.find('.js-form-item-label label,' + '.js-form-item-field-name label,' + '.js-form-item-existing-storage-label label').addClass('js-form-required form-required'); var $newFieldType = $form.find('select[name="new_storage_type"]'); var $existingStorageName = $form.find('select[name="existing_storage_name"]'); var $existingStorageLabel = $form.find('input[name="existing_storage_label"]'); + $newFieldType.on('change', function () { if (this.value !== '') { if ($existingStorageName.length) { @@ -24,9 +24,9 @@ } } }); + $existingStorageName.on('change', function () { var value = this.value; - if (value !== '') { if ($newFieldType.length) { $newFieldType[0].value = ''; @@ -41,6 +41,7 @@ } } }; + Drupal.behaviors.fieldUIDisplayOverview = { attach: function attach(context, settings) { once('field-display-overview', 'table#field-display-overview', context).forEach(function (overview) { @@ -48,17 +49,20 @@ }); } }; + Drupal.fieldUIOverview = { attach: function attach(table, rowsData, rowHandlers) { var tableDrag = Drupal.tableDrag[table.id]; + tableDrag.onDrop = this.onDrop; tableDrag.row.prototype.onSwap = this.onSwap; + $(table).find('tr.draggable').each(function () { var row = this; - if (row.id in rowsData) { var data = rowsData[row.id]; data.tableDrag = tableDrag; + var rowHandler = new rowHandlers[data.rowHandler](row, data); $(row).data('fieldUIRowHandler', rowHandler); } @@ -70,15 +74,13 @@ var rowHandler = $row.data('fieldUIRowHandler'); var refreshRows = {}; refreshRows[rowHandler.name] = $trigger.get(0); - var region = rowHandler.getRegion(); + var region = rowHandler.getRegion(); if (region !== rowHandler.region) { var $fieldParent = $row.find('select.js-field-parent'); - if ($fieldParent.length) { $fieldParent[0].value = ''; } - $.extend(refreshRows, rowHandler.regionChange(region)); rowHandler.region = region; } @@ -90,11 +92,9 @@ var row = dragObject.rowObject.element; var $row = $(row); var rowHandler = $row.data('fieldUIRowHandler'); - if (typeof rowHandler !== 'undefined') { var regionRow = $row.prevAll('tr.region-message').get(0); var region = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); - if (region !== rowHandler.region) { var refreshRows = rowHandler.regionChange(region); rowHandler.region = region; @@ -106,16 +106,15 @@ var rowObject = this; $(rowObject.table).find('tr.region-message').each(function () { var $this = $(this); - if ($this.prev('tr').get(0) === rowObject.group[rowObject.group.length - 1]) { if (rowObject.method !== 'keyboard' || rowObject.direction === 'down') { rowObject.swap('after', this); } } - if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length === 0) { $this.removeClass('region-populated').addClass('region-empty'); - } else if ($this.is('.region-empty')) { + } + else if ($this.is('.region-empty')) { $this.removeClass('region-empty').addClass('region-populated'); } }); @@ -127,20 +126,19 @@ rowNames.push(rowName); ajaxElements.push(rows[rowName]); }); - if (rowNames.length) { $(ajaxElements).after(Drupal.theme.ajaxProgressThrobber()); var $refreshRows = $('input[name=refresh_rows]'); - if ($refreshRows.length) { $refreshRows[0].value = rowNames.join(' '); } - $('input[data-drupal-selector="edit-refresh"]').trigger('mousedown'); + $(ajaxElements).prop('disabled', true); } } }; + Drupal.fieldUIDisplayOverview = {}; Drupal.fieldUIDisplayOverview.field = function (row, data) { @@ -149,13 +147,14 @@ this.region = data.region; this.tableDrag = data.tableDrag; this.defaultPlugin = data.defaultPlugin; + this.$pluginSelect = $(row).find('.field-plugin-type'); this.$pluginSelect.on('change', Drupal.fieldUIOverview.onChange); + this.$regionSelect = $(row).find('select.field-region'); this.$regionSelect.on('change', Drupal.fieldUIOverview.onChange); return this; }; - Drupal.fieldUIDisplayOverview.field.prototype = { getRegion: function getRegion() { if (this.$regionSelect.length) { @@ -164,21 +163,18 @@ }, regionChange: function regionChange(region) { region = region.replace(/-/g, '_'); - if (this.$regionSelect.length) { this.$regionSelect[0].value = region; } if (this.region === 'hidden') { var value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin : this.$pluginSelect.find('option')[0].value; - if (typeof value !== 'undefined') { if (this.$pluginSelect.length) { this.$pluginSelect[0].value = value; } } } - var refreshRows = {}; refreshRows[this.name] = this.$pluginSelect.get(0); return refreshRows; diff --git a/core/modules/file/file.js b/core/modules/file/file.js index b963984b4428a9efaab4688a37211b78c5c5fba1..684187b1102625b177f9a8bca71bb46092678b08 100644 --- a/core/modules/file/file.js +++ b/core/modules/file/file.js @@ -10,13 +10,11 @@ attach: function attach(context, settings) { var $context = $(context); var elements; - function initFileValidation(selector) { $(once('fileValidate', $context.find(selector))).on('change.fileValidate', { extensions: elements[selector] }, Drupal.file.validateExtension); } - if (settings.file && settings.file.elements) { elements = settings.file.elements; Object.keys(elements).forEach(initFileValidation); @@ -25,17 +23,16 @@ detach: function detach(context, settings, trigger) { var $context = $(context); var elements; - function removeFileValidation(selector) { $(once.remove('fileValidate', $context.find(selector))).off('change.fileValidate', Drupal.file.validateExtension); } - if (trigger === 'unload' && settings.file && settings.file.elements) { elements = settings.file.elements; Object.keys(elements).forEach(removeFileValidation); } } }; + Drupal.behaviors.fileAutoUpload = { attach: function attach(context) { $(once('auto-file-upload', 'input[type="file"]', context)).on('change.autoFileUpload', Drupal.file.triggerUploadButton); @@ -46,6 +43,7 @@ } } }; + Drupal.behaviors.fileButtons = { attach: function attach(context) { var $context = $(context); @@ -60,6 +58,7 @@ } } }; + Drupal.behaviors.filePreviewLinks = { attach: function attach(context) { $(context).find('div.js-form-managed-file .file a').on('click', Drupal.file.openInNewWindow); @@ -68,15 +67,15 @@ $(context).find('div.js-form-managed-file .file a').off('click', Drupal.file.openInNewWindow); } }; + Drupal.file = Drupal.file || { validateExtension: function validateExtension(event) { event.preventDefault(); $('.file-upload-js-error').remove(); - var extensionPattern = event.data.extensions.replace(/,\s*/g, '|'); + var extensionPattern = event.data.extensions.replace(/,\s*/g, '|'); if (extensionPattern.length > 1 && this.value.length > 0) { var acceptableMatch = new RegExp("\\.(".concat(extensionPattern, ")$"), 'gi'); - if (!acceptableMatch.test(this.value)) { var error = Drupal.t('The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.', { '%filename': this.value.replace('C:\\fakepath\\', ''), @@ -94,8 +93,8 @@ disableFields: function disableFields(event) { var $clickedButton = $(this); $clickedButton.trigger('formUpdated'); - var $enabledFields = []; + var $enabledFields = []; if ($clickedButton.closest('div.js-form-managed-file').length > 0) { $enabledFields = $clickedButton.closest('div.js-form-managed-file').find('input.js-form-file'); } @@ -109,15 +108,15 @@ progressBar: function progressBar(event) { var $clickedButton = $(this); var $progressId = $clickedButton.closest('div.js-form-managed-file').find('input.file-progress'); - if ($progressId.length) { var originalName = $progressId.attr('name'); + $progressId.attr('name', originalName.match(/APC_UPLOAD_PROGRESS|UPLOAD_IDENTIFIER/)[0]); + setTimeout(function () { $progressId.attr('name', originalName); }, 1000); } - setTimeout(function () { $clickedButton.closest('div.js-form-managed-file').find('div.ajax-progress-bar').slideDown(); }, 500); diff --git a/core/modules/filter/filter.admin.js b/core/modules/filter/filter.admin.js index 43baa73394c05cf47e750fa1c025cab85962779e..bcb58743b3a16abacf1c1f22ab6b6b7cda41939e 100644 --- a/core/modules/filter/filter.admin.js +++ b/core/modules/filter/filter.admin.js @@ -14,10 +14,10 @@ var $row = $context.find("#".concat($checkbox.attr('id').replace(/-status$/, '-weight'))).closest('tr'); var $filterSettings = $context.find("[data-drupal-selector='".concat($checkbox.attr('id').replace(/-status$/, '-settings'), "']")); var filterSettingsTab = $filterSettings.data('verticalTab'); + $checkbox.on('click.filterUpdate', function () { if ($checkbox.is(':checked')) { $row.show(); - if (filterSettingsTab) { filterSettingsTab.tabShow().updateSummary(); } else { @@ -25,14 +25,12 @@ } } else { $row.hide(); - if (filterSettingsTab) { filterSettingsTab.tabHide().updateSummary(); } else { $filterSettings.hide(); } } - Drupal.tableDrag['filter-order'].restripeTable(); }); diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js index bbf687101411b06278bc481fcbbea20c7b38503c..aa4869ed1d63c77a37d7a464fc66c834f799c350 100644 --- a/core/modules/filter/filter.filter_html.admin.js +++ b/core/modules/filter/filter.filter_html.admin.js @@ -4,17 +4,11 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function ($, Drupal, document) { @@ -22,7 +16,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.filterConfiguration.liveSettingParsers.filter_html = { getRules: function getRules() { var currentValue = document.querySelector('#edit-filters-filter-html-settings-allowed-html').value; - var rules = Drupal.behaviors.filterFilterHtmlUpdating._parseSetting(currentValue); var rule = new Drupal.FilterHTMLRule(); @@ -38,7 +31,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - return args.reduce(function (mainData, otherData) { return mainData.filter(function (data) { return !otherData.includes(data); @@ -58,23 +50,22 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len that.$allowedHTMLFormItem = $(formItem); that.$allowedHTMLDescription = that.$allowedHTMLFormItem.closest('.js-form-item').find('#edit-filters-filter-html-settings-allowed-html--description'); that.userTags = that._parseSetting(formItem.value); + $(document).on('drupalEditorFeatureAdded', function (e, feature) { that.newFeatures[feature.name] = feature.rules; - that._updateAllowedTags(); }).on('drupalEditorFeatureModified', function (e, feature) { if (that.newFeatures.hasOwnProperty(feature.name)) { that.newFeatures[feature.name] = feature.rules; - that._updateAllowedTags(); } }).on('drupalEditorFeatureRemoved', function (e, feature) { if (that.newFeatures.hasOwnProperty(feature.name)) { delete that.newFeatures[feature.name]; - that._updateAllowedTags(); } }); + that.$allowedHTMLFormItem.on('change.updateUserTags', function () { that.userTags = difference(Object.values(that._parseSetting(this.value)), Object.values(that.autoTags)); }); @@ -82,8 +73,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }, _updateAllowedTags: function _updateAllowedTags() { var _this = this; - this.autoTags = this._calculateAutoAllowedTags(this.userTags, this.newFeatures); + this.$allowedHTMLDescription.find('.editor-update-message').remove(); if (Object.keys(this.autoTags).length > 0) { @@ -95,38 +86,35 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len userTagsWithoutOverrides[tag] = _this.userTags[tag]; }); this.$allowedHTMLFormItem.val("".concat(this._generateSetting(userTagsWithoutOverrides), " ").concat(this._generateSetting(this.autoTags))); - } else { + } + else { this.$allowedHTMLFormItem.val(this._generateSetting(this.userTags)); } }, _calculateAutoAllowedTags: function _calculateAutoAllowedTags(userAllowedTags, newFeatures) { var editorRequiredTags = {}; + Object.keys(newFeatures || {}).forEach(function (featureName) { var feature = newFeatures[featureName]; var featureRule; var filterRule; var tag; - for (var f = 0; f < feature.length; f++) { featureRule = feature[f]; - for (var t = 0; t < featureRule.required.tags.length; t++) { tag = featureRule.required.tags[t]; - if (!editorRequiredTags.hasOwnProperty(tag)) { filterRule = new Drupal.FilterHTMLRule(); filterRule.restrictedTags.tags = [tag]; filterRule.restrictedTags.allowed.attributes = featureRule.required.attributes.slice(0); - if (userAllowedTags[tag] !== undefined && userAllowedTags[tag].restrictedTags.allowed.classes[0] !== '') { filterRule.restrictedTags.allowed.classes = featureRule.required.classes.slice(0); } - editorRequiredTags[tag] = filterRule; - } else { + } + else { filterRule = editorRequiredTags[tag]; filterRule.restrictedTags.allowed.attributes = [].concat(_toConsumableArray(filterRule.restrictedTags.allowed.attributes), _toConsumableArray(featureRule.required.attributes)); - if (userAllowedTags[tag] !== undefined && userAllowedTags[tag].restrictedTags.allowed.classes[0] !== '') { filterRule.restrictedTags.allowed.classes = [].concat(_toConsumableArray(filterRule.restrictedTags.allowed.classes), _toConsumableArray(featureRule.required.classes)); } @@ -134,26 +122,25 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len } } }); + var autoAllowedTags = {}; Object.keys(editorRequiredTags).forEach(function (tag) { if (!userAllowedTags.hasOwnProperty(tag)) { autoAllowedTags[tag] = editorRequiredTags[tag]; - } else { + } + else { var requiredAttributes = editorRequiredTags[tag].restrictedTags.allowed.attributes; var allowedAttributes = userAllowedTags[tag].restrictedTags.allowed.attributes; var needsAdditionalAttributes = requiredAttributes.length && difference(requiredAttributes, allowedAttributes).length; var requiredClasses = editorRequiredTags[tag].restrictedTags.allowed.classes; var allowedClasses = userAllowedTags[tag].restrictedTags.allowed.classes; var needsAdditionalClasses = requiredClasses.length && difference(requiredClasses, allowedClasses).length; - if (needsAdditionalAttributes || needsAdditionalClasses) { autoAllowedTags[tag] = userAllowedTags[tag].clone(); } - if (needsAdditionalAttributes) { autoAllowedTags[tag].restrictedTags.allowed.attributes = [].concat(_toConsumableArray(allowedAttributes), _toConsumableArray(requiredAttributes)); } - if (needsAdditionalClasses) { autoAllowedTags[tag].restrictedTags.allowed.classes = [].concat(_toConsumableArray(allowedClasses), _toConsumableArray(requiredClasses)); } @@ -168,18 +155,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var attribute; var allowedTags = setting.match(/(<[^>]+>)/g); var rules = {}; - for (var t = 0; t < allowedTags.length; t++) { var $tagObject = $(allowedTags[t]); + tag = $tagObject.prop('tagName').toLowerCase(); + rule = new Drupal.FilterHTMLRule(); rule.restrictedTags.tags = [tag]; - attributes = $tagObject.prop('attributes'); + attributes = $tagObject.prop('attributes'); for (var i = 0; i < attributes.length; i++) { attribute = attributes.item(i); var attributeName = attribute.nodeName; - if (attributeName === 'class') { var attributeValue = attribute.textContent; rule.restrictedTags.allowed.classes = attributeValue.split(' '); @@ -187,33 +174,26 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len rule.restrictedTags.allowed.attributes.push(attributeName); } } - rules[tag] = rule; } - return rules; }, _generateSetting: function _generateSetting(tags) { return Object.keys(tags).reduce(function (setting, tag) { var rule = tags[tag]; var allowedClasses = rule.restrictedTags.allowed.classes; - if (setting.length) { setting += ' '; } - setting += "<".concat(tag); - if (rule.restrictedTags.allowed.attributes.length) { setting += " ".concat(rule.restrictedTags.allowed.attributes.join(' ')); } - if (allowedClasses.length === 1 && allowedClasses[0] === '') { setting += ' class'; } else if (allowedClasses.length) { setting += " class=\"".concat(allowedClasses.join(' '), "\""); } - setting += '>'; return setting; }, ''); @@ -222,9 +202,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len Drupal.theme.filterFilterHTMLUpdateMessage = function (tags) { var html = ''; - var tagList = Drupal.behaviors.filterFilterHtmlUpdating._generateSetting(tags); - html += '<p class="editor-update-message">'; html += Drupal.t('Based on the text editor configuration, these tags have automatically been added: <strong>@tag-list</strong>.', { '@tag-list': tagList diff --git a/core/modules/filter/filter.js b/core/modules/filter/filter.js index d7964d951991c70a6666f1c0d323a975a892e498..5417c44ed9f6b8ce56c7c70af9c6236be466aca3 100644 --- a/core/modules/filter/filter.js +++ b/core/modules/filter/filter.js @@ -13,8 +13,8 @@ var value = event.target.value; $this.closest('.js-filter-wrapper').find('[data-drupal-format-id]').hide().filter("[data-drupal-format-id=\"".concat(value, "\"]")).show(); } - - $(once('filter-guidelines', '.js-filter-guidelines', context)).find(':header').hide().closest('.js-filter-wrapper').find('select.js-filter-list').on('change.filterGuidelines', updateFilterGuidelines).trigger('change.filterGuidelines'); + $(once('filter-guidelines', '.js-filter-guidelines', context)).find(':header').hide().closest('.js-filter-wrapper').find('select.js-filter-list').on('change.filterGuidelines', updateFilterGuidelines) + .trigger('change.filterGuidelines'); } }; })(jQuery, Drupal); \ No newline at end of file diff --git a/core/modules/history/js/history.js b/core/modules/history/js/history.js index 8e13059da8c3738ccbc8fdcb897f357beb8ebcc0..319c33d3623fe814433731d579b439fac3bbe8df 100644 --- a/core/modules/history/js/history.js +++ b/core/modules/history/js/history.js @@ -7,10 +7,11 @@ (function ($, Drupal, drupalSettings, storage) { var currentUserID = parseInt(drupalSettings.user.uid, 10); + var secondsIn30Days = 2592000; var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days; - var embeddedLastReadTimestamps = false; + var embeddedLastReadTimestamps = false; if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) { embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps; } @@ -21,7 +22,6 @@ callback(); return; } - $.ajax({ url: Drupal.url('history/get_node_read_timestamps'), type: 'POST', @@ -41,7 +41,6 @@ if (embeddedLastReadTimestamps && embeddedLastReadTimestamps[nodeID]) { return parseInt(embeddedLastReadTimestamps[nodeID], 10); } - return parseInt(storage.getItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID)) || 0, 10); }, markAsRead: function markAsRead(nodeID) { @@ -53,7 +52,6 @@ if (embeddedLastReadTimestamps && embeddedLastReadTimestamps[nodeID]) { return; } - storage.setItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID), timestamp); } }); @@ -66,7 +64,6 @@ if (embeddedLastReadTimestamps && embeddedLastReadTimestamps[nodeID]) { return contentTimestamp > parseInt(embeddedLastReadTimestamps[nodeID], 10); } - var minLastReadTimestamp = parseInt(storage.getItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID)) || 0, 10); return contentTimestamp > minLastReadTimestamp; } diff --git a/core/modules/language/language.admin.js b/core/modules/language/language.admin.js index 4ae06b194e00e2c5c8c526ba1b2c446b0e83473d..1206c8f3491fa50a8c42783b701512080e84eaed 100644 --- a/core/modules/language/language.admin.js +++ b/core/modules/language/language.admin.js @@ -10,7 +10,6 @@ attach: function attach() { var $configForm = $('#language-negotiation-configure-form'); var inputSelector = 'input[name$="[configurable]"]'; - function toggleTable(checkbox) { var $checkbox = $(checkbox); $checkbox.closest('.table-language-group').find('table, .tabledrag-toggle-weight').toggle($checkbox.prop('checked')); diff --git a/core/modules/layout_builder/js/layout-builder.js b/core/modules/layout_builder/js/layout-builder.js index 729d5364136d818fa125ba0ff7752dfa68fa03f3..c99f747b964d1bf0f608b16cea4678525ccf584b 100644 --- a/core/modules/layout_builder/js/layout-builder.js +++ b/core/modules/layout_builder/js/layout-builder.js @@ -7,11 +7,13 @@ (function ($, Drupal, Sortable) { var ajax = Drupal.ajax, - behaviors = Drupal.behaviors, - debounce = Drupal.debounce, - announce = Drupal.announce, - formatPlural = Drupal.formatPlural; + behaviors = Drupal.behaviors, + debounce = Drupal.debounce, + announce = Drupal.announce, + formatPlural = Drupal.formatPlural; + var layoutBuilderBlocksFiltered = false; + behaviors.layoutBuilderBlockFilter = { attach: function attach(context) { var $categories = $('.js-layout-builder-categories', context); @@ -27,8 +29,10 @@ if (query.length >= 2) { $categories.find('.js-layout-builder-category:not([open])').attr('remember-closed', ''); + $categories.find('.js-layout-builder-category').attr('open', ''); $filterLinks.each(toggleBlockEntry); + $categories.find('.js-layout-builder-category:not(:has(.js-layout-builder-block-link:visible))').hide(); announce(formatPlural($categories.find('.js-layout-builder-block-link:visible').length, '1 block is available in the modified list.', '@count blocks are available in the modified list.')); layoutBuilderBlocksFiltered = true; @@ -40,7 +44,6 @@ announce(Drupal.t('All available blocks are listed.')); } }; - $(once('block-filter-text', 'input.js-layout-builder-filter', context)).on('keyup', debounce(filterBlockList, 200)); } }; @@ -48,8 +51,8 @@ Drupal.layoutBuilderBlockUpdate = function (item, from, to) { var $item = $(item); var $from = $(from); - var itemRegion = $item.closest('.js-layout-builder-region'); + var itemRegion = $item.closest('.js-layout-builder-region'); if (to === itemRegion[0]) { var deltaTo = $item.closest('[data-layout-delta]').data('layout-delta'); var deltaFrom = $from ? $from.closest('[data-layout-delta]').data('layout-delta') : deltaTo; @@ -76,33 +79,37 @@ }); } }; + behaviors.layoutBuilderDisableInteractiveElements = { attach: function attach() { var $blocks = $('#layout-builder [data-layout-block-uuid]'); $blocks.find('input, textarea, select').prop('disabled', true); - $blocks.find('a').not(function (index, element) { + $blocks.find('a') + .not(function (index, element) { return $(element).closest('[data-contextual-id]').length > 0; }).on('click mouseup touchstart', function (e) { e.preventDefault(); e.stopPropagation(); }); + $blocks.find('button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"]):not(.tabbable)').not(function (index, element) { return $(element).closest('[data-contextual-id]').length > 0; }).attr('tabindex', -1); } }; + $(window).on('dialog:aftercreate', function (event, dialog, $element) { if (Drupal.offCanvas.isOffCanvas($element)) { $('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted'); - var id = $element.find('[data-layout-builder-target-highlight-id]').attr('data-layout-builder-target-highlight-id'); + var id = $element.find('[data-layout-builder-target-highlight-id]').attr('data-layout-builder-target-highlight-id'); if (id) { $("[data-layout-builder-highlight-id=\"".concat(id, "\"]")).addClass('is-layout-builder-highlighted'); } $('#layout-builder').removeClass('layout-builder--move-blocks-active'); - var layoutBuilderWrapperValue = $element.find('[data-add-layout-builder-wrapper]').attr('data-add-layout-builder-wrapper'); + var layoutBuilderWrapperValue = $element.find('[data-add-layout-builder-wrapper]').attr('data-add-layout-builder-wrapper'); if (layoutBuilderWrapperValue) { $('#layout-builder').addClass(layoutBuilderWrapperValue); } @@ -111,9 +118,9 @@ if (document.querySelector('[data-off-canvas-main-canvas]')) { var mainCanvas = document.querySelector('[data-off-canvas-main-canvas]'); + mainCanvas.addEventListener('transitionend', function () { var $target = $('.is-layout-builder-highlighted'); - if ($target.length > 0) { var targetTop = $target.offset().top; var targetBottom = targetTop + $target.outerHeight(); @@ -137,24 +144,30 @@ } }); } - $(window).on('dialog:afterclose', function (event, dialog, $element) { if (Drupal.offCanvas.isOffCanvas($element)) { $('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted'); + $('#layout-builder').removeClass('layout-builder--move-blocks-active'); } }); + behaviors.layoutBuilderToggleContentPreview = { attach: function attach(context) { var $layoutBuilder = $('#layout-builder'); + var $layoutBuilderContentPreview = $('#layout-builder-content-preview'); + var contentPreviewId = $layoutBuilderContentPreview.data('content-preview-id'); + var isContentPreview = JSON.parse(localStorage.getItem(contentPreviewId)) !== false; var disableContentPreview = function disableContentPreview() { $layoutBuilder.addClass('layout-builder--content-preview-disabled'); + $('[data-layout-content-preview-placeholder-label]', context).each(function (i, element) { var $element = $(element); + $element.children(':not([data-contextual-id])').hide(0); var contentPreviewPlaceholderText = $element.attr('data-layout-content-preview-placeholder-label'); var contentPreviewPlaceholderLabel = Drupal.theme('layoutBuilderPrependContentPreviewPlaceholderLabel', contentPreviewPlaceholderText); @@ -164,16 +177,16 @@ var enableContentPreview = function enableContentPreview() { $layoutBuilder.removeClass('layout-builder--content-preview-disabled'); + $('.js-layout-builder-content-preview-placeholder-label').remove(); + $('[data-layout-content-preview-placeholder-label]').each(function (i, element) { $(element).children().show(); }); }; - $('#layout-builder-content-preview', context).on('change', function (event) { var isChecked = $(event.currentTarget).is(':checked'); localStorage.setItem(contentPreviewId, JSON.stringify(isChecked)); - if (isChecked) { enableContentPreview(); announce(Drupal.t('Block previews are visible. Block labels are hidden.')); diff --git a/core/modules/locale/locale.admin.js b/core/modules/locale/locale.admin.js index b01f9a8d8b68fd55affaf2517b2d2e423449a1a4..7e3f661f52f7dccd074ffcca413bda7c4d3027a2 100644 --- a/core/modules/locale/locale.admin.js +++ b/core/modules/locale/locale.admin.js @@ -9,7 +9,6 @@ Drupal.behaviors.localeTranslateDirty = { attach: function attach() { var form = once('localetranslatedirty', '#locale-translate-edit-form'); - if (form.length) { var $form = $(form); $form.one('formUpdated.localeTranslateDirty', 'table', function () { @@ -22,7 +21,6 @@ var rowToMark = once('localemark', $row); var marker = Drupal.theme('localeTranslateChangedMarker'); $row.addClass('changed'); - if (rowToMark.length) { $(rowToMark).find('td:first-child .js-form-item').append(marker); } @@ -32,30 +30,28 @@ detach: function detach(context, settings, trigger) { if (trigger === 'unload') { var form = once.remove('localetranslatedirty', '#locale-translate-edit-form'); - if (form.length) { $(form).off('formUpdated.localeTranslateDirty'); } } } }; + Drupal.behaviors.hideUpdateInformation = { attach: function attach(context, settings) { var table = once('expand-updates', '#locale-translation-status-form'); - if (table.length) { var $table = $(table); var $tbodies = $table.find('tbody'); + $tbodies.on('click keydown', '.description', function (e) { if (e.keyCode && e.keyCode !== 13 && e.keyCode !== 32) { return; } - e.preventDefault(); var $tr = $(this).closest('tr'); $tr.toggleClass('expanded'); var $localePrefix = $tr.find('.locale-translation-update__prefix'); - if ($localePrefix.length) { $localePrefix[0].textContent = $tr.hasClass('expanded') ? Drupal.t('Hide description') : Drupal.t('Show description'); } diff --git a/core/modules/locale/locale.bulk.js b/core/modules/locale/locale.bulk.js index 80c2841099c3ff79059e74909966d622ce8add9a..c2c696e0acc4f1fb6bd13083c350456ce6d6ad8f 100644 --- a/core/modules/locale/locale.bulk.js +++ b/core/modules/locale/locale.bulk.js @@ -9,13 +9,11 @@ Drupal.behaviors.importLanguageCodeSelector = { attach: function attach(context, settings) { var form = once('autodetect-lang', '#locale-translate-import-form'); - if (form.length) { var $form = $(form); var $langcode = $form.find('.langcode-input'); $form.find('.file-import-input').on('change', function () { var matches = this.value.match(/([^.][.]*)([\w-]+)\.po$/); - if (matches && $langcode.find("option[value=\"".concat(matches[2], "\"]")).length) { $langcode[0].value = matches[2]; } diff --git a/core/modules/media/js/form.js b/core/modules/media/js/form.js index 52f7bdc11f414fa5d8cc777758b244d56250b9e5..a540d0ba1ccb11531a1e8e39953e621b0e329570 100644 --- a/core/modules/media/js/form.js +++ b/core/modules/media/js/form.js @@ -13,20 +13,17 @@ var name = nameInput && nameInput.value; var dateInput = context.querySelector('.field--name-created input'); var date = dateInput && dateInput.value; - if (name && date) { return Drupal.t('By @name on @date', { '@name': name, '@date': date }); } - if (name) { return Drupal.t('By @name', { '@name': name }); } - if (date) { return Drupal.t('Authored on @date', { '@date': date diff --git a/core/modules/media/js/type_form.js b/core/modules/media/js/type_form.js index 4bfe34493fdf1063af1e082c053fdabbaf324b78..d49a72c1b6351b7aaf1e343c184b2d2ddea05b03 100644 --- a/core/modules/media/js/type_form.js +++ b/core/modules/media/js/type_form.js @@ -14,11 +14,9 @@ $(context).find('input[name^="options"]:checked').parent().each(function () { vals.push(Drupal.checkPlain($(this).find('label')[0].textContent)); }); - if (!$(context).find('#edit-options-status').is(':checked')) { vals.unshift(Drupal.t('Not published')); } - return vals.join(', '); }); $(context).find('#edit-language').drupalSetSummary(function (context) { diff --git a/core/modules/media_library/js/media_library.click_to_select.js b/core/modules/media_library/js/media_library.click_to_select.js index 4c4aeaa397ef90388df08b7e66b12f0383543b3e..40f9c9b46d42a1e61c8b5026f965227592508faf 100644 --- a/core/modules/media_library/js/media_library.click_to_select.js +++ b/core/modules/media_library/js/media_library.click_to_select.js @@ -16,14 +16,16 @@ $(once('media-library-click-to-select', '.js-click-to-select-checkbox input', context)).on('change', function (_ref) { var currentTarget = _ref.currentTarget; $(currentTarget).closest('.js-click-to-select').toggleClass('checked', $(currentTarget).prop('checked')); - }).on('focus blur', function (_ref2) { + }) + .on('focus blur', function (_ref2) { var currentTarget = _ref2.currentTarget, - type = _ref2.type; + type = _ref2.type; $(currentTarget).closest('.js-click-to-select').toggleClass('is-focus', type === 'focus'); }); + $(once('media-library-click-to-select-hover', '.js-click-to-select-trigger, .js-click-to-select-checkbox', context)).on('mouseover mouseout', function (_ref3) { var currentTarget = _ref3.currentTarget, - type = _ref3.type; + type = _ref3.type; $(currentTarget).closest('.js-click-to-select').toggleClass('is-hover', type === 'mouseover'); }); } diff --git a/core/modules/media_library/js/media_library.ui.js b/core/modules/media_library/js/media_library.ui.js index 340f1851cebedf8e36d460fe950d9d212221d82c..9a2734a758a8684cd5cd8512fe53a6099a7604b5 100644 --- a/core/modules/media_library/js/media_library.ui.js +++ b/core/modules/media_library/js/media_library.ui.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal, window, _ref) { var tabbable = _ref.tabbable; Drupal.MediaLibrary = { @@ -29,6 +28,7 @@ }).on('click', function (e) { e.preventDefault(); e.stopPropagation(); + var ajaxObject = Drupal.ajax({ wrapper: 'media-library-content', url: e.currentTarget.href, @@ -42,41 +42,43 @@ ajaxObject.success = function (response, status) { return Promise.resolve(Drupal.Ajax.prototype.success.call(ajaxObject, response, status)).then(function () { var mediaLibraryContent = document.getElementById('media-library-content'); - if (mediaLibraryContent) { var tabbableContent = tabbable(mediaLibraryContent); - if (tabbableContent.length) { tabbableContent[0].focus(); } } }); }; - ajaxObject.execute(); + $menu.find('.active-tab').remove(); $menu.find('a').removeClass('active'); $(e.currentTarget).addClass('active').html(Drupal.t('<span class="visually-hidden">Show </span>@title<span class="visually-hidden"> media</span><span class="active-tab visually-hidden"> (selected)</span>', { '@title': $(e.currentTarget).data('title') })); + Drupal.announce(Drupal.t('Showing @title media.', { '@title': $(e.currentTarget).data('title') })); }); } }; + Drupal.behaviors.MediaLibraryViewsDisplay = { attach: function attach(context) { var $view = $(context).hasClass('.js-media-library-view') ? $(context) : $('.js-media-library-view', context); + $view.closest('.views-element-container').attr('id', 'media-library-view'); + $(once('media-library-views-display-link', '.views-display-link-widget, .views-display-link-widget_table', context)).on('click', function (e) { e.preventDefault(); e.stopPropagation(); var $link = $(e.currentTarget); + var loadingAnnouncement = ''; var displayAnnouncement = ''; var focusSelector = ''; - if ($link.hasClass('views-display-link-widget')) { loadingAnnouncement = Drupal.t('Loading grid view.'); displayAnnouncement = Drupal.t('Changed to grid view.'); @@ -99,20 +101,16 @@ if (displayAnnouncement || focusSelector) { var success = ajaxObject.success; - ajaxObject.success = function (response, status) { success.bind(this)(response, status); - if (focusSelector) { $(focusSelector).focus(); } - if (displayAnnouncement) { Drupal.announce(displayAnnouncement); } }; } - ajaxObject.execute(); if (loadingAnnouncement) { @@ -121,15 +119,14 @@ }); } }; + Drupal.behaviors.MediaLibraryItemSelection = { attach: function attach(context, settings) { var $form = $('.js-media-library-views-form, .js-media-library-add-form', context); var currentSelection = Drupal.MediaLibrary.currentSelection; - if (!$form.length) { return; } - var $mediaItems = $('.js-media-library-item input[type="checkbox"]', $form); function disableItems($items) { @@ -149,8 +146,8 @@ $(once('media-item-change', $mediaItems)).on('change', function (e) { var id = e.currentTarget.value; - var position = currentSelection.indexOf(id); + var position = currentSelection.indexOf(id); if (e.currentTarget.checked) { if (position === -1) { currentSelection.push(id); @@ -158,9 +155,7 @@ } else if (position !== -1) { currentSelection.splice(position, 1); } - var mediaLibraryModalSelection = document.querySelector('#media-library-modal-selection'); - if (mediaLibraryModalSelection) { mediaLibraryModalSelection.value = currentSelection.join(); $(mediaLibraryModalSelection).trigger('change'); @@ -170,6 +165,7 @@ item.value = currentSelection.join(); }); }); + $(once('media-library-selection-change', $form.find('#media-library-modal-selection'))).on('change', function (e) { updateSelectionCount(settings.media_library.selection_remaining); @@ -180,6 +176,7 @@ enableItems($mediaItems); } }); + currentSelection.forEach(function (value) { $form.find("input[type=\"checkbox\"][value=\"".concat(value, "\"]")).prop('checked', true).trigger('change'); }); @@ -187,25 +184,22 @@ if (!once('media-library-selection-info', 'html').length) { return; } - $(window).on('dialog:aftercreate', function () { var $buttonPane = $('.media-library-widget-modal .ui-dialog-buttonpane'); - if (!$buttonPane.length) { return; } - $buttonPane.append(Drupal.theme('mediaLibrarySelectionCount')); updateSelectionCount(settings.media_library.selection_remaining); }); } }; + Drupal.behaviors.MediaLibraryModalClearSelection = { attach: function attach() { if (!once('media-library-clear-selection', 'html').length) { return; } - $(window).on('dialog:afterclose', function () { Drupal.MediaLibrary.currentSelection = []; }); diff --git a/core/modules/media_library/js/media_library.view.js b/core/modules/media_library/js/media_library.view.js index 4e9e8be788a5fa067497b715833401a77fdeb6c9..23169278247ee67667aa9dd4b7190d03bd5a3017 100644 --- a/core/modules/media_library/js/media_library.view.js +++ b/core/modules/media_library/js/media_library.view.js @@ -4,12 +4,10 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { Drupal.behaviors.MediaLibrarySelectAll = { attach: function attach(context) { var $view = $(once('media-library-select-all', '.js-media-library-view[data-view-display-id="page"]', context)); - if ($view.length && $view.find('.js-media-library-item').length) { var $checkbox = $(Drupal.theme('checkbox')).on('click', function (_ref) { var currentTarget = _ref.currentTarget; diff --git a/core/modules/media_library/js/media_library.widget.js b/core/modules/media_library/js/media_library.widget.js index b83668f9ea00419bf54800c5179b88d5a5009a68..a3718d5a91c1c35a4680a57b75d3dd388f342f50 100644 --- a/core/modules/media_library/js/media_library.widget.js +++ b/core/modules/media_library/js/media_library.widget.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal, Sortable) { Drupal.behaviors.MediaLibraryWidgetSortable = { attach: function attach(context) { @@ -22,6 +21,7 @@ }); } }; + Drupal.behaviors.MediaLibraryWidgetToggleWeight = { attach: function attach(context) { var strings = { @@ -41,10 +41,12 @@ $(once('media-library-toggle', '.js-media-library-item-weight', context)).parent().hide(); } }; + Drupal.behaviors.MediaLibraryWidgetDisableButton = { attach: function attach(context) { once('media-library-disable', '.js-media-library-open-button[data-disabled-focus="true"]', context).forEach(function (button) { $(button).focus(); + setTimeout(function () { $(button).attr('disabled', 'disabled'); }, 50); diff --git a/core/modules/menu_ui/menu_ui.admin.js b/core/modules/menu_ui/menu_ui.admin.js index cbaea32075b6b1584280452b6bb9b52d6cf02b26..bd6fbfed398bea54a0b2462a62407224f39aa8aa 100644 --- a/core/modules/menu_ui/menu_ui.admin.js +++ b/core/modules/menu_ui/menu_ui.admin.js @@ -9,10 +9,10 @@ Drupal.behaviors.menuUiChangeParentItems = { attach: function attach(context, settings) { var menu = once('menu-parent', '#edit-menu'); - if (menu.length) { var $menu = $(menu); Drupal.menuUiUpdateParentList(); + $menu.on('change', 'input', Drupal.menuUiUpdateParentList); } } @@ -44,6 +44,7 @@ $select.append(selectContents); totalOptions++; }); + $select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0); } }); diff --git a/core/modules/menu_ui/menu_ui.js b/core/modules/menu_ui/menu_ui.js index caf4bd10872671ce156101eb4559e640a27ef5bd..ac471e443839c2c56882262c9f3ddf6cb05056fd 100644 --- a/core/modules/menu_ui/menu_ui.js +++ b/core/modules/menu_ui/menu_ui.js @@ -10,15 +10,14 @@ attach: function attach(context) { $(context).find('.menu-link-form').drupalSetSummary(function (context) { var $context = $(context); - if ($context.find('.js-form-item-menu-enabled input').is(':checked')) { return Drupal.checkPlain($context.find('.js-form-item-menu-title input')[0].value); } - return Drupal.t('Not in menu'); }); } }; + Drupal.behaviors.menuUiLinkAutomaticTitle = { attach: function attach(context) { var $context = $(context); @@ -27,15 +26,12 @@ var $checkbox = $this.find('.js-form-item-menu-enabled input'); var $linkTitle = $context.find('.js-form-item-menu-title input'); var $title = $this.closest('form').find('.js-form-item-title-0-value input'); - if (!($checkbox.length && $linkTitle.length && $title.length)) { return; } - if ($checkbox.is(':checked') && $linkTitle[0].value.length) { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); } - $linkTitle.on('keyup', function () { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); }); @@ -48,7 +44,6 @@ $linkTitle[0].value = ''; $linkTitle.removeData('menuLinkAutomaticTitleOverridden'); } - $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated'); $checkbox.trigger('formUpdated'); }); diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index e2034ebccc838fc4af4013e8d0216f02f1a16594..00ddb2af8a0c9290f1a349d34e23b4ad59f1aed2 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -19,11 +19,9 @@ $(context).find('input[name^="options"]:checked').next('label').each(function () { vals.push(Drupal.checkPlain(this.textContent)); }); - if (!$(context).find('#edit-options-status').is(':checked')) { vals.unshift(Drupal.t('Not published')); } - return vals.join(', '); }); $('#edit-language', context).drupalSetSummary(function (context) { @@ -40,11 +38,9 @@ $editContext.find('input:checked').next('label').each(function () { vals.push(Drupal.checkPlain(this.textContent)); }); - if (!$editContext.find('#edit-display-submitted').is(':checked')) { vals.unshift(Drupal.t("Don't display post information")); } - return vals.join(', '); }); } diff --git a/core/modules/node/node.js b/core/modules/node/node.js index a7e70ca4422476b859eaff735d9cb4e365aba8b3..f7022baedf0fe5f5bd4e2f35886c52773b90c0b6 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -14,20 +14,17 @@ var name = nameElement && nameElement.value; var dateElement = context.querySelector('.field--name-created input'); var date = dateElement && dateElement.value; - if (name && date) { return Drupal.t('By @name on @date', { '@name': name, '@date': date }); } - if (name) { return Drupal.t('By @name', { '@name': name }); } - if (date) { return Drupal.t('Authored on @date', { '@date': date @@ -37,14 +34,12 @@ $context.find('.node-form-options').drupalSetSummary(function (context) { var $optionsContext = $(context); var vals = []; - if ($optionsContext.find('input').is(':checked')) { $optionsContext.find('input:checked').next('label').each(function () { vals.push(Drupal.checkPlain(this.textContent.trim())); }); return vals.join(', '); } - return Drupal.t('Not promoted'); }); } diff --git a/core/modules/node/node.preview.js b/core/modules/node/node.preview.js index 669dada2ec2d93646d2ca2a374f6a69c33330265..d140e2a8c3b4a6a0c9149c1a3a4dfd6fb9ea592a 100644 --- a/core/modules/node/node.preview.js +++ b/core/modules/node/node.preview.js @@ -28,11 +28,9 @@ }).showModal(); } } - if (!context.querySelector('.node-preview-container')) { return; } - if (once('node-preview', 'html').length) { $(document).on('click.preview', 'a:not([href^="#"], .node-preview-container a)', clickPreviewModal); } @@ -45,10 +43,10 @@ } } }; + Drupal.behaviors.nodePreviewSwitchViewMode = { attach: function attach(context) { var autosubmit = once('autosubmit', '[data-drupal-autosubmit]', context); - if (autosubmit.length) { $(autosubmit).on('formUpdated.preview', function () { $(this.form).trigger('submit'); diff --git a/core/modules/path/path.js b/core/modules/path/path.js index 500fd5cbe95d7ec7fd0a78ca4972413ef40c75a4..ea241ae68e27013bf7f219dab83d10bd2d62e884 100644 --- a/core/modules/path/path.js +++ b/core/modules/path/path.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { Drupal.behaviors.pathDetailsSummaries = { attach: function attach(context) { diff --git a/core/modules/quickedit/js/editors/formEditor.js b/core/modules/quickedit/js/editors/formEditor.js index 9eec923948f1d725cf423c15accbca34d552a0ee..5ed0be6ed971bdd837bc460f9fba8ec58944c45e 100644 --- a/core/modules/quickedit/js/editors/formEditor.js +++ b/core/modules/quickedit/js/editors/formEditor.js @@ -12,41 +12,30 @@ stateChange: function stateChange(fieldModel, state) { var from = fieldModel.previous('state'); var to = state; - switch (to) { case 'inactive': break; - case 'candidate': if (from !== 'inactive') { this.removeForm(); } - break; - case 'highlighted': break; - case 'activating': if (from !== 'invalid') { this.loadForm(); } - break; - case 'active': break; - case 'changed': break; - case 'saving': this.save(); break; - case 'saved': break; - case 'invalid': this.showValidationErrors(); break; @@ -62,7 +51,9 @@ }, loadForm: function loadForm() { var fieldModel = this.fieldModel; + var id = "quickedit-form-for-".concat(fieldModel.id.replace(/[/[\]]/g, '_')); + var $formContainer = $(Drupal.theme('quickeditFormContainer', { id: id, loadingMsg: Drupal.t('Loading…') @@ -91,10 +82,10 @@ }); $formContainer.on('formUpdated.quickedit', ':input', function (event) { var state = fieldModel.get('state'); - if (state === 'invalid') { fieldModel.set('state', 'activating'); - } else { + } + else { fieldModel.set('state', 'changed'); } }).on('keypress.quickedit', 'input', function (event) { @@ -102,6 +93,7 @@ return false; } }); + fieldModel.set('state', 'active'); }); }, @@ -109,7 +101,6 @@ if (this.$formContainer === null) { return; } - delete this.formSaveAjax; Drupal.detachBehaviors(this.$formContainer.get(0), null, 'unload'); this.$formContainer.off('change.quickedit', ':input').off('keypress.quickedit', 'input').remove(); @@ -120,11 +111,11 @@ var $submit = $formContainer.find('.quickedit-form-submit'); var editorModel = this.model; var fieldModel = this.fieldModel; + var formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving({ nocssjs: false, other_view_modes: fieldModel.findOtherViewModes() }, $submit); - function cleanUpAjax() { Drupal.quickedit.util.form.unajaxifySaving(formSaveAjax); formSaveAjax = null; @@ -134,7 +125,6 @@ cleanUpAjax(); fieldModel.set('state', 'saved'); fieldModel.set('htmlForOtherViewModes', response.other_view_modes); - _.defer(function () { fieldModel.set('html', response.data); }); diff --git a/core/modules/quickedit/js/editors/formattedTextEditor.js b/core/modules/quickedit/js/editors/formattedTextEditor.js index 11215324fd741cb02a1203ee6bdf6160a873c0a6..2043451bc2cd3473b423d917895f8410a0fc9f84 100644 --- a/core/modules/quickedit/js/editors/formattedTextEditor.js +++ b/core/modules/quickedit/js/editors/formattedTextEditor.js @@ -17,31 +17,25 @@ this.textFormat = drupalSettings.editor.formats[metadata.format]; this.textFormatHasTransformations = metadata.formatHasTransformations; this.textEditor = Drupal.editors[this.textFormat.editor]; - var $fieldItems = this.$el.find('.quickedit-field'); + var $fieldItems = this.$el.find('.quickedit-field'); if ($fieldItems.length) { this.$textElement = $fieldItems.eq(0); } else { this.$textElement = this.$el; } - this.model.set('originalValue', this.$textElement.html()); - if (Drupal.editors && Drupal.editors.ckeditor5 && once('quickedit-ckeditor5-destroy', 'body').length) { var ckeditor5Detach = Drupal.editors.ckeditor5.detach; - Drupal.editors.ckeditor5.detach = function quickeditDetach(element, format, trigger) { var destroyPromise = ckeditor5Detach.call(this, element, format, trigger); - if (destroyPromise && destroyPromise.then) { var textElement = null; var originalValue = null; - Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; - destroyPromise.then(function () { if (textElement && originalValue) { textElement.innerHTML = originalValue; @@ -58,45 +52,36 @@ var editorModel = this.model; var from = fieldModel.previous('state'); var to = state; - switch (to) { case 'inactive': break; - case 'candidate': if (from !== 'inactive' && from !== 'highlighted') { this.textEditor.detach(this.$textElement.get(0), this.textFormat); } - if (from === 'active' && this.textFormatHasTransformations) { this.revert(); } - if (from === 'invalid') { this.removeValidationErrors(); } - break; - case 'highlighted': break; - case 'activating': if (this.textFormatHasTransformations) { var $textElement = this.$textElement; - this._getUntransformedText(function (untransformedText) { $textElement.html(untransformedText); fieldModel.set('state', 'active'); }); - } else { + } + else { _.defer(function () { fieldModel.set('state', 'active'); }); } - break; - case 'active': { var textElement = this.$textElement.get(0); @@ -108,21 +93,16 @@ }); break; } - case 'changed': break; - case 'saving': if (from === 'invalid') { this.removeValidationErrors(); } - this.save(); break; - case 'saved': break; - case 'invalid': this.showValidationErrors(); break; @@ -141,6 +121,7 @@ }, _getUntransformedText: function _getUntransformedText(callback) { var fieldID = this.fieldModel.get('fieldID'); + var textLoaderAjax = Drupal.ajax({ url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/!entity_type/!id/!field_name/!langcode/!view_mode')), submit: { diff --git a/core/modules/quickedit/js/editors/image.js b/core/modules/quickedit/js/editors/image.js index 9f798849c33580634646e7800a54821664a80184..7cbac162c2bc3120ec5b2522896556c7543c83c6 100644 --- a/core/modules/quickedit/js/editors/image.js +++ b/core/modules/quickedit/js/editors/image.js @@ -12,12 +12,10 @@ this.model.set('originalValue', this.$el.html().trim()); this.model.set('currentValue', function (index, value) { var matches = $(this).attr('name').match(/(alt|title)]$/); - if (matches) { var name = matches[1]; var $toolgroup = $("#".concat(options.fieldModel.toolbarView.getMainWysiwygToolgroupId())); var $input = $toolgroup.find(".quickedit-image-field-info input[name=\"".concat(name, "\"]")); - if ($input.length) { return $input[0].value; } @@ -26,37 +24,31 @@ }, stateChange: function stateChange(fieldModel, state, options) { var from = fieldModel.previous('state'); - switch (state) { case 'inactive': break; - case 'candidate': if (from !== 'inactive') { this.$el.find('.quickedit-image-dropzone').remove(); this.$el.removeClass('quickedit-image-element'); } - if (from === 'invalid') { this.removeValidationErrors(); } - break; - case 'highlighted': break; - case 'activating': _.defer(function () { fieldModel.set('state', 'active'); }); - break; - case 'active': { var self = this; + this.$el.addClass('quickedit-image-element'); + var $dropzone = this.renderDropzone('upload', Drupal.t('Drop file here or click to upload')); $dropzone.on('dragenter', function (e) { $(this).addClass('hover'); @@ -77,6 +69,7 @@ } }); }); + $dropzone.on('dragover dragenter dragleave drop click', function (e) { e.preventDefault(); e.stopPropagation(); @@ -84,21 +77,16 @@ this.renderToolbar(fieldModel); break; } - case 'changed': break; - case 'saving': if (from === 'invalid') { this.removeValidationErrors(); } - this.save(options); break; - case 'saved': break; - case 'invalid': this.showValidationErrors(); break; @@ -108,10 +96,13 @@ this.renderDropzone('upload loading', Drupal.t('Uploading <i>@file</i>…', { '@file': file.name })); + var fieldID = this.fieldModel.get('fieldID'); var url = Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/image/upload/!entity_type/!id/!field_name/!langcode/!view_mode')); + var data = new FormData(); data.append('files[image]', file); + var self = this; this.ajax({ type: 'POST', @@ -122,6 +113,7 @@ self.fieldModel.set('state', 'changed'); self.fieldModel.get('entity').set('inTempStore', true); self.removeValidationErrors(); + var $content = $(response.html).closest('[data-quickedit-field-id]').children(); $el.empty().append($content); } @@ -144,23 +136,19 @@ ajaxOptions.success = function (response) { if (response.main_error) { this.renderDropzone('error', response.main_error); - if (response.errors.length) { this.model.set('validationErrors', response.errors); } - this.showValidationErrors(); } else { successCallback(response); } }; - $.ajax(ajaxOptions); }, renderToolbar: function renderToolbar(fieldModel) { var $toolgroup = $("#".concat(fieldModel.toolbarView.getMainWysiwygToolgroupId())); var $toolbar = $toolgroup.find('.quickedit-image-field-info'); - if ($toolbar.length === 0) { var fieldID = fieldModel.get('fieldID'); var url = Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/image/info/!entity_type/!id/!field_name/!langcode/!view_mode')); @@ -181,7 +169,6 @@ }, renderDropzone: function renderDropzone(state, text) { var $dropzone = this.$el.find('.quickedit-image-dropzone'); - if ($dropzone.length) { $dropzone.removeClass('upload error hover loading').addClass(".quickedit-image-dropzone ".concat(state)).children('.quickedit-image-text').html(text); } else { @@ -191,7 +178,6 @@ })); this.$el.append($dropzone); } - return $dropzone; }, revert: function revert() { diff --git a/core/modules/quickedit/js/editors/plainTextEditor.js b/core/modules/quickedit/js/editors/plainTextEditor.js index cee3a1a6e1fe2fa7bd9588652aba086e14d1bf28..9b383cd6ec18f78f99bd617bb1465fd1a2afaef1 100644 --- a/core/modules/quickedit/js/editors/plainTextEditor.js +++ b/core/modules/quickedit/js/editors/plainTextEditor.js @@ -12,14 +12,15 @@ Drupal.quickedit.EditorView.prototype.initialize.call(this, options); var editorModel = this.model; var fieldModel = this.fieldModel; + var $fieldItems = this.$el.find('.quickedit-field'); var $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el; this.$textElement = $textElement; editorModel.set('originalValue', this.$textElement[0].textContent.trim()); + var previousText = editorModel.get('originalValue'); $textElement.on('keyup paste', function (event) { var currentText = $textElement[0].textContent.trim(); - if (previousText !== currentText) { previousText = currentText; editorModel.set('currentValue', currentText); @@ -33,50 +34,37 @@ stateChange: function stateChange(fieldModel, state, options) { var from = fieldModel.previous('state'); var to = state; - switch (to) { case 'inactive': break; - case 'candidate': if (from !== 'inactive') { this.$textElement.removeAttr('contenteditable'); } - if (from === 'invalid') { this.removeValidationErrors(); } - break; - case 'highlighted': break; - case 'activating': _.defer(function () { fieldModel.set('state', 'active'); }); - break; - case 'active': this.$textElement.attr('contenteditable', 'true'); break; - case 'changed': break; - case 'saving': if (from === 'invalid') { this.removeValidationErrors(); } - this.save(options); break; - case 'saved': break; - case 'invalid': this.showValidationErrors(); break; diff --git a/core/modules/quickedit/js/models/BaseModel.js b/core/modules/quickedit/js/models/BaseModel.js index 6f1c60a269d3b0c59083edc5501acb84440908f1..8f6e6cfa4a7688686b295b5697af2b4f37efa472 100644 --- a/core/modules/quickedit/js/models/BaseModel.js +++ b/core/modules/quickedit/js/models/BaseModel.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } (function (Drupal, Backbone) { @@ -21,11 +20,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" = if (!options) { options = {}; } - options.validate = true; } } - return Backbone.Model.prototype.set.call(this, key, val, options); } }); diff --git a/core/modules/quickedit/js/models/EntityModel.js b/core/modules/quickedit/js/models/EntityModel.js index 9776a9c61d8937332bf3f6ad3364145169b9e045..d1c682bd403d1451885db05c3bf39f4b1bbe7220 100644 --- a/core/modules/quickedit/js/models/EntityModel.js +++ b/core/modules/quickedit/js/models/EntityModel.js @@ -14,6 +14,7 @@ id: null, label: null, fields: null, + isActive: false, inTempStore: false, isDirty: false, @@ -24,13 +25,15 @@ }, initialize: function initialize() { this.set('fields', new Drupal.quickedit.FieldCollection()); + this.listenTo(this, 'change:state', this.stateChange); + this.listenTo(this.get('fields'), 'change:state', this.fieldStateChange); + Drupal.quickedit.BaseModel.prototype.initialize.call(this); }, stateChange: function stateChange(entityModel, state, options) { var to = state; - switch (to) { case 'closed': this.set({ @@ -39,20 +42,16 @@ isDirty: false }); break; - case 'launching': break; - case 'opening': entityModel.get('fields').each(function (fieldModel) { fieldModel.set('state', 'candidate', options); }); break; - case 'opened': this.set('isActive', true); break; - case 'committing': { var fields = this.get('fields'); @@ -68,18 +67,15 @@ }); break; } - case 'deactivating': { var changedFields = this.get('fields').filter(function (fieldModel) { return _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length; }); - if ((changedFields.length || this.get('fieldsInTempStore').length) && !options.saved && !options.confirmed) { this.set('state', 'opened', { confirming: true }); - _.defer(function () { Drupal.quickedit.app.confirmEntityDeactivation(entityModel); }); @@ -96,10 +92,8 @@ } }); } - break; } - case 'closing': options.reason = 'stop'; this.get('fields').each(function (fieldModel) { @@ -115,44 +109,38 @@ var current = fieldModel.get('state'); var previous = fieldModel.previous('state'); var fieldsInTempStore = entityModel.get('fieldsInTempStore'); - if (current === 'saved') { entityModel.set('inTempStore', true); fieldModel.set('inTempStore', true); fieldsInTempStore.push(fieldModel.get('fieldID')); fieldsInTempStore = _.uniq(fieldsInTempStore); entityModel.set('fieldsInTempStore', fieldsInTempStore); - } else if (current === 'candidate' && previous === 'inactive') { + } + else if (current === 'candidate' && previous === 'inactive') { fieldModel.set('inTempStore', _.intersection([fieldModel.get('fieldID')], fieldsInTempStore).length > 0); } }, fieldStateChange: function fieldStateChange(fieldModel, state) { var entityModel = this; var fieldState = state; - switch (this.get('state')) { case 'closed': case 'launching': break; - case 'opening': _.defer(function () { entityModel.set('state', 'opened', { 'accept-field-states': Drupal.quickedit.app.readyFieldStates }); }); - break; - case 'opened': if (fieldState === 'changed') { entityModel.set('isDirty', true); } else { this._updateInTempStoreAttributes(entityModel, fieldModel); } - break; - case 'committing': { if (fieldState === 'invalid') { @@ -168,7 +156,6 @@ var options = { 'accept-field-states': Drupal.quickedit.app.readyFieldStates }; - if (entityModel.set('isCommitting', true, options)) { entityModel.save({ success: function success() { @@ -191,38 +178,33 @@ } }); } - break; } - case 'deactivating': _.defer(function () { entityModel.set('state', 'closing', { 'accept-field-states': Drupal.quickedit.app.readyFieldStates }); }); - break; - case 'closing': _.defer(function () { entityModel.set('state', 'closed', { 'accept-field-states': ['inactive'] }); }); - break; } }, save: function save(options) { var entityModel = this; + var entitySaverAjax = Drupal.ajax({ url: Drupal.url("quickedit/entity/".concat(entityModel.get('entityID'))), error: function error() { options.error.call(entityModel); } }); - entitySaverAjax.commands.quickeditEntitySaved = function (ajax, response, status) { entityModel.get('fields').each(function (fieldModel) { fieldModel.set('inTempStore', false); @@ -234,16 +216,15 @@ options.success.call(entityModel); } }; - entitySaverAjax.options.headers = entitySaverAjax.options.headers || {}; entitySaverAjax.options.headers['X-Drupal-Quickedit-CSRF-Token'] = drupalSettings.quickedit.csrf_token; entitySaverAjax.execute(); }, validate: function validate(attrs, options) { var acceptedFieldStates = options['accept-field-states'] || []; + var currentState = this.get('state'); var nextState = attrs.state; - if (currentState !== nextState) { if (_.indexOf(this.constructor.states, nextState) === -1) { return "\"".concat(nextState, "\" is an invalid state"); @@ -252,7 +233,6 @@ if (!this._acceptStateChange(currentState, nextState, options)) { return 'state change not accepted'; } - if (!this._fieldsHaveAcceptableStates(acceptedFieldStates)) { return 'state change not accepted because fields are not in acceptable state'; } @@ -260,7 +240,6 @@ var currentIsCommitting = this.get('isCommitting'); var nextIsCommitting = attrs.isCommitting; - if (currentIsCommitting === false && nextIsCommitting === true) { if (!this._fieldsHaveAcceptableStates(acceptedFieldStates)) { return 'isCommitting change not accepted because fields are not in acceptable state'; @@ -277,15 +256,17 @@ if (from === 'closing' && to === 'closed') { accept = true; - } else if (from === 'committing' && to === 'opened' && context.reason && (context.reason === 'invalid' || context.reason === 'networkerror')) { + } + else if (from === 'committing' && to === 'opened' && context.reason && (context.reason === 'invalid' || context.reason === 'networkerror')) { accept = true; - } else if (from === 'deactivating' && to === 'opened' && context.confirming) { + } + else if (from === 'deactivating' && to === 'opened' && context.confirming) { accept = true; - } else if (from === 'opened' && to === 'deactivating' && context.confirmed) { + } + else if (from === 'opened' && to === 'deactivating' && context.confirmed) { accept = true; } } - return accept; }, _fieldsHaveAcceptableStates: function _fieldsHaveAcceptableStates(acceptedFieldStates) { @@ -293,26 +274,34 @@ if (acceptedFieldStates.length > 0) { var fieldStates = this.get('fields').pluck('state') || []; - if (_.difference(fieldStates, acceptedFieldStates).length) { accept = false; } } - return accept; }, destroy: function destroy(options) { Drupal.quickedit.BaseModel.prototype.destroy.call(this, options); this.stopListening(); + this.get('fields').reset(); }, - sync: function sync() {} + sync: function sync() { + } }, { - states: ['closed', 'launching', 'opening', 'opened', 'committing', 'deactivating', 'closing'], + states: [ + 'closed', + 'launching', + 'opening', + 'opened', + 'committing', + 'deactivating', + 'closing'], followsStateSequence: function followsStateSequence(from, to) { return _.indexOf(this.states, from) < _.indexOf(this.states, to); } }); + Drupal.quickedit.EntityCollection = Backbone.Collection.extend({ model: Drupal.quickedit.EntityModel }); diff --git a/core/modules/quickedit/js/models/FieldModel.js b/core/modules/quickedit/js/models/FieldModel.js index 76037ede04b854f49b013652050858feecce3604..835506b3732fad596e06af6a1f82b9bee6c9cc57 100644 --- a/core/modules/quickedit/js/models/FieldModel.js +++ b/core/modules/quickedit/js/models/FieldModel.js @@ -15,6 +15,7 @@ metadata: null, acceptStateChange: null, logicalFieldID: null, + state: 'inactive', isChanged: false, inTempStore: false, @@ -23,27 +24,28 @@ }, initialize: function initialize(options) { this.set('html', options.el.outerHTML); + this.get('entity').get('fields').add(this); + this.set('logicalFieldID', this.get('fieldID').split('/').slice(0, 4).join('/')); + Drupal.quickedit.BaseModel.prototype.initialize.call(this, options); }, destroy: function destroy(options) { if (this.get('state') !== 'inactive') { throw new Error('FieldModel cannot be destroyed if it is not inactive state.'); } - Drupal.quickedit.BaseModel.prototype.destroy.call(this, options); }, - sync: function sync() {}, + sync: function sync() { + }, validate: function validate(attrs, options) { var current = this.get('state'); var next = attrs.state; - if (current !== next) { if (_.indexOf(this.constructor.states, next) === -1) { return "\"".concat(next, "\" is an invalid state"); } - if (!this.get('acceptStateChange')(current, next, options, this)) { return 'state change not accepted'; } @@ -58,7 +60,8 @@ findOtherViewModes: function findOtherViewModes() { var currentField = this; var otherViewModes = []; - Drupal.quickedit.collections.fields.where({ + Drupal.quickedit.collections.fields + .where({ logicalFieldID: currentField.get('logicalFieldID') }).forEach(function (field) { if (field !== currentField && field.get('fieldID') !== currentField.get('fieldID')) { @@ -68,11 +71,21 @@ return otherViewModes; } }, { - states: ['inactive', 'candidate', 'highlighted', 'activating', 'active', 'changed', 'saving', 'saved', 'invalid'], + states: [ + 'inactive', + 'candidate', + 'highlighted', + 'activating', + 'active', + 'changed', + 'saving', + 'saved', + 'invalid'], followsStateSequence: function followsStateSequence(from, to) { return _.indexOf(this.states, from) < _.indexOf(this.states, to); } }); + Drupal.quickedit.FieldCollection = Backbone.Collection.extend({ model: Drupal.quickedit.FieldModel }); diff --git a/core/modules/quickedit/js/quickedit.js b/core/modules/quickedit/js/quickedit.js index 7b604e3dfd71b654be86f316d60b5eaf0397471b..49f7cf836fc35d48175cd301938e836f894a57f7 100644 --- a/core/modules/quickedit/js/quickedit.js +++ b/core/modules/quickedit/js/quickedit.js @@ -6,19 +6,25 @@ **/ (function ($, _, Backbone, Drupal, drupalSettings, JSON, storage) { - var options = $.extend(drupalSettings.quickedit, { + var options = $.extend(drupalSettings.quickedit, + { strings: { quickEdit: Drupal.t('Quick edit') } }); + var fieldsMetadataQueue = []; + var fieldsAvailableQueue = []; + var contextualLinksQueue = []; + var entityInstancesTracker = {}; function initQuickEdit(bodyElement) { Drupal.quickedit.collections.entities = new Drupal.quickedit.EntityCollection(); Drupal.quickedit.collections.fields = new Drupal.quickedit.FieldCollection(); + Drupal.quickedit.app = new Drupal.quickedit.AppView({ el: bodyElement, model: new Drupal.quickedit.AppModel(), @@ -29,7 +35,6 @@ function processEntity(entityElement) { var entityID = entityElement.getAttribute('data-quickedit-entity-id'); - if (!entityInstancesTracker.hasOwnProperty(entityID)) { entityInstancesTracker[entityID] = 0; } else { @@ -46,6 +51,7 @@ entityInstanceID: entityInstanceID }); $(fieldElement).addClass('quickedit-field'); + var field = new Drupal.quickedit.FieldModel({ el: fieldElement, fieldID: fieldID, @@ -54,23 +60,21 @@ metadata: Drupal.quickedit.metadata.get(fieldID), acceptStateChange: _.bind(Drupal.quickedit.app.acceptEditorStateChange, Drupal.quickedit.app) }); + Drupal.quickedit.collections.fields.add(field); } function loadMissingEditors(callback) { var loadedEditors = _.keys(Drupal.quickedit.editors); - var missingEditors = []; Drupal.quickedit.collections.fields.each(function (fieldModel) { var metadata = Drupal.quickedit.metadata.get(fieldModel.get('fieldID')); - if (metadata.access && _.indexOf(loadedEditors, metadata.editor) === -1) { missingEditors.push(metadata.editor); Drupal.quickedit.editors[metadata.editor] = false; } }); missingEditors = _.uniq(missingEditors); - if (missingEditors.length === 0) { callback(); return; @@ -87,16 +91,13 @@ function initializeEntityContextualLink(contextualLink) { var metadata = Drupal.quickedit.metadata; - function hasFieldWithPermission(fieldIDs) { for (var i = 0; i < fieldIDs.length; i++) { var fieldID = fieldIDs[i]; - if (metadata.get(fieldID, 'access') === true) { return true; } } - return false; } @@ -108,13 +109,11 @@ entityID: contextualLink.entityID, entityInstanceID: contextualLink.entityInstanceID }); - var fieldIDs = _.pluck(fields, 'fieldID'); if (fieldIDs.length === 0) { return false; } - if (hasFieldWithPermission(fieldIDs)) { var entityModel = new Drupal.quickedit.EntityModel({ el: contextualLink.region, @@ -133,7 +132,6 @@ _.each(fields, function (field) { initializeField(field.el, field.fieldID, contextualLink.entityID, contextualLink.entityInstanceID); }); - fieldsAvailableQueue = _.difference(fieldsAvailableQueue, fields); var initContextualLink = _.once(function () { @@ -149,11 +147,9 @@ loadMissingEditors(initContextualLink); return true; } - if (allMetadataExists(fieldIDs)) { return true; } - return false; } @@ -171,14 +167,12 @@ if (!$entityElement.length) { throw new Error("Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id=\"".concat(fieldID, "\"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id=\"").concat(entityID, "\"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes.")); } - var entityElement = $(fieldElement).closest($entityElement); if (entityElement.length === 0) { var $lowestCommonParent = $entityElement.parents().has(fieldElement).first(); entityElement = $lowestCommonParent.find($entityElement); } - var entityInstanceID = entityElement.get(0).getAttribute('data-quickedit-entity-instance-id'); if (!metadata.has(fieldID)) { @@ -190,7 +184,6 @@ }); return; } - if (metadata.get(fieldID, 'access') !== true) { return; } @@ -200,7 +193,8 @@ entityInstanceID: entityInstanceID })) { initializeField(fieldElement, fieldID, entityID, entityInstanceID); - } else { + } + else { fieldsAvailableQueue.push({ el: fieldElement, fieldID: fieldID, @@ -215,7 +209,6 @@ var entityModel = Drupal.quickedit.collections.entities.findWhere({ el: entityElement }); - if (entityModel) { var contextualLinkView = entityModel.get('contextualLinkView'); contextualLinkView.undelegateEvents(); @@ -227,7 +220,6 @@ function hasOtherRegion(contextualLink) { return contextualLink.region !== entityElement; } - contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion); }); $context.find('[data-quickedit-field-id]').addBack('[data-quickedit-field-id]').each(function (index, fieldElement) { @@ -238,7 +230,6 @@ function hasOtherFieldElement(field) { return field.el !== fieldElement; } - fieldsMetadataQueue = _.filter(fieldsMetadataQueue, hasOtherFieldElement); fieldsAvailableQueue = _.filter(fieldsAvailableQueue, hasOtherFieldElement); }); @@ -247,11 +238,8 @@ function fetchMissingMetadata(callback) { if (fieldsMetadataQueue.length) { var fieldIDs = _.pluck(fieldsMetadataQueue, 'fieldID'); - var fieldElementsWithoutMetadata = _.pluck(fieldsMetadataQueue, 'el'); - var entityIDs = _.uniq(_.pluck(fieldsMetadataQueue, 'entityID'), true); - entityIDs = _.difference(entityIDs, Drupal.quickedit.metadata.intersection(entityIDs)); fieldsMetadataQueue = []; $.ajax({ @@ -266,7 +254,6 @@ _.each(results, function (fieldMetadata, fieldID) { Drupal.quickedit.metadata.add(fieldID, fieldMetadata); }); - callback(fieldElementsWithoutMetadata); } }); @@ -276,17 +263,20 @@ Drupal.behaviors.quickedit = { attach: function attach(context) { once('quickedit-init', 'body').forEach(initQuickEdit); - var fields = once('quickedit', '[data-quickedit-field-id]', context); + var fields = once('quickedit', '[data-quickedit-field-id]', context); if (fields.length === 0) { return; } once('quickedit', '[data-quickedit-entity-id]', context).forEach(processEntity); + fields.forEach(processField); + contextualLinksQueue = _.filter(contextualLinksQueue, function (contextualLink) { return !initializeEntityContextualLink(contextualLink); }); + fetchMissingMetadata(function (fieldElementsWithFreshMetadata) { _.each(fieldElementsWithFreshMetadata, processField); @@ -301,6 +291,7 @@ } } }; + Drupal.quickedit = { app: null, collections: { @@ -327,19 +318,15 @@ }, intersection: function intersection(fieldIDs) { var prefixedFieldIDs = _.map(fieldIDs, this._prefixFieldID); - var intersection = _.intersection(prefixedFieldIDs, _.keys(sessionStorage)); - return _.map(intersection, this._unprefixFieldID); } } }; var permissionsHashKey = Drupal.quickedit.metadata._prefixFieldID('permissionsHash'); - var permissionsHashValue = storage.getItem(permissionsHashKey); var permissionsHash = drupalSettings.user.permissionsHash; - if (permissionsHashValue !== permissionsHash) { if (typeof permissionsHash === 'string') { _.chain(storage).keys().each(function (key) { @@ -348,7 +335,6 @@ } }); } - storage.setItem(permissionsHashKey, permissionsHash); } @@ -358,14 +344,12 @@ once('quickedit', data.$region); processEntity(data.$region.get(0)); } - var contextualLink = { entityID: data.$region.attr('data-quickedit-entity-id'), entityInstanceID: data.$region.attr('data-quickedit-entity-instance-id'), el: data.$el[0], region: data.$region[0] }; - if (!initializeEntityContextualLink(contextualLink)) { contextualLinksQueue.push(contextualLink); } diff --git a/core/modules/quickedit/js/theme.js b/core/modules/quickedit/js/theme.js index 2e9723f7220316bf86467ac21de15aab15d5a31c..c6101ad46b704ad066c2e65b15d1930e3f4869e7 100644 --- a/core/modules/quickedit/js/theme.js +++ b/core/modules/quickedit/js/theme.js @@ -42,11 +42,9 @@ classes.unshift('quickedit-toolgroup'); var html = ''; html += "<div class=\"".concat(classes.join(' '), "\""); - if (settings.id) { html += " id=\"".concat(settings.id, "\""); } - html += '>'; html += Drupal.theme('quickeditButtons', { buttons: settings.buttons @@ -57,14 +55,11 @@ Drupal.theme.quickeditButtons = function (settings) { var html = ''; - var _loop = function _loop(i) { var button = settings.buttons[i]; - if (!button.hasOwnProperty('type')) { button.type = 'button'; } - var attributes = []; var attrMap = settings.buttons[i].attributes || {}; Object.keys(attrMap).forEach(function (attr) { @@ -72,11 +67,9 @@ }); html += "<button type=\"".concat(button.type, "\" class=\"").concat(button.classes, "\" ").concat(attributes.join(' '), ">").concat(button.label, "</button>"); }; - for (var i = 0; i < settings.buttons.length; i++) { _loop(i); } - return html; }; @@ -102,15 +95,12 @@ Drupal.theme.quickeditImageToolbar = function (settings) { var html = '<form class="quickedit-image-field-info">'; - if (settings.alt_field) { html += "<div><label for=\"alt\" class=\"".concat(settings.alt_field_required ? 'required' : '', "\">").concat(Drupal.t('Alternative text'), "</label>") + "<input type=\"text\" placeholder=\"".concat(settings.alt, "\" value=\"").concat(settings.alt, "\" name=\"alt\" ").concat(settings.alt_field_required ? 'required' : '', "/>") + ' </div>'; } - if (settings.title_field) { html += "<div><label for=\"title\" class=\"".concat(settings.title_field_required ? 'form-required' : '', "\">").concat(Drupal.t('Title'), "</label>") + "<input type=\"text\" placeholder=\"".concat(settings.title, "\" value=\"").concat(settings.title, "\" name=\"title\" ").concat(settings.title_field_required ? 'required' : '', "/>") + '</div>'; } - html += '</form>'; return html; }; diff --git a/core/modules/quickedit/js/util.js b/core/modules/quickedit/js/util.js index 7c3e80d2d24612945dc20f5417117a1f13de7568..a7c42d0909c557a8ff854c87a21ab583b77b2157 100644 --- a/core/modules/quickedit/js/util.js +++ b/core/modules/quickedit/js/util.js @@ -7,7 +7,9 @@ (function ($, Drupal) { Drupal.quickedit.util = Drupal.quickedit.util || {}; + Drupal.quickedit.util.constants = {}; + Drupal.quickedit.util.constants.transitionEnd = 'transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit'; Drupal.quickedit.util.buildUrl = function (id, urlFormat) { @@ -46,6 +48,7 @@ Drupal.quickedit.util.form = { load: function load(options, callback) { var fieldID = options.fieldID; + var formLoaderAjax = Drupal.ajax({ url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode')), submit: { @@ -58,16 +61,15 @@ '@field-label': fieldLabel }); Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message); + var fieldModel = Drupal.quickedit.app.model.get('activeField'); fieldModel.set('state', 'candidate'); } }); - formLoaderAjax.commands.quickeditFieldForm = function (ajax, response, status) { callback(response.data, ajax); Drupal.ajax.instances[this.instanceIndex] = null; }; - formLoaderAjax.execute(); }, ajaxifySaving: function ajaxifySaving(options, $submit) { @@ -82,7 +84,6 @@ }, success: function success(response, status) { var _this = this; - Object.keys(response || {}).forEach(function (i) { if (response[i].command && _this.commands[response[i].command]) { _this.commands[response[i].command](_this, response[i], status); diff --git a/core/modules/quickedit/js/views/AppView.js b/core/modules/quickedit/js/views/AppView.js index 26aabbd611425e8b43d7bafbe7cb3ef9b0a764b2..fbc9cfb76c197ae29d32f4030e418f76d1783e7c 100644 --- a/core/modules/quickedit/js/views/AppView.js +++ b/core/modules/quickedit/js/views/AppView.js @@ -13,8 +13,10 @@ this.singleFieldStates = ['highlighted', 'activating', 'active']; this.changedFieldStates = ['changed', 'saving', 'saved', 'invalid']; this.readyFieldStates = ['candidate', 'highlighted']; + this.listenTo(options.entitiesCollection, 'change:state', this.appStateChange); this.listenTo(options.entitiesCollection, 'change:isActive', this.enforceSingleActiveEntity); + this.listenTo(options.fieldsCollection, 'change:state', this.editorStateChange); this.listenTo(options.fieldsCollection, 'change:html', this.renderUpdatedField); this.listenTo(options.fieldsCollection, 'change:html', this.propagateUpdatedField); @@ -24,7 +26,6 @@ appStateChange: function appStateChange(entityModel, state) { var app = this; var entityToolbarView; - switch (state) { case 'launching': reload = false; @@ -36,29 +37,23 @@ entityModel.get('fields').each(function (fieldModel) { app.setupEditor(fieldModel); }); - _.defer(function () { entityModel.set('state', 'opening'); }); - break; - case 'closed': entityToolbarView = entityModel.toolbarView; entityModel.get('fields').each(function (fieldModel) { app.teardownEditor(fieldModel); }); - if (entityToolbarView) { entityToolbarView.remove(); delete entityModel.toolbarView; } - if (reload) { reload = false; window.location.reload(); } - break; } }, @@ -69,21 +64,26 @@ if (from === 'candidate' && to === 'inactive') { accept = true; } - } else { + } + else { if (!Drupal.quickedit.FieldModel.followsStateSequence(from, to)) { accept = false; - if (_.indexOf(this.activeFieldStates, from) !== -1 && to === 'candidate') { accept = true; - } else if ((from === 'changed' || from === 'invalid') && to === 'candidate') { + } + else if ((from === 'changed' || from === 'invalid') && to === 'candidate') { accept = true; - } else if (from === 'highlighted' && to === 'candidate') { + } + else if (from === 'highlighted' && to === 'candidate') { accept = true; - } else if (from === 'saved' && to === 'candidate') { + } + else if (from === 'saved' && to === 'candidate') { accept = true; - } else if (from === 'invalid' && to === 'saving') { + } + else if (from === 'invalid' && to === 'saving') { accept = true; - } else if (from === 'invalid' && to === 'activating') { + } + else if (from === 'invalid' && to === 'activating') { accept = true; } } @@ -91,13 +91,10 @@ if (accept) { var activeField; var activeFieldState; - if ((this.readyFieldStates.indexOf(from) !== -1 || from === 'invalid') && this.activeFieldStates.indexOf(to) !== -1) { activeField = this.model.get('activeField'); - if (activeField && activeField !== fieldModel) { activeFieldState = activeField.get('state'); - if (this.activeFieldStates.indexOf(activeFieldState) !== -1) { activeField.set('state', 'candidate'); } else if (activeFieldState === 'changed' || activeFieldState === 'invalid') { @@ -109,20 +106,22 @@ accept = false; } } - } else if (_.indexOf(this.activeFieldStates, from) !== -1 && to === 'candidate') { + } + else if (_.indexOf(this.activeFieldStates, from) !== -1 && to === 'candidate') { if (context && context.reason === 'mouseleave') { accept = false; } - } else if ((from === 'changed' || from === 'invalid') && to === 'candidate') { + } + else if ((from === 'changed' || from === 'invalid') && to === 'candidate') { if (context && context.reason === 'mouseleave') { accept = false; - } else if (context && context.confirmed) { + } + else if (context && context.confirmed) { accept = true; } } } } - return accept; }, setupEditor: function setupEditor(fieldModel) { @@ -136,6 +135,7 @@ model: editorModel, fieldModel: fieldModel }); + var toolbarView = new Drupal.quickedit.FieldToolbarView({ el: fieldToolbarRoot, model: fieldModel, @@ -143,11 +143,13 @@ editorView: editorView, entityModel: entityModel }); + var decorationView = new Drupal.quickedit.FieldDecorationView({ el: $(editorView.getEditedElement()), model: fieldModel, editorView: editorView }); + fieldModel.editorView = editorView; fieldModel.toolbarView = toolbarView; fieldModel.decorationView = decorationView; @@ -159,15 +161,16 @@ fieldModel.toolbarView.remove(); delete fieldModel.toolbarView; + fieldModel.decorationView.remove(); delete fieldModel.decorationView; + fieldModel.editorView.remove(); delete fieldModel.editorView; }, confirmEntityDeactivation: function confirmEntityDeactivation(entityModel) { var that = this; var discardDialog; - function closeDiscardDialog(action) { discardDialog.close(action); that.model.set('activeModal', null); @@ -180,7 +183,6 @@ entityModel.set('state', 'deactivating', { confirmed: true }); - if (entityModel.get('reload')) { reload = true; entityModel.set('reload', false); @@ -235,17 +237,17 @@ if (from === 'changed' || from === 'invalid') { fieldModel.editorView.revert(); } - this.model.set('activeField', null); } }, renderUpdatedField: function renderUpdatedField(fieldModel, html, options) { var $fieldWrapper = $(fieldModel.get('el')); var $context = $fieldWrapper.parent(); - var renderField = function renderField() { fieldModel.destroy(); + $fieldWrapper.replaceWith(html); + Drupal.attachBehaviors($context.get(0)); }; @@ -268,14 +270,17 @@ if (options.propagation) { return; } - var htmlForOtherViewModes = updatedField.get('htmlForOtherViewModes'); - Drupal.quickedit.collections.fields.where({ + Drupal.quickedit.collections.fields + .where({ logicalFieldID: updatedField.get('logicalFieldID') }).forEach(function (field) { - if (field === updatedField) {} else if (field.getViewMode() === updatedField.getViewMode()) { + if (field === updatedField) { + } + else if (field.getViewMode() === updatedField.getViewMode()) { field.set('html', updatedField.get('html')); - } else if (field.getViewMode() in htmlForOtherViewModes) { + } + else if (field.getViewMode() in htmlForOtherViewModes) { field.set('html', htmlForOtherViewModes[field.getViewMode()], { propagation: true }); diff --git a/core/modules/quickedit/js/views/ContextualLinkView.js b/core/modules/quickedit/js/views/ContextualLinkView.js index ecc563c1b673e03fb2143d65b110dd7ef747200f..30875c258b365d79053fe0541260180e6e0f678e 100644 --- a/core/modules/quickedit/js/views/ContextualLinkView.js +++ b/core/modules/quickedit/js/views/ContextualLinkView.js @@ -12,7 +12,6 @@ event.preventDefault(); event.target.click(); } - return { 'click a': function clickA(event) { event.preventDefault(); @@ -30,6 +29,7 @@ }, render: function render(entityModel, isActive) { this.$el.find('a').attr('aria-pressed', isActive); + this.$el.closest('.contextual').toggle(!isActive); return this; } diff --git a/core/modules/quickedit/js/views/EditorView.js b/core/modules/quickedit/js/views/EditorView.js index 29b9fdc9c3456011bf64f41946419c4d0042dc72..7046d8333790e18976d48f0d91a9b28b9ecc829b 100644 --- a/core/modules/quickedit/js/views/EditorView.js +++ b/core/modules/quickedit/js/views/EditorView.js @@ -29,67 +29,56 @@ stateChange: function stateChange(fieldModel, state) { var from = fieldModel.previous('state'); var to = state; - switch (to) { case 'inactive': break; - case 'candidate': if (from === 'invalid') { this.removeValidationErrors(); } - break; - case 'highlighted': break; - case 'activating': { var loadDependencies = function loadDependencies(callback) { callback(); }; - loadDependencies(function () { fieldModel.set('state', 'active'); }); break; } - case 'active': break; - case 'changed': break; - case 'saving': if (from === 'invalid') { this.removeValidationErrors(); } - this.save(); break; - case 'saved': break; - case 'invalid': this.showValidationErrors(); break; } }, - revert: function revert() {}, + revert: function revert() { + } + , save: function save() { var fieldModel = this.fieldModel; var editorModel = this.model; var backstageId = "quickedit_backstage-".concat(this.fieldModel.id.replace(/[/[\]_\s]/g, '-')); - function fillAndSubmitForm(value) { var $form = $("#".concat(backstageId)).find('form'); - $form.find(':input[type!="hidden"][type!="submit"]:not(select)').not('[name$="\\[summary\\]"]').val(value); + $form.find(':input[type!="hidden"][type!="submit"]:not(select)') + .not('[name$="\\[summary\\]"]').val(value); $form.find('.quickedit-form-submit').trigger('click.quickedit'); } - var formOptions = { fieldID: this.fieldModel.get('fieldID'), $el: this.$el, @@ -106,7 +95,6 @@ $form.prop('novalidate', true); var $submit = $form.find('.quickedit-form-submit'); self.formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving(formOptions, $submit); - function removeHiddenForm() { Drupal.quickedit.util.form.unajaxifySaving(self.formSaveAjax); delete self.formSaveAjax; @@ -127,7 +115,6 @@ }; self.formSaveAjax.commands.quickeditFieldForm = function () {}; - fillAndSubmitForm(editorModel.get('currentValue')); }); }, diff --git a/core/modules/quickedit/js/views/EntityToolbarView.js b/core/modules/quickedit/js/views/EntityToolbarView.js index be9b8a070d53624e258b5959feb21045d52fb4bb..e20d743e5e36c8eb5fa2dc8d9d1a58a51fe34c48 100644 --- a/core/modules/quickedit/js/views/EntityToolbarView.js +++ b/core/modules/quickedit/js/views/EntityToolbarView.js @@ -20,40 +20,42 @@ var that = this; this.appModel = options.appModel; this.$entity = $(this.model.get('el')); + this.listenTo(this.model, 'change:isActive change:isDirty change:state', this.render); this.listenTo(this.appModel, 'change:highlightedField change:activeField', this.render); this.listenTo(this.model.get('fields'), 'change:state', this.fieldStateChange); + $(window).on('resize.quickedit scroll.quickedit drupalViewportOffsetChange.quickedit', debounce($.proxy(this.windowChangeHandler, this), 150)); + $(document).on('drupalViewportOffsetChange.quickedit', function (event, offsets) { if (that.$fence) { that.$fence.css(offsets); } }); + var $toolbar = this.buildToolbarEl(); this.setElement($toolbar); this._fieldToolbarRoot = $toolbar.find('.quickedit-toolbar-field').get(0); + this.render(); }, render: function render() { if (this.model.get('isActive')) { var $body = $('body'); - if ($body.children('#quickedit-entity-toolbar').length === 0) { $body.append(this.$el); } - if ($body.children('#quickedit-toolbar-fence').length === 0) { this.$fence = $(Drupal.theme('quickeditEntityToolbarFence')).css(Drupal.displace()).appendTo($body); } - this.label(); + this.show('ops'); this.position(); } var $button = this.$el.find('.quickedit-button.action-save'); var isDirty = this.model.get('isDirty'); - switch (this.model.get('state')) { case 'opened': $button[0].textContent = Drupal.t('Save'); @@ -64,16 +66,15 @@ $button[0].textContent = Drupal.t('Saving'); $button.addClass('action-saving icon-throbber icon-end').attr('disabled', 'disabled'); break; - default: $button.attr('aria-hidden', true); break; } - return this; }, remove: function remove() { this.$fence.remove(); + $(window).off('resize.quickedit scroll.quickedit drupalViewportOffsetChange.quickedit'); $(document).off('drupalViewportOffsetChange.quickedit'); Backbone.View.prototype.remove.call(this); @@ -86,7 +87,6 @@ case 'active': this.render(); break; - case 'invalid': this.render(); break; @@ -102,54 +102,43 @@ var of; var activeField; var highlightedField; - do { switch (check) { case 0: of = element; break; - case 1: activeField = Drupal.quickedit.app.model.get('activeField'); of = activeField && activeField.editorView && activeField.editorView.$formContainer && activeField.editorView.$formContainer.find('.quickedit-form'); break; - case 2: of = activeField && activeField.editorView && activeField.editorView.getEditedElement(); - if (activeField && activeField.editorView && activeField.editorView.getQuickEditUISettings().padding) { horizontalPadding = 5; } - break; - case 3: highlightedField = Drupal.quickedit.app.model.get('highlightedField'); of = highlightedField && highlightedField.editorView && highlightedField.editorView.getEditedElement(); delay = 250; break; - default: { var fieldModels = this.model.get('fields').models; var topMostPosition = 1000000; var topMostField = null; - for (var i = 0; i < fieldModels.length; i++) { var pos = fieldModels[i].get('el').getBoundingClientRect().top; - if (pos < topMostPosition) { topMostPosition = pos; topMostField = fieldModels[i]; } } - of = topMostField.get('el'); delay = 50; break; } } - check++; } while (!of); @@ -159,13 +148,11 @@ var classListMethod = isBelow ? 'add' : 'remove'; state.elements.popper.classList[classListMethod]('quickedit-toolbar-pointer-top'); } - function positionToolbar() { var popperElement = that.el; var referenceElement = of; var boundariesElement = that.$fence[0]; var popperedge = edge === 'left' ? 'start' : 'end'; - if (referenceElement !== undefined) { if (!popperElement.classList.contains('js-popper-processed')) { that.popper = Popper.createPopper(referenceElement, popperElement, { @@ -204,8 +191,8 @@ that.popper.forceUpdate(); } } - - that.$el.css({ + that.$el + .css({ 'max-width': document.documentElement.clientWidth < 450 ? document.documentElement.clientWidth : 450, 'min-width': document.documentElement.clientWidth < 240 ? document.documentElement.clientWidth : 240, width: '100%' @@ -232,7 +219,8 @@ var $toolbar = $(Drupal.theme('quickeditEntityToolbar', { id: 'quickedit-entity-toolbar' })); - $toolbar.find('.quickedit-toolbar-entity').prepend(Drupal.theme('quickeditToolgroup', { + $toolbar.find('.quickedit-toolbar-entity') + .prepend(Drupal.theme('quickeditToolgroup', { classes: ['ops'], buttons: [{ label: Drupal.t('Save'), @@ -246,6 +234,7 @@ classes: 'action-cancel quickedit-button icon icon-close icon-only' }] })); + $toolbar.css({ left: this.$entity.offset().left, top: this.$entity.offset().top @@ -258,11 +247,11 @@ label: function label() { var label = ''; var entityLabel = this.model.get('label'); + var activeField = Drupal.quickedit.app.model.get('activeField'); var activeFieldLabel = activeField && activeField.get('metadata').label; var highlightedField = Drupal.quickedit.app.model.get('highlightedField'); var highlightedFieldLabel = highlightedField && highlightedField.get('metadata').label; - if (activeFieldLabel) { label = Drupal.theme('quickeditEntityToolbarLabel', { entityLabel: entityLabel, @@ -276,7 +265,6 @@ } else { label = Drupal.checkPlain(entityLabel); } - this.$el.find('.quickedit-toolbar-label').html(label); }, addClass: function addClass(toolgroup, classes) { diff --git a/core/modules/quickedit/js/views/FieldDecorationView.js b/core/modules/quickedit/js/views/FieldDecorationView.js index 5d4e804311fc6f4d8472edf74df53aeeee3d039d..714d5efbe172d9cd840036b1e162893e5a802fdd 100644 --- a/core/modules/quickedit/js/views/FieldDecorationView.js +++ b/core/modules/quickedit/js/views/FieldDecorationView.js @@ -27,57 +27,42 @@ stateChange: function stateChange(model, state) { var from = model.previous('state'); var to = state; - switch (to) { case 'inactive': this.undecorate(); break; - case 'candidate': this.decorate(); - if (from !== 'inactive') { this.stopHighlight(); - if (from !== 'highlighted') { this.model.set('isChanged', false); this.stopEdit(); } } - this._unpad(); - break; - case 'highlighted': this.startHighlight(); break; - case 'activating': this.prepareEdit(); break; - case 'active': if (from !== 'activating') { this.prepareEdit(); } - if (this.editorView.getQuickEditUISettings().padding) { this._pad(); } - break; - case 'changed': this.model.set('isChanged', true); break; - case 'saving': break; - case 'saved': break; - case 'invalid': break; } @@ -135,7 +120,6 @@ if (this.$el.data('quickedit-padded')) { return; } - var self = this; if (this.$el[0].style.width === '') { @@ -144,9 +128,9 @@ } var posProp = this._getPositionProperties(this.$el); - setTimeout(function () { self.$el.removeClass('quickedit-animate-disable-width'); + self.$el.css({ position: 'relative', top: "".concat(posProp.top - 5, "px"), @@ -163,7 +147,6 @@ if (!this.$el.data('quickedit-padded')) { return; } - var self = this; if (this._widthAttributeIsEmpty) { @@ -171,9 +154,9 @@ } var posProp = this._getPositionProperties(this.$el); - setTimeout(function () { self.$el.removeClass('quickedit-animate-disable-width'); + self.$el.css({ position: 'relative', top: "".concat(posProp.top + 5, "px"), @@ -192,19 +175,16 @@ var r = {}; var props = ['top', 'left', 'bottom', 'right', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'margin-bottom']; var propCount = props.length; - for (var i = 0; i < propCount; i++) { p = props[i]; r[p] = parseInt(this._replaceBlankPosition($e.css(p)), 10); } - return r; }, _replaceBlankPosition: function _replaceBlankPosition(pos) { if (pos === 'auto' || !pos) { pos = '0px'; } - return pos; } }); diff --git a/core/modules/quickedit/js/views/FieldToolbarView.js b/core/modules/quickedit/js/views/FieldToolbarView.js index ac295816368e018a0e973c37f4e8761136233a84..6f0461c680b3f763fb6d2dbae90ae108942bce1b 100644 --- a/core/modules/quickedit/js/views/FieldToolbarView.js +++ b/core/modules/quickedit/js/views/FieldToolbarView.js @@ -13,7 +13,9 @@ initialize: function initialize(options) { this.$editedElement = options.$editedElement; this.editorView = options.editorView; + this.$root = this.$el; + this._id = "quickedit-toolbar-for-".concat(this.model.id.replace(/[/[\]]/g, '_')); this.listenTo(this.model, 'change:state', this.stateChange); }, @@ -21,53 +23,41 @@ this.setElement($(Drupal.theme('quickeditFieldToolbar', { id: this._id }))); + this.$el.prependTo(this.$root); return this; }, stateChange: function stateChange(model, state) { var from = model.previous('state'); var to = state; - switch (to) { case 'inactive': break; - case 'candidate': if (from !== 'inactive' && from !== 'highlighted') { this.$el.remove(); this.setElement(); } - break; - case 'highlighted': break; - case 'activating': this.render(); - if (this.editorView.getQuickEditUISettings().fullWidthToolbar) { this.$el.addClass('quickedit-toolbar-fullwidth'); } - if (this.editorView.getQuickEditUISettings().unifiedToolbar) { this.insertWYSIWYGToolGroups(); } - break; - case 'active': break; - case 'changed': break; - case 'saving': break; - case 'saved': break; - case 'invalid': break; } @@ -82,6 +72,7 @@ classes: ['wysiwyg-main', 'quickedit-animate-slow', 'quickedit-animate-invisible', 'quickedit-animate-delay-veryfast'], buttons: [] })); + this.show('wysiwyg-floated'); this.show('wysiwyg-main'); }, @@ -99,7 +90,6 @@ }, show: function show(toolgroup) { var $group = this._find(toolgroup); - $group.on(Drupal.quickedit.util.constants.transitionEnd, function (event) { $group.off(Drupal.quickedit.util.constants.transitionEnd); }); diff --git a/core/modules/responsive_image/js/responsive_image.ajax.js b/core/modules/responsive_image/js/responsive_image.ajax.js index 145adcf00aa8d4b0b7bddc9a9407e28b97e6c0ce..5c89559858de675c1fe4070ae86615f0696d58dc 100644 --- a/core/modules/responsive_image/js/responsive_image.ajax.js +++ b/core/modules/responsive_image/js/responsive_image.ajax.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (Drupal) { Drupal.behaviors.responsiveImageAJAX = { attach: function attach() { diff --git a/core/modules/settings_tray/js/settings_tray.js b/core/modules/settings_tray/js/settings_tray.js index db383efee61d261ac11268554229c14b3a53df41..68b6e52869afe1a0c0b853d6d2b6d2a34b82e906 100644 --- a/core/modules/settings_tray/js/settings_tray.js +++ b/core/modules/settings_tray/js/settings_tray.js @@ -16,7 +16,6 @@ if ($(event.target).closest('.contextual-links').length) { return; } - event.preventDefault(); } @@ -40,26 +39,21 @@ if (!document.querySelector('[data-off-canvas-main-canvas]')) { throw new Error('data-off-canvas-main-canvas is missing from settings-tray-page-wrapper.html.twig'); } - editMode = !!editMode; var $editables; var editButton = document.querySelector(toggleEditSelector); - if (editMode) { if (editButton) { editButton.textContent = Drupal.t('Editing'); } - closeToolbarTrays(); $editables = $(once('settingstray', '[data-drupal-settingstray="editable"]')); - if ($editables.length) { document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true); $editables.not(contextualItemsSelector).on('click.settingstray', function (e) { if ($(e.target).closest('.contextual').length || !localStorage.getItem('Drupal.contextualToolbar.isViewing')) { return; } - $(e.currentTarget).find(blockConfigureSelector).trigger('click'); disableQuickEdit(); }); @@ -67,31 +61,26 @@ if (!$(e.target).parent().hasClass('contextual') || $(e.target).parent().hasClass('quickedit')) { closeOffCanvas(); } - if ($(e.target).parent().hasClass('contextual') || $(e.target).parent().hasClass('quickedit')) { return; } - $(e.currentTarget).find('li.quickedit a').trigger('click'); }); } - } else { + } + else { $editables = $(once.remove('settingstray', '[data-drupal-settingstray="editable"]')); - if ($editables.length) { document.querySelector('[data-off-canvas-main-canvas]').removeEventListener('click', preventClick, true); $editables.off('.settingstray'); $(quickEditItemSelector).off('.settingstray'); } - if (editButton) { editButton.textContent = Drupal.t('Edit'); } - closeOffCanvas(); disableQuickEdit(); } - getItemsToToggle().toggleClass('js-settings-tray-edit-mode', editMode); $('.edit-mode-inactive').toggleClass('visually-hidden', editMode); } @@ -105,13 +94,14 @@ } function prepareAjaxLinks() { - Drupal.ajax.instances.filter(function (instance) { + Drupal.ajax.instances + .filter(function (instance) { return instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas'; - }).forEach(function (instance) { + }) + .forEach(function (instance) { if (!instance.options.data.hasOwnProperty('dialogOptions')) { instance.options.data.dialogOptions = {}; } - instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id'); instance.progress = { type: 'fullscreen' @@ -121,18 +111,18 @@ $(document).on('drupalContextualLinkAdded', function (event, data) { prepareAjaxLinks(); + once('settings_tray.edit_mode_init', 'body').forEach(function () { var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false'; - if (editMode) { setEditModeState(true); } }); + data.$el.find(blockConfigureSelector).on('click.settingstray', function () { if (!isInEditMode()) { $(toggleEditSelector).trigger('click').trigger('click.settings_tray'); } - disableQuickEdit(); }); }); @@ -142,17 +132,18 @@ toggleEditMode(); } }); + Drupal.behaviors.toggleEditMode = { attach: function attach() { $(once('settingstray', toggleEditSelector)).on('click.settingstray', toggleEditMode); } }; + $(window).on({ 'dialog:beforecreate': function dialogBeforecreate(event, dialog, $element, settings) { if ($element.is('#drupal-off-canvas')) { $('body .settings-tray-active-editable').removeClass('settings-tray-active-editable'); var $activeElement = $("#".concat(settings.settingsTrayActiveEditableId)); - if ($activeElement.length) { $activeElement.addClass('settings-tray-active-editable'); } diff --git a/core/modules/system/js/system.date.js b/core/modules/system/js/system.date.js index 42138f4209f721c3b8e152fd408383b4f24b8013..8cd3adafbe40b58eca979a0b5cc8f2021713d9cb 100644 --- a/core/modules/system/js/system.date.js +++ b/core/modules/system/js/system.date.js @@ -7,6 +7,7 @@ (function ($, Drupal, drupalSettings) { var dateFormats = drupalSettings.dateFormats; + Drupal.behaviors.dateFormat = { attach: function attach(context) { var source = once('dateFormat', '[data-drupal-date-formatter="source"]', context); @@ -21,6 +22,7 @@ var dateString = baseValue.replace(/\\?(.?)/gi, function (key, value) { return dateFormats[key] ? dateFormats[key] : value; }); + target.forEach(function (item) { item.querySelectorAll('em').forEach(function (em) { em.textContent = dateString; @@ -29,7 +31,8 @@ $(target).toggleClass('js-hide', !dateString.length); } - $(source).on('keyup.dateFormat change.dateFormat input.dateFormat', dateFormatHandler).trigger('keyup'); + $(source).on('keyup.dateFormat change.dateFormat input.dateFormat', dateFormatHandler) + .trigger('keyup'); } }; })(jQuery, Drupal, drupalSettings); \ No newline at end of file diff --git a/core/modules/system/js/system.js b/core/modules/system/js/system.js index e92564b80c9fbbbb93a6804f521282545bb40b12..6c341751bbc34708dd1846a71a0b775451c8bd85 100644 --- a/core/modules/system/js/system.js +++ b/core/modules/system/js/system.js @@ -7,12 +7,12 @@ (function ($, Drupal, drupalSettings) { var ids = []; + Drupal.behaviors.copyFieldValue = { attach: function attach(context) { Object.keys(drupalSettings.copyFieldValue || {}).forEach(function (element) { ids.push(element); }); - if (ids.length) { $(once('copy-field-values', 'body')).on('value:copy', this.valueTargetCopyHandler); $(once('copy-field-values', "#".concat(ids.join(', #')))).on('blur', this.valueSourceBlurHandler); @@ -26,7 +26,6 @@ }, valueTargetCopyHandler: function valueTargetCopyHandler(e, value) { var target = e.target; - if (target.value === '') { target.value = value; } diff --git a/core/modules/system/js/system.modules.js b/core/modules/system/js/system.modules.js index f4451e5ab46b1a7f886b5386d8fec21b6f0cf7d4..d77afdba8b1ef126e9683703f6dc736aa8a3adc3 100644 --- a/core/modules/system/js/system.modules.js +++ b/core/modules/system/js/system.modules.js @@ -4,46 +4,35 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } - function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } (function ($, Drupal, debounce) { Drupal.behaviors.tableFilterByText = { attach: function attach(context, settings) { var _once = once('table-filter-text', 'input.table-filter-text'), - _once2 = _slicedToArray(_once, 1), - input = _once2[0]; - + _once2 = _slicedToArray(_once, 1), + input = _once2[0]; if (!input) { return; } - var $table = $(input.getAttribute('data-table')); var $rowsAndDetails; var $rows; var $details; var searching = false; - function hidePackageDetails(index, element) { var $packDetails = $(element); var $visibleRows = $packDetails.find('tbody tr:visible'); $packDetails.toggle($visibleRows.length > 0); } - function filterModuleList(e) { var query = e.target.value; var re = new RegExp("\\b".concat(query), 'i'); - function showModuleRow(index, row) { var sources = row.querySelectorAll('.table-filter-text-source, .module-name, .module-description'); var sourcesConcat = ''; @@ -53,13 +42,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var textMatch = sourcesConcat.search(re) !== -1; $(row).closest('tr').toggle(textMatch); } - $rowsAndDetails.show(); if (query.length >= 2) { searching = true; $rows.each(showModuleRow); + $details.not('[open]').attr('data-drupal-system-state', 'forced-open'); + $details.attr('open', true).each(hidePackageDetails); Drupal.announce(Drupal.t('!modules modules are available in the modified list.', { '!modules': $rowsAndDetails.find('tbody tr:visible').length @@ -70,14 +60,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } $details.filter('[data-drupal-system-state="forced-open"]').removeAttr('data-drupal-system-state').attr('open', false); } } - function preventEnterKey(event) { if (event.which === 13) { event.preventDefault(); event.stopPropagation(); } } - if ($table.length) { $rowsAndDetails = $table.find('tr, details'); $rows = $table.find('tbody tr'); diff --git a/core/modules/system/tests/modules/ajax_test/js/command_promise-ajax.js b/core/modules/system/tests/modules/ajax_test/js/command_promise-ajax.js index 6244626fced46ce00e4b042d87d275ffcd5dcc5a..77dc8d392fc8c3cb3c97a52e3b11cd1e025dc7a0 100644 --- a/core/modules/system/tests/modules/ajax_test/js/command_promise-ajax.js +++ b/core/modules/system/tests/modules/ajax_test/js/command_promise-ajax.js @@ -8,11 +8,9 @@ (function ($, Drupal) { Drupal.AjaxCommands.prototype.ajaxCommandReturnPromise = function (ajax, response) { var _this = this; - return new Promise(function (resolve, reject) { setTimeout(function () { _this.insert(ajax, response); - resolve(); }, Math.random() * 500); }); diff --git a/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js index d8040df5b02f8c43d20d9e34feb1acaaa7229f78..7aae231d7d11a2f2256a32001d4bb144787b9f09 100644 --- a/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js +++ b/core/modules/system/tests/modules/css_disable_transitions_test/js/disable_transitions.theme.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - if (window.jQuery) { jQuery.fx.off = true; } \ No newline at end of file diff --git a/core/modules/system/tests/modules/jquery_keyevent_polyfilll_test/js/jquery.keyevent.polyfill.js b/core/modules/system/tests/modules/jquery_keyevent_polyfilll_test/js/jquery.keyevent.polyfill.js index 94b4116052eaf7f2a3bd473d33a0e3d33fba2f79..63a35a797e91e3b1a5bbf254befdb0cb231d480a 100644 --- a/core/modules/system/tests/modules/jquery_keyevent_polyfilll_test/js/jquery.keyevent.polyfill.js +++ b/core/modules/system/tests/modules/jquery_keyevent_polyfilll_test/js/jquery.keyevent.polyfill.js @@ -19,18 +19,14 @@ if (button && 1) { return 1; } - if (button && 2) { return 3; } - if (button && 4) { return 2; } - return 0; } - return event.which; }); })(jQuery); \ No newline at end of file diff --git a/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.js b/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.js index 4d71a2f3811bfe08a828b93d8a024ff68224bd81..edea0ceec0b1f1542da4b44a8759270eb525208a 100644 --- a/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.js +++ b/core/modules/system/tests/modules/js_ajax_test/js/js_ajax_test.ajax.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { Drupal.AjaxCommands.prototype.jsAjaxTestCommand = function (ajax, response) { var $domElement = $(response.selector); diff --git a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js b/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js index 2a7a3fd1991889a9782af4a6ed3b7e33244ad5d4..7203717a3059b1aeeda6894e3246a226cb865510 100644 --- a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js +++ b/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (_ref, $) { var behaviors = _ref.behaviors; behaviors.jqueryCookie = { diff --git a/core/modules/system/tests/modules/js_deprecation_test/js/js_deprecation_test.js b/core/modules/system/tests/modules/js_deprecation_test/js/js_deprecation_test.js index 48ccbad18c0a9a8a1885fa8363595b1e24e7af64..e6c6299c8d08b7d246bb16834892f8b8821ab677 100644 --- a/core/modules/system/tests/modules/js_deprecation_test/js/js_deprecation_test.js +++ b/core/modules/system/tests/modules/js_deprecation_test/js/js_deprecation_test.js @@ -4,18 +4,15 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (_ref) { var deprecationError = _ref.deprecationError, - deprecatedProperty = _ref.deprecatedProperty, - behaviors = _ref.behaviors; - + deprecatedProperty = _ref.deprecatedProperty, + behaviors = _ref.behaviors; var deprecatedFunction = function deprecatedFunction() { deprecationError({ message: 'This function is deprecated for testing purposes.' }); }; - var objectWithDeprecatedProperty = deprecatedProperty({ target: { deprecatedProperty: 'Kitten' diff --git a/core/modules/system/tests/modules/js_errors_test/js/js_errors_test.js b/core/modules/system/tests/modules/js_errors_test/js/js_errors_test.js index a3357d06f801eb847a768e6cea2fddc31a3ac4f8..13b8a5ee4eed270df82cbb6d0cff583684748758 100644 --- a/core/modules/system/tests/modules/js_errors_test/js/js_errors_test.js +++ b/core/modules/system/tests/modules/js_errors_test/js/js_errors_test.js @@ -4,10 +4,9 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (_ref) { var throwError = _ref.throwError, - behaviors = _ref.behaviors; + behaviors = _ref.behaviors; behaviors.testErrors = { attach: function attach() { throwError(new Error('A manually thrown error.')); diff --git a/core/modules/system/tests/modules/js_message_test/js/js_message_test.js b/core/modules/system/tests/modules/js_message_test/js/js_message_test.js index e4f2ce8a00fb7316657c50f99abca8da77e042f3..fc4752630a3ff8f92fe87e5d2a5ea6c3bc285020 100644 --- a/core/modules/system/tests/modules/js_message_test/js/js_message_test.js +++ b/core/modules/system/tests/modules/js_message_test/js/js_message_test.js @@ -12,6 +12,7 @@ testMessages.types.forEach(function (type) { indexes[type] = []; }); + var messageObjects = { default: { zone: new Drupal.Message(), @@ -26,6 +27,7 @@ indexes: indexes }; }); + behaviors.js_message_test = { attach: function attach() { $(once('messages-details', '[data-drupal-messages-area]')).on('click', '[data-action]', function (e) { @@ -34,7 +36,6 @@ var area = $target.closest('[data-drupal-messages-area]').attr('data-drupal-messages-area') || 'default'; var message = messageObjects[area].zone; var action = $target.attr('data-action'); - if (action === 'add') { messageObjects[area].indexes[type].push(message.add("This is a message of the type, ".concat(type, ". You be the judge of its importance."), { type: type diff --git a/core/modules/system/tests/modules/js_testing_log_test/js/js_testing_log.js b/core/modules/system/tests/modules/js_testing_log_test/js/js_testing_log.js index 2a5348723b0dc8ee65442d539840f1aa3dd88ac2..a2734e2a7ee170d2956ed9a962065de16b84ab56 100644 --- a/core/modules/system/tests/modules/js_testing_log_test/js/js_testing_log.js +++ b/core/modules/system/tests/modules/js_testing_log_test/js/js_testing_log.js @@ -4,20 +4,16 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (Drupal) { if (typeof console !== 'undefined' && console.warn) { var originalWarnFunction = console.warn; - console.warn = function (warning) { var warnings = JSON.parse(sessionStorage.getItem('js_testing_log_test.warnings') || JSON.stringify([])); warnings.push(warning); sessionStorage.setItem('js_testing_log_test.warnings', JSON.stringify(warnings)); originalWarnFunction(warning); }; - var originalThrowFunction = Drupal.throwError; - Drupal.throwError = function (error) { var errors = JSON.parse(sessionStorage.getItem('js_testing_log_test.errors') || JSON.stringify([])); errors.push(error.stack); diff --git a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js index 7e65949bcb4c82379cf9fadffce51df5d62d39fa..b30642c4d2aad4ad9389c83c4aeb3b77fcd95c5f 100644 --- a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js +++ b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js @@ -9,7 +9,6 @@ Drupal.behaviors.js_webassert_test_wait_for_ajax_request = { attach: function attach(context) { var waitAjaxInput = document.querySelector('input[name="test_assert_wait_on_ajax_input"]'); - if (waitAjaxInput) { waitAjaxInput.value = 'js_webassert_test'; } diff --git a/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js b/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js index ee367765651c4a5d4272c0e7f41ee85ce534ce7d..c9e8d6d0a75eec1da9175ae0481cbe6e6196f560 100644 --- a/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js +++ b/core/modules/system/tests/modules/off_canvas_test/js/resize-helper.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (_ref) { var offCanvas = _ref.offCanvas; var originalResetSize = offCanvas.resetSize; diff --git a/core/modules/system/tests/modules/tabledrag_test/js/tabledrag_test.js b/core/modules/system/tests/modules/tabledrag_test/js/tabledrag_test.js index 6eb1d1ebc450112a5a2dbac6358f69bfccb522fd..668c5ee10bfef1f013ba6a0b73fde6133fa6157e 100644 --- a/core/modules/system/tests/modules/tabledrag_test/js/tabledrag_test.js +++ b/core/modules/system/tests/modules/tabledrag_test/js/tabledrag_test.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { Drupal.behaviors.tableDragTest = { attach: function attach(context) { diff --git a/core/modules/taxonomy/taxonomy.js b/core/modules/taxonomy/taxonomy.js index 0fe952bf06341937918875008e84d7687586a8fd..ce47197de4f1b7110d9e5217adf5f372836a9db3 100644 --- a/core/modules/taxonomy/taxonomy.js +++ b/core/modules/taxonomy/taxonomy.js @@ -19,21 +19,17 @@ $table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top'); $table.find('tr.taxonomy-term-divider-bottom').removeClass('taxonomy-term-divider-bottom'); var tableBody = $table[0].tBodies[0]; - if (backStep) { for (var n = 0; n < backStep; n++) { $(tableBody.rows[n]).addClass('taxonomy-term-preview'); } - $(tableBody.rows[backStep - 1]).addClass('taxonomy-term-divider-top'); $(tableBody.rows[backStep]).addClass('taxonomy-term-divider-bottom'); } - if (forwardStep) { for (var k = rows - forwardStep - 1; k < rows - 1; k++) { $(tableBody.rows[k]).addClass('taxonomy-term-preview'); } - $(tableBody.rows[rows - forwardStep - 2]).addClass('taxonomy-term-divider-top'); $(tableBody.rows[rows - forwardStep - 1]).addClass('taxonomy-term-divider-bottom'); } diff --git a/core/modules/text/text.js b/core/modules/text/text.js index 8b8074cb5487826e7ef8555ca1ff58f99f2d5c52..ba7c80aacd5ff84cc1826e1a3c045d614a2dc69c 100644 --- a/core/modules/text/text.js +++ b/core/modules/text/text.js @@ -39,7 +39,6 @@ $button.html(Drupal.t('Hide summary')); $link.appendTo($summaryLabel); } - e.preventDefault(); toggleClick = !toggleClick; }).appendTo($summaryLabel); diff --git a/core/modules/toolbar/js/escapeAdmin.js b/core/modules/toolbar/js/escapeAdmin.js index 9d51e33b940e871e73c553f8c86918760249c33a..8983efc0fbac393b8294fb415a2f21004906a7e5 100644 --- a/core/modules/toolbar/js/escapeAdmin.js +++ b/core/modules/toolbar/js/escapeAdmin.js @@ -17,7 +17,6 @@ Drupal.behaviors.escapeAdmin = { attach: function attach() { var toolbarEscape = once('escapeAdmin', '[data-toolbar-escape-admin]'); - if (toolbarEscape.length && pathInfo.currentPathIsAdmin) { if (escapeAdminPath !== null) { $(toolbarEscape).attr('href', escapeAdminPath); diff --git a/core/modules/toolbar/js/toolbar.js b/core/modules/toolbar/js/toolbar.js index 53e052ba6fb82853e1c92a71dd08f206bdde3e73..dacecf99f350052cf222803face0bee6538d1767 100644 --- a/core/modules/toolbar/js/toolbar.js +++ b/core/modules/toolbar/js/toolbar.js @@ -12,18 +12,19 @@ 'toolbar.standard': '', 'toolbar.wide': '' } - }, drupalSettings.toolbar, { + }, drupalSettings.toolbar, + { strings: { horizontal: Drupal.t('Horizontal orientation'), vertical: Drupal.t('Vertical orientation') } }); + Drupal.behaviors.toolbar = { attach: function attach(context) { if (!window.matchMedia('only screen').matches) { return; } - once('toolbar', '#toolbar-administration', context).forEach(function (toolbar) { var model = new Drupal.toolbar.ToolbarModel({ locked: JSON.parse(localStorage.getItem('Drupal.toolbar.trayVerticalLocked')), @@ -31,6 +32,7 @@ height: $('#toolbar-administration').outerHeight() }); Drupal.toolbar.models.toolbarModel = model; + Object.keys(options.breakpoints).forEach(function (label) { var mq = options.breakpoints[label]; var mql = window.matchMedia(mq); @@ -52,8 +54,10 @@ el: toolbar, model: model }); + model.trigger('change:isFixed', model, model.get('isFixed')); model.trigger('change:activeTray', model, model.get('activeTray')); + var menuModel = new Drupal.toolbar.MenuModel(); Drupal.toolbar.models.menuModel = menuModel; Drupal.toolbar.views.menuVisualView = new Drupal.toolbar.MenuVisualView({ @@ -61,16 +65,20 @@ model: menuModel, strings: options.strings }); + Drupal.toolbar.setSubtrees.done(function (subtrees) { menuModel.set('subtrees', subtrees); var theme = drupalSettings.ajaxPageState.theme; localStorage.setItem("Drupal.toolbar.subtrees.".concat(theme), JSON.stringify(subtrees)); model.set('areSubtreesLoaded', true); }); + Drupal.toolbar.views.toolbarVisualView.loadSubtrees(); - $(document).on('drupalViewportOffsetChange.toolbar', function (event, offsets) { + $(document) + .on('drupalViewportOffsetChange.toolbar', function (event, offsets) { model.set('offsets', offsets); }); + model.on('change:orientation', function (model, orientation) { $(document).trigger('drupalToolbarOrientationChange', orientation); }).on('change:activeTab', function (model, tab) { @@ -84,7 +92,6 @@ activeTab: $('.toolbar-bar .toolbar-tab:not(.home-toolbar-tab) a').get(0) }); } - $(window).on({ 'dialog:aftercreate': function dialogAftercreate(event, dialog, $element, settings) { var $toolbar = $('#toolbar-bar'); @@ -106,6 +113,7 @@ }); } }; + Drupal.toolbar = { views: {}, models: {}, @@ -118,7 +126,6 @@ isOriented: mql.matches, isTrayToggleVisible: false }); - if (!mql.matches || !model.get('orientation')) { model.set({ orientation: 'vertical' @@ -126,15 +133,12 @@ validate: true }); } - break; - case 'toolbar.standard': model.set({ isFixed: mql.matches }); break; - case 'toolbar.wide': model.set({ orientation: mql.matches && !model.get('locked') ? 'horizontal' : 'vertical' @@ -145,7 +149,6 @@ isTrayToggleVisible: mql.matches }); break; - default: break; } diff --git a/core/modules/toolbar/js/toolbar.menu.js b/core/modules/toolbar/js/toolbar.menu.js index 9e22f3a1ae95b3fcff3e47fd4ef1621d94185f9f..db37166409526ebf4064b62ba67186e314f2790f 100644 --- a/core/modules/toolbar/js/toolbar.menu.js +++ b/core/modules/toolbar/js/toolbar.menu.js @@ -7,7 +7,6 @@ (function ($, Drupal, drupalSettings) { var activeItem = Drupal.url(drupalSettings.path.currentPath); - $.fn.drupalToolbarMenu = function () { var ui = { handleOpen: Drupal.t('Extend'), @@ -36,7 +35,6 @@ if (!Drupal.toolbar.models.toolbarModel.get('isFixed')) { Drupal.toolbar.models.toolbarModel.set('activeTab', null); } - event.stopPropagation(); } @@ -49,7 +47,6 @@ $menu.find('li > a').wrap('<div class="toolbar-box">'); $menu.find('li').each(function (index, element) { var $item = $(element); - if ($item.children('ul.toolbar-menu').length) { var $box = $item.children('.toolbar-box'); var $link = $box.find('a'); @@ -65,7 +62,6 @@ level = !level ? 1 : level; var $lis = $lists.children('li').addClass("level-".concat(level)); $lists = $lis.children('ul'); - if ($lists.length) { markListLevels($lists, level + 1); } @@ -73,11 +69,9 @@ function openActiveItem($menu) { var pathItem = $menu.find("a[href=\"".concat(window.location.pathname, "\"]")); - if (pathItem.length && !activeItem) { activeItem = window.location.pathname; } - if (activeItem) { var $activeItem = $menu.find("a[href=\"".concat(activeItem, "\"]")).addClass('menu-item--active'); var $activeTrail = $activeItem.parentsUntil('.root', 'li').addClass('menu-item--active-trail'); @@ -87,7 +81,6 @@ return this.each(function (selector) { var menu = once('toolbar-menu', this); - if (menu.length) { var $menu = $(menu); $menu.on('click.toolbar', '.toolbar-box', toggleClickHandler).on('click.toolbar', '.toolbar-box a', linkClickHandler); diff --git a/core/modules/toolbar/js/views/BodyVisualView.js b/core/modules/toolbar/js/views/BodyVisualView.js index 71293844fe39e09fd90f48396d5ee71f56e394ac..c98a96b7c99350a160a3be03d89a3fd7a0c359d1 100644 --- a/core/modules/toolbar/js/views/BodyVisualView.js +++ b/core/modules/toolbar/js/views/BodyVisualView.js @@ -16,7 +16,8 @@ $('body').toggleClass('toolbar-fixed', isViewportOverflowConstrained || this.model.get('isFixed')); }, render: function render() { - $('body').toggleClass('toolbar-tray-open', !!this.model.get('activeTray')); + $('body') + .toggleClass('toolbar-tray-open', !!this.model.get('activeTray')); } }); })(jQuery, Drupal, Backbone); \ No newline at end of file diff --git a/core/modules/toolbar/js/views/MenuVisualView.js b/core/modules/toolbar/js/views/MenuVisualView.js index 2cbd95067a39e65877b1780c8e77a1b57fe12459..9ff3b58891324e9fc88a2be95201eec0d1bdb425 100644 --- a/core/modules/toolbar/js/views/MenuVisualView.js +++ b/core/modules/toolbar/js/views/MenuVisualView.js @@ -12,12 +12,10 @@ }, render: function render() { var _this = this; - var subtrees = this.model.get('subtrees'); Object.keys(subtrees || {}).forEach(function (id) { $(once('toolbar-subtrees', _this.$el.find("#toolbar-link-".concat(id)))).after(subtrees[id]); }); - if ('drupalToolbarMenu' in $.fn) { this.$el.children('.toolbar-menu').drupalToolbarMenu(); } diff --git a/core/modules/toolbar/js/views/ToolbarAuralView.js b/core/modules/toolbar/js/views/ToolbarAuralView.js index fae40f334b9ced6a1be1193634a58166ea2f5f09..625762ba9fb891be512e9b14f9bd26d036965824 100644 --- a/core/modules/toolbar/js/views/ToolbarAuralView.js +++ b/core/modules/toolbar/js/views/ToolbarAuralView.js @@ -19,15 +19,12 @@ }, onActiveTrayChange: function onActiveTrayChange(model, tray) { var relevantTray = tray === null ? model.previous('activeTray') : tray; - if (!relevantTray) { return; } - var action = tray === null ? Drupal.t('closed') : Drupal.t('opened'); var trayNameElement = relevantTray.querySelector('.toolbar-tray-name'); var text; - if (trayNameElement !== null) { text = Drupal.t('Tray "@tray" @action.', { '@tray': trayNameElement.textContent, @@ -38,7 +35,6 @@ '@action': action }); } - Drupal.announce(text); } }); diff --git a/core/modules/toolbar/js/views/ToolbarVisualView.js b/core/modules/toolbar/js/views/ToolbarVisualView.js index c9f109dcb6d43af7565d0a0d5578a490328b7e04..52beaf9f243abbc7dfd814dcb824543fe6712bbf 100644 --- a/core/modules/toolbar/js/views/ToolbarVisualView.js +++ b/core/modules/toolbar/js/views/ToolbarVisualView.js @@ -12,7 +12,6 @@ event.preventDefault(); event.target.click(); }; - return { 'click .toolbar-bar .toolbar-tab .trigger': 'onTabClick', 'click .toolbar-toggle-orientation button': 'onOrientationToggleClick', @@ -26,7 +25,9 @@ this.listenTo(this.model, 'change:mqMatches', this.onMediaQueryChange); this.listenTo(this.model, 'change:offsets', this.adjustPlacement); this.listenTo(this.model, 'change:activeTab change:orientation change:isOriented', this.updateToolbarHeight); + this.$el.find('.toolbar-tray .toolbar-lining').has('.toolbar-menu').append(Drupal.theme('toolbarOrientationToggle')); + this.model.trigger('change:activeTab'); }, updateToolbarHeight: function updateToolbarHeight() { @@ -55,13 +56,13 @@ if (this.model.changed.orientation === 'vertical' || this.model.changed.activeTab) { this.loadSubtrees(); } - return this; }, onTabClick: function onTabClick(event) { if (event.currentTarget.hasAttribute('data-toolbar-tray')) { var activeTab = this.model.get('activeTab'); var clickedTab = event.currentTarget; + this.model.set('activeTab', !activeTab || clickedTab !== activeTab ? clickedTab : null); event.preventDefault(); event.stopPropagation(); @@ -71,13 +72,11 @@ var orientation = this.model.get('orientation'); var antiOrientation = orientation === 'vertical' ? 'horizontal' : 'vertical'; var locked = antiOrientation === 'vertical'; - if (locked) { localStorage.setItem('Drupal.toolbar.trayVerticalLocked', 'true'); } else { localStorage.removeItem('Drupal.toolbar.trayVerticalLocked'); } - this.model.set({ locked: locked, orientation: antiOrientation @@ -94,16 +93,14 @@ $(this.model.previous('activeTray')).removeClass('is-active'); if ($tab.length > 0) { - $tab.addClass('is-active').prop('aria-pressed', true); + $tab.addClass('is-active') + .prop('aria-pressed', true); var name = $tab.attr('data-toolbar-tray'); var id = $tab.get(0).id; - if (id) { localStorage.setItem('Drupal.toolbar.activeTabID', JSON.stringify(id)); } - var $tray = this.$el.find("[data-toolbar-tray=\"".concat(name, "\"].toolbar-tray")); - if ($tray.length) { $tray.addClass('is-active'); this.model.set('activeTray', $tray.get(0)); @@ -117,21 +114,22 @@ }, updateBarAttributes: function updateBarAttributes() { var isOriented = this.model.get('isOriented'); - if (isOriented) { this.$el.find('.toolbar-bar').attr('data-offset-top', ''); } else { this.$el.find('.toolbar-bar').removeAttr('data-offset-top'); } - this.$el.toggleClass('toolbar-oriented', isOriented); }, updateTrayOrientation: function updateTrayOrientation() { var orientation = this.model.get('orientation'); + var antiOrientation = orientation === 'vertical' ? 'horizontal' : 'vertical'; + $('body').toggleClass('toolbar-vertical', orientation === 'vertical').toggleClass('toolbar-horizontal', orientation === 'horizontal'); var removeClass = antiOrientation === 'horizontal' ? 'toolbar-tray-horizontal' : 'toolbar-tray-vertical'; var $trays = this.$el.find('.toolbar-tray').removeClass(removeClass).addClass("toolbar-tray-".concat(orientation)); + var iconClass = "toolbar-icon-toggle-".concat(orientation); var iconAntiClass = "toolbar-icon-toggle-".concat(antiOrientation); var $orientationToggle = this.$el.find('.toolbar-toggle-orientation').toggle(this.model.get('isTrayToggleVisible')); @@ -139,6 +137,7 @@ $orientationToggleButton[0].value = antiOrientation; $orientationToggleButton.attr('title', this.strings[antiOrientation]).removeClass(iconClass).addClass(iconAntiClass); $orientationToggleButton[0].textContent = this.strings[antiOrientation]; + var dir = document.documentElement.dir; var edge = dir === 'rtl' ? 'right' : 'left'; $trays.removeAttr('data-offset-left data-offset-right data-offset-top'); @@ -147,7 +146,6 @@ }, adjustPlacement: function adjustPlacement() { var $trays = this.$el.find('.toolbar-tray'); - if (!this.model.get('isOriented')) { $trays.removeClass('toolbar-tray-horizontal').addClass('toolbar-tray-vertical'); } @@ -155,7 +153,6 @@ loadSubtrees: function loadSubtrees() { var $activeTab = $(this.model.get('activeTab')); var orientation = this.model.get('orientation'); - if (!this.model.get('areSubtreesLoaded') && typeof $activeTab.data('drupal-subtrees') !== 'undefined' && orientation === 'vertical') { var subtreesHash = drupalSettings.toolbar.subtreesHash; var theme = drupalSettings.ajaxPageState.theme; @@ -163,10 +160,10 @@ var cachedSubtreesHash = localStorage.getItem("Drupal.toolbar.subtreesHash.".concat(theme)); var cachedSubtrees = JSON.parse(localStorage.getItem("Drupal.toolbar.subtrees.".concat(theme))); var isVertical = this.model.get('orientation') === 'vertical'; - if (isVertical && subtreesHash === cachedSubtreesHash && cachedSubtrees) { Drupal.toolbar.setSubtrees.resolve(cachedSubtrees); - } else if (isVertical) { + } + else if (isVertical) { localStorage.removeItem("Drupal.toolbar.subtreesHash.".concat(theme)); localStorage.removeItem("Drupal.toolbar.subtrees.".concat(theme)); Drupal.ajax({ diff --git a/core/modules/tour/js/tour.js b/core/modules/tour/js/tour.js index c9bf7798c5ed197dc5553cdc1563bd7215b76676..17bea0794c3e1643dbf2cb1d7791becdea597609 100644 --- a/core/modules/tour/js/tour.js +++ b/core/modules/tour/js/tour.js @@ -7,6 +7,7 @@ (function ($, Backbone, Drupal, settings, document, Shepherd) { var queryString = decodeURI(window.location.search); + Drupal.behaviors.tour = { attach: function attach(context) { once('tour', 'body').forEach(function () { @@ -15,24 +16,25 @@ el: $(context).find('#toolbar-tab-tour'), model: model }); - model.on('change:isActive', function (tourModel, isActive) { + model + .on('change:isActive', function (tourModel, isActive) { $(document).trigger(isActive ? 'drupalTourStarted' : 'drupalTourStopped'); }); - if (settings._tour_internal) { model.set('tour', settings._tour_internal); } - if (/tour=?/i.test(queryString)) { model.set('isActive', true); } }); } }; + Drupal.tour = Drupal.tour || { models: {}, views: {} }; + Drupal.tour.models.StateModel = Backbone.Model.extend({ defaults: { tour: [], @@ -57,10 +59,8 @@ toggleTour: function toggleTour() { if (this.model.get('isActive')) { this._removeIrrelevantTourItems(this._getTour()); - var tourItems = this.model.get('tour'); var that = this; - if (tourItems.length) { settings.tourShepherdConfig.defaultStepOptions.popperOptions.modifiers.push({ name: 'moveArrowJoyridePosition', @@ -70,7 +70,6 @@ var state = _ref.state; var arrow = state.elements.arrow; var placement = state.placement; - if (arrow && /^top|bottom/.test(placement) && /-start|-end$/.test(placement)) { var horizontalPosition = placement.split('-')[1]; var offset = horizontalPosition === 'start' ? 28 : state.elements.popper.clientWidth - 56; @@ -99,6 +98,7 @@ tourItemOptions.when = { show: function show() { var nextButton = shepherdTour.currentStep.el.querySelector('footer button'); + nextButton.focus(); if (Drupal.tour.hasOwnProperty('convertToJoyrideMarkup')) { @@ -146,7 +146,6 @@ '!tour_item': filteredTourItemId + 1, '!total': filteredTour.length }); - if (filteredTourItemId === filteredTour.length - 1) { filteredTour[filteredTourItemId].cancelText = Drupal.t('End tour'); } diff --git a/core/modules/tracker/js/tracker-history.js b/core/modules/tracker/js/tracker-history.js index 74ac7330242f2630c6368fa77e6497a88f099e70..632918d395d604820368859686d78f7b22804412 100644 --- a/core/modules/tracker/js/tracker-history.js +++ b/core/modules/tracker/js/tracker-history.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal, window) { function processNodeNewIndicators(placeholders) { var newNodeString = Drupal.t('new'); @@ -13,14 +12,12 @@ var timestamp = parseInt(placeholder.getAttribute('data-history-node-timestamp'), 10); var nodeID = placeholder.getAttribute('data-history-node-id'); var lastViewTimestamp = Drupal.history.getLastRead(nodeID); - if (timestamp > lastViewTimestamp) { var message = lastViewTimestamp === 0 ? newNodeString : updatedNodeString; $(placeholder).append("<span class=\"marker\">".concat(message, "</span>")); } }); } - function processNewRepliesIndicators(placeholders) { var placeholdersToUpdate = {}; placeholders.forEach(function (placeholder) { @@ -32,12 +29,11 @@ placeholdersToUpdate[nodeID] = placeholder; } }); - var nodeIDs = Object.keys(placeholdersToUpdate); + var nodeIDs = Object.keys(placeholdersToUpdate); if (nodeIDs.length === 0) { return; } - $.ajax({ url: Drupal.url('comments/render_new_comments_node_links'), type: 'POST', @@ -63,35 +59,28 @@ var nodeNewPlaceholders = once('history', '[data-history-node-timestamp]', context).filter(function (placeholder) { var nodeTimestamp = parseInt(placeholder.getAttribute('data-history-node-timestamp'), 10); var nodeID = placeholder.getAttribute('data-history-node-id'); - if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) { nodeIDs.push(nodeID); return true; } - return false; }); + var newRepliesPlaceholders = once('history', '[data-history-node-last-comment-timestamp]', context).filter(function (placeholder) { var lastCommentTimestamp = parseInt(placeholder.getAttribute('data-history-node-last-comment-timestamp'), 10); var nodeTimestamp = parseInt(placeholder.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10); - if (lastCommentTimestamp === nodeTimestamp) { return false; } - var nodeID = placeholder.previousSibling.previousSibling.getAttribute('data-history-node-id'); - if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) { if (nodeIDs.indexOf(nodeID) === -1) { nodeIDs.push(nodeID); } - return true; } - return false; }); - if (nodeNewPlaceholders.length === 0 && newRepliesPlaceholders.length === 0) { return; } diff --git a/core/modules/user/tests/themes/password_theme_function_test/js/password-theme-functions.js b/core/modules/user/tests/themes/password_theme_function_test/js/password-theme-functions.js index 06c0108577a42e34aa3c38cc13206b5e2782152c..4f9ab12353738786bed4d54e98000720228d18b9 100644 --- a/core/modules/user/tests/themes/password_theme_function_test/js/password-theme-functions.js +++ b/core/modules/user/tests/themes/password_theme_function_test/js/password-theme-functions.js @@ -27,6 +27,7 @@ Drupal.behaviors.passwordThemeFunctionTest = { attach: function attach(context, settings) { var strength = Drupal.evaluatePasswordStrength('password', settings.password); + var message = strength.message; } }; diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 659db32c215e8292c7a2a85ac398a012ecf5afb8..dacab7a0859ffab12954f3b16f8b1e490f25937f 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -24,6 +24,7 @@ } } }; + Drupal.behaviors.password = { attach: function attach(context, settings) { var cssClasses = Drupal.user.password.css; @@ -34,40 +35,37 @@ var $confirmInput = $passwordWidget.find('input.js-password-confirm'); var $passwordConfirmMessage = $(Drupal.theme('passwordConfirmMessage', settings.password)); var $passwordMatchStatus = $passwordConfirmMessage.find('[data-drupal-selector="password-match-status-text"]').first(); - if ($passwordMatchStatus.length === 0) { $passwordMatchStatus = $passwordConfirmMessage.find('span').first(); Drupal.deprecationError({ message: 'Returning <span> without data-drupal-selector="password-match-status-text" attribute is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3152101' }); } - var $confirmInputParent = $confirmInput.parent().addClass('confirm-parent').append($passwordConfirmMessage); + var passwordStrengthBarClassesToRemove = [cssClasses.passwordWeak || '', cssClasses.passwordFair || '', cssClasses.passwordGood || '', cssClasses.passwordStrong || ''].join(' ').trim(); + var confirmTextWrapperClassesToRemove = [cssClasses.passwordsMatch || '', cssClasses.passwordsNotMatch || ''].join(' ').trim(); + var widgetClassesToRemove = [cssClasses.widgetInitial || '', cssClasses.passwordEmpty || '', cssClasses.passwordFilled || '', cssClasses.confirmEmpty || '', cssClasses.confirmFilled || ''].join(' ').trim(); var password = {}; if (settings.password.showStrengthIndicator) { var $passwordStrength = $(Drupal.theme('passwordStrength', settings.password)); password.$strengthBar = $passwordStrength.find('[data-drupal-selector="password-strength-indicator"]').first(); - if (password.$strengthBar.length === 0) { password.$strengthBar = $passwordStrength.find('.js-password-strength__indicator').first(); Drupal.deprecationError({ message: 'The js-password-strength__indicator class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__indicator with a data-drupal-selector="password-strength-indicator" attribute. See https://www.drupal.org/node/3152101' }); } - password.$strengthTextWrapper = $passwordStrength.find('[data-drupal-selector="password-strength-text"]').first(); - if (password.$strengthTextWrapper.length === 0) { password.$strengthTextWrapper = $passwordStrength.find('.js-password-strength__text').first(); Drupal.deprecationError({ message: 'The js-password-strength__text class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__text with a data-drupal-selector="password-strength-text" attribute. See https://www.drupal.org/node/3152101' }); } - password.$suggestions = $(Drupal.theme('passwordSuggestions', settings.password, [])); password.$suggestions.hide(); $mainInputParent.append($passwordStrength); @@ -87,7 +85,6 @@ if (confirmTextWrapperClassesToRemove) { $passwordMatchStatus.removeClass(confirmTextWrapperClassesToRemove); } - $passwordMatchStatus.html(confirmMessage).addClass(confirmClass); } }; @@ -99,14 +96,14 @@ if (password.$suggestions.html() !== $currentPasswordSuggestions.html()) { password.$suggestions.replaceWith($currentPasswordSuggestions); - password.$suggestions = $currentPasswordSuggestions.toggle(result.strength !== 100); + password.$suggestions = $currentPasswordSuggestions.toggle( + result.strength !== 100); } - if (passwordStrengthBarClassesToRemove) { password.$strengthBar.removeClass(passwordStrengthBarClassesToRemove); } - password.$strengthBar.css('width', "".concat(result.strength, "%")).addClass(result.indicatorClass); + password.$strengthTextWrapper.html(result.indicatorText); } @@ -120,13 +117,11 @@ visibility: 'hidden' }); } - if (widgetClassesToRemove) { $passwordWidget.removeClass(widgetClassesToRemove); addWidgetClasses(); } }; - if (widgetClassesToRemove) { addWidgetClasses(); } @@ -148,6 +143,7 @@ var hasUppercase = /[A-Z]/.test(password); var hasNumbers = /[0-9]/.test(password); var hasPunctuation = /[^a-zA-Z0-9]/.test(password); + var $usernameBox = $('input.username'); var username = $usernameBox.length > 0 ? $usernameBox[0].value : passwordSettings.username; @@ -160,17 +156,14 @@ msg.push(passwordSettings.addLowerCase); weaknesses += 1; } - if (!hasUppercase) { msg.push(passwordSettings.addUpperCase); weaknesses += 1; } - if (!hasNumbers) { msg.push(passwordSettings.addNumbers); weaknesses += 1; } - if (!hasPunctuation) { msg.push(passwordSettings.addPunctuation); weaknesses += 1; @@ -180,11 +173,9 @@ case 1: strength -= 12.5; break; - case 2: strength -= 25; break; - case 3: case 4: strength -= 40; @@ -195,7 +186,6 @@ msg.push(passwordSettings.sameAsUsername); strength = 5; } - var cssClasses = Drupal.user.password.css; if (strength < 60) { diff --git a/core/modules/user/user.permissions.js b/core/modules/user/user.permissions.js index e6d4ea4691a5f7988f0209574b9df9f8dca10e28..968116db54a4f40898c1dfba6511fa611a350661 100644 --- a/core/modules/user/user.permissions.js +++ b/core/modules/user/user.permissions.js @@ -9,12 +9,10 @@ Drupal.behaviors.permissions = { attach: function attach(context) { var _this = this; - once('permissions', 'table#permissions').forEach(function (table) { var $table = $(table); var $ancestor; var method; - if ($table.prev().length) { $ancestor = $table.prev(); method = 'after'; @@ -22,11 +20,14 @@ $ancestor = $table.parent(); method = 'append'; } - $table.detach(); + var $dummy = $(Drupal.theme('checkbox')).removeClass('form-checkbox').addClass('dummy-checkbox js-dummy-checkbox').attr('disabled', 'disabled').attr('checked', 'checked').attr('title', Drupal.t('This permission is inherited from the authenticated user role.')).hide(); $table.find('input[type="checkbox"]').not('.js-rid-anonymous, .js-rid-authenticated').addClass('real-checkbox js-real-checkbox').after($dummy); - $table.find('input[type=checkbox].js-rid-authenticated').on('click.permissions', _this.toggle).each(_this.toggle); + + $table.find('input[type=checkbox].js-rid-authenticated').on('click.permissions', _this.toggle) + .each(_this.toggle); + $ancestor[method]($table); }); }, diff --git a/core/modules/views/js/ajax_view.js b/core/modules/views/js/ajax_view.js index 225836f4f8b8d7612891b41347801c94a95f2ec4..daf4fa10d5214952ce06ff18765ad53c02c8c8cb 100644 --- a/core/modules/views/js/ajax_view.js +++ b/core/modules/views/js/ajax_view.js @@ -7,7 +7,6 @@ (function ($, Drupal, drupalSettings) { Drupal.behaviors.ViewsAjaxView = {}; - Drupal.behaviors.ViewsAjaxView.attach = function (context, settings) { if (settings && settings.views && settings.views.ajaxViews) { var ajaxViews = settings.views.ajaxViews; @@ -16,14 +15,12 @@ }); } }; - Drupal.behaviors.ViewsAjaxView.detach = function (context, settings, trigger) { if (trigger === 'unload') { if (settings && settings.views && settings.views.ajaxViews) { var ajaxViews = settings.views.ajaxViews; Object.keys(ajaxViews || {}).forEach(function (i) { var selector = ".js-view-dom-id-".concat(ajaxViews[i].view_dom_id); - if ($(selector, context).length) { delete Drupal.views.instances[i]; delete settings.views.ajaxViews[i]; @@ -34,11 +31,13 @@ }; Drupal.views = {}; + Drupal.views.instances = {}; Drupal.views.ajaxView = function (settings) { var selector = ".js-view-dom-id-".concat(settings.view_dom_id); this.$view = $(selector); + var ajaxPath = drupalSettings.views.ajax_path; if (ajaxPath.constructor.toString().indexOf('Array') !== -1) { @@ -46,15 +45,12 @@ } var queryString = window.location.search || ''; - if (queryString !== '') { queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, ''); - if (queryString !== '') { queryString = (/\?/.test(ajaxPath) ? '&' : '?') + queryString; } } - this.element_settings = { url: ajaxPath + queryString, submit: settings, @@ -66,9 +62,13 @@ } }; this.settings = settings; + this.$exposed_form = $("form#views-exposed-form-".concat(settings.view_name.replace(/_/g, '-'), "-").concat(settings.view_display_id.replace(/_/g, '-'))); once('exposed-form', this.$exposed_form).forEach($.proxy(this.attachExposedFormAjax, this)); - once('ajax-pager', this.$view.filter($.proxy(this.filterNestedViews, this))).forEach($.proxy(this.attachPagerAjax, this)); + + once('ajax-pager', this.$view + .filter($.proxy(this.filterNestedViews, this))).forEach($.proxy(this.attachPagerAjax, this)); + var selfSettings = $.extend({}, this.element_settings, { event: 'RefreshView', base: this.selector, @@ -101,7 +101,8 @@ var $link = $(link); var viewData = {}; var href = $link.attr('href'); - $.extend(viewData, this.settings, Drupal.Views.parseQueryString(href), Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); + $.extend(viewData, this.settings, Drupal.Views.parseQueryString(href), + Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); var selfSettings = $.extend({}, this.element_settings, { submit: viewData, base: false, @@ -113,11 +114,9 @@ Drupal.AjaxCommands.prototype.viewsScrollTop = function (ajax, response) { var offset = $(response.selector).offset(); var scrollTarget = response.selector; - while ($(scrollTarget).scrollTop() === 0 && $(scrollTarget).parent()) { scrollTarget = $(scrollTarget).parent(); } - if (offset.top - 10 < $(scrollTarget).scrollTop()) { $(scrollTarget).animate({ scrollTop: offset.top - 10 diff --git a/core/modules/views/js/base.js b/core/modules/views/js/base.js index 4f434ecc7f1bcdbff989540bc205826fb217a0ce..87a919f9962698f97358507bdf424c728c72f4ce 100644 --- a/core/modules/views/js/base.js +++ b/core/modules/views/js/base.js @@ -11,22 +11,17 @@ Drupal.Views.parseQueryString = function (query) { var args = {}; var pos = query.indexOf('?'); - if (pos !== -1) { query = query.substring(pos + 1); } - var pair; var pairs = query.split('&'); - for (var i = 0; i < pairs.length; i++) { pair = pairs[i].split('='); - if (pair[0] !== 'q' && pair[1]) { args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); } } - return args; }; @@ -34,41 +29,33 @@ var returnObj = {}; var path = Drupal.Views.getPath(href); var viewHref = Drupal.url(viewPath).substring(drupalSettings.path.baseUrl.length); - if (viewHref && path.substring(0, viewHref.length + 1) === "".concat(viewHref, "/")) { returnObj.view_args = decodeURIComponent(path.substring(viewHref.length + 1, path.length)); returnObj.view_path = path; } - return returnObj; }; Drupal.Views.pathPortion = function (href) { var protocol = window.location.protocol; - if (href.substring(0, protocol.length) === protocol) { href = href.substring(href.indexOf('/', protocol.length + 2)); } - return href; }; Drupal.Views.getPath = function (href) { href = Drupal.Views.pathPortion(href); href = href.substring(drupalSettings.path.baseUrl.length, href.length); - if (href.substring(0, 3) === '?q=') { href = href.substring(3, href.length); } - var chars = ['#', '?', '&']; - for (var i = 0; i < chars.length; i++) { if (href.indexOf(chars[i]) > -1) { href = href.substr(0, href.indexOf(chars[i])); } } - return href; }; })(jQuery, Drupal, drupalSettings); \ No newline at end of file diff --git a/core/modules/views_ui/js/ajax.js b/core/modules/views_ui/js/ajax.js index 2d83544b4043668d85f05a1f8982d8ff588301bd..a71350f5afded593dfee083cd0de6bb83c50a006 100644 --- a/core/modules/views_ui/js/ajax.js +++ b/core/modules/views_ui/js/ajax.js @@ -32,7 +32,6 @@ Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) { $('div.views-edit-view div.form-actions').removeClass('js-hide'); - if (response.changed) { $('div.views-edit-view div.view-changed.messages').removeClass('js-hide'); } @@ -68,19 +67,20 @@ }); } }; + Drupal.behaviors.syncPreviewDisplay = { attach: function attach(context) { $(once('views-ajax', '#views-tabset a')).on('click', function () { var href = $(this).attr('href'); var displayId = href.substr(11); var viewsPreviewId = document.querySelector('#views-live-preview #preview-display-id'); - if (viewsPreviewId) { viewsPreviewId.value = displayId; } }); } }; + Drupal.behaviors.viewsAjax = { collapseReplaced: false, attach: function attach(context, settings) { @@ -95,33 +95,28 @@ var elementSettings = baseElementSettings; elementSettings.base = $link.attr('id'); elementSettings.element = link; - if ($link.attr('href')) { elementSettings.url = $link.attr('href'); } - Drupal.ajax(elementSettings); }); once('views-ajax', 'div#views-live-preview a').forEach(function (link) { var $link = $(link); - if (!$link.attr('href')) { return true; } - var elementSettings = baseElementSettings; elementSettings.url = $link.attr('href'); - if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') { return true; } - elementSettings.wrapper = 'views-preview-wrapper'; elementSettings.method = 'replaceWith'; elementSettings.base = link.id; elementSettings.element = link; Drupal.ajax(elementSettings); }); + once('views-ajax', 'div#views-live-preview input[type=submit]').forEach(function (submit) { var $submit = $(submit); $submit.on('click', function () { @@ -130,11 +125,9 @@ }); var elementSettings = baseElementSettings; elementSettings.url = $(submit.form).attr('action'); - if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') { return true; } - elementSettings.wrapper = 'views-preview-wrapper'; elementSettings.method = 'replaceWith'; elementSettings.event = 'click'; diff --git a/core/modules/views_ui/js/dialog.views.js b/core/modules/views_ui/js/dialog.views.js index 625f4798aca260d28728bc0fa1275238fdf6e5d1..15e5729cf30034672e35462f8dd34f55321c1031 100644 --- a/core/modules/views_ui/js/dialog.views.js +++ b/core/modules/views_ui/js/dialog.views.js @@ -12,7 +12,6 @@ var $scroll = $modal.find('[data-drupal-views-scroll]'); var offset = 0; var modalHeight; - if ($scroll.length) { $modal.closest('.views-ui-dialog').addClass('views-ui-dialog-scroll'); $scroll.css({ @@ -23,6 +22,7 @@ $viewsOverride.each(function () { offset += $(this).outerHeight(); }); + var scrollOffset = $scroll.outerHeight() - $scroll.height(); $scroll.height(modalHeight - offset - scrollOffset); $modal.css('overflow', 'hidden'); diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 2d1a3656fb17ae69933fcde38afb3e119a113ca9..05bb6624c6f750a394997c942aabd33b90ea4f5e 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -7,6 +7,7 @@ (function ($, Drupal, drupalSettings) { Drupal.viewsUi = {}; + Drupal.behaviors.viewsUiEditView = { attach: function attach() { $('[data-drupal-selector="edit-query-options-disable-sql-rewrite"]').on('click', function () { @@ -14,14 +15,15 @@ }); } }; + Drupal.behaviors.viewsUiAddView = { attach: function attach(context) { var $context = $(context); var exclude = new RegExp('[^a-z0-9\\-]+', 'g'); var replace = '-'; var suffix; - var $fields = $context.find('[id^="edit-page-title"], [id^="edit-block-title"], [id^="edit-page-link-properties-title"]'); + var $fields = $context.find('[id^="edit-page-title"], [id^="edit-block-title"], [id^="edit-page-link-properties-title"]'); if ($fields.length) { if (!this.fieldsFiller) { this.fieldsFiller = new Drupal.viewsUi.FormFieldFiller($fields); @@ -31,7 +33,6 @@ } var $pathField = $context.find('[id^="edit-page-path"]'); - if ($pathField.length) { if (!this.pathFiller) { this.pathFiller = new Drupal.viewsUi.FormFieldFiller($pathField, exclude, replace); @@ -41,7 +42,6 @@ } var $feedField = $context.find('[id^="edit-page-feed-properties-path"]'); - if ($feedField.length) { if (!this.feedFiller) { suffix = '.xml'; @@ -55,10 +55,15 @@ Drupal.viewsUi.FormFieldFiller = function ($target, exclude, replace, suffix) { this.source = $('#edit-label'); + this.target = $target; + this.exclude = exclude || false; + this.replace = replace || ''; + this.suffix = suffix || ''; + var self = this; this.populate = function () { @@ -68,7 +73,6 @@ this.unbind = function () { return self._unbind.call(self); }; - this.bind(); }; @@ -80,11 +84,9 @@ }, getTransliterated: function getTransliterated() { var from = this.source.length ? this.source[0].value : ''; - if (this.exclude) { from = from.toLowerCase().replace(this.exclude, this.replace); } - return from; }, _populate: function _populate() { @@ -104,15 +106,14 @@ this.bind(); } }); + Drupal.behaviors.addItemForm = { attach: function attach(context) { var $context = $(context); var $form = $context; - if (!$context.is('form[id^="views-ui-add-handler-form"]')) { $form = $context.find('form[id^="views-ui-add-handler-form"]'); } - if (once('views-ui-add-handler-form', $form).length) { new Drupal.viewsUi.AddItemForm($form); } @@ -122,21 +123,21 @@ Drupal.viewsUi.AddItemForm = function ($form) { this.$form = $form; this.$form.find('.views-filterable-options :checkbox').on('click', $.proxy(this.handleCheck, this)); + this.$selected_div = this.$form.find('.views-selected-options').parent(); this.$selected_div.hide(); + this.checkedItems = []; }; Drupal.viewsUi.AddItemForm.prototype.handleCheck = function (event) { var $target = $(event.target); var label = $target.closest('td').next().html().trim(); - if ($target.is(':checked')) { this.$selected_div.show().css('display', 'block'); this.checkedItems.push(label); } else { var position = $.inArray(label, this.checkedItems); - for (var i = 0; i < this.checkedItems.length; i++) { if (i === position) { this.checkedItems.splice(i, 1); @@ -144,12 +145,10 @@ break; } } - if (this.checkedItems.length === 0) { this.$selected_div.hide(); } } - this.refreshCheckedItems(); }; @@ -160,11 +159,9 @@ Drupal.behaviors.viewsUiRenderAddViewButton = { attach: function attach(context) { var menu = once('views-ui-render-add-view-button', '#views-display-menu-tabs', context); - if (!menu.length) { return; } - var $menu = $(menu); var $addDisplayDropdown = $("<li class=\"add\"><a href=\"#\"><span class=\"icon add\"></span>".concat(Drupal.t('Add'), "</a><ul class=\"action-list\" style=\"display:none;\"></ul></li>")); var $displayButtons = $menu.nextAll('input.add-display').detach(); @@ -174,6 +171,7 @@ this.value = $this.attr('data-drupal-dropdown-label'); }); $addDisplayDropdown.appendTo($menu); + $menu.find('li.add > a').on('click', function (event) { event.preventDefault(); var $trigger = $(this); @@ -182,7 +180,6 @@ $('li.add', $menu).on('mouseleave', function (event) { var $this = $(this); var $trigger = $this.children('a[href="#"]'); - if ($this.children('.action-list').is(':visible')) { Drupal.behaviors.viewsUiRenderAddViewButton.toggleMenu($trigger); } @@ -199,11 +196,9 @@ attach: function attach(context) { var $context = $(context); var $form = $context; - if (!$context.is('form[id^="views-ui-add-handler-form"]')) { $form = $context.find('form[id^="views-ui-add-handler-form"]'); } - if (once('views-ui-filter-options', $form).length) { new Drupal.viewsUi.OptionsSearch($form); } @@ -212,6 +207,7 @@ Drupal.viewsUi.OptionsSearch = function ($form) { this.$form = $form; + this.$form.on('click', 'td.title', function (event) { var $target = $(event.currentTarget); $target.closest('tr').find('input').trigger('click'); @@ -221,14 +217,15 @@ this.$form.on('formUpdated', "".concat(searchBoxSelector, ",").concat(controlGroupSelector), $.proxy(this.handleFilter, this)); this.$searchBox = this.$form.find(searchBoxSelector); this.$controlGroup = this.$form.find(controlGroupSelector); + this.options = this.getOptions(this.$form.find('.filterable-option')); + this.$searchBox.on('keypress', function (event) { if (event.which === 13) { event.preventDefault(); } }); }; - $.extend(Drupal.viewsUi.OptionsSearch.prototype, { getOptions: function getOptions($allOptions) { var $title; @@ -236,7 +233,6 @@ var $option; var options = []; var length = $allOptions.length; - for (var i = 0; i < length; i++) { $option = $($allOptions[i]); $title = $option.find('.title'); @@ -246,43 +242,39 @@ $div: $option }; } - return options; }, handleFilter: function handleFilter(event) { var search = this.$searchBox[0].value.toLowerCase(); var words = search.split(' '); var group = this.$controlGroup[0].value; + this.options.forEach(function (option) { function hasWord(word) { return option.searchText.indexOf(word) !== -1; } - var found = true; - if (search) { found = words.every(hasWord); } - if (found && group !== 'all') { found = option.$div.hasClass(group); } - option.$div.toggle(found); }); + $(event.target).trigger('dialogContentResize'); } }); + Drupal.behaviors.viewsUiPreview = { attach: function attach(context) { var $contextualFiltersBucket = $(context).find('.views-display-column .views-ui-display-tab-bucket.argument'); - if ($contextualFiltersBucket.length === 0) { return; } var $contextualFilters = $contextualFiltersBucket.find('.views-display-setting a'); - if ($contextualFilters.length) { $('#preview-args').parent().show(); } else { @@ -297,11 +289,17 @@ Drupal.viewsUi.RearrangeFilterHandler = function ($table, $operator) { this.table = $table; + this.operator = $operator; + this.hasGroupOperator = this.operator.length > 0; + this.draggableRows = $table.find('.draggable'); + this.addGroupButton = $('#views-add-group'); + this.removeGroupButtons = $table.find('.views-remove-group'); + this.insertAddRemoveFilterGroupLinks(); if (this.hasGroupOperator) { @@ -310,21 +308,24 @@ } this.modifyTableDrag(); + this.redrawOperatorLabels(); $(once('views-rearrange-filter-handler', $table.find('.views-group-title select'))).on('change.views-rearrange-filter-handler', $.proxy(this, 'redrawOperatorLabels')); + $(once('views-rearrange-filter-handler', $table.find('a.views-groups-remove-link'))).on('click.views-rearrange-filter-handler', $.proxy(this, 'updateRowspans')).on('click.views-rearrange-filter-handler', $.proxy(this, 'redrawOperatorLabels')); }; - $.extend(Drupal.viewsUi.RearrangeFilterHandler.prototype, { insertAddRemoveFilterGroupLinks: function insertAddRemoveFilterGroupLinks() { - $(once('views-rearrange-filter-handler', $("<ul class=\"action-links\"><li><a id=\"views-add-group-link\" href=\"#\">".concat(this.addGroupButton[0].value, "</a></li></ul>")).prependTo(this.table.parent()))).find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton')); + $(once('views-rearrange-filter-handler', + $("<ul class=\"action-links\"><li><a id=\"views-add-group-link\" href=\"#\">".concat(this.addGroupButton[0].value, "</a></li></ul>")).prependTo(this.table.parent()))).find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton')); + var length = this.removeGroupButtons.length; var i; - for (i = 0; i < length; i++) { var $removeGroupButton = $(this.removeGroupButtons[i]); var buttonId = $removeGroupButton.attr('id'); - $(once('views-rearrange-filter-handler', $("<a href=\"#\" class=\"views-remove-group-link\">".concat(Drupal.t('Remove group'), "</a>")).insertBefore($removeGroupButton))).on('click.views-rearrange-filter-handler', { + $(once('views-rearrange-filter-handler', + $("<a href=\"#\" class=\"views-remove-group-link\">".concat(Drupal.t('Remove group'), "</a>")).insertBefore($removeGroupButton))).on('click.views-rearrange-filter-handler', { buttonId: buttonId }, $.proxy(this, 'clickRemoveGroupButton')); } @@ -341,20 +342,20 @@ var newRow; var titleRow; var titleRows = once('duplicateGroupsOperator', 'tr.views-group-title'); - if (!titleRows.length) { return this.operator; } this.operator.find('label').add('div.description').addClass('visually-hidden'); this.operator.find('select').addClass('form-select'); + var dropdowns = this.operator; + titleRow = $('tr#views-group-title-2'); newRow = $('<tr class="filter-group-operator-row"><td colspan="5"></td></tr>'); newRow.find('td').append(this.operator); newRow.insertBefore(titleRow); var length = titleRows.length; - for (var i = 2; i < length; i++) { titleRow = $(titleRows[i]); var fakeOperator = this.operator.clone(); @@ -364,19 +365,18 @@ newRow.insertBefore(titleRow); dropdowns.add(fakeOperator); } - return dropdowns; }, syncGroupsOperators: function syncGroupsOperators() { if (this.dropdowns.length < 2) { return; } - this.dropdowns.on('change', $.proxy(this, 'operatorChangeHandler')); }, operatorChangeHandler: function operatorChangeHandler(event) { var $target = $(event.target); var operators = this.dropdowns.find('select').not($target); + operators.each(function (index, item) { item.value = $target[0].value; }); @@ -389,27 +389,21 @@ if (filterHandler.hasGroupOperator) { var thisRow = $(this.group); var previousRow = thisRow.prev('tr'); - if (previousRow.length && !previousRow.hasClass('group-message') && !previousRow.hasClass('draggable')) { var next = thisRow.next(); - if (next.is('tr')) { this.swap('after', next); } } - filterHandler.updateRowspans(); } - filterHandler.redrawOperatorLabels(); }; tableDrag.onDrop = function () { var changeMarker = $(this.oldRowElement).find('.tabledrag-changed'); - if (changeMarker.length) { var operatorLabel = changeMarker.prevAll('.views-operator-label'); - if (operatorLabel.length) { operatorLabel.insertAfter(changeMarker); } @@ -418,7 +412,6 @@ var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0); var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); var groupField = $('select.views-group-select', this.rowObject.element); - if (!groupField.is(".views-group-select-".concat(groupName))) { var oldGroupName = groupField.attr('class').replace(/([^ ]+[ ]+)*views-group-select-([^ ]+)([ ]+[^ ]+)*/, '$2'); groupField.removeClass("views-group-select-".concat(oldGroupName)).addClass("views-group-select-".concat(groupName)); @@ -430,20 +423,20 @@ for (var i = 0; i < this.draggableRows.length; i++) { var $draggableRow = $(this.draggableRows[i]); var $firstCell = $draggableRow.find('td').eq(0); - if ($firstCell.length) { var operatorValue = $draggableRow.prevAll('.views-group-title').find('option:selected').html(); var operatorLabel = "<span class=\"views-operator-label\">".concat(operatorValue, "</span>"); var $nextRow = $draggableRow.nextAll(':visible').eq(0); var $existingOperatorLabel = $firstCell.find('.views-operator-label'); - if ($nextRow.hasClass('draggable')) { if ($existingOperatorLabel.length) { $existingOperatorLabel.replaceWith(operatorLabel); - } else { + } + else { $firstCell.append(operatorLabel); } - } else { + } + else { $existingOperatorLabel.remove(); } } @@ -456,10 +449,8 @@ var $operatorCell; var rows = $(this.table).find('tr'); var length = rows.length; - for (var i = 0; i < length; i++) { $row = $(rows[i]); - if ($row.hasClass('views-group-title')) { $operatorCell = $row.find('td.group-operator'); draggableCount = 0; @@ -474,10 +465,10 @@ } } }); + Drupal.behaviors.viewsFilterConfigSelectAll = { attach: function attach(context) { var selectAll = once('filterConfigSelectAll', '.js-form-item-options-value-all', context); - if (selectAll.length) { var $selectAll = $(selectAll); var $selectAllCheckbox = $selectAll.find('input[type=checkbox]'); @@ -486,6 +477,7 @@ $selectAllCheckbox.on('click', function () { $checkboxes.prop('checked', $(this).is(':checked')); }); + $checkboxes.on('click', function () { if ($(this).is('checked') === false) { $selectAllCheckbox.prop('checked', false); @@ -494,11 +486,13 @@ } } }; + Drupal.behaviors.viewsRemoveIconClass = { attach: function attach(context) { $(once('dropbutton-icon', '.dropbutton', context)).find('.icon').removeClass('icon'); } }; + Drupal.behaviors.viewsUiCheckboxify = { attach: function attach(context, settings) { var buttons = once('views-ui-checkboxify', '[data-drupal-selector="edit-options-expose-button-button"], [data-drupal-selector="edit-options-group-button-button"]').forEach(function (button) { @@ -506,10 +500,10 @@ }); } }; + Drupal.behaviors.viewsUiChangeDefaultWidget = { attach: function attach(context) { var $context = $(context); - function changeDefaultWidget(event) { if ($(event.target).prop('checked')) { $context.find('input.default-radios').parent().hide(); @@ -522,7 +516,8 @@ } } - $context.find('input[name="options[group_info][multiple]"]').on('change', changeDefaultWidget).trigger('change'); + $context.find('input[name="options[group_info][multiple]"]').on('change', changeDefaultWidget) + .trigger('change'); } }; @@ -553,7 +548,6 @@ if (!submit) { return; } - if (this.value === 'default') { submit.value = Drupal.t('Apply (all displays)'); } else if (this.value === 'default_revert') { @@ -561,13 +555,13 @@ } else { submit.value = Drupal.t('Apply (this display)'); } - var $dialog = $context.closest('.ui-dialog-content'); $dialog.trigger('dialogButtonsChange'); }).trigger('change'); }); } }; + Drupal.behaviors.viewsUiHandlerRemoveLink = { attach: function attach(context) { var $context = $(context); @@ -577,6 +571,7 @@ $context.find("#views-removed-".concat(id)).prop('checked', true); event.preventDefault(); }); + $(once('display', 'a.display-remove-link', context)).on('click', function (event) { var id = $(this).attr('id').replace('display-remove-link-', ''); $context.find("#display-row-".concat(id)).hide(); @@ -585,15 +580,14 @@ }); } }; + Drupal.behaviors.viewsUiRearrangeFilter = { attach: function attach(context) { if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag['views-rearrange-filters'] === 'undefined') { return; } - var table = once('views-rearrange-filters', '#views-rearrange-filters', context); var operator = once('views-rearrange-filters', '.js-form-item-filter-groups-operator', context); - if (table.length) { new Drupal.viewsUi.RearrangeFilterHandler($(table), $(operator)); } diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index f98f50d63527408974834f843417be449d588274..c18cda62db65020517fa49b97da93a8ae1b7e316 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -4,36 +4,26 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } - function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } (function ($, Drupal) { Drupal.behaviors.viewTableFilterByText = { attach: function attach(context, settings) { var _once = once('views-filter-text', 'input.views-filter-text'), - _once2 = _slicedToArray(_once, 1), - input = _once2[0]; - + _once2 = _slicedToArray(_once, 1), + input = _once2[0]; if (!input) { return; } - var $table = $(input.getAttribute('data-table')); var $rows; - function filterViewList(e) { var query = e.target.value.toLowerCase(); - function showViewRow(index, row) { var sources = row.querySelectorAll('[data-drupal-selector="views-table-filter-text-source"]'); var sourcesConcat = ''; @@ -50,7 +40,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } $rows.show(); } } - if ($table.length) { $rows = $table.find('tbody tr'); $(input).on('keyup', filterViewList); diff --git a/core/profiles/demo_umami/themes/umami/js/components/navigation/menu-main/menu-main.js b/core/profiles/demo_umami/themes/umami/js/components/navigation/menu-main/menu-main.js index 0705b50f5587e025119f888a457866f62f66e3b0..66d2ed45a381dbf410127c0eba0dff64fc3f4a9d 100644 --- a/core/profiles/demo_umami/themes/umami/js/components/navigation/menu-main/menu-main.js +++ b/core/profiles/demo_umami/themes/umami/js/components/navigation/menu-main/menu-main.js @@ -8,12 +8,10 @@ (function () { var toggler = document.querySelector('[data-drupal-selector="menu-main-toggle"]'); var menu = document.querySelector('[data-drupal-selector="menu-main"]'); - function toggleMenu() { toggler.classList.toggle('menu-main-toggle--active'); menu.classList.toggle('menu-main--active'); return false; } - toggler.addEventListener('click', toggleMenu); })(); \ No newline at end of file diff --git a/core/themes/bartik/color/preview.js b/core/themes/bartik/color/preview.js index e626e7d8e8a3f09c83e8bcf691604cc149be0d05..f9fd798464059ad6fccc8c5d3cb9290037f8181d 100644 --- a/core/themes/bartik/color/preview.js +++ b/core/themes/bartik/color/preview.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal, drupalSettings) { Drupal.color = { logoChanged: false, @@ -13,20 +12,23 @@ $('.color-preview .color-preview-logo img').attr('src', drupalSettings.color.logo); this.logoChanged = true; } - if (drupalSettings.color.logo === null) { $('div').remove('.color-preview-logo'); } - var $colorPreview = $form.find('.color-preview'); var $colorPalette = $form.find('.js-color-palette'); + $colorPreview.css('backgroundColor', $colorPalette.find('input[name="palette[bg]"]')[0].value); + $colorPreview.find('.color-preview-main h2, .color-preview .preview-content').css('color', $colorPalette.find('input[name="palette[text]"]')[0].value); $colorPreview.find('.color-preview-content a').css('color', $colorPalette.find('input[name="palette[link]"]')[0].value); + var $colorPreviewBlock = $colorPreview.find('.color-preview-sidebar .color-preview-block'); $colorPreviewBlock.css('background-color', $colorPalette.find('input[name="palette[sidebar]"]')[0].value); $colorPreviewBlock.css('border-color', $colorPalette.find('input[name="palette[sidebarborders]"]')[0].value); + $colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]')[0].value); + var gradientStart = $colorPalette.find('input[name="palette[top]"]')[0].value; var gradientEnd = $colorPalette.find('input[name="palette[bottom]"]')[0].value; $colorPreview.find('.color-preview-header').attr('style', "background-color: ".concat(gradientStart, "; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(").concat(gradientStart, "), to(").concat(gradientEnd, ")); background-image: -moz-linear-gradient(-90deg, ").concat(gradientStart, ", ").concat(gradientEnd, ");")); diff --git a/core/themes/claro/js/autocomplete.js b/core/themes/claro/js/autocomplete.js index 79db89081fcb84fef2051cd889d9fc1c01510161..51480d2b76c1bb8978218f6067d0f867907f3a71 100644 --- a/core/themes/claro/js/autocomplete.js +++ b/core/themes/claro/js/autocomplete.js @@ -12,18 +12,15 @@ var $input = $(value); var timeout = 400; var classRemoveTimeout; - var classRemove = function classRemove($autoCompleteElem) { $autoCompleteElem.removeClass('is-autocompleting'); $autoCompleteElem.siblings('[data-drupal-selector="autocomplete-message"]').addClass('hidden'); }; - $input.on('input autocompletesearch autocompleteresponses', function (event) { if (event && event.type && event.type === 'autocompletesearch') { $(event.target).addClass('is-autocompleting'); $(event.target).siblings('[data-drupal-selector="autocomplete-message"]').removeClass('hidden'); } - clearTimeout(classRemoveTimeout); classRemoveTimeout = setTimeout(classRemove, timeout, $(event.target)); }); diff --git a/core/themes/claro/js/details.js b/core/themes/claro/js/details.js index 853c99163fd171eddfaf58ce12fe0c2713437c1c..bc1e16fced26f89041176f64eacda73b91c7660f 100644 --- a/core/themes/claro/js/details.js +++ b/core/themes/claro/js/details.js @@ -15,15 +15,14 @@ }); } }; + Drupal.behaviors.claroDetailsToggleShim = { attach: function attach(context) { if (Modernizr.details || !Drupal.CollapsibleDetails.instances.length) { return; } - $(once('claroDetailsToggleShim', 'details .details-title', context)).on('keypress', function (event) { var keyCode = event.keyCode || event.charCode; - if (keyCode === 32) { $(event.target).closest('summary').trigger('click'); event.preventDefault(); diff --git a/core/themes/claro/js/media-library.ui.js b/core/themes/claro/js/media-library.ui.js index 2a8e8a08b9ebf472e1dfd178dd1e0b42c9286f6e..fa54a35d0d3c4475a57cf9d27f92e3e6c3898cd8 100644 --- a/core/themes/claro/js/media-library.ui.js +++ b/core/themes/claro/js/media-library.ui.js @@ -4,26 +4,21 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal, window) { Drupal.behaviors.MediaLibraryItemSelectionClaro = { attach: function attach() { if (!once('media-library-selection-info-claro-event', 'html').length) { return; } - $(window).on('dialog:aftercreate', function (event, dialog, $element, settings) { var moveCounter = function moveCounter($selectedCount, $buttonPane) { var $moveSelectedCount = $selectedCount.detach(); $buttonPane.prepend($moveSelectedCount); }; - var $buttonPane = $element.closest('.media-library-widget-modal').find('.ui-dialog-buttonpane'); - if (!$buttonPane.length) { return; } - var $selectedCount = $buttonPane.find('.js-media-library-selected-count'); if ($selectedCount.length) { @@ -31,7 +26,6 @@ } else { var selectedCountObserver = new MutationObserver(function () { var $selectedCountFind = $buttonPane.find('.js-media-library-selected-count'); - if ($selectedCountFind.length) { moveCounter($selectedCountFind, $buttonPane); selectedCountObserver.disconnect(); diff --git a/core/themes/claro/js/messages.js b/core/themes/claro/js/messages.js index 10eb94445d389c776848cd3badfadea997765031..23500b511848f5da4f3dc6ac63af2f27b8e3ae29 100644 --- a/core/themes/claro/js/messages.js +++ b/core/themes/claro/js/messages.js @@ -9,7 +9,7 @@ Drupal.theme.message = function (_ref, _ref2) { var text = _ref.text; var type = _ref2.type, - id = _ref2.id; + id = _ref2.id; var messagesTypes = Drupal.Message.getMessageTypeLabels(); var messageWrapper = document.createElement('div'); messageWrapper.setAttribute('class', "messages messages--".concat(type)); diff --git a/core/themes/claro/js/mobile.install.js b/core/themes/claro/js/mobile.install.js index 095fd11775483ca5353500f5aefa00289ef09a2c..3ab8e20655e027bd68d2471ae16ca6fb87ffeccb 100644 --- a/core/themes/claro/js/mobile.install.js +++ b/core/themes/claro/js/mobile.install.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function () { function findActiveStep(steps) { for (var i = 0; i < steps.length; i++) { @@ -12,17 +11,13 @@ return i + 1; } } - if (steps[steps.length - 1].className === 'done') { return steps.length; } - return 0; } - function installStepsSetup() { var steps = document.querySelectorAll('.task-list li'); - if (steps.length) { var header = document.querySelector('header[role="banner"]'); var stepIndicator = document.createElement('div'); @@ -31,7 +26,6 @@ header.appendChild(stepIndicator); } } - if (document.addEventListener) { document.addEventListener('DOMContentLoaded', installStepsSetup); } diff --git a/core/themes/claro/js/nav-tabs.js b/core/themes/claro/js/nav-tabs.js index 92e4655832686b8753fa47ec1354e9bfad241397..cd195a0e53c40fd236f79f2ec09e76ee83598814 100644 --- a/core/themes/claro/js/nav-tabs.js +++ b/core/themes/claro/js/nav-tabs.js @@ -4,17 +4,14 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { function init(tab) { var $tab = $(tab); var $target = $tab.find('[data-drupal-nav-tabs-target]'); var $active = $target.find('.js-active-tab'); - var openMenu = function openMenu() { $target.toggleClass('is-open'); }; - var toggleOrder = function toggleOrder(reset) { var current = $active.index(); var original = $active.data('original-order'); @@ -22,21 +19,18 @@ if (original === 0 || reset === (current === original)) { return; } - var siblings = { first: '[data-original-order="0"]', previous: "[data-original-order=\"".concat(original - 1, "\"]") }; var $first = $target.find(siblings.first); var $previous = $target.find(siblings.previous); - if (reset && current !== original) { $active.insertAfter($previous); } else if (!reset && current === original) { $active.insertBefore($first); } }; - var toggleCollapsed = function toggleCollapsed() { if (window.matchMedia('(min-width: 48em)').matches) { if ($tab.hasClass('is-horizontal') && !$tab.attr('data-width')) { @@ -54,16 +48,15 @@ toggleOrder(false); } }; - $tab.addClass('position-container is-horizontal-enabled'); $target.find('.js-tab').each(function (index, element) { var $item = $(element); $item.attr('data-original-order', $item.index()); }); $tab.on('click.tabs', '[data-drupal-nav-tabs-trigger]', openMenu); - $(window).on('resize.tabs', Drupal.debounce(toggleCollapsed, 150)).trigger('resize.tabs'); + $(window) + .on('resize.tabs', Drupal.debounce(toggleCollapsed, 150)).trigger('resize.tabs'); } - Drupal.behaviors.navTabs = { attach: function attach(context) { once('nav-tabs', '[data-drupal-nav-tabs].is-collapsible', context).forEach(init); diff --git a/core/themes/claro/js/responsive-details.js b/core/themes/claro/js/responsive-details.js index ec59b2afac219c6a9670a4908fac4fc0256a9074..ab84dfa0023ad43ecda53ae49798e6c3f31d1313 100644 --- a/core/themes/claro/js/responsive-details.js +++ b/core/themes/claro/js/responsive-details.js @@ -9,14 +9,11 @@ Drupal.behaviors.responsiveDetails = { attach: function attach(context) { var details = once('responsive-details', 'details', context); - if (!details.length) { return; } - var $details = $(details); var $summaries = $details.find('> summary'); - function detailsToggle(matches) { if (matches) { $details.attr('open', true); @@ -28,11 +25,9 @@ $summaries.off('.details-open'); } } - function handleDetailsMQ(event) { detailsToggle(event.matches); } - var mql = window.matchMedia('(min-width:48em)'); mql.addListener(handleDetailsMQ); detailsToggle(mql.matches); diff --git a/core/themes/claro/js/tabledrag.js b/core/themes/claro/js/tabledrag.js index 3beafe0c77900a7e38ff37a5e96f3ec36437327f..fc3bfce5c49f3659aed1f5f3f0dcd7882d96b8c2 100644 --- a/core/themes/claro/js/tabledrag.js +++ b/core/themes/claro/js/tabledrag.js @@ -12,6 +12,7 @@ var $row = $(row); var $firstCell = $row.find('td:first-of-type').eq(0).wrapInner(Drupal.theme('tableDragCellContentWrapper')).wrapInner($(Drupal.theme('tableDragCellItemsWrapper')).addClass('js-tabledrag-cell-content')); var $targetElem = $firstCell.find('.js-tabledrag-cell-content'); + $targetElem.eq(0).find('> .tabledrag-cell-content__item > .js-tabledrag-handle, > .tabledrag-cell-content__item > .js-indentation').prependTo($targetElem); }; @@ -24,7 +25,6 @@ markChanged: function markChanged() { var marker = $(Drupal.theme('tableDragChangedMarker')).addClass('js-tabledrag-changed-marker'); var cell = $(this.element).find('td:first-of-type'); - if (cell.find('.js-tabledrag-changed-marker').length === 0) { cell.find('.js-tabledrag-handle').after(marker); } @@ -53,7 +53,6 @@ toggleButtonContent: function toggleButtonContent(show) { var classes = ['action-link', 'action-link--extrasmall', 'tabledrag-toggle-weight']; var text = ''; - if (show) { classes.push('action-link--icon-hide'); text = Drupal.t('Hide row weights'); @@ -61,7 +60,6 @@ classes.push('action-link--icon-show'); text = Drupal.t('Show row weights'); } - return "<span class=\"".concat(classes.join(' '), "\">").concat(text, "</a>"); }, tableDragCellContentWrapper: function tableDragCellContentWrapper() { diff --git a/core/themes/olivero/js/message.theme.js b/core/themes/olivero/js/message.theme.js index 5696e5523ad2a51de1b215b6562e7f854622e326..8166cbcf8b474deb1acdb10a79a3cdf96abc0094 100644 --- a/core/themes/olivero/js/message.theme.js +++ b/core/themes/olivero/js/message.theme.js @@ -9,7 +9,7 @@ Drupal.theme.message = function (_ref, _ref2) { var text = _ref.text; var type = _ref2.type, - id = _ref2.id; + id = _ref2.id; var messagesTypes = Drupal.Message.getMessageTypeLabels(); var messageWrapper = document.createElement('div'); messageWrapper.setAttribute('class', "messages-list__item messages messages--".concat(type)); @@ -19,11 +19,9 @@ messageWrapper.setAttribute('data-drupal-message-id', id); messageWrapper.setAttribute('data-drupal-message-type', type); var svg = ''; - if (['error', 'warning', 'status', 'info'].indexOf(type) > -1) { svg = '<div class="messages__icon"><svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">'; } - if (type === 'error') { svg += '<path d="M0.117801 16.7381C0.202622 17.9153 0.292289 18.562 0.481317 19.3904C0.922384 21.3161 1.6785 23.0626 2.76178 24.6589C4.58178 27.3355 7.18213 29.3823 10.1993 30.5062C12.458 31.3467 14.942 31.6495 17.3461 31.3782C22.5831 30.7872 27.1246 27.6164 29.4875 22.9027C30.3769 21.132 30.8616 19.3929 31.0797 17.1983C31.1209 16.7768 31.1209 15.1733 31.0797 14.7518C30.8786 12.7195 30.4714 11.1693 29.7032 9.49549C28.3848 6.62269 26.1722 4.18589 23.4289 2.58235C19.4399 0.249712 14.5373 -0.171762 10.1993 1.44389C5.82985 3.07165 2.38372 6.62753 0.915114 11.0215C0.512822 12.223 0.289865 13.2863 0.161423 14.604C0.127495 14.9674 0.0959901 16.4425 0.117801 16.7381ZM4.02924 14.9577C4.2837 12.2108 5.46391 9.69412 7.40024 7.76115C9.15966 6.00743 11.3529 4.89319 13.8224 4.49352C14.4234 4.39905 14.8717 4.36514 15.6012 4.36271C16.6941 4.36271 17.4793 4.45718 18.5093 4.71636C19.2969 4.91257 20.0143 5.17902 20.7873 5.55931C21.2526 5.78943 21.9409 6.18183 21.9554 6.22786C21.9651 6.25692 5.90498 22.3093 5.86621 22.3093C5.82501 22.3093 5.46391 21.6916 5.21915 21.2071C4.51877 19.8071 4.10921 18.2956 4.005 16.7138C3.98077 16.336 3.99288 15.3453 4.02924 14.9577ZM25.3725 9.6384C25.4428 9.7038 25.816 10.3602 26.0341 10.8035C26.6618 12.0776 27.0301 13.359 27.1876 14.8366C27.2385 15.2968 27.2458 16.5225 27.2022 16.9561C27.0859 18.0776 26.8847 18.9786 26.526 19.9669C26.2377 20.7663 25.7748 21.6843 25.2998 22.394C23.8748 24.5232 21.7882 26.1364 19.3987 26.9576C18.1046 27.4009 16.985 27.585 15.5891 27.585C14.8232 27.585 14.4646 27.5607 13.786 27.4541C12.2568 27.2192 10.6574 26.6209 9.40685 25.8191L9.23237 25.7077L17.2879 17.6609C23.3562 11.598 25.3507 9.61903 25.3725 9.6384Z"/>'; } else if (type === 'warning') { @@ -33,11 +31,9 @@ } else if (type === 'info') { svg += '<path d="M32,16c0,8.8-7.2,16-16,16S0,24.8,0,16C0,7.2,7.2,0,16,0S32,7.2,32,16z M16.4,5.3c-3.5,0-5.8,1.5-7.5,4.1c-0.2,0.3-0.2,0.8,0.2,1l2.2,1.7c0.3,0.3,0.8,0.2,1.1-0.1c1.2-1.5,1.9-2.3,3.7-2.3c1.3,0,2.9,0.8,2.9,2.1c0,1-0.8,1.5-2.1,2.2c-1.5,0.9-3.5,1.9-3.5,4.6v0.3c0,0.4,0.3,0.8,0.8,0.8h3.6c0.4,0,0.8-0.3,0.8-0.8v-0.1c0-1.8,5.4-1.9,5.4-6.9C23.9,8.1,20.1,5.3,16.4,5.3z M16,21.3c-1.6,0-3,1.3-3,3c0,1.6,1.3,3,3,3s3-1.3,3-3C19,22.6,17.6,21.3,16,21.3z"/>'; } - if (['error', 'warning', 'status', 'info'].indexOf(type) > -1) { svg += '</svg></div>'; } - messageWrapper.innerHTML = "\n <div class=\"messages__container\" data-drupal-selector=\"messages-container\">\n <div class=\"messages__header".concat(!svg ? ' no-icon' : '', "\">\n <h2 class=\"visually-hidden\">").concat(messagesTypes[type], "</h2>\n ").concat(svg, "\n </div>\n <div class=\"messages__content\">\n ").concat(text, "\n </div>\n </div>\n "); Drupal.olivero.closeMessage(messageWrapper); return messageWrapper; diff --git a/core/themes/olivero/js/nav-resize.js b/core/themes/olivero/js/nav-resize.js index 83b2d0b01d7d7bc14dd9cdf733a6c4484df591b1..419e44644c2feb3cfb2d99c0707b2b392246f1dd 100644 --- a/core/themes/olivero/js/nav-resize.js +++ b/core/themes/olivero/js/nav-resize.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function (Drupal, once) { function transitionToDesktopNavigation(navWrapper, navItem) { document.body.classList.remove('is-always-mobile-nav'); @@ -16,10 +15,10 @@ function checkIfDesktopNavigationWraps(entries) { var navItem = document.querySelector('.primary-nav__menu-item'); - if (Drupal.olivero.isDesktopNav() && entries[0].contentRect.height > navItem.clientHeight) { var navMediaQuery = window.matchMedia("(max-width: ".concat(window.innerWidth + 5, "px)")); document.body.classList.add('is-always-mobile-nav'); + navMediaQuery.addEventListener('change', function () { transitionToDesktopNavigation(entries[0].target, navItem); }, { diff --git a/core/themes/olivero/js/navigation-utils.js b/core/themes/olivero/js/navigation-utils.js index abdc3c5c53b2ad90aac2a6a86024b661400fd161..93d75e0523052343f4739227702976ecb2caf5f3 100644 --- a/core/themes/olivero/js/navigation-utils.js +++ b/core/themes/olivero/js/navigation-utils.js @@ -12,7 +12,6 @@ var navButtons = document.querySelector('[data-drupal-selector="mobile-buttons"]'); return navButtons ? window.getComputedStyle(navButtons).getPropertyValue('display') === 'none' : false; } - Drupal.olivero.isDesktopNav = isDesktopNav; var stickyHeaderToggleButton = document.querySelector('[data-drupal-selector="sticky-header-toggle"]'); var siteHeaderFixable = document.querySelector('[data-drupal-selector="site-header-fixable"]'); @@ -27,6 +26,7 @@ value: expandedState, expiry: now.getTime() + 20160000 }; + localStorage.setItem('Drupal.olivero.stickyHeaderState', JSON.stringify(item)); } @@ -37,7 +37,6 @@ } else { siteHeaderFixable.classList.remove('is-expanded'); } - stickyHeaderToggleButton.setAttribute('aria-checked', pinnedState); setStickyHeaderStorage(pinnedState); } @@ -53,13 +52,11 @@ localStorage.removeItem('Drupal.olivero.stickyHeaderState'); return false; } - return item.value; } if ('IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) { var fixableElements = document.querySelectorAll('[data-drupal-selector="site-header-fixable"], [data-drupal-selector="social-bar-inner"]'); - function toggleDesktopNavVisibility(entries) { if (!isDesktopNav()) return; entries.forEach(function (entry) { @@ -78,16 +75,13 @@ function getRootMargin() { var rootMarginTop = 72; var _document = document, - body = _document.body; - + body = _document.body; if (body.classList.contains('toolbar-fixed')) { rootMarginTop -= 39; } - if (body.classList.contains('toolbar-horizontal') && body.classList.contains('toolbar-tray-open')) { rootMarginTop -= 40; } - return "".concat(rootMarginTop, "px 0px 0px 0px"); } @@ -98,12 +92,10 @@ threshold: [0.999, 1] }; var observer = new IntersectionObserver(toggleDesktopNavVisibility, options); - if (primaryNav) { observer.observe(primaryNav); } } - if (stickyHeaderToggleButton) { stickyHeaderToggleButton.addEventListener('click', function () { toggleStickyHeaderState(!stickyHeaderIsEnabled()); @@ -111,21 +103,18 @@ } var siteHeaderInner = document.querySelector('[data-drupal-selector="site-header-inner"]'); - if (siteHeaderInner) { siteHeaderInner.addEventListener('focusin', function () { if (isDesktopNav() && !stickyHeaderIsEnabled()) { var header = document.querySelector('[data-drupal-selector="site-header"]'); var headerNav = header.querySelector('[data-drupal-selector="header-nav"]'); var headerMargin = header.clientHeight - headerNav.clientHeight; - if (window.scrollY > headerMargin) { window.scrollTo(0, headerMargin); } } }); } - monitorNavPosition(); setStickyHeaderStorage(getStickyHeaderStorage()); toggleStickyHeaderState(getStickyHeaderStorage()); diff --git a/core/themes/olivero/js/navigation.js b/core/themes/olivero/js/navigation.js index e3817cd38de3b79c0735697b2a378c46c66031f9..96038be4e0e0cdd8f13412fef948ff9f76f8414e 100644 --- a/core/themes/olivero/js/navigation.js +++ b/core/themes/olivero/js/navigation.js @@ -13,7 +13,6 @@ function toggleNav(props, state) { var value = !!state; props.navButton.setAttribute('aria-expanded', value); - if (value) { props.body.classList.add('is-overlay-active'); props.body.classList.add('is-fixed'); @@ -31,6 +30,7 @@ props.navButton.addEventListener('click', function () { toggleNav(props, !isNavOpen(props.navWrapper)); }); + document.addEventListener('keyup', function (e) { if (e.key === 'Escape' || e.key === 'Esc') { if (props.olivero.areAnySubNavsOpen()) { @@ -46,13 +46,13 @@ props.overlay.addEventListener('touchstart', function () { toggleNav(props, false); }); + props.header.addEventListener('keydown', function (e) { if (e.key === 'Tab' && isNavOpen(props.navWrapper)) { var tabbableNavElements = tabbable.tabbable(props.navWrapper); tabbableNavElements.unshift(props.navButton); var firstTabbableEl = tabbableNavElements[0]; var lastTabbableEl = tabbableNavElements[tabbableNavElements.length - 1]; - if (e.shiftKey) { if (document.activeElement === firstTabbableEl && !props.olivero.isDesktopNav()) { lastTabbableEl.focus(); @@ -64,6 +64,7 @@ } } }); + window.addEventListener('resize', function () { if (props.olivero.isDesktopNav()) { toggleNav(props, false); @@ -73,6 +74,7 @@ Drupal.olivero.closeAllSubNav(); }); + props.navWrapper.addEventListener('click', function (e) { if (e.target.matches("[href*=\"".concat(window.location.pathname, "#\"], [href*=\"").concat(window.location.pathname, "#\"] *, [href^=\"#\"], [href^=\"#\"] *"))) { toggleNav(props, false); @@ -85,7 +87,6 @@ var headerId = 'header'; var header = once('navigation', "#".concat(headerId), context).shift(); var navWrapperId = 'header-nav'; - if (header) { var navWrapper = header.querySelector("#".concat(navWrapperId)); var olivero = Drupal.olivero; diff --git a/core/themes/olivero/js/search.js b/core/themes/olivero/js/search.js index 00ae2a5079f5e14896dab81f24fdd6876a35150b..709720ca040faad00672740d531f91a8f4f2fbf9 100644 --- a/core/themes/olivero/js/search.js +++ b/core/themes/olivero/js/search.js @@ -14,12 +14,10 @@ function searchIsVisible() { return searchWideWrapper.classList.contains('is-active'); } - Drupal.olivero.searchIsVisible = searchIsVisible; function watchForClickOut(e) { var clickInSearchArea = e.target.matches("\n ".concat(searchWideWrapperSelector, ",\n ").concat(searchWideWrapperSelector, " *,\n ").concat(searchWideButtonSelector, ",\n ").concat(searchWideButtonSelector, " *\n ")); - if (!clickInSearchArea && searchIsVisible()) { toggleSearchVisibility(false); } @@ -29,7 +27,6 @@ if (e.relatedTarget) { var inSearchBar = e.relatedTarget.matches("".concat(searchWideWrapperSelector, ", ").concat(searchWideWrapperSelector, " *")); var inSearchButton = e.relatedTarget.matches("".concat(searchWideButtonSelector, ", ").concat(searchWideButtonSelector, " *")); - if (!inSearchBar && !inSearchButton) { toggleSearchVisibility(false); } @@ -55,7 +52,6 @@ searchWideWrapper.addEventListener('transitionend', handleFocus, { once: true }); - if (visibility === true) { Drupal.olivero.closeAllSubNav(); searchWideWrapper.classList.add('is-active'); @@ -81,12 +77,11 @@ }); } } - Drupal.olivero.toggleSearchVisibility = toggleSearchVisibility; + Drupal.behaviors.searchWide = { attach: function attach(context) { var searchWideButtonEl = once('search-wide', searchWideButtonSelector, context).shift(); - if (searchWideButtonEl) { searchWideButtonEl.setAttribute('aria-expanded', searchIsVisible()); searchWideButtonEl.addEventListener('click', function () { diff --git a/core/themes/olivero/js/second-level-navigation.js b/core/themes/olivero/js/second-level-navigation.js index 8575af8ec5e3aa5ec2106dc2fe19fad09f1fadfe..25947d69a4eb9da666176d2c583d1c69ea3553c3 100644 --- a/core/themes/olivero/js/second-level-navigation.js +++ b/core/themes/olivero/js/second-level-navigation.js @@ -13,7 +13,6 @@ var buttonSelector = '[data-drupal-selector="primary-nav-submenu-toggle-button"]'; var button = topLevelMenuItem.querySelector(buttonSelector); var state = toState !== undefined ? toState : button.getAttribute('aria-expanded') !== 'true'; - if (state) { if (isDesktopNav()) { secondLevelNavMenus.forEach(function (el) { @@ -22,7 +21,6 @@ el.querySelector('[data-drupal-selector="primary-nav-menu-🥕"]').classList.remove('is-active-menu-parent'); }); } - button.setAttribute('aria-expanded', 'true'); topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu--level-2"]').classList.add('is-active-menu-parent'); topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu-🥕"]').classList.add('is-active-menu-parent'); @@ -33,14 +31,12 @@ topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu-🥕"]').classList.remove('is-active-menu-parent'); } } - Drupal.olivero.toggleSubNav = toggleSubNav; function handleBlur(e) { if (!Drupal.olivero.isDesktopNav()) return; setTimeout(function () { var menuParentItem = e.target.closest('[data-drupal-selector="primary-nav-menu-item-has-children"]'); - if (!menuParentItem.contains(document.activeElement)) { toggleSubNav(menuParentItem, false); } @@ -51,6 +47,7 @@ var button = el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]'); button.removeAttribute('aria-hidden'); button.removeAttribute('tabindex'); + el.addEventListener('touchstart', function () { el.classList.add('is-touch-event'); }, { @@ -60,6 +57,7 @@ if (isDesktopNav() && !el.classList.contains('is-touch-event')) { el.classList.add('is-active-mouseover-event'); toggleSubNav(el, true); + setTimeout(function () { el.classList.remove('is-active-mouseover-event'); }, 500); @@ -83,11 +81,9 @@ if (el.contains(document.activeElement)) { el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]').focus(); } - toggleSubNav(el, false); }); } - Drupal.olivero.closeAllSubNav = closeAllSubNav; function areAnySubNavsOpen() { @@ -95,20 +91,20 @@ secondLevelNavMenus.forEach(function (el) { var button = el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]'); var state = button.getAttribute('aria-expanded') === 'true'; - if (state) { subNavsAreOpen = true; } }); return subNavsAreOpen; } - Drupal.olivero.areAnySubNavsOpen = areAnySubNavsOpen; + document.addEventListener('keyup', function (e) { if (e.key === 'Escape' || e.key === 'Esc') { if (isDesktopNav()) closeAllSubNav(); } }); + document.addEventListener('touchstart', function (e) { if (areAnySubNavsOpen() && !e.target.matches('[data-drupal-selector="header-nav"], [data-drupal-selector="header-nav"] *')) { closeAllSubNav(); diff --git a/core/themes/olivero/js/tabs.js b/core/themes/olivero/js/tabs.js index 81d7475d1af38b086b2d30ea996ba5f20dcb5a49..1c3594f9f2f14f10d22ca6375b45bf026946a2c8 100644 --- a/core/themes/olivero/js/tabs.js +++ b/core/themes/olivero/js/tabs.js @@ -24,14 +24,12 @@ tabs.classList.remove(expandedClass); } } - if (isTabsMobileLayout() && !activeTab.matches('.tabs__tab:first-child')) { var newActiveTab = activeTab.cloneNode(true); var firstTab = tabs.querySelector('.tabs__tab:first-child'); tabs.insertBefore(newActiveTab, firstTab); tabs.removeChild(activeTab); } - tabs.querySelector('.tabs__trigger').addEventListener('click', handleTriggerClick); } diff --git a/core/themes/seven/js/mobile.install.js b/core/themes/seven/js/mobile.install.js index 095fd11775483ca5353500f5aefa00289ef09a2c..3ab8e20655e027bd68d2471ae16ca6fb87ffeccb 100644 --- a/core/themes/seven/js/mobile.install.js +++ b/core/themes/seven/js/mobile.install.js @@ -4,7 +4,6 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function () { function findActiveStep(steps) { for (var i = 0; i < steps.length; i++) { @@ -12,17 +11,13 @@ return i + 1; } } - if (steps[steps.length - 1].className === 'done') { return steps.length; } - return 0; } - function installStepsSetup() { var steps = document.querySelectorAll('.task-list li'); - if (steps.length) { var header = document.querySelector('header[role="banner"]'); var stepIndicator = document.createElement('div'); @@ -31,7 +26,6 @@ header.appendChild(stepIndicator); } } - if (document.addEventListener) { document.addEventListener('DOMContentLoaded', installStepsSetup); } diff --git a/core/themes/seven/js/nav-tabs.js b/core/themes/seven/js/nav-tabs.js index 029a4be8198e1557d87607bb503508b68179f920..d4dec687665c2f25a2e37ee3515b7612d5013e36 100644 --- a/core/themes/seven/js/nav-tabs.js +++ b/core/themes/seven/js/nav-tabs.js @@ -4,32 +4,26 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - (function ($, Drupal) { function init(tab) { var $tab = $(tab); var $target = $tab.find('[data-drupal-nav-tabs-target]'); var isCollapsible = $tab.hasClass('is-collapsible'); - function openMenu(e) { $target.toggleClass('is-open'); } - function handleResize(e) { $tab.addClass('is-horizontal'); var $tabs = $tab.find('.tabs'); var isHorizontal = $tabs.outerHeight() <= $tabs.find('.tabs__tab').outerHeight(); $tab.toggleClass('is-horizontal', isHorizontal); - if (isCollapsible) { $tab.toggleClass('is-collapse-enabled', !isHorizontal); } - if (isHorizontal) { $target.removeClass('is-open'); } } - $tab.addClass('position-container is-horizontal-enabled'); $tab.on('click.tabs', '[data-drupal-nav-tabs-trigger]', openMenu); $(window).on('resize.tabs', Drupal.debounce(handleResize, 150)).trigger('resize.tabs'); @@ -38,7 +32,6 @@ Drupal.behaviors.navTabs = { attach: function attach(context, settings) { var notSmartPhone = window.matchMedia('(min-width: 300px)'); - if (notSmartPhone.matches) { once('nav-tabs', '[data-drupal-nav-tabs]', context).forEach(init); } diff --git a/core/themes/seven/js/responsive-details.js b/core/themes/seven/js/responsive-details.js index ec59b2afac219c6a9670a4908fac4fc0256a9074..ab84dfa0023ad43ecda53ae49798e6c3f31d1313 100644 --- a/core/themes/seven/js/responsive-details.js +++ b/core/themes/seven/js/responsive-details.js @@ -9,14 +9,11 @@ Drupal.behaviors.responsiveDetails = { attach: function attach(context) { var details = once('responsive-details', 'details', context); - if (!details.length) { return; } - var $details = $(details); var $summaries = $details.find('> summary'); - function detailsToggle(matches) { if (matches) { $details.attr('open', true); @@ -28,11 +25,9 @@ $summaries.off('.details-open'); } } - function handleDetailsMQ(event) { detailsToggle(event.matches); } - var mql = window.matchMedia('(min-width:48em)'); mql.addListener(handleDetailsMQ); detailsToggle(mql.matches); diff --git a/core/themes/stable/js/tour.js b/core/themes/stable/js/tour.js index 20eda20a167f5c3928b2e88b2b945d47ee4e1e25..1ea80c3bd40a75f333aadb202913ff40a978ede4 100644 --- a/core/themes/stable/js/tour.js +++ b/core/themes/stable/js/tour.js @@ -4,17 +4,11 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function (Drupal) { @@ -22,11 +16,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var changeTag = function changeTag(element, tag) { if (element) { var newTagElement = document.createElement(tag); - _toConsumableArray(element.attributes).forEach(function (attr) { newTagElement.setAttribute(attr.name, attr.value); }); - newTagElement.innerHTML = element.innerHTML; element.parentNode.replaceChild(newTagElement, element); } @@ -39,6 +31,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var shepherdText = shepherdElement.querySelector('.shepherd-text'); var shepherdNext = shepherdElement.querySelector('footer .button'); var tourProgress = shepherdElement.querySelector('.tour-progress'); + shepherdElement.classList.add('joyride-tip-guide'); shepherdContent.classList.add('joyride-content-wrapper'); shepherdNext.classList.add('joyride-next-tip'); @@ -54,13 +47,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (shepherdElement.classList.contains('tip-uses-get-output')) { shepherdText.appendChild(shepherdNext); + shepherdText.appendChild(shepherdCancel); shepherdContent.querySelector('.shepherd-header').remove(); + Array.from(shepherdText.children).forEach(function (node) { if (node.tagName === 'P' && node.textContent === '' && node.classList.length === 0) { node.remove(); } }); + shepherdContent.innerHTML = shepherdText.innerHTML; } else { shepherdContent.insertBefore(shepherdTitle, shepherdContent.firstChild); @@ -70,17 +66,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len shepherdContent.insertBefore(shepherdNext, tourProgress.nextSibling); shepherdCancel.innerHTML = '<span aria-hidden="true">×</span>'; shepherdTitle.classList.add('tour-tip-label'); + changeTag(shepherdTitle, 'h2'); + shepherdText.outerHTML = shepherdText.innerHTML; } changeTag(shepherdElement.querySelector('.joyride-close-tip'), 'a'); changeTag(shepherdElement.querySelector('.joyride-next-tip'), 'a'); - var shepherdArrow = shepherdElement.querySelector('.shepherd-arrow'); + var shepherdArrow = shepherdElement.querySelector('.shepherd-arrow'); if (shepherdArrow) { shepherdArrow.classList.add('joyride-nub'); - if (shepherdTour.currentStep.options.attachTo.on) { var stepToTipPosition = { bottom: 'top', @@ -88,9 +85,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len left: 'right', right: 'left' }; - shepherdArrow.classList.add(stepToTipPosition[shepherdTour.currentStep.options.attachTo.on.split('-')[0]]); + shepherdArrow.classList.add( + stepToTipPosition[ + shepherdTour.currentStep.options.attachTo.on.split('-')[0]]); } - changeTag(shepherdArrow, 'span'); } else { var nub = document.createElement('span'); diff --git a/core/themes/stable9/js/tour.js b/core/themes/stable9/js/tour.js index 20eda20a167f5c3928b2e88b2b945d47ee4e1e25..1ea80c3bd40a75f333aadb202913ff40a978ede4 100644 --- a/core/themes/stable9/js/tour.js +++ b/core/themes/stable9/js/tour.js @@ -4,17 +4,11 @@ * https://www.drupal.org/node/2815083 * @preserve **/ - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } (function (Drupal) { @@ -22,11 +16,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var changeTag = function changeTag(element, tag) { if (element) { var newTagElement = document.createElement(tag); - _toConsumableArray(element.attributes).forEach(function (attr) { newTagElement.setAttribute(attr.name, attr.value); }); - newTagElement.innerHTML = element.innerHTML; element.parentNode.replaceChild(newTagElement, element); } @@ -39,6 +31,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len var shepherdText = shepherdElement.querySelector('.shepherd-text'); var shepherdNext = shepherdElement.querySelector('footer .button'); var tourProgress = shepherdElement.querySelector('.tour-progress'); + shepherdElement.classList.add('joyride-tip-guide'); shepherdContent.classList.add('joyride-content-wrapper'); shepherdNext.classList.add('joyride-next-tip'); @@ -54,13 +47,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (shepherdElement.classList.contains('tip-uses-get-output')) { shepherdText.appendChild(shepherdNext); + shepherdText.appendChild(shepherdCancel); shepherdContent.querySelector('.shepherd-header').remove(); + Array.from(shepherdText.children).forEach(function (node) { if (node.tagName === 'P' && node.textContent === '' && node.classList.length === 0) { node.remove(); } }); + shepherdContent.innerHTML = shepherdText.innerHTML; } else { shepherdContent.insertBefore(shepherdTitle, shepherdContent.firstChild); @@ -70,17 +66,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len shepherdContent.insertBefore(shepherdNext, tourProgress.nextSibling); shepherdCancel.innerHTML = '<span aria-hidden="true">×</span>'; shepherdTitle.classList.add('tour-tip-label'); + changeTag(shepherdTitle, 'h2'); + shepherdText.outerHTML = shepherdText.innerHTML; } changeTag(shepherdElement.querySelector('.joyride-close-tip'), 'a'); changeTag(shepherdElement.querySelector('.joyride-next-tip'), 'a'); - var shepherdArrow = shepherdElement.querySelector('.shepherd-arrow'); + var shepherdArrow = shepherdElement.querySelector('.shepherd-arrow'); if (shepherdArrow) { shepherdArrow.classList.add('joyride-nub'); - if (shepherdTour.currentStep.options.attachTo.on) { var stepToTipPosition = { bottom: 'top', @@ -88,9 +85,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len left: 'right', right: 'left' }; - shepherdArrow.classList.add(stepToTipPosition[shepherdTour.currentStep.options.attachTo.on.split('-')[0]]); + shepherdArrow.classList.add( + stepToTipPosition[ + shepherdTour.currentStep.options.attachTo.on.split('-')[0]]); } - changeTag(shepherdArrow, 'span'); } else { var nub = document.createElement('span'); diff --git a/core/yarn.lock b/core/yarn.lock index ce65fab02c0c7f5d77aa5171f10bd629750ceb43..5e4cef3adccd43264f5eb408b824554953b65b82 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -17,47 +17,38 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.18.8", "@babel/compat-data@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.0.tgz#2a592fd89bacb1fcde68de31bee4f2f2dacb0e86" - integrity sha512-y5rqgTTPTmaF5e2nVhOxw+Ur9HDJLsWb6U/KpgUzRZEdPfE6VOubXBKLdbcUTijzRptednSBDQbYZBOSqJxpJw== +"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.20.0", "@babel/compat-data@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.1.tgz#f2e6ef7790d8c8dbf03d379502dcc246dcce0b30" + integrity sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ== "@babel/core@^7.0.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.0.tgz#d2f5f4f2033c00de8096be3c9f45772563e150c3" - integrity sha512-reM4+U7B9ss148rh2n1Qs9ASS+w94irYXga7c2jaQv9RVzpS7Mv1a9rnYYwuDa45G+DkORt9g6An2k/V4d9LbQ== + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.2.tgz#8dc9b1620a673f92d3624bd926dc49a52cf25b92" + integrity sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.0" - "@babel/helper-compilation-targets" "^7.19.0" - "@babel/helper-module-transforms" "^7.19.0" - "@babel/helpers" "^7.19.0" - "@babel/parser" "^7.19.0" + "@babel/generator" "^7.20.2" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-module-transforms" "^7.20.2" + "@babel/helpers" "^7.20.1" + "@babel/parser" "^7.20.2" "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.0" - "@babel/types" "^7.19.0" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.1" semver "^6.3.0" -"@babel/generator@^7.18.13": - version "7.18.13" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.13.tgz#59550cbb9ae79b8def15587bdfbaa388c4abf212" - integrity sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ== +"@babel/generator@^7.20.1", "@babel/generator@^7.20.2": + version "7.20.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.4.tgz#4d9f8f0c30be75fd90a0562099a26e5839602ab8" + integrity sha512-luCf7yk/cm7yab6CAW1aiFnmEfBJplb/JojV56MYEK7ziWfGmFlTfmL9Ehwfy4gFhbjBfWO1wj7/TuSbVNEEtA== dependencies: - "@babel/types" "^7.18.13" - "@jridgewell/gen-mapping" "^0.3.2" - jsesc "^2.5.1" - -"@babel/generator@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.19.0.tgz#785596c06425e59334df2ccee63ab166b738419a" - integrity sha512-S1ahxf1gZ2dpoiFgA+ohK9DIpz50bJ0CWs7Zlzb54Z4sG8qmdIrGrVqmy1sAtTVRb+9CU6U8VqT9L0Zj7hxHVg== - dependencies: - "@babel/types" "^7.19.0" + "@babel/types" "^7.20.2" "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" @@ -76,27 +67,27 @@ "@babel/helper-explode-assignable-expression" "^7.18.6" "@babel/types" "^7.18.9" -"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.0.tgz#537ec8339d53e806ed422f1e06c8f17d55b96bb0" - integrity sha512-Ai5bNWXIvwDvWM7njqsG3feMlL9hCVQsPYXodsZyLwshYkZVJt59Gftau4VrE8S9IT9asd2uSP1hG6wCNw+sXA== +"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" + integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== dependencies: - "@babel/compat-data" "^7.19.0" + "@babel/compat-data" "^7.20.0" "@babel/helper-validator-option" "^7.18.6" - browserslist "^4.20.2" + browserslist "^4.21.3" semver "^6.3.0" "@babel/helper-create-class-features-plugin@^7.18.6": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.19.0.tgz#bfd6904620df4e46470bae4850d66be1054c404b" - integrity sha512-NRz8DwF4jT3UfrmUoZjd0Uph9HQnP30t7Ash+weACcyNkiYTywpIjDBgReJMKgr+n86sn2nPVVmJ28Dm053Kqw== + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.20.2.tgz#3c08a5b5417c7f07b5cf3dfb6dc79cbec682e8c2" + integrity sha512-k22GoYRAHPYr9I+Gvy2ZQlAe5mGy8BqWst2wRt8cwIufWTxrsVshhIBvYNqC80N0GSFWTsqRVexOtfzlgOEDvA== dependencies: "@babel/helper-annotate-as-pure" "^7.18.6" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-member-expression-to-functions" "^7.18.9" "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/helper-replace-supers" "^7.18.9" + "@babel/helper-replace-supers" "^7.19.1" "@babel/helper-split-export-declaration" "^7.18.6" "@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.19.0": @@ -107,10 +98,10 @@ "@babel/helper-annotate-as-pure" "^7.18.6" regexpu-core "^5.1.0" -"@babel/helper-define-polyfill-provider@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.2.tgz#bd10d0aca18e8ce012755395b05a79f45eca5073" - integrity sha512-r9QJJ+uDWrd+94BSPcP6/de67ygLtvVy6cK4luE6MOuDsZIdoaPBnfSpbO/+LTifjPckbKXRuI9BB/Z2/y3iTg== +"@babel/helper-define-polyfill-provider@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz#8612e55be5d51f0cd1f36b4a5a83924e89884b7a" + integrity sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww== dependencies: "@babel/helper-compilation-targets" "^7.17.7" "@babel/helper-plugin-utils" "^7.16.7" @@ -160,19 +151,19 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.19.0.tgz#309b230f04e22c58c6a2c0c0c7e50b216d350c30" - integrity sha512-3HBZ377Fe14RbLIA+ac3sY4PTgpxHVkFrESaWhoI5PuyXPBBX8+C34qblV9G89ZtycGJCmCI/Ut+VUDK4bltNQ== +"@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.19.6", "@babel/helper-module-transforms@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" + integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-simple-access" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/helper-validator-identifier" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.0" - "@babel/types" "^7.19.0" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" "@babel/helper-optimise-call-expression@^7.18.6": version "7.18.6" @@ -181,10 +172,10 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz#4796bb14961521f0f8715990bee2fb6e51ce21bf" - integrity sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw== +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629" + integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ== "@babel/helper-remap-async-to-generator@^7.18.6", "@babel/helper-remap-async-to-generator@^7.18.9": version "7.18.9" @@ -196,30 +187,30 @@ "@babel/helper-wrap-function" "^7.18.9" "@babel/types" "^7.18.9" -"@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.18.9.tgz#1092e002feca980fbbb0bd4d51b74a65c6a500e6" - integrity sha512-dNsWibVI4lNT6HiuOIBr1oyxo40HvIVmbwPUm3XZ7wMh4k2WxrxTqZwSqw/eEmXDS9np0ey5M2bz9tBmO9c+YQ== +"@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.19.1.tgz#e1592a9b4b368aa6bdb8784a711e0bcbf0612b78" + integrity sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-member-expression-to-functions" "^7.18.9" "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/traverse" "^7.18.9" - "@babel/types" "^7.18.9" + "@babel/traverse" "^7.19.1" + "@babel/types" "^7.19.0" -"@babel/helper-simple-access@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz#d6d8f51f4ac2978068df934b569f08f29788c7ea" - integrity sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g== +"@babel/helper-simple-access@^7.19.4", "@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== dependencies: - "@babel/types" "^7.18.6" + "@babel/types" "^7.20.2" "@babel/helper-skip-transparent-expression-wrappers@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.18.9.tgz#778d87b3a758d90b471e7b9918f34a9a02eb5818" - integrity sha512-imytd2gHi3cJPsybLRbmFrF7u5BIEuI2cNheyKi3/iOBC63kNn3q8Crn2xVuESli0aM4KYsyEqKyS7lFL8YVtw== + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz#fbe4c52f60518cab8140d77101f0e63a8a230684" + integrity sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg== dependencies: - "@babel/types" "^7.18.9" + "@babel/types" "^7.20.0" "@babel/helper-split-export-declaration@^7.18.6": version "7.18.6" @@ -228,17 +219,12 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-string-parser@^7.18.10": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" - integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== - -"@babel/helper-validator-identifier@^7.16.7": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076" - integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g== +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== -"@babel/helper-validator-identifier@^7.18.6": +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== @@ -258,14 +244,14 @@ "@babel/traverse" "^7.19.0" "@babel/types" "^7.19.0" -"@babel/helpers@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.19.0.tgz#f30534657faf246ae96551d88dd31e9d1fa1fc18" - integrity sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg== +"@babel/helpers@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.1.tgz#2ab7a0fcb0a03b5bf76629196ed63c2d7311f4c9" + integrity sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg== dependencies: "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.0" - "@babel/types" "^7.19.0" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.0" "@babel/highlight@^7.18.6": version "7.18.6" @@ -276,15 +262,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.18.10", "@babel/parser@^7.18.13": - version "7.18.13" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.13.tgz#5b2dd21cae4a2c5145f1fbd8ca103f9313d3b7e4" - integrity sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg== - -"@babel/parser@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.0.tgz#497fcafb1d5b61376959c1c338745ef0577aa02c" - integrity sha512-74bEXKX2h+8rrfQUfsBfuZZHzsEs6Eql4pqy/T4Nn6Y9wNPggQOqD6z6pn5Bl8ZfysKouFZT/UXEH94ummEeQw== +"@babel/parser@^7.18.10", "@babel/parser@^7.20.1", "@babel/parser@^7.20.2": + version "7.20.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2" + integrity sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg== "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.18.6": version "7.18.6" @@ -302,10 +283,10 @@ "@babel/helper-skip-transparent-expression-wrappers" "^7.18.9" "@babel/plugin-proposal-optional-chaining" "^7.18.9" -"@babel/plugin-proposal-async-generator-functions@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.19.0.tgz#cf5740194f170467df20581712400487efc79ff1" - integrity sha512-nhEByMUTx3uZueJ/QkJuSlCfN4FGg+xy+vRsfGQGzSauq5ks2Deid2+05Q3KhfaUjvec1IGhw/Zm3cFm8JigTQ== +"@babel/plugin-proposal-async-generator-functions@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.1.tgz#352f02baa5d69f4e7529bdac39aaa02d41146af9" + integrity sha512-Gh5rchzSwE4kC+o/6T8waD0WHEQIsDmjltY8WnWRXHUdH8axZhuH86Ov9M72YhJfDrZseQwuuWaaIT/TmePp3g== dependencies: "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-plugin-utils" "^7.19.0" @@ -377,16 +358,16 @@ "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-syntax-numeric-separator" "^7.10.4" -"@babel/plugin-proposal-object-rest-spread@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.18.9.tgz#f9434f6beb2c8cae9dfcf97d2a5941bbbf9ad4e7" - integrity sha512-kDDHQ5rflIeY5xl69CEqGEZ0KY369ehsCIEbTGb4siHG5BE9sga/T0r0OUwyZNLMmZE79E1kbsqAjwFCW4ds6Q== +"@babel/plugin-proposal-object-rest-spread@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.2.tgz#a556f59d555f06961df1e572bb5eca864c84022d" + integrity sha512-Ks6uej9WFK+fvIMesSqbAto5dD8Dz4VuuFvGJFKgIGSkJuRGcrwGECPA1fDgQK3/DbExBJpEkTeYeB8geIFCSQ== dependencies: - "@babel/compat-data" "^7.18.8" - "@babel/helper-compilation-targets" "^7.18.9" - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/compat-data" "^7.20.1" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-plugin-utils" "^7.20.2" "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.18.8" + "@babel/plugin-transform-parameters" "^7.20.1" "@babel/plugin-proposal-optional-catch-binding@^7.18.6": version "7.18.6" @@ -466,12 +447,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" -"@babel/plugin-syntax-import-assertions@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.18.6.tgz#cd6190500a4fa2fe31990a963ffab4b63e4505e4" - integrity sha512-/DU3RXad9+bZwrgWJQKbr39gYbJpLJHezqEzRzi/BHRlJ9zsQb4CK2CA/5apllXNomwA1qHwzvHl+AdEmC5krQ== +"@babel/plugin-syntax-import-assertions@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz#bb50e0d4bea0957235390641209394e87bdb9cc4" + integrity sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.19.0" "@babel/plugin-syntax-json-strings@^7.8.3": version "7.8.3" @@ -559,25 +540,25 @@ dependencies: "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-block-scoping@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.18.9.tgz#f9b7e018ac3f373c81452d6ada8bd5a18928926d" - integrity sha512-5sDIJRV1KtQVEbt/EIBwGy4T01uYIo4KRB3VUqzkhrAIOGx7AoctL9+Ux88btY0zXdDyPJ9mW+bg+v+XEkGmtw== +"@babel/plugin-transform-block-scoping@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.20.2.tgz#f59b1767e6385c663fd0bce655db6ca9c8b236ed" + integrity sha512-y5V15+04ry69OV2wULmwhEA6jwSWXO1TwAtIwiPXcvHcoOQUqpyMVd2bDsQJMW8AurjulIyUV8kDqtjSwHy1uQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-classes@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.19.0.tgz#0e61ec257fba409c41372175e7c1e606dc79bb20" - integrity sha512-YfeEE9kCjqTS9IitkgfJuxjcEtLUHMqa8yUJ6zdz8vR7hKuo6mOy2C05P0F1tdMmDCeuyidKnlrw/iTppHcr2A== +"@babel/plugin-transform-classes@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.20.2.tgz#c0033cf1916ccf78202d04be4281d161f6709bb2" + integrity sha512-9rbPp0lCVVoagvtEyQKSo5L8oo0nQS/iif+lwlAz29MccX2642vWDlSZK+2T2buxbopotId2ld7zZAzRfz9j1g== dependencies: "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-compilation-targets" "^7.19.0" + "@babel/helper-compilation-targets" "^7.20.0" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/helper-plugin-utils" "^7.19.0" - "@babel/helper-replace-supers" "^7.18.9" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-replace-supers" "^7.19.1" "@babel/helper-split-export-declaration" "^7.18.6" globals "^11.1.0" @@ -588,12 +569,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-destructuring@^7.18.13": - version "7.18.13" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.18.13.tgz#9e03bc4a94475d62b7f4114938e6c5c33372cbf5" - integrity sha512-TodpQ29XekIsex2A+YJPj5ax2plkGa8YYY6mFjCohk/IG9IY42Rtuj1FuDeemfg2ipxIFLzPeA83SIBnlhSIow== +"@babel/plugin-transform-destructuring@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.20.2.tgz#c23741cfa44ddd35f5e53896e88c75331b8b2792" + integrity sha512-mENM+ZHrvEgxLTBXUiQ621rRXZes3KWUv6NdQlrnr1TkWVw+hUjQBZuP2X32qKlrlG2BzgR95gkuCRSkJl8vIw== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.20.2" "@babel/plugin-transform-dotall-regex@^7.18.6", "@babel/plugin-transform-dotall-regex@^7.4.4": version "7.18.6" @@ -648,35 +629,32 @@ dependencies: "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-modules-amd@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.18.6.tgz#8c91f8c5115d2202f277549848874027d7172d21" - integrity sha512-Pra5aXsmTsOnjM3IajS8rTaLCy++nGM4v3YR4esk5PCsyg9z8NA5oQLwxzMUtDBd8F+UmVza3VxoAaWCbzH1rg== +"@babel/plugin-transform-modules-amd@^7.19.6": + version "7.19.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.19.6.tgz#aca391801ae55d19c4d8d2ebfeaa33df5f2a2cbd" + integrity sha512-uG3od2mXvAtIFQIh0xrpLH6r5fpSQN04gIVovl+ODLdUMANokxQLZnPBHcjmv3GxRjnqwLuHvppjjcelqUFZvg== dependencies: - "@babel/helper-module-transforms" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" - babel-plugin-dynamic-import-node "^2.3.3" + "@babel/helper-module-transforms" "^7.19.6" + "@babel/helper-plugin-utils" "^7.19.0" -"@babel/plugin-transform-modules-commonjs@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.18.6.tgz#afd243afba166cca69892e24a8fd8c9f2ca87883" - integrity sha512-Qfv2ZOWikpvmedXQJDSbxNqy7Xr/j2Y8/KfijM0iJyKkBTmWuvCA1yeH1yDM7NJhBW/2aXxeucLj6i80/LAJ/Q== +"@babel/plugin-transform-modules-commonjs@^7.19.6": + version "7.19.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.19.6.tgz#25b32feef24df8038fc1ec56038917eacb0b730c" + integrity sha512-8PIa1ym4XRTKuSsOUXqDG0YaOlEuTVvHMe5JCfgBMOtHvJKw/4NGovEGN33viISshG/rZNVrACiBmPQLvWN8xQ== dependencies: - "@babel/helper-module-transforms" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/helper-simple-access" "^7.18.6" - babel-plugin-dynamic-import-node "^2.3.3" + "@babel/helper-module-transforms" "^7.19.6" + "@babel/helper-plugin-utils" "^7.19.0" + "@babel/helper-simple-access" "^7.19.4" -"@babel/plugin-transform-modules-systemjs@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.19.0.tgz#5f20b471284430f02d9c5059d9b9a16d4b085a1f" - integrity sha512-x9aiR0WXAWmOWsqcsnrzGR+ieaTMVyGyffPVA7F8cXAGt/UxefYv6uSHZLkAFChN5M5Iy1+wjE+xJuPt22H39A== +"@babel/plugin-transform-modules-systemjs@^7.19.6": + version "7.19.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.19.6.tgz#59e2a84064b5736a4471b1aa7b13d4431d327e0d" + integrity sha512-fqGLBepcc3kErfR9R3DnVpURmckXP7gj7bAlrTQyBxrigFqszZCkFkcoxzCp2v32XmwXLvbw+8Yq9/b+QqksjQ== dependencies: "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-module-transforms" "^7.19.0" + "@babel/helper-module-transforms" "^7.19.6" "@babel/helper-plugin-utils" "^7.19.0" - "@babel/helper-validator-identifier" "^7.18.6" - babel-plugin-dynamic-import-node "^2.3.3" + "@babel/helper-validator-identifier" "^7.19.1" "@babel/plugin-transform-modules-umd@^7.18.6": version "7.18.6" @@ -686,10 +664,10 @@ "@babel/helper-module-transforms" "^7.18.6" "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-named-capturing-groups-regex@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.19.0.tgz#58c52422e4f91a381727faed7d513c89d7f41ada" - integrity sha512-HDSuqOQzkU//kfGdiHBt71/hkDTApw4U/cMVgKgX7PqfB3LOaK+2GtCEsBu1dL9CkswDm0Gwehht1dCr421ULQ== +"@babel/plugin-transform-named-capturing-groups-regex@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.19.1.tgz#ec7455bab6cd8fb05c525a94876f435a48128888" + integrity sha512-oWk9l9WItWBQYS4FgXD4Uyy5kq898lvkXpXQxoJEY1RnvPk4R/Dvu2ebXU9q8lP+rlMwUQTFf2Ok6d78ODa0kw== dependencies: "@babel/helper-create-regexp-features-plugin" "^7.19.0" "@babel/helper-plugin-utils" "^7.19.0" @@ -709,12 +687,12 @@ "@babel/helper-plugin-utils" "^7.18.6" "@babel/helper-replace-supers" "^7.18.6" -"@babel/plugin-transform-parameters@^7.18.8": - version "7.18.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.18.8.tgz#ee9f1a0ce6d78af58d0956a9378ea3427cccb48a" - integrity sha512-ivfbE3X2Ss+Fj8nnXvKJS6sjRG4gzwPMsP+taZC+ZzEGjAYlvENixmt1sZ5Ca6tWls+BlKSGKPJ6OOXvXCbkFg== +"@babel/plugin-transform-parameters@^7.20.1": + version "7.20.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.20.3.tgz#7b3468d70c3c5b62e46be0a47b6045d8590fb748" + integrity sha512-oZg/Fpx0YDrj13KsLyO8I/CX3Zdw7z0O9qOd95SqcoIzuqy/WTGWvePeHAnZCN54SfdyjHcb1S30gc8zlzlHcA== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.20.2" "@babel/plugin-transform-property-literals@^7.18.6": version "7.18.6" @@ -790,17 +768,17 @@ "@babel/helper-plugin-utils" "^7.18.6" "@babel/preset-env@^7.0.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.19.0.tgz#fd18caf499a67d6411b9ded68dc70d01ed1e5da7" - integrity sha512-1YUju1TAFuzjIQqNM9WsF4U6VbD/8t3wEAlw3LFYuuEr+ywqLRcSXxFKz4DCEj+sN94l/XTDiUXYRrsvMpz9WQ== + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.20.2.tgz#9b1642aa47bb9f43a86f9630011780dab7f86506" + integrity sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg== dependencies: - "@babel/compat-data" "^7.19.0" - "@babel/helper-compilation-targets" "^7.19.0" - "@babel/helper-plugin-utils" "^7.19.0" + "@babel/compat-data" "^7.20.1" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-plugin-utils" "^7.20.2" "@babel/helper-validator-option" "^7.18.6" "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.18.6" "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.18.9" - "@babel/plugin-proposal-async-generator-functions" "^7.19.0" + "@babel/plugin-proposal-async-generator-functions" "^7.20.1" "@babel/plugin-proposal-class-properties" "^7.18.6" "@babel/plugin-proposal-class-static-block" "^7.18.6" "@babel/plugin-proposal-dynamic-import" "^7.18.6" @@ -809,7 +787,7 @@ "@babel/plugin-proposal-logical-assignment-operators" "^7.18.9" "@babel/plugin-proposal-nullish-coalescing-operator" "^7.18.6" "@babel/plugin-proposal-numeric-separator" "^7.18.6" - "@babel/plugin-proposal-object-rest-spread" "^7.18.9" + "@babel/plugin-proposal-object-rest-spread" "^7.20.2" "@babel/plugin-proposal-optional-catch-binding" "^7.18.6" "@babel/plugin-proposal-optional-chaining" "^7.18.9" "@babel/plugin-proposal-private-methods" "^7.18.6" @@ -820,7 +798,7 @@ "@babel/plugin-syntax-class-static-block" "^7.14.5" "@babel/plugin-syntax-dynamic-import" "^7.8.3" "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-import-assertions" "^7.18.6" + "@babel/plugin-syntax-import-assertions" "^7.20.0" "@babel/plugin-syntax-json-strings" "^7.8.3" "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" @@ -833,10 +811,10 @@ "@babel/plugin-transform-arrow-functions" "^7.18.6" "@babel/plugin-transform-async-to-generator" "^7.18.6" "@babel/plugin-transform-block-scoped-functions" "^7.18.6" - "@babel/plugin-transform-block-scoping" "^7.18.9" - "@babel/plugin-transform-classes" "^7.19.0" + "@babel/plugin-transform-block-scoping" "^7.20.2" + "@babel/plugin-transform-classes" "^7.20.2" "@babel/plugin-transform-computed-properties" "^7.18.9" - "@babel/plugin-transform-destructuring" "^7.18.13" + "@babel/plugin-transform-destructuring" "^7.20.2" "@babel/plugin-transform-dotall-regex" "^7.18.6" "@babel/plugin-transform-duplicate-keys" "^7.18.9" "@babel/plugin-transform-exponentiation-operator" "^7.18.6" @@ -844,14 +822,14 @@ "@babel/plugin-transform-function-name" "^7.18.9" "@babel/plugin-transform-literals" "^7.18.9" "@babel/plugin-transform-member-expression-literals" "^7.18.6" - "@babel/plugin-transform-modules-amd" "^7.18.6" - "@babel/plugin-transform-modules-commonjs" "^7.18.6" - "@babel/plugin-transform-modules-systemjs" "^7.19.0" + "@babel/plugin-transform-modules-amd" "^7.19.6" + "@babel/plugin-transform-modules-commonjs" "^7.19.6" + "@babel/plugin-transform-modules-systemjs" "^7.19.6" "@babel/plugin-transform-modules-umd" "^7.18.6" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.19.0" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.19.1" "@babel/plugin-transform-new-target" "^7.18.6" "@babel/plugin-transform-object-super" "^7.18.6" - "@babel/plugin-transform-parameters" "^7.18.8" + "@babel/plugin-transform-parameters" "^7.20.1" "@babel/plugin-transform-property-literals" "^7.18.6" "@babel/plugin-transform-regenerator" "^7.18.6" "@babel/plugin-transform-reserved-words" "^7.18.6" @@ -863,11 +841,11 @@ "@babel/plugin-transform-unicode-escapes" "^7.18.10" "@babel/plugin-transform-unicode-regex" "^7.18.6" "@babel/preset-modules" "^0.1.5" - "@babel/types" "^7.19.0" - babel-plugin-polyfill-corejs2 "^0.3.2" - babel-plugin-polyfill-corejs3 "^0.5.3" - babel-plugin-polyfill-regenerator "^0.4.0" - core-js-compat "^3.22.1" + "@babel/types" "^7.20.2" + babel-plugin-polyfill-corejs2 "^0.3.3" + babel-plugin-polyfill-corejs3 "^0.6.0" + babel-plugin-polyfill-regenerator "^0.4.1" + core-js-compat "^3.25.1" semver "^6.3.0" "@babel/preset-modules@^0.1.5": @@ -893,11 +871,11 @@ source-map-support "^0.5.16" "@babel/runtime@^7.8.4": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259" - integrity sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA== + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.1.tgz#1148bb33ab252b165a06698fde7576092a78b4a9" + integrity sha512-mrzLkl6U9YLF8qpqI7TB82PESyEGjm/0Ly91jG575eVxMMlb8fYfOXFZIJ8XfLrJZQbm7dlKry2bJmXBUEkdFg== dependencies: - regenerator-runtime "^0.13.4" + regenerator-runtime "^0.13.10" "@babel/template@^7.18.10": version "7.18.10" @@ -908,62 +886,29 @@ "@babel/parser" "^7.18.10" "@babel/types" "^7.18.10" -"@babel/traverse@^7.18.9": - version "7.18.13" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.13.tgz#5ab59ef51a997b3f10c4587d648b9696b6cb1a68" - integrity sha512-N6kt9X1jRMLPxxxPYWi7tgvJRH/rtoU+dbKAPDM44RFHiMH8igdsaSBgFeskhSl/kLWLDUvIh1RXCrTmg0/zvA== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.18.13" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.18.9" - "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.18.13" - "@babel/types" "^7.18.13" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/traverse@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.0.tgz#eb9c561c7360005c592cc645abafe0c3c4548eed" - integrity sha512-4pKpFRDh+utd2mbRC8JLnlsMUii3PMHjpL6a0SZ4NMZy7YFP9aXORxEhdMVOc9CpWtDF09IkciQLEhK7Ml7gRA== +"@babel/traverse@^7.19.0", "@babel/traverse@^7.19.1", "@babel/traverse@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.1.tgz#9b15ccbf882f6d107eeeecf263fbcdd208777ec8" + integrity sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.0" + "@babel/generator" "^7.20.1" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-hoist-variables" "^7.18.6" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.19.0" - "@babel/types" "^7.19.0" + "@babel/parser" "^7.20.1" + "@babel/types" "^7.20.0" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.18.10", "@babel/types@^7.18.13", "@babel/types@^7.18.6", "@babel/types@^7.18.9": - version "7.18.13" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.13.tgz#30aeb9e514f4100f7c1cb6e5ba472b30e48f519a" - integrity sha512-ePqfTihzW0W6XAU+aMw2ykilisStJfDnsejDCXRchCcMJ4O0+8DhPXf2YUbZ6wjBlsEmZwLK/sPweWtu8hcJYQ== - dependencies: - "@babel/helper-string-parser" "^7.18.10" - "@babel/helper-validator-identifier" "^7.18.6" - to-fast-properties "^2.0.0" - -"@babel/types@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.0.tgz#75f21d73d73dc0351f3368d28db73465f4814600" - integrity sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA== +"@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.4.4": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.2.tgz#67ac09266606190f496322dbaff360fdaa5e7842" + integrity sha512-FnnvsNWgZCr232sqtXggapvlkk/tuwR/qhGzcmxI0GXLCjmPYQPzio2FbdlWuY6y1sHFfQKk+rRbUZ9VStQMog== dependencies: - "@babel/helper-string-parser" "^7.18.10" - "@babel/helper-validator-identifier" "^7.18.6" - to-fast-properties "^2.0.0" - -"@babel/types@^7.4.4": - version "7.17.10" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.10.tgz#d35d7b4467e439fcf06d195f8100e0fea7fc82c4" - integrity sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" "@ckeditor/ckeditor5-alignment@~35.3.0": @@ -2195,36 +2140,29 @@ babel-plugin-add-header-comment@^1.0.3: resolved "https://registry.yarnpkg.com/babel-plugin-add-header-comment/-/babel-plugin-add-header-comment-1.0.3.tgz#511c4901062640d5a480b4ac3edd6944195850ec" integrity sha1-URxJAQYmQNWkgLSsPt1pRBlYUOw= -babel-plugin-dynamic-import-node@^2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3" - integrity sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ== - dependencies: - object.assign "^4.1.0" - -babel-plugin-polyfill-corejs2@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.2.tgz#e4c31d4c89b56f3cf85b92558954c66b54bd972d" - integrity sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q== +babel-plugin-polyfill-corejs2@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz#5d1bd3836d0a19e1b84bbf2d9640ccb6f951c122" + integrity sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q== dependencies: "@babel/compat-data" "^7.17.7" - "@babel/helper-define-polyfill-provider" "^0.3.2" + "@babel/helper-define-polyfill-provider" "^0.3.3" semver "^6.1.1" -babel-plugin-polyfill-corejs3@^0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.3.tgz#d7e09c9a899079d71a8b670c6181af56ec19c5c7" - integrity sha512-zKsXDh0XjnrUEW0mxIHLfjBfnXSMr5Q/goMe/fxpQnLm07mcOZiIZHBNWCMx60HmdvjxfXcalac0tfFg0wqxyw== +babel-plugin-polyfill-corejs3@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz#56ad88237137eade485a71b52f72dbed57c6230a" + integrity sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA== dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.2" - core-js-compat "^3.21.0" + "@babel/helper-define-polyfill-provider" "^0.3.3" + core-js-compat "^3.25.1" -babel-plugin-polyfill-regenerator@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.0.tgz#8f51809b6d5883e07e71548d75966ff7635527fe" - integrity sha512-RW1cnryiADFeHmfLS+WW/G431p1PsW5qdRdz0SDRi7TKcUgc7Oh/uXkT7MZ/+tGsT1BkczEAmD5XjUyJ5SWDTw== +babel-plugin-polyfill-regenerator@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz#390f91c38d90473592ed43351e801a9d3e0fd747" + integrity sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw== dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.2" + "@babel/helper-define-polyfill-provider" "^0.3.3" backbone@1.4.x: version "1.4.1" @@ -2287,7 +2225,7 @@ browser-stdout@1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== -browserslist@^4.14.5, browserslist@^4.21.4: +browserslist@^4.14.5, browserslist@^4.21.3, browserslist@^4.21.4: version "4.21.4" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987" integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw== @@ -2297,16 +2235,6 @@ browserslist@^4.14.5, browserslist@^4.21.4: node-releases "^2.0.6" update-browserslist-db "^1.0.9" -browserslist@^4.20.2, browserslist@^4.21.3: - version "4.21.3" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" - integrity sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ== - dependencies: - caniuse-lite "^1.0.30001370" - electron-to-chromium "^1.4.202" - node-releases "^2.0.6" - update-browserslist-db "^1.0.5" - buffer-from@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" @@ -2344,7 +2272,7 @@ camelcase@^5.0.0, camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426: +caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426: version "1.0.30001431" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz#e7c59bd1bc518fae03a4656be442ce6c4887a795" integrity sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ== @@ -2567,19 +2495,16 @@ confusing-browser-globals@^1.0.10: integrity sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA== convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== -core-js-compat@^3.21.0, core-js-compat@^3.22.1: - version "3.25.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.25.0.tgz#489affbfbf9cb3fa56192fe2dd9ebaee985a66c5" - integrity sha512-extKQM0g8/3GjFx9US12FAgx8KJawB7RCQ5y8ipYLbmfzEzmFRWdDjIlxDx82g7ygcNG85qMVUSRyABouELdow== +core-js-compat@^3.25.1: + version "3.26.1" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.26.1.tgz#0e710b09ebf689d719545ac36e49041850f943df" + integrity sha512-622/KzTudvXCDLRw70iHW4KKs1aGpcRcowGWyYJr2DEBfRrd6hNJybxSWJFuZYD4ma86xhrwDDHxmDaIq4EA8A== dependencies: - browserslist "^4.21.3" - semver "7.0.0" + browserslist "^4.21.4" core-util-is@1.0.2: version "1.0.2" @@ -2961,7 +2886,7 @@ ejs@^3.1.6: dependencies: jake "^10.8.5" -electron-to-chromium@^1.4.202, electron-to-chromium@^1.4.251: +electron-to-chromium@^1.4.251: version "1.4.284" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592" integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA== @@ -3576,9 +3501,9 @@ get-caller-file@^2.0.1: integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.2.tgz#336975123e05ad0b7ba41f152ee4aadbea6cf598" - integrity sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA== + version "1.1.3" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385" + integrity sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A== dependencies: function-bind "^1.1.1" has "^1.0.3" @@ -4921,16 +4846,6 @@ object.assign@4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" -object.assign@^4.1.0: - version "4.1.4" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" - integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" - has-symbols "^1.0.3" - object-keys "^1.1.1" - object.assign@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" @@ -5686,10 +5601,10 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -regenerate-unicode-properties@^10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz#7f442732aa7934a3740c779bb9b3340dccc1fb56" - integrity sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw== +regenerate-unicode-properties@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz#7c3192cab6dd24e21cb4461e5ddd7dd24fa8374c" + integrity sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ== dependencies: regenerate "^1.4.2" @@ -5698,10 +5613,10 @@ regenerate@^1.4.2: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.13.4: - version "0.13.9" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" - integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== +regenerator-runtime@^0.13.10: + version "0.13.10" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz#ed07b19616bcbec5da6274ebc75ae95634bfc2ee" + integrity sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw== regenerator-transform@^0.15.0: version "0.15.0" @@ -5725,26 +5640,26 @@ regexpp@^3.2.0: integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== regexpu-core@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.1.0.tgz#2f8504c3fd0ebe11215783a41541e21c79942c6d" - integrity sha512-bb6hk+xWd2PEOkj5It46A16zFMs2mv86Iwpdu94la4S3sJ7C973h2dHpYKwIBGaWSO7cIRJ+UX0IeMaWcO4qwA== + version "5.2.1" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.2.1.tgz#a69c26f324c1e962e9ffd0b88b055caba8089139" + integrity sha512-HrnlNtpvqP1Xkb28tMhBUO2EbyUHdQlsnlAhzWcwHy8WJR53UWr7/MAvqrsQKMbV4qdpv03oTMG8iIhfsPFktQ== dependencies: regenerate "^1.4.2" - regenerate-unicode-properties "^10.0.1" - regjsgen "^0.6.0" - regjsparser "^0.8.2" + regenerate-unicode-properties "^10.1.0" + regjsgen "^0.7.1" + regjsparser "^0.9.1" unicode-match-property-ecmascript "^2.0.0" unicode-match-property-value-ecmascript "^2.0.0" -regjsgen@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.6.0.tgz#83414c5354afd7d6627b16af5f10f41c4e71808d" - integrity sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA== +regjsgen@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.7.1.tgz#ee5ef30e18d3f09b7c369b76e7c2373ed25546f6" + integrity sha512-RAt+8H2ZEzHeYWxZ3H2z6tF18zyyOnlcdaafLrm21Bguj7uZy6ULibiAFdXEtKQY4Sy7wDTwDiOazasMLc4KPA== -regjsparser@^0.8.2: - version "0.8.4" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.8.4.tgz#8a14285ffcc5de78c5b95d62bbf413b6bc132d5f" - integrity sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA== +regjsparser@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.9.1.tgz#272d05aa10c7c1f67095b1ff0addae8442fc5709" + integrity sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ== dependencies: jsesc "~0.5.0" @@ -5890,11 +5805,6 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -5921,11 +5831,6 @@ schema-utils@^3.1.0, schema-utils@^3.1.1: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" @@ -6549,9 +6454,9 @@ unicode-match-property-value-ecmascript@^2.0.0: integrity sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw== unicode-property-aliases-ecmascript@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8" - integrity sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ== + version "2.1.0" + resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz#43d41e3be698bd493ef911077c9b131f827e8ccd" + integrity sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w== unique-string@^2.0.0: version "2.0.0" @@ -6580,7 +6485,7 @@ unpipe@1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== -update-browserslist-db@^1.0.5, update-browserslist-db@^1.0.9: +update-browserslist-db@^1.0.9: version "1.0.10" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==