Chris@0: /** Chris@0: * DO NOT EDIT THIS FILE. Chris@0: * See the following change record for more information, Chris@0: * https://www.drupal.org/node/2815083 Chris@0: * @preserve Chris@0: **/ Chris@0: function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } Chris@0: Chris@0: (function ($, window, Drupal, drupalSettings) { Chris@0: Drupal.behaviors.AJAX = { Chris@0: attach: function attach(context, settings) { Chris@0: function loadAjaxBehavior(base) { Chris@14: var elementSettings = settings.ajax[base]; Chris@14: if (typeof elementSettings.selector === 'undefined') { Chris@14: elementSettings.selector = '#' + base; Chris@0: } Chris@14: $(elementSettings.selector).once('drupal-ajax').each(function () { Chris@14: elementSettings.element = this; Chris@14: elementSettings.base = base; Chris@14: Drupal.ajax(elementSettings); Chris@0: }); Chris@0: } Chris@0: Chris@14: Object.keys(settings.ajax || {}).forEach(function (base) { Chris@14: return loadAjaxBehavior(base); Chris@0: }); Chris@0: Chris@14: Drupal.ajax.bindAjaxLinks(document.body); Chris@14: Chris@0: $('.use-ajax-submit').once('ajax').each(function () { Chris@14: var elementSettings = {}; Chris@0: Chris@14: elementSettings.url = $(this.form).attr('action'); Chris@0: Chris@14: elementSettings.setClick = true; Chris@0: Chris@14: elementSettings.event = 'click'; Chris@0: Chris@14: elementSettings.progress = { type: 'throbber' }; Chris@14: elementSettings.base = $(this).attr('id'); Chris@14: elementSettings.element = this; Chris@0: Chris@14: Drupal.ajax(elementSettings); Chris@0: }); Chris@0: }, Chris@0: detach: function detach(context, settings, trigger) { Chris@0: if (trigger === 'unload') { Chris@0: Drupal.ajax.expired().forEach(function (instance) { Chris@0: Drupal.ajax.instances[instance.instanceIndex] = null; Chris@0: }); Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.AjaxError = function (xmlhttp, uri, customMessage) { Chris@0: var statusCode = void 0; Chris@0: var statusText = void 0; Chris@0: var responseText = void 0; Chris@0: if (xmlhttp.status) { Chris@0: statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status }); Chris@0: } else { Chris@0: statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.'); Chris@0: } Chris@0: statusCode += '\n' + Drupal.t('Debugging information follows.'); Chris@14: var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri }); Chris@0: statusText = ''; Chris@0: Chris@0: try { Chris@17: statusText = '\n' + Drupal.t('StatusText: !statusText', { Chris@17: '!statusText': $.trim(xmlhttp.statusText) Chris@17: }); Chris@0: } catch (e) {} Chris@0: Chris@0: responseText = ''; Chris@0: Chris@0: try { Chris@17: responseText = '\n' + Drupal.t('ResponseText: !responseText', { Chris@17: '!responseText': $.trim(xmlhttp.responseText) Chris@17: }); Chris@0: } catch (e) {} Chris@0: Chris@0: responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ''); Chris@0: responseText = responseText.replace(/[\n]+\s+/g, '\n'); Chris@0: Chris@17: var readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', { Chris@17: '!readyState': xmlhttp.readyState Chris@17: }) : ''; Chris@0: Chris@17: customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', { Chris@17: '!customMessage': customMessage Chris@17: }) : ''; Chris@0: Chris@0: this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText; Chris@0: Chris@0: this.name = 'AjaxError'; Chris@0: }; Chris@0: Chris@0: Drupal.AjaxError.prototype = new Error(); Chris@0: Drupal.AjaxError.prototype.constructor = Drupal.AjaxError; Chris@0: Chris@0: Drupal.ajax = function (settings) { Chris@0: if (arguments.length !== 1) { Chris@0: throw new Error('Drupal.ajax() function must be called with one configuration object only'); Chris@0: } Chris@0: Chris@0: var base = settings.base || false; Chris@0: var element = settings.element || false; Chris@0: delete settings.base; Chris@0: delete settings.element; Chris@0: Chris@0: if (!settings.progress && !element) { Chris@0: settings.progress = false; Chris@0: } Chris@0: Chris@0: var ajax = new Drupal.Ajax(base, element, settings); Chris@0: ajax.instanceIndex = Drupal.ajax.instances.length; Chris@0: Drupal.ajax.instances.push(ajax); Chris@0: Chris@0: return ajax; Chris@0: }; Chris@0: Chris@0: Drupal.ajax.instances = []; Chris@0: Chris@0: Drupal.ajax.expired = function () { Chris@0: return Drupal.ajax.instances.filter(function (instance) { Chris@0: return instance && instance.element !== false && !document.body.contains(instance.element); Chris@0: }); Chris@0: }; Chris@0: Chris@14: Drupal.ajax.bindAjaxLinks = function (element) { Chris@14: $(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) { Chris@14: var $linkElement = $(ajaxLink); Chris@14: Chris@14: var elementSettings = { Chris@14: progress: { type: 'throbber' }, Chris@14: dialogType: $linkElement.data('dialog-type'), Chris@14: dialog: $linkElement.data('dialog-options'), Chris@14: dialogRenderer: $linkElement.data('dialog-renderer'), Chris@14: base: $linkElement.attr('id'), Chris@14: element: ajaxLink Chris@14: }; Chris@14: var href = $linkElement.attr('href'); Chris@14: Chris@14: if (href) { Chris@14: elementSettings.url = href; Chris@14: elementSettings.event = 'click'; Chris@14: } Chris@14: Drupal.ajax(elementSettings); Chris@14: }); Chris@14: }; Chris@14: Chris@14: Drupal.Ajax = function (base, element, elementSettings) { Chris@0: var defaults = { Chris@0: event: element ? 'mousedown' : null, Chris@0: keypress: true, Chris@0: selector: base ? '#' + base : null, Chris@0: effect: 'none', Chris@0: speed: 'none', Chris@0: method: 'replaceWith', Chris@0: progress: { Chris@0: type: 'throbber', Chris@0: message: Drupal.t('Please wait...') Chris@0: }, Chris@0: submit: { Chris@0: js: true Chris@0: } Chris@0: }; Chris@0: Chris@14: $.extend(this, defaults, elementSettings); Chris@0: Chris@0: this.commands = new Drupal.AjaxCommands(); Chris@0: Chris@0: this.instanceIndex = false; Chris@0: Chris@0: if (this.wrapper) { Chris@0: this.wrapper = '#' + this.wrapper; Chris@0: } Chris@0: Chris@0: this.element = element; Chris@0: Chris@14: this.element_settings = elementSettings; Chris@14: Chris@14: this.elementSettings = elementSettings; Chris@0: Chris@0: if (this.element && this.element.form) { Chris@0: this.$form = $(this.element.form); Chris@0: } Chris@0: Chris@0: if (!this.url) { Chris@0: var $element = $(this.element); Chris@0: if ($element.is('a')) { Chris@0: this.url = $element.attr('href'); Chris@0: } else if (this.element && element.form) { Chris@0: this.url = this.$form.attr('action'); Chris@0: } Chris@0: } Chris@0: Chris@0: var originalUrl = this.url; Chris@0: Chris@17: this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1'); Chris@0: Chris@0: if (drupalSettings.ajaxTrustedUrl[originalUrl]) { Chris@0: drupalSettings.ajaxTrustedUrl[this.url] = true; Chris@0: } Chris@0: Chris@0: var ajax = this; Chris@0: Chris@0: ajax.options = { Chris@0: url: ajax.url, Chris@0: data: ajax.submit, Chris@14: beforeSerialize: function beforeSerialize(elementSettings, options) { Chris@14: return ajax.beforeSerialize(elementSettings, options); Chris@0: }, Chris@14: beforeSubmit: function beforeSubmit(formValues, elementSettings, options) { Chris@0: ajax.ajaxing = true; Chris@14: return ajax.beforeSubmit(formValues, elementSettings, options); Chris@0: }, Chris@0: beforeSend: function beforeSend(xmlhttprequest, options) { Chris@0: ajax.ajaxing = true; Chris@0: return ajax.beforeSend(xmlhttprequest, options); Chris@0: }, Chris@0: success: function success(response, status, xmlhttprequest) { Chris@0: if (typeof response === 'string') { Chris@0: response = $.parseJSON(response); Chris@0: } Chris@0: Chris@0: if (response !== null && !drupalSettings.ajaxTrustedUrl[ajax.url]) { Chris@0: if (xmlhttprequest.getResponseHeader('X-Drupal-Ajax-Token') !== '1') { Chris@0: var customMessage = Drupal.t('The response failed verification so will not be processed.'); Chris@0: return ajax.error(xmlhttprequest, ajax.url, customMessage); Chris@0: } Chris@0: } Chris@0: Chris@0: return ajax.success(response, status); Chris@0: }, Chris@0: complete: function complete(xmlhttprequest, status) { Chris@0: ajax.ajaxing = false; Chris@0: if (status === 'error' || status === 'parsererror') { Chris@0: return ajax.error(xmlhttprequest, ajax.url); Chris@0: } Chris@0: }, Chris@0: Chris@0: dataType: 'json', Chris@0: type: 'POST' Chris@0: }; Chris@0: Chris@14: if (elementSettings.dialog) { Chris@14: ajax.options.data.dialogOptions = elementSettings.dialog; Chris@0: } Chris@0: Chris@0: if (ajax.options.url.indexOf('?') === -1) { Chris@0: ajax.options.url += '?'; Chris@0: } else { Chris@0: ajax.options.url += '&'; Chris@0: } Chris@0: Chris@14: var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax'); Chris@14: if (elementSettings.dialogRenderer) { Chris@14: wrapper += '.' + elementSettings.dialogRenderer; Chris@0: } Chris@0: ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=' + wrapper; Chris@0: Chris@14: $(ajax.element).on(elementSettings.event, function (event) { Chris@0: if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) { Chris@17: throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', { Chris@17: '!url': ajax.url Chris@17: })); Chris@0: } Chris@0: return ajax.eventResponse(this, event); Chris@0: }); Chris@0: Chris@14: if (elementSettings.keypress) { Chris@0: $(ajax.element).on('keypress', function (event) { Chris@0: return ajax.keypressResponse(this, event); Chris@0: }); Chris@0: } Chris@0: Chris@14: if (elementSettings.prevent) { Chris@14: $(ajax.element).on(elementSettings.prevent, false); Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; Chris@0: Chris@0: Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax'; Chris@0: Chris@0: Drupal.Ajax.prototype.execute = function () { Chris@0: if (this.ajaxing) { Chris@0: return; Chris@0: } Chris@0: Chris@0: try { Chris@0: this.beforeSerialize(this.element, this.options); Chris@0: Chris@0: return $.ajax(this.options); Chris@0: } catch (e) { Chris@0: this.ajaxing = false; Chris@0: window.alert('An error occurred while attempting to process ' + this.options.url + ': ' + e.message); Chris@0: Chris@0: return $.Deferred().reject(); Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.keypressResponse = function (element, event) { Chris@0: var ajax = this; Chris@0: Chris@0: if (event.which === 13 || event.which === 32 && element.type !== 'text' && element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number') { Chris@0: event.preventDefault(); Chris@0: event.stopPropagation(); Chris@14: $(element).trigger(ajax.elementSettings.event); Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.eventResponse = function (element, event) { Chris@0: event.preventDefault(); Chris@0: event.stopPropagation(); Chris@0: Chris@0: var ajax = this; Chris@0: Chris@0: if (ajax.ajaxing) { Chris@0: return; Chris@0: } Chris@0: Chris@0: try { Chris@0: if (ajax.$form) { Chris@0: if (ajax.setClick) { Chris@0: element.form.clk = element; Chris@0: } Chris@0: Chris@0: ajax.$form.ajaxSubmit(ajax.options); Chris@0: } else { Chris@0: ajax.beforeSerialize(ajax.element, ajax.options); Chris@0: $.ajax(ajax.options); Chris@0: } Chris@0: } catch (e) { Chris@0: ajax.ajaxing = false; Chris@0: window.alert('An error occurred while attempting to process ' + ajax.options.url + ': ' + e.message); Chris@0: } Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.beforeSerialize = function (element, options) { Chris@17: if (this.$form && document.body.contains(this.$form.get(0))) { Chris@0: var settings = this.settings || drupalSettings; Chris@0: Drupal.detachBehaviors(this.$form.get(0), settings, 'serialize'); Chris@0: } Chris@0: Chris@0: options.data[Drupal.Ajax.AJAX_REQUEST_PARAMETER] = 1; Chris@0: Chris@0: var pageState = drupalSettings.ajaxPageState; Chris@0: options.data['ajax_page_state[theme]'] = pageState.theme; Chris@0: options.data['ajax_page_state[theme_token]'] = pageState.theme_token; Chris@0: options.data['ajax_page_state[libraries]'] = pageState.libraries; Chris@0: }; Chris@0: Chris@14: Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) {}; Chris@0: Chris@0: Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) { Chris@0: if (this.$form) { Chris@0: options.extraData = options.extraData || {}; Chris@0: Chris@0: options.extraData.ajax_iframe_upload = '1'; Chris@0: Chris@0: var v = $.fieldValue(this.element); Chris@0: if (v !== null) { Chris@0: options.extraData[this.element.name] = v; Chris@0: } Chris@0: } Chris@0: Chris@0: $(this.element).prop('disabled', true); Chris@0: Chris@0: if (!this.progress || !this.progress.type) { Chris@0: return; Chris@0: } Chris@0: Chris@0: var progressIndicatorMethod = 'setProgressIndicator' + this.progress.type.slice(0, 1).toUpperCase() + this.progress.type.slice(1).toLowerCase(); Chris@0: if (progressIndicatorMethod in this && typeof this[progressIndicatorMethod] === 'function') { Chris@0: this[progressIndicatorMethod].call(this); Chris@0: } Chris@0: }; Chris@0: Chris@17: Drupal.theme.ajaxProgressThrobber = function (message) { Chris@17: var messageMarkup = typeof message === 'string' ? Drupal.theme('ajaxProgressMessage', message) : ''; Chris@17: var throbber = '
 
'; Chris@17: Chris@17: return '
' + throbber + messageMarkup + '
'; Chris@17: }; Chris@17: Chris@17: Drupal.theme.ajaxProgressIndicatorFullscreen = function () { Chris@17: return '
 
'; Chris@17: }; Chris@17: Chris@17: Drupal.theme.ajaxProgressMessage = function (message) { Chris@17: return '
' + message + '
'; Chris@17: }; Chris@17: Chris@0: Drupal.Ajax.prototype.setProgressIndicatorBar = function () { Chris@0: var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop); Chris@0: if (this.progress.message) { Chris@0: progressBar.setProgress(-1, this.progress.message); Chris@0: } Chris@0: if (this.progress.url) { Chris@0: progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500); Chris@0: } Chris@0: this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar'); Chris@0: this.progress.object = progressBar; Chris@0: $(this.element).after(this.progress.element); Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.setProgressIndicatorThrobber = function () { Chris@17: this.progress.element = $(Drupal.theme('ajaxProgressThrobber', this.progress.message)); Chris@0: $(this.element).after(this.progress.element); Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.setProgressIndicatorFullscreen = function () { Chris@17: this.progress.element = $(Drupal.theme('ajaxProgressIndicatorFullscreen')); Chris@0: $('body').after(this.progress.element); Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.success = function (response, status) { Chris@14: var _this = this; Chris@14: Chris@0: if (this.progress.element) { Chris@0: $(this.progress.element).remove(); Chris@0: } Chris@0: if (this.progress.object) { Chris@0: this.progress.object.stopMonitoring(); Chris@0: } Chris@0: $(this.element).prop('disabled', false); Chris@0: Chris@0: var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray(); Chris@0: Chris@0: var focusChanged = false; Chris@14: Object.keys(response || {}).forEach(function (i) { Chris@14: if (response[i].command && _this.commands[response[i].command]) { Chris@14: _this.commands[response[i].command](_this, response[i], status); Chris@0: if (response[i].command === 'invoke' && response[i].method === 'focus') { Chris@0: focusChanged = true; Chris@0: } Chris@0: } Chris@14: }); Chris@0: Chris@0: if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) { Chris@0: var target = false; Chris@0: Chris@17: for (var n = elementParents.length - 1; !target && n >= 0; n--) { Chris@0: target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]'); Chris@0: } Chris@0: Chris@0: if (target) { Chris@0: $(target).trigger('focus'); Chris@0: } Chris@0: } Chris@0: Chris@17: if (this.$form && document.body.contains(this.$form.get(0))) { Chris@0: var settings = this.settings || drupalSettings; Chris@0: Drupal.attachBehaviors(this.$form.get(0), settings); Chris@0: } Chris@0: Chris@0: this.settings = null; Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.getEffect = function (response) { Chris@0: var type = response.effect || this.effect; Chris@0: var speed = response.speed || this.speed; Chris@0: Chris@0: var effect = {}; Chris@0: if (type === 'none') { Chris@0: effect.showEffect = 'show'; Chris@0: effect.hideEffect = 'hide'; Chris@0: effect.showSpeed = ''; Chris@0: } else if (type === 'fade') { Chris@0: effect.showEffect = 'fadeIn'; Chris@0: effect.hideEffect = 'fadeOut'; Chris@0: effect.showSpeed = speed; Chris@0: } else { Chris@0: effect.showEffect = type + 'Toggle'; Chris@0: effect.hideEffect = type + 'Toggle'; Chris@0: effect.showSpeed = speed; Chris@0: } Chris@0: Chris@0: return effect; Chris@0: }; Chris@0: Chris@0: Drupal.Ajax.prototype.error = function (xmlhttprequest, uri, customMessage) { Chris@0: if (this.progress.element) { Chris@0: $(this.progress.element).remove(); Chris@0: } Chris@0: if (this.progress.object) { Chris@0: this.progress.object.stopMonitoring(); Chris@0: } Chris@0: Chris@0: $(this.wrapper).show(); Chris@0: Chris@0: $(this.element).prop('disabled', false); Chris@0: Chris@17: if (this.$form && document.body.contains(this.$form.get(0))) { Chris@0: var settings = this.settings || drupalSettings; Chris@0: Drupal.attachBehaviors(this.$form.get(0), settings); Chris@0: } Chris@0: throw new Drupal.AjaxError(xmlhttprequest, uri, customMessage); Chris@0: }; Chris@0: Chris@17: Drupal.theme.ajaxWrapperNewContent = function ($newContent, ajax, response) { Chris@17: return (response.effect || ajax.effect) !== 'none' && $newContent.filter(function (i) { Chris@17: return !($newContent[i].nodeName === '#comment' || $newContent[i].nodeName === '#text' && /^(\s|\n|\r)*$/.test($newContent[i].textContent)); Chris@17: }).length > 1 ? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent) : $newContent; Chris@17: }; Chris@17: Chris@17: Drupal.theme.ajaxWrapperMultipleRootElements = function ($elements) { Chris@17: return $('
').append($elements); Chris@17: }; Chris@17: Chris@0: Drupal.AjaxCommands = function () {}; Chris@0: Drupal.AjaxCommands.prototype = { Chris@17: insert: function insert(ajax, response) { Chris@0: var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); Chris@0: var method = response.method || ajax.method; Chris@0: var effect = ajax.getEffect(response); Chris@0: Chris@17: var settings = response.settings || ajax.settings || drupalSettings; Chris@0: Chris@17: var $newContent = $($.parseHTML(response.data, document, true)); Chris@17: Chris@17: $newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response); Chris@0: Chris@0: switch (method) { Chris@0: case 'html': Chris@0: case 'replaceWith': Chris@0: case 'replaceAll': Chris@0: case 'empty': Chris@0: case 'remove': Chris@0: Drupal.detachBehaviors($wrapper.get(0), settings); Chris@17: break; Chris@17: default: Chris@17: break; Chris@0: } Chris@0: Chris@14: $wrapper[method]($newContent); Chris@0: Chris@0: if (effect.showEffect !== 'show') { Chris@14: $newContent.hide(); Chris@0: } Chris@0: Chris@17: var $ajaxNewContent = $newContent.find('.ajax-new-content'); Chris@17: if ($ajaxNewContent.length) { Chris@17: $ajaxNewContent.hide(); Chris@14: $newContent.show(); Chris@17: $ajaxNewContent[effect.showEffect](effect.showSpeed); Chris@0: } else if (effect.showEffect !== 'show') { Chris@14: $newContent[effect.showEffect](effect.showSpeed); Chris@0: } Chris@0: Chris@17: if ($newContent.parents('html').length) { Chris@17: $newContent.each(function (index, element) { Chris@17: if (element.nodeType === Node.ELEMENT_NODE) { Chris@17: Drupal.attachBehaviors(element, settings); Chris@17: } Chris@17: }); Chris@0: } Chris@0: }, Chris@0: remove: function remove(ajax, response, status) { Chris@0: var settings = response.settings || ajax.settings || drupalSettings; Chris@0: $(response.selector).each(function () { Chris@0: Drupal.detachBehaviors(this, settings); Chris@0: }).remove(); Chris@0: }, Chris@0: changed: function changed(ajax, response, status) { Chris@0: var $element = $(response.selector); Chris@0: if (!$element.hasClass('ajax-changed')) { Chris@0: $element.addClass('ajax-changed'); Chris@0: if (response.asterisk) { Chris@0: $element.find(response.asterisk).append(' * '); Chris@0: } Chris@0: } Chris@0: }, Chris@0: alert: function alert(ajax, response, status) { Chris@0: window.alert(response.text, response.title); Chris@0: }, Chris@18: announce: function announce(ajax, response) { Chris@18: if (response.priority) { Chris@18: Drupal.announce(response.text, response.priority); Chris@18: } else { Chris@18: Drupal.announce(response.text); Chris@18: } Chris@18: }, Chris@0: redirect: function redirect(ajax, response, status) { Chris@0: window.location = response.url; Chris@0: }, Chris@0: css: function css(ajax, response, status) { Chris@0: $(response.selector).css(response.argument); Chris@0: }, Chris@0: settings: function settings(ajax, response, status) { Chris@0: var ajaxSettings = drupalSettings.ajax; Chris@0: Chris@0: if (ajaxSettings) { Chris@0: Drupal.ajax.expired().forEach(function (instance) { Chris@0: Chris@0: if (instance.selector) { Chris@0: var selector = instance.selector.replace('#', ''); Chris@0: if (selector in ajaxSettings) { Chris@0: delete ajaxSettings[selector]; Chris@0: } Chris@0: } Chris@0: }); Chris@0: } Chris@0: Chris@0: if (response.merge) { Chris@0: $.extend(true, drupalSettings, response.settings); Chris@0: } else { Chris@0: ajax.settings = response.settings; Chris@0: } Chris@0: }, Chris@0: data: function data(ajax, response, status) { Chris@0: $(response.selector).data(response.name, response.value); Chris@0: }, Chris@0: invoke: function invoke(ajax, response, status) { Chris@0: var $element = $(response.selector); Chris@0: $element[response.method].apply($element, _toConsumableArray(response.args)); Chris@0: }, Chris@0: restripe: function restripe(ajax, response, status) { Chris@0: $(response.selector).find('> tbody > tr:visible, > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even'); Chris@0: }, Chris@0: update_build_id: function update_build_id(ajax, response, status) { Chris@0: $('input[name="form_build_id"][value="' + response.old + '"]').val(response.new); Chris@0: }, Chris@0: add_css: function add_css(ajax, response, status) { Chris@0: $('head').prepend(response.data); Chris@0: Chris@0: var match = void 0; Chris@17: var importMatch = /^@import url\("(.*)"\);$/gim; Chris@0: if (document.styleSheets[0].addImport && importMatch.test(response.data)) { Chris@0: importMatch.lastIndex = 0; Chris@0: do { Chris@0: match = importMatch.exec(response.data); Chris@0: document.styleSheets[0].addImport(match[1]); Chris@0: } while (match); Chris@0: } Chris@0: } Chris@0: }; Chris@0: })(jQuery, window, Drupal, drupalSettings);