first commit
642
core/misc/ajaxdfb4.js
Normal file
|
@ -0,0 +1,642 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* 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;
|
||||
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;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
}
|
||||
Object.keys(settings.ajax || {}).forEach(function (base) {
|
||||
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';
|
||||
elementSettings.progress = {
|
||||
type: 'throbber'
|
||||
};
|
||||
elementSettings.base = el.id;
|
||||
elementSettings.element = el;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
},
|
||||
detach: function detach(context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
Drupal.ajax.expired().forEach(function (instance) {
|
||||
Drupal.ajax.instances[instance.instanceIndex] = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
|
||||
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
|
||||
}));
|
||||
} 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) {}
|
||||
responseText = '';
|
||||
try {
|
||||
responseText = "\n".concat(Drupal.t('ResponseText: !responseText', {
|
||||
'!responseText': xmlhttp.responseText.trim()
|
||||
}));
|
||||
} 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;
|
||||
Drupal.ajax = function (settings) {
|
||||
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;
|
||||
delete settings.element;
|
||||
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);
|
||||
return ajax;
|
||||
};
|
||||
Drupal.ajax.instances = [];
|
||||
Drupal.ajax.expired = function () {
|
||||
return Drupal.ajax.instances.filter(function (instance) {
|
||||
return instance && instance.element !== false && !document.body.contains(instance.element);
|
||||
});
|
||||
};
|
||||
Drupal.ajax.bindAjaxLinks = function (element) {
|
||||
once('ajax', '.use-ajax', element).forEach(function (ajaxLink) {
|
||||
var $linkElement = $(ajaxLink);
|
||||
var elementSettings = {
|
||||
progress: {
|
||||
type: 'throbber'
|
||||
},
|
||||
dialogType: $linkElement.data('dialog-type'),
|
||||
dialog: $linkElement.data('dialog-options'),
|
||||
dialogRenderer: $linkElement.data('dialog-renderer'),
|
||||
base: $linkElement.attr('id'),
|
||||
element: ajaxLink
|
||||
};
|
||||
var href = $linkElement.attr('href');
|
||||
if (href) {
|
||||
elementSettings.url = href;
|
||||
elementSettings.event = 'click';
|
||||
}
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
};
|
||||
Drupal.Ajax = function (base, element, elementSettings) {
|
||||
var defaults = {
|
||||
event: element ? 'mousedown' : null,
|
||||
keypress: true,
|
||||
selector: base ? "#".concat(base) : null,
|
||||
effect: 'none',
|
||||
speed: 'none',
|
||||
method: 'replaceWith',
|
||||
progress: {
|
||||
type: 'throbber',
|
||||
message: Drupal.t('Please wait...')
|
||||
},
|
||||
submit: {
|
||||
js: true
|
||||
}
|
||||
};
|
||||
$.extend(this, defaults, elementSettings);
|
||||
this.commands = new Drupal.AjaxCommands();
|
||||
this.instanceIndex = false;
|
||||
if (this.wrapper) {
|
||||
this.wrapper = "#".concat(this.wrapper);
|
||||
}
|
||||
this.element = element;
|
||||
this.element_settings = elementSettings;
|
||||
this.elementSettings = elementSettings;
|
||||
if (this.element && this.element.form) {
|
||||
this.$form = $(this.element.form);
|
||||
}
|
||||
if (!this.url) {
|
||||
var $element = $(this.element);
|
||||
if ($element.is('a')) {
|
||||
this.url = $element.attr('href');
|
||||
} else if (this.element && element.form) {
|
||||
this.url = this.$form.attr('action');
|
||||
}
|
||||
}
|
||||
var originalUrl = this.url;
|
||||
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,
|
||||
isInProgress: function isInProgress() {
|
||||
return ajax.ajaxing;
|
||||
},
|
||||
beforeSerialize: function beforeSerialize(elementSettings, options) {
|
||||
return ajax.beforeSerialize(elementSettings, options);
|
||||
},
|
||||
beforeSubmit: function beforeSubmit(formValues, elementSettings, options) {
|
||||
ajax.ajaxing = true;
|
||||
return ajax.beforeSubmit(formValues, elementSettings, options);
|
||||
},
|
||||
beforeSend: function beforeSend(xmlhttprequest, options) {
|
||||
ajax.ajaxing = true;
|
||||
return ajax.beforeSend(xmlhttprequest, options);
|
||||
},
|
||||
success: function success(response, status, xmlhttprequest) {
|
||||
var _this = this;
|
||||
if (typeof response === 'string') {
|
||||
response = $.parseJSON(response);
|
||||
}
|
||||
if (response !== null && !drupalSettings.ajaxTrustedUrl[ajax.url]) {
|
||||
if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') {
|
||||
var customMessage = Drupal.t('The response failed verification so will not be processed.');
|
||||
return ajax.error(xmlhttprequest, ajax.url, customMessage);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(ajax.success(response, status)).then(function () {
|
||||
ajax.ajaxing = false;
|
||||
$(document).trigger('ajaxSuccess', [xmlhttprequest, _this]);
|
||||
$(document).trigger('ajaxComplete', [xmlhttprequest, _this]);
|
||||
if (--$.active === 0) {
|
||||
$(document).trigger('ajaxStop');
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function error(xmlhttprequest, status, _error) {
|
||||
ajax.ajaxing = false;
|
||||
},
|
||||
complete: function complete(xmlhttprequest, status) {
|
||||
if (status === 'error' || status === 'parsererror') {
|
||||
return ajax.error(xmlhttprequest, ajax.url);
|
||||
}
|
||||
},
|
||||
dataType: 'json',
|
||||
jsonp: false,
|
||||
type: 'POST'
|
||||
};
|
||||
if (elementSettings.dialog) {
|
||||
ajax.options.data.dialogOptions = elementSettings.dialog;
|
||||
}
|
||||
if (ajax.options.url.indexOf('?') === -1) {
|
||||
ajax.options.url += '?';
|
||||
} 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);
|
||||
});
|
||||
if (elementSettings.keypress) {
|
||||
$(ajax.element).on('keypress', function (event) {
|
||||
return ajax.keypressResponse(this, event);
|
||||
});
|
||||
}
|
||||
if (elementSettings.prevent) {
|
||||
$(ajax.element).on(elementSettings.prevent, false);
|
||||
}
|
||||
};
|
||||
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);
|
||||
} catch (e) {
|
||||
this.ajaxing = false;
|
||||
window.alert("An error occurred while attempting to process ".concat(this.options.url, ": ").concat(e.message));
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
};
|
||||
Drupal.Ajax.prototype.keypressResponse = function (element, event) {
|
||||
var ajax = this;
|
||||
if (event.which === 13 || event.which === 32 && element.type !== 'text' && element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$(element).trigger(ajax.elementSettings.event);
|
||||
}
|
||||
};
|
||||
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);
|
||||
$.ajax(ajax.options);
|
||||
}
|
||||
} catch (e) {
|
||||
ajax.ajaxing = false;
|
||||
window.alert("An error occurred while attempting to process ".concat(ajax.options.url, ": ").concat(e.message));
|
||||
}
|
||||
};
|
||||
Drupal.Ajax.prototype.beforeSerialize = function (element, options) {
|
||||
if (this.$form && document.body.contains(this.$form.get(0))) {
|
||||
var settings = this.settings || drupalSettings;
|
||||
Drupal.detachBehaviors(this.$form.get(0), settings, 'serialize');
|
||||
}
|
||||
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.beforeSend = function (xmlhttprequest, options) {
|
||||
if (this.$form) {
|
||||
options.extraData = options.extraData || {};
|
||||
options.extraData.ajax_iframe_upload = '1';
|
||||
var v = $.fieldValue(this.element);
|
||||
if (v !== null) {
|
||||
options.extraData[this.element.name] = v;
|
||||
}
|
||||
}
|
||||
$(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);
|
||||
}
|
||||
};
|
||||
Drupal.theme.ajaxProgressThrobber = function (message) {
|
||||
var messageMarkup = typeof message === 'string' ? Drupal.theme('ajaxProgressMessage', message) : '';
|
||||
var throbber = '<div class="throbber"> </div>';
|
||||
return "<div class=\"ajax-progress ajax-progress-throbber\">".concat(throbber).concat(messageMarkup, "</div>");
|
||||
};
|
||||
Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
|
||||
return '<div class="ajax-progress ajax-progress-fullscreen"> </div>';
|
||||
};
|
||||
Drupal.theme.ajaxProgressMessage = function (message) {
|
||||
return "<div class=\"message\">".concat(message, "</div>");
|
||||
};
|
||||
Drupal.theme.ajaxProgressBar = function ($element) {
|
||||
return $('<div class="ajax-progress ajax-progress-bar"></div>').append($element);
|
||||
};
|
||||
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);
|
||||
};
|
||||
Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () {
|
||||
this.progress.element = $(Drupal.theme('ajaxProgressThrobber', this.progress.message));
|
||||
$(this.element).after(this.progress.element);
|
||||
};
|
||||
Drupal.Ajax.prototype.setProgressIndicatorFullscreen = function () {
|
||||
this.progress.element = $(Drupal.theme('ajaxProgressIndicatorFullscreen'));
|
||||
$('body').append(this.progress.element);
|
||||
};
|
||||
Drupal.Ajax.prototype.commandExecutionQueue = function (response, status) {
|
||||
var _this2 = this;
|
||||
var ajaxCommands = this.commands;
|
||||
return Object.keys(response || {}).reduce(function (executionQueue, key) {
|
||||
return executionQueue.then(function () {
|
||||
var command = response[key].command;
|
||||
if (command && ajaxCommands[command]) {
|
||||
return ajaxCommands[command](_this2, response[key], status);
|
||||
}
|
||||
});
|
||||
}, Promise.resolve());
|
||||
};
|
||||
Drupal.Ajax.prototype.success = function (response, status) {
|
||||
var _this3 = 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;
|
||||
return command === 'focusFirst' || command === 'invoke' && method === 'focus';
|
||||
});
|
||||
return this.commandExecutionQueue(response, status).then(function () {
|
||||
if (!focusChanged && _this3.element && !$(_this3.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 (_this3.$form && document.body.contains(_this3.$form.get(0))) {
|
||||
var settings = _this3.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(_this3.$form.get(0), settings);
|
||||
}
|
||||
_this3.settings = null;
|
||||
}).catch(function (error) {
|
||||
return console.error(Drupal.t('An error occurred during the execution of the Ajax response: !error', {
|
||||
'!error': error
|
||||
}));
|
||||
});
|
||||
};
|
||||
Drupal.Ajax.prototype.getEffect = function (response) {
|
||||
var type = response.effect || this.effect;
|
||||
var speed = response.speed || this.speed;
|
||||
var effect = {};
|
||||
if (type === 'none') {
|
||||
effect.showEffect = 'show';
|
||||
effect.hideEffect = 'hide';
|
||||
effect.showSpeed = '';
|
||||
} else if (type === 'fade') {
|
||||
effect.showEffect = 'fadeIn';
|
||||
effect.hideEffect = 'fadeOut';
|
||||
effect.showSpeed = speed;
|
||||
} else {
|
||||
effect.showEffect = "".concat(type, "Toggle");
|
||||
effect.hideEffect = "".concat(type, "Toggle");
|
||||
effect.showSpeed = speed;
|
||||
}
|
||||
return effect;
|
||||
};
|
||||
Drupal.Ajax.prototype.error = function (xmlhttprequest, uri, customMessage) {
|
||||
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));
|
||||
}).length > 1 ? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent) : $newContent;
|
||||
};
|
||||
Drupal.theme.ajaxWrapperMultipleRootElements = function ($elements) {
|
||||
return $('<div></div>').append($elements);
|
||||
};
|
||||
Drupal.AjaxCommands = function () {};
|
||||
Drupal.AjaxCommands.prototype = {
|
||||
insert: function insert(ajax, response) {
|
||||
var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
|
||||
var method = response.method || ajax.method;
|
||||
var effect = ajax.getEffect(response);
|
||||
var settings = response.settings || ajax.settings || drupalSettings;
|
||||
var $newContent = $($.parseHTML(response.data, document, true));
|
||||
$newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response);
|
||||
switch (method) {
|
||||
case 'html':
|
||||
case 'replaceWith':
|
||||
case 'replaceAll':
|
||||
case 'empty':
|
||||
case 'remove':
|
||||
Drupal.detachBehaviors($wrapper.get(0), settings);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$wrapper[method]($newContent);
|
||||
if (effect.showEffect !== 'show') {
|
||||
$newContent.hide();
|
||||
}
|
||||
var $ajaxNewContent = $newContent.find('.ajax-new-content');
|
||||
if ($ajaxNewContent.length) {
|
||||
$ajaxNewContent.hide();
|
||||
$newContent.show();
|
||||
$ajaxNewContent[effect.showEffect](effect.showSpeed);
|
||||
} else if (effect.showEffect !== 'show') {
|
||||
$newContent[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
if ($newContent.parents('html').length) {
|
||||
$newContent.each(function (index, element) {
|
||||
if (element.nodeType === Node.ELEMENT_NODE) {
|
||||
Drupal.attachBehaviors(element, settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
remove: function remove(ajax, response, status) {
|
||||
var settings = response.settings || ajax.settings || drupalSettings;
|
||||
$(response.selector).each(function () {
|
||||
Drupal.detachBehaviors(this, settings);
|
||||
}).remove();
|
||||
},
|
||||
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> "));
|
||||
}
|
||||
}
|
||||
},
|
||||
alert: function alert(ajax, response, status) {
|
||||
window.alert(response.text);
|
||||
},
|
||||
announce: function announce(ajax, response) {
|
||||
if (response.priority) {
|
||||
Drupal.announce(response.text, response.priority);
|
||||
} else {
|
||||
Drupal.announce(response.text);
|
||||
}
|
||||
},
|
||||
redirect: function redirect(ajax, response, status) {
|
||||
window.location = response.url;
|
||||
},
|
||||
css: function css(ajax, response, status) {
|
||||
$(response.selector).css(response.argument);
|
||||
},
|
||||
settings: function settings(ajax, response, status) {
|
||||
var ajaxSettings = drupalSettings.ajax;
|
||||
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 {
|
||||
ajax.settings = response.settings;
|
||||
}
|
||||
},
|
||||
data: function data(ajax, response, status) {
|
||||
$(response.selector).data(response.name, response.value);
|
||||
},
|
||||
focusFirst: function focusFirst(ajax, response, status) {
|
||||
var focusChanged = false;
|
||||
var container = document.querySelector(response.selector);
|
||||
if (container) {
|
||||
var tabbableElements = tabbable(container);
|
||||
if (tabbableElements.length) {
|
||||
tabbableElements[0].focus();
|
||||
focusChanged = true;
|
||||
} else if (isFocusable(container)) {
|
||||
container.focus();
|
||||
focusChanged = true;
|
||||
}
|
||||
}
|
||||
if (ajax.hasOwnProperty('element') && !focusChanged) {
|
||||
ajax.element.focus();
|
||||
}
|
||||
},
|
||||
invoke: function invoke(ajax, response, status) {
|
||||
var $element = $(response.selector);
|
||||
$element[response.method].apply($element, _toConsumableArray(response.args));
|
||||
},
|
||||
restripe: function restripe(ajax, response, status) {
|
||||
$(response.selector).find('> tbody > tr:visible, > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
|
||||
},
|
||||
update_build_id: function update_build_id(ajax, response, status) {
|
||||
document.querySelectorAll("input[name=\"form_build_id\"][value=\"".concat(response.old, "\"]")).forEach(function (item) {
|
||||
item.value = response.new;
|
||||
});
|
||||
},
|
||||
add_css: function add_css(ajax, response, status) {
|
||||
$('head').prepend(response.data);
|
||||
},
|
||||
message: function message(ajax, response) {
|
||||
var messages = new Drupal.Message(document.querySelector(response.messageWrapperQuerySelector));
|
||||
if (response.clearPrevious) {
|
||||
messages.clear();
|
||||
}
|
||||
messages.add(response.message, response.messageOptions);
|
||||
},
|
||||
add_js: function add_js(ajax, response, status) {
|
||||
var parentEl = document.querySelector(response.selector || 'body');
|
||||
var settings = ajax.settings || drupalSettings;
|
||||
var allUniqueBundleIds = response.data.map(function (script) {
|
||||
var uniqueBundleId = script.src + ajax.instanceIndex;
|
||||
loadjs(script.src, uniqueBundleId, {
|
||||
async: false,
|
||||
before: function before(path, scriptEl) {
|
||||
Object.keys(script).forEach(function (attributeKey) {
|
||||
scriptEl.setAttribute(attributeKey, script[attributeKey]);
|
||||
});
|
||||
parentEl.appendChild(scriptEl);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return uniqueBundleId;
|
||||
});
|
||||
return new Promise(function (resolve, reject) {
|
||||
loadjs.ready(allUniqueBundleIds, {
|
||||
success: function success() {
|
||||
Drupal.attachBehaviors(parentEl, settings);
|
||||
resolve();
|
||||
},
|
||||
error: function error(depsNotFound) {
|
||||
var message = Drupal.t("The following files could not be loaded: @dependencies", {
|
||||
'@dependencies': depsNotFound.join(', ')
|
||||
});
|
||||
reject(message);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
var stopEvent = function stopEvent(xhr, settings) {
|
||||
return xhr.getResponseHeader('X-Drupal-Ajax-Token') === '1' && settings.isInProgress && settings.isInProgress();
|
||||
};
|
||||
$.extend(true, $.event.special, {
|
||||
ajaxSuccess: {
|
||||
trigger: function trigger(event, xhr, settings) {
|
||||
if (stopEvent(xhr, settings)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
ajaxComplete: {
|
||||
trigger: function trigger(event, xhr, settings) {
|
||||
if (stopEvent(xhr, settings)) {
|
||||
$.active++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery, window, Drupal, drupalSettings, loadjs, window.tabbable);
|
49
core/misc/announcedfb4.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function (Drupal, debounce) {
|
||||
var liveElement;
|
||||
var announcements = [];
|
||||
Drupal.behaviors.drupalAnnounce = {
|
||||
attach: function attach(context) {
|
||||
if (!liveElement) {
|
||||
liveElement = document.createElement('div');
|
||||
liveElement.id = 'drupal-live-announce';
|
||||
liveElement.className = 'visually-hidden';
|
||||
liveElement.setAttribute('aria-live', 'polite');
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
document.body.appendChild(liveElement);
|
||||
}
|
||||
}
|
||||
};
|
||||
function announce() {
|
||||
var text = [];
|
||||
var priority = 'polite';
|
||||
var announcement;
|
||||
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');
|
||||
liveElement.setAttribute('aria-live', priority);
|
||||
liveElement.innerHTML = text.join('\n');
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
}
|
||||
}
|
||||
Drupal.announce = function (text, priority) {
|
||||
announcements.push({
|
||||
text: text,
|
||||
priority: priority
|
||||
});
|
||||
return debounce(announce, 200)();
|
||||
};
|
||||
})(Drupal, Drupal.debounce);
|
62
core/misc/collapsedfb4.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Modernizr, Drupal) {
|
||||
function CollapsibleDetails(node) {
|
||||
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));
|
||||
},
|
||||
onSummaryClick: function onSummaryClick(e) {
|
||||
this.toggle();
|
||||
e.preventDefault();
|
||||
},
|
||||
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));
|
||||
});
|
||||
}
|
||||
};
|
||||
var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e, $target) {
|
||||
$target.parents('details').not('[open]').find('> summary').trigger('click');
|
||||
};
|
||||
$('body').on('formFragmentLinkClickOrHashChange.details', handleFragmentLinkClickOrHashChange);
|
||||
Drupal.CollapsibleDetails = CollapsibleDetails;
|
||||
})(jQuery, Modernizr, Drupal);
|
29
core/misc/debouncedfb4.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
Drupal.debounce = function (func, wait, immediate) {
|
||||
var timeout;
|
||||
var result;
|
||||
return function () {
|
||||
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;
|
||||
};
|
||||
};
|
20
core/misc/details-ariadfb4.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Drupal) {
|
||||
Drupal.behaviors.detailsAria = {
|
||||
attach: function attach() {
|
||||
$(once('detailsAria', 'body')).on('click.detailsAria', 'summary', function (event) {
|
||||
var $summary = $(event.currentTarget);
|
||||
var open = $(event.currentTarget.parentNode).attr('open') === 'open' ? 'false' : 'true';
|
||||
$summary.attr({
|
||||
'aria-expanded': open,
|
||||
'aria-pressed': open
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal);
|
39
core/misc/details-summarized-contentdfb4.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Drupal) {
|
||||
function DetailsSummarizedContent(node) {
|
||||
this.$node = $(node);
|
||||
this.setupSummary();
|
||||
}
|
||||
$.extend(DetailsSummarizedContent, {
|
||||
instances: []
|
||||
});
|
||||
$.extend(DetailsSummarizedContent.prototype, {
|
||||
setupSummary: function setupSummary() {
|
||||
this.$detailsSummarizedContentWrapper = $(Drupal.theme('detailsSummarizedContentWrapper'));
|
||||
this.$node.on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)).trigger('summaryUpdated').find('> summary').append(this.$detailsSummarizedContentWrapper);
|
||||
},
|
||||
onSummaryUpdated: function onSummaryUpdated() {
|
||||
var text = this.$node.drupalGetSummary();
|
||||
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) {
|
||||
return new DetailsSummarizedContent(details);
|
||||
}));
|
||||
}
|
||||
};
|
||||
Drupal.DetailsSummarizedContent = DetailsSummarizedContent;
|
||||
Drupal.theme.detailsSummarizedContentWrapper = function () {
|
||||
return "<span class=\"summary\"></span>";
|
||||
};
|
||||
Drupal.theme.detailsSummarizedContentText = function (text) {
|
||||
return text ? " (".concat(text, ")") : '';
|
||||
};
|
||||
})(jQuery, Drupal);
|
26
core/misc/drupal.initdfb4.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
if (window.jQuery) {
|
||||
jQuery.noConflict();
|
||||
}
|
||||
document.documentElement.className += ' js';
|
||||
(function (Drupal, drupalSettings) {
|
||||
var domReady = function domReady(callback) {
|
||||
var listener = function listener() {
|
||||
callback();
|
||||
document.removeEventListener('DOMContentLoaded', listener);
|
||||
};
|
||||
if (document.readyState !== 'loading') {
|
||||
setTimeout(callback, 0);
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', listener);
|
||||
}
|
||||
};
|
||||
domReady(function () {
|
||||
Drupal.attachBehaviors(document, drupalSettings);
|
||||
});
|
||||
})(Drupal, window.drupalSettings);
|
13
core/misc/drupalSettingsLoaderdfb4.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(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 = {};
|
||||
if (settingsElement !== null) {
|
||||
window.drupalSettings = JSON.parse(settingsElement.textContent);
|
||||
}
|
||||
})();
|
181
core/misc/drupaldfb4.js
Normal file
|
@ -0,0 +1,181 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
window.Drupal = {
|
||||
behaviors: {},
|
||||
locale: {}
|
||||
};
|
||||
(function (Drupal, drupalSettings, drupalTranslations, console, Proxy, Reflect) {
|
||||
Drupal.throwError = function (error) {
|
||||
setTimeout(function () {
|
||||
throw error;
|
||||
}, 0);
|
||||
};
|
||||
Drupal.attachBehaviors = function (context, settings) {
|
||||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
var behaviors = Drupal.behaviors;
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].attach === 'function') {
|
||||
try {
|
||||
behaviors[i].attach(context, settings);
|
||||
} catch (e) {
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Drupal.detachBehaviors = function (context, settings, trigger) {
|
||||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
trigger = trigger || 'unload';
|
||||
var behaviors = Drupal.behaviors;
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].detach === 'function') {
|
||||
try {
|
||||
behaviors[i].detach(context, settings, trigger);
|
||||
} catch (e) {
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Drupal.checkPlain = function (str) {
|
||||
str = str.toString().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
return str;
|
||||
};
|
||||
Drupal.formatString = function (str, args) {
|
||||
var processedArgs = {};
|
||||
Object.keys(args || {}).forEach(function (key) {
|
||||
switch (key.charAt(0)) {
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
});
|
||||
return Drupal.stringReplace(str, processedArgs, null);
|
||||
};
|
||||
Drupal.stringReplace = function (str, args, keys) {
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
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]);
|
||||
};
|
||||
Drupal.t = function (str, args, options) {
|
||||
options = options || {};
|
||||
options.context = options.context || '';
|
||||
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;
|
||||
};
|
||||
Drupal.url = function (path) {
|
||||
return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
||||
};
|
||||
Drupal.url.toAbsolute = function (url) {
|
||||
var urlParsingNode = document.createElement('a');
|
||||
try {
|
||||
url = decodeURIComponent(url);
|
||||
} catch (e) {}
|
||||
urlParsingNode.setAttribute('href', url);
|
||||
return urlParsingNode.cloneNode(false).href;
|
||||
};
|
||||
Drupal.url.isLocal = function (url) {
|
||||
var absoluteUrl = Drupal.url.toAbsolute(url);
|
||||
var protocol = window.location.protocol;
|
||||
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) {}
|
||||
try {
|
||||
baseUrl = decodeURIComponent(baseUrl);
|
||||
} catch (e) {}
|
||||
return absoluteUrl === baseUrl || absoluteUrl.indexOf("".concat(baseUrl, "/")) === 0;
|
||||
};
|
||||
Drupal.formatPlural = function (count, singular, plural, args, options) {
|
||||
args = args || {};
|
||||
args['@count'] = count;
|
||||
var pluralDelimiter = drupalSettings.pluralDelimiter;
|
||||
var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter);
|
||||
var index = 0;
|
||||
if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) {
|
||||
index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula.default;
|
||||
} else if (args['@count'] !== 1) {
|
||||
index = 1;
|
||||
}
|
||||
return translations[index];
|
||||
};
|
||||
Drupal.encodePath = function (item) {
|
||||
return window.encodeURIComponent(item).replace(/%2F/g, '/');
|
||||
};
|
||||
Drupal.deprecationError = function (_ref) {
|
||||
var message = _ref.message;
|
||||
if (drupalSettings.suppressDeprecationErrors === false && typeof console !== 'undefined' && console.warn) {
|
||||
console.warn("[Deprecation] ".concat(message));
|
||||
}
|
||||
};
|
||||
Drupal.deprecatedProperty = function (_ref2) {
|
||||
var target = _ref2.target,
|
||||
deprecatedProperty = _ref2.deprecatedProperty,
|
||||
message = _ref2.message;
|
||||
if (!Proxy || !Reflect) {
|
||||
return target;
|
||||
}
|
||||
return new Proxy(target, {
|
||||
get: function get(target, key) {
|
||||
if (key === deprecatedProperty) {
|
||||
Drupal.deprecationError({
|
||||
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));
|
||||
}
|
||||
});
|
||||
};
|
||||
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);
|
||||
}
|
||||
};
|
||||
Drupal.theme.placeholder = function (str) {
|
||||
return "<em class=\"placeholder\">".concat(Drupal.checkPlain(str), "</em>");
|
||||
};
|
||||
})(Drupal, window.drupalSettings, window.drupalTranslations, window.console, window.Proxy, window.Reflect);
|
8
core/misc/feed.svg
Normal file
|
@ -0,0 +1,8 @@
|
|||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<rect fill="#ff9900" width="16" height="16" x="0" y="0" rx="3" ry="3"/>
|
||||
<g fill="#ffffff">
|
||||
<circle cx="4.25" cy="11.812" r="1.5"/>
|
||||
<path d="M10,13.312H7.875c0-2.83-2.295-5.125-5.125-5.125l0,0V6.062C6.754,6.062,10,9.308,10,13.312z"/>
|
||||
<path d="M11.5,13.312c0-4.833-3.917-8.75-8.75-8.75V2.375c6.041,0,10.937,4.896,10.937,10.937H11.5z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 462 B |
132
core/misc/formdfb4.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Drupal, debounce) {
|
||||
$.fn.drupalGetSummary = function () {
|
||||
var callback = this.data('summaryCallback');
|
||||
return this[0] && callback ? callback(this[0]).trim() : '';
|
||||
};
|
||||
$.fn.drupalSetSummary = function (callback) {
|
||||
var self = this;
|
||||
if (typeof callback !== 'function') {
|
||||
var val = callback;
|
||||
callback = function callback() {
|
||||
return val;
|
||||
};
|
||||
}
|
||||
return this.data('summaryCallback', callback).off('formUpdated.summary').on('formUpdated.summary', function () {
|
||||
self.trigger('summaryUpdated');
|
||||
}).trigger('summaryUpdated');
|
||||
};
|
||||
Drupal.behaviors.formSingleSubmit = {
|
||||
attach: function attach() {
|
||||
function onFormSubmit(e) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
function triggerFormUpdated(element) {
|
||||
$(element).trigger('formUpdated');
|
||||
}
|
||||
function fieldsList(form) {
|
||||
return [].map.call(form.querySelectorAll('[name][id]'), function (el) {
|
||||
return el.id;
|
||||
});
|
||||
}
|
||||
Drupal.behaviors.formUpdated = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
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 ';
|
||||
var eventHandler = debounce(function (event) {
|
||||
triggerFormUpdated(event.target);
|
||||
}, 300);
|
||||
formFields = fieldsList(form).join(',');
|
||||
form.setAttribute('data-drupal-form-fields', formFields);
|
||||
$(form).on(events, eventHandler);
|
||||
});
|
||||
}
|
||||
if (contextIsForm) {
|
||||
formFields = fieldsList(context).join(',');
|
||||
var currentFields = $(context).attr('data-drupal-form-fields');
|
||||
if (formFields !== currentFields) {
|
||||
triggerFormUpdated(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
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');
|
||||
$(form).off('.formUpdated');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
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);
|
BIN
core/misc/help.png
Normal file
After Width: | Height: | Size: 294 B |
1
core/misc/icons/73b355/check.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#73b355"><path d="M6.464 13.676c-.194.194-.513.194-.707 0l-4.96-4.955c-.194-.193-.194-.513 0-.707l1.405-1.407c.194-.195.512-.195.707 0l2.849 2.848c.194.193.513.193.707 0l6.629-6.626c.195-.194.514-.194.707 0l1.404 1.404c.193.194.193.513 0 .707l-8.741 8.736z"/></svg>
|
After Width: | Height: | Size: 334 B |
1
core/misc/icons/e29700/warning.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#e29700"><path d="M14.66 12.316l-5.316-10.633c-.738-1.476-1.946-1.476-2.685 0l-5.317 10.633c-.738 1.477.008 2.684 1.658 2.684h10.002c1.65 0 2.396-1.207 1.658-2.684zm-7.66-8.316h2.002v5h-2.002v-5zm2.252 8.615c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.239c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.239z"/></svg>
|
After Width: | Height: | Size: 412 B |
1
core/misc/icons/e32700/error.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#e32700"><path d="M8.002 1c-3.868 0-7.002 3.134-7.002 7s3.134 7 7.002 7c3.865 0 7-3.134 7-7s-3.135-7-7-7zm4.025 9.284c.062.063.1.149.1.239 0 .091-.037.177-.1.24l-1.262 1.262c-.064.062-.15.1-.24.1s-.176-.036-.24-.1l-2.283-2.283-2.286 2.283c-.064.062-.15.1-.24.1s-.176-.036-.24-.1l-1.261-1.262c-.063-.062-.1-.148-.1-.24 0-.088.036-.176.1-.238l2.283-2.285-2.283-2.284c-.063-.064-.1-.15-.1-.24s.036-.176.1-.24l1.262-1.262c.063-.063.149-.1.24-.1.089 0 .176.036.24.1l2.285 2.284 2.283-2.284c.064-.063.15-.1.24-.1s.176.036.24.1l1.262 1.262c.062.063.1.149.1.24 0 .089-.037.176-.1.24l-2.283 2.284 2.283 2.284z"/></svg>
|
After Width: | Height: | Size: 679 B |
1
core/misc/icons/ee0000/required.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#EE0000" d="M0,7.562l1.114-3.438c2.565,0.906,4.43,1.688,5.59,2.35C6.398,3.553,6.237,1.544,6.22,0.447h3.511 c-0.05,1.597-0.234,3.6-0.558,6.003c1.664-0.838,3.566-1.613,5.714-2.325L16,7.562c-2.05,0.678-4.06,1.131-6.028,1.356 c0.984,0.856,2.372,2.381,4.166,4.575l-2.906,2.059c-0.935-1.274-2.041-3.009-3.316-5.206c-1.194,2.275-2.244,4.013-3.147,5.206 l-2.856-2.059c1.872-2.307,3.211-3.832,4.017-4.575C3.849,8.516,1.872,8.062,0,7.562"/></svg>
|
After Width: | Height: | Size: 513 B |
35
core/misc/jquery.once.bcdfb4.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(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;
|
||||
$.fn.once = function jQueryOnce(id) {
|
||||
Drupal.deprecationError({
|
||||
message: "jQuery.once() ".concat(deprecatedMessageSuffix)
|
||||
});
|
||||
return originalJQOnce.apply(this, [id]);
|
||||
};
|
||||
$.fn.removeOnce = function jQueryRemoveOnce(id) {
|
||||
Drupal.deprecationError({
|
||||
message: "jQuery.removeOnce() ".concat(deprecatedMessageSuffix)
|
||||
});
|
||||
return originalJQRemoveOnce.apply(this, [id]);
|
||||
};
|
||||
var drupalOnce = once;
|
||||
function augmentedOnce(id, selector, context) {
|
||||
originalJQOnce.apply($(selector, context), [id]);
|
||||
return drupalOnce(id, selector, context);
|
||||
}
|
||||
function remove(id, selector, context) {
|
||||
originalJQRemoveOnce.apply($(selector, context), [id]);
|
||||
return drupalOnce.remove(id, selector, context);
|
||||
}
|
||||
window.once = Object.assign(augmentedOnce, drupalOnce, {
|
||||
remove: remove
|
||||
});
|
||||
})(jQuery, once);
|
BIN
core/misc/menu-collapsed-rtl.png
Normal file
After Width: | Height: | Size: 107 B |
BIN
core/misc/menu-collapsed.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
core/misc/menu-expanded.png
Normal file
After Width: | Height: | Size: 106 B |
58
core/misc/modernizr-additional-testsad3d.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* 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));
|
||||
}
|
||||
};
|
||||
var _deprecatedPropertyModernizrCopy = function _deprecatedPropertyModernizrCopy(_ref2) {
|
||||
var target = _ref2.target,
|
||||
deprecatedProperty = _ref2.deprecatedProperty,
|
||||
message = _ref2.message;
|
||||
if (!Proxy || !Reflect) {
|
||||
return target;
|
||||
}
|
||||
return new Proxy(target, {
|
||||
get: function get(target, key) {
|
||||
if (key === deprecatedProperty) {
|
||||
_deprecationErrorModernizrCopy({
|
||||
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;
|
||||
}
|
||||
Modernizr.addTest('touchevents', function () {
|
||||
_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 {
|
||||
var query = ['@media (', Modernizr._prefixes.join('touch-enabled),('), 'heartz', ')', '{#modernizr{top:9px;position:absolute}}'].join('');
|
||||
Modernizr.testStyles(query, function (node) {
|
||||
bool = node.offsetTop === 9;
|
||||
});
|
||||
}
|
||||
return bool;
|
||||
});
|
||||
})(Modernizr);
|
9
core/misc/polyfills/element.matchesdfb4.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
if (!Element.prototype.matches) {
|
||||
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
||||
}
|
9
core/misc/polyfills/nodelist.foreachdfb4.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
if (window.NodeList && !NodeList.prototype.forEach) {
|
||||
NodeList.prototype.forEach = Array.prototype.forEach;
|
||||
}
|
31
core/misc/polyfills/object.assigndfb4.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
if (typeof Object.assign !== 'function') {
|
||||
Object.defineProperty(Object, 'assign', {
|
||||
value: function assign(target, varArgs) {
|
||||
'use strict';
|
||||
|
||||
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)) {
|
||||
to[nextKey] = nextSource[nextKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
},
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
}
|
82
core/misc/progressdfb4.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Drupal) {
|
||||
Drupal.theme.progressBar = function (id) {
|
||||
return "<div id=\"".concat(id, "\" class=\"progress\" aria-live=\"polite\">") + '<div class="progress__label"> </div>' + '<div class="progress__track"><div class="progress__bar"></div></div>' + '<div class="progress__percentage"></div>' + '<div class="progress__description"> </div>' + '</div>';
|
||||
};
|
||||
Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) {
|
||||
this.id = id;
|
||||
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);
|
||||
}
|
||||
},
|
||||
startMonitoring: function startMonitoring(uri, delay) {
|
||||
this.delay = delay;
|
||||
this.uri = uri;
|
||||
this.sendPing();
|
||||
},
|
||||
stopMonitoring: function stopMonitoring() {
|
||||
clearTimeout(this.timer);
|
||||
this.uri = null;
|
||||
},
|
||||
sendPing: function sendPing() {
|
||||
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,
|
||||
url: uri,
|
||||
data: '',
|
||||
dataType: 'json',
|
||||
success: function success(progress) {
|
||||
if (progress.status === 0) {
|
||||
pb.displayError(progress.data);
|
||||
return;
|
||||
}
|
||||
pb.setProgress(progress.percentage, progress.message, progress.label);
|
||||
pb.timer = setTimeout(function () {
|
||||
pb.sendPing();
|
||||
}, pb.delay);
|
||||
},
|
||||
error: function error(xmlhttp) {
|
||||
var e = new Drupal.AjaxError(xmlhttp, pb.uri);
|
||||
pb.displayError("<pre>".concat(e.message, "</pre>"));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery, Drupal);
|
336
core/misc/statesdfb4.js
Normal file
|
@ -0,0 +1,336 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
(function ($, Drupal) {
|
||||
var states = {
|
||||
postponed: []
|
||||
};
|
||||
Drupal.states = states;
|
||||
function invert(a, invertState) {
|
||||
return invertState && typeof a !== 'undefined' ? !a : a;
|
||||
}
|
||||
function _compare2(a, b) {
|
||||
if (a === b) {
|
||||
return typeof a === 'undefined' ? a : true;
|
||||
}
|
||||
return typeof a === 'undefined' || typeof b === 'undefined';
|
||||
}
|
||||
function ternary(a, b) {
|
||||
if (typeof a === 'undefined') {
|
||||
return b;
|
||||
}
|
||||
if (typeof b === 'undefined') {
|
||||
return a;
|
||||
}
|
||||
return a && b;
|
||||
}
|
||||
Drupal.behaviors.states = {
|
||||
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) {
|
||||
new states.Dependent({
|
||||
element: $($states[i]),
|
||||
state: states.State.sanitize(state),
|
||||
constraints: config[state]
|
||||
});
|
||||
});
|
||||
};
|
||||
for (var i = 0; i < il; i++) {
|
||||
_loop(i);
|
||||
}
|
||||
while (states.postponed.length) {
|
||||
states.postponed.shift()();
|
||||
}
|
||||
}
|
||||
};
|
||||
states.Dependent = function (args) {
|
||||
var _this = this;
|
||||
$.extend(this, {
|
||||
values: {},
|
||||
oldValue: null
|
||||
}, args);
|
||||
this.dependees = this.getDependees();
|
||||
Object.keys(this.dependees || {}).forEach(function (selector) {
|
||||
_this.initializeDependee(selector, _this.dependees[selector]);
|
||||
});
|
||||
};
|
||||
states.Dependent.comparisons = {
|
||||
RegExp: function RegExp(reference, value) {
|
||||
return reference.test(value);
|
||||
},
|
||||
Function: function Function(reference, value) {
|
||||
return reference(value);
|
||||
},
|
||||
Number: function Number(reference, value) {
|
||||
return typeof value === 'string' ? _compare2(reference.toString(), value) : _compare2(reference, value);
|
||||
}
|
||||
};
|
||||
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
|
||||
});
|
||||
});
|
||||
},
|
||||
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);
|
||||
}
|
||||
return _compare2(reference, value);
|
||||
},
|
||||
update: function update(selector, state, value) {
|
||||
if (value !== this.values[selector][state.name]) {
|
||||
this.values[selector][state.name] = value;
|
||||
this.reevaluate();
|
||||
}
|
||||
},
|
||||
reevaluate: function reevaluate() {
|
||||
var value = this.verifyConstraints(this.constraints);
|
||||
if (value !== this.oldValue) {
|
||||
this.oldValue = value;
|
||||
value = invert(value, this.state.invert);
|
||||
this.element.trigger({
|
||||
type: "state:".concat(this.state),
|
||||
value: value,
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
},
|
||||
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)) {
|
||||
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) {
|
||||
if (typeof state !== 'string' || /[0-9]/.test(state[0])) {
|
||||
state = null;
|
||||
} else if (typeof selector === 'undefined') {
|
||||
selector = state;
|
||||
state = null;
|
||||
}
|
||||
if (state !== null) {
|
||||
state = states.State.sanitize(state);
|
||||
return invert(this.compare(value, selector, state), state.invert);
|
||||
}
|
||||
return this.verifyConstraints(value, selector);
|
||||
},
|
||||
getDependees: function getDependees() {
|
||||
var cache = {};
|
||||
var _compare = this.compare;
|
||||
this.compare = function (reference, selector, state) {
|
||||
(cache[selector] || (cache[selector] = [])).push(state.name);
|
||||
};
|
||||
this.verifyConstraints(this.constraints);
|
||||
this.compare = _compare;
|
||||
return cache;
|
||||
}
|
||||
};
|
||||
states.Trigger = function (args) {
|
||||
$.extend(this, args);
|
||||
if (this.state in states.Trigger.states) {
|
||||
this.element = $(this.selector);
|
||||
if (!this.element.data("trigger:".concat(this.state))) {
|
||||
this.initialize();
|
||||
}
|
||||
}
|
||||
};
|
||||
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 {
|
||||
Object.keys(trigger || {}).forEach(function (event) {
|
||||
_this3.defaultTrigger(event, trigger[event]);
|
||||
});
|
||||
}
|
||||
this.element.data("trigger:".concat(this.state), true);
|
||||
},
|
||||
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),
|
||||
value: value,
|
||||
oldValue: oldValue
|
||||
});
|
||||
oldValue = value;
|
||||
}
|
||||
}, this));
|
||||
states.postponed.push($.proxy(function () {
|
||||
this.element.trigger({
|
||||
type: "state:".concat(this.state),
|
||||
value: oldValue,
|
||||
oldValue: null
|
||||
});
|
||||
}, this));
|
||||
}
|
||||
};
|
||||
states.Trigger.states = {
|
||||
empty: {
|
||||
keyup: function keyup() {
|
||||
return this.val() === '';
|
||||
},
|
||||
change: function change() {
|
||||
return this.val() === '';
|
||||
}
|
||||
},
|
||||
checked: {
|
||||
change: function change() {
|
||||
var checked = false;
|
||||
this.each(function () {
|
||||
checked = $(this).prop('checked');
|
||||
return !checked;
|
||||
});
|
||||
return checked;
|
||||
}
|
||||
},
|
||||
value: {
|
||||
keyup: function keyup() {
|
||||
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();
|
||||
}
|
||||
},
|
||||
collapsed: {
|
||||
collapsed: function collapsed(e) {
|
||||
return typeof e !== 'undefined' && 'value' in e ? e.value : !this.is('[open]');
|
||||
}
|
||||
}
|
||||
};
|
||||
states.State = function (state) {
|
||||
this.pristine = state;
|
||||
this.name = state;
|
||||
var process = true;
|
||||
do {
|
||||
while (this.name.charAt(0) === '!') {
|
||||
this.name = this.name.substring(1);
|
||||
this.invert = !this.invert;
|
||||
}
|
||||
if (this.name in states.State.aliases) {
|
||||
this.name = states.State.aliases[this.name];
|
||||
} else {
|
||||
process = false;
|
||||
}
|
||||
} while (process);
|
||||
};
|
||||
states.State.sanitize = function (state) {
|
||||
if (state instanceof states.State) {
|
||||
return state;
|
||||
}
|
||||
return new states.State(state);
|
||||
};
|
||||
states.State.aliases = {
|
||||
enabled: '!disabled',
|
||||
invisible: '!visible',
|
||||
invalid: '!valid',
|
||||
untouched: '!touched',
|
||||
optional: '!required',
|
||||
filled: '!empty',
|
||||
unchecked: '!checked',
|
||||
irrelevant: '!relevant',
|
||||
expanded: '!collapsed',
|
||||
open: '!collapsed',
|
||||
closed: 'collapsed',
|
||||
readwrite: '!readonly'
|
||||
};
|
||||
states.State.prototype = {
|
||||
invert: false,
|
||||
toString: function toString() {
|
||||
return this.name;
|
||||
}
|
||||
};
|
||||
var $document = $(document);
|
||||
$document.on('state:disabled', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).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) {
|
||||
var label = "label".concat(e.target.id ? "[for=".concat(e.target.id, "]") : '');
|
||||
var $label = $(e.target).attr({
|
||||
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');
|
||||
}
|
||||
} else {
|
||||
$(e.target).removeAttr('required aria-required').closest('.js-form-item, .js-form-wrapper').find('label.js-form-required').removeClass('js-form-required form-required');
|
||||
}
|
||||
}
|
||||
});
|
||||
$document.on('state:visible', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggle(e.value);
|
||||
}
|
||||
});
|
||||
$document.on('state:checked', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).closest('.js-form-item, .js-form-wrapper').find('input').prop('checked', e.value).trigger('change');
|
||||
}
|
||||
});
|
||||
$document.on('state:collapsed', function (e) {
|
||||
if (e.trigger) {
|
||||
if ($(e.target).is('[open]') === e.value) {
|
||||
$(e.target).find('> summary').trigger('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery, Drupal);
|