1/** 2* DO NOT EDIT THIS FILE. 3* See the following change record for more information, 4* https://www.drupal.org/node/2815083 5* @preserve 6**/ 7 8function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 9 10function _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); } } 11 12function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 13 14(function (Drupal) { 15 Drupal.Message = function () { 16 function _class() { 17 var messageWrapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 18 19 _classCallCheck(this, _class); 20 21 if (!messageWrapper) { 22 this.messageWrapper = Drupal.Message.defaultWrapper(); 23 } else { 24 this.messageWrapper = messageWrapper; 25 } 26 } 27 28 _createClass(_class, [{ 29 key: "add", 30 value: function add(message) { 31 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 32 33 if (!options.hasOwnProperty('type')) { 34 options.type = 'status'; 35 } 36 37 if (typeof message !== 'string') { 38 throw new Error('Message must be a string.'); 39 } 40 41 Drupal.Message.announce(message, options); 42 options.id = options.id ? String(options.id) : "".concat(options.type, "-").concat(Math.random().toFixed(15).replace('0.', '')); 43 44 if (!Drupal.Message.getMessageTypeLabels().hasOwnProperty(options.type)) { 45 var type = options.type; 46 throw new Error("The message type, ".concat(type, ", is not present in Drupal.Message.getMessageTypeLabels().")); 47 } 48 49 this.messageWrapper.appendChild(Drupal.theme('message', { 50 text: message 51 }, options)); 52 return options.id; 53 } 54 }, { 55 key: "select", 56 value: function select(id) { 57 return this.messageWrapper.querySelector("[data-drupal-message-id^=\"".concat(id, "\"]")); 58 } 59 }, { 60 key: "remove", 61 value: function remove(id) { 62 return this.messageWrapper.removeChild(this.select(id)); 63 } 64 }, { 65 key: "clear", 66 value: function clear() { 67 var _this = this; 68 69 Array.prototype.forEach.call(this.messageWrapper.querySelectorAll('[data-drupal-message-id]'), function (message) { 70 _this.messageWrapper.removeChild(message); 71 }); 72 } 73 }], [{ 74 key: "defaultWrapper", 75 value: function defaultWrapper() { 76 var wrapper = document.querySelector('[data-drupal-messages]'); 77 78 if (!wrapper) { 79 wrapper = document.querySelector('[data-drupal-messages-fallback]'); 80 wrapper.removeAttribute('data-drupal-messages-fallback'); 81 wrapper.setAttribute('data-drupal-messages', ''); 82 wrapper.classList.remove('hidden'); 83 } 84 85 return wrapper.innerHTML === '' ? Drupal.Message.messageInternalWrapper(wrapper) : wrapper.firstElementChild; 86 } 87 }, { 88 key: "getMessageTypeLabels", 89 value: function getMessageTypeLabels() { 90 return { 91 status: Drupal.t('Status message'), 92 error: Drupal.t('Error message'), 93 warning: Drupal.t('Warning message') 94 }; 95 } 96 }, { 97 key: "announce", 98 value: function announce(message, options) { 99 if (!options.priority && (options.type === 'warning' || options.type === 'error')) { 100 options.priority = 'assertive'; 101 } 102 103 if (options.announce !== '') { 104 Drupal.announce(options.announce || message, options.priority); 105 } 106 } 107 }, { 108 key: "messageInternalWrapper", 109 value: function messageInternalWrapper(messageWrapper) { 110 var innerWrapper = document.createElement('div'); 111 innerWrapper.setAttribute('class', 'messages__wrapper'); 112 messageWrapper.insertAdjacentElement('afterbegin', innerWrapper); 113 return innerWrapper; 114 } 115 }]); 116 117 return _class; 118 }(); 119 120 Drupal.theme.message = function (_ref, _ref2) { 121 var text = _ref.text; 122 var type = _ref2.type, 123 id = _ref2.id;
124 var messagesTypes = Drupal.Message.getMessageTypeLabels(); 125 var messageWrapper = document.createElement('div'); 126 messageWrapper.setAttribute('class', "messages messages--".concat(type)); 127 messageWrapper.setAttribute('role', type === 'error' || type === 'warning' ? 'alert' : 'status'); 128 messageWrapper.setAttribute('data-drupal-message-id', id); 129 messageWrapper.setAttribute('data-drupal-message-type', type); 130 messageWrapper.setAttribute('aria-label', messagesTypes[type]); 131 messageWrapper.innerHTML = "".concat(text); 132 return messageWrapper; 133 }; 134})(Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.