Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -19,6 +19,14 @@
|
|||
* Attaches the Ajax behavior to each Ajax form element.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Initialize all {@link Drupal.Ajax} objects declared in
|
||||
* `drupalSettings.ajax` or initialize {@link Drupal.Ajax} objects from
|
||||
* DOM elements having the `use-ajax-submit` or `use-ajax` css class.
|
||||
* @prop {Drupal~behaviorDetach} detach
|
||||
* During `unload` remove all {@link Drupal.Ajax} objects related to
|
||||
* the removed content.
|
||||
*/
|
||||
Drupal.behaviors.AJAX = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -50,8 +58,9 @@
|
|||
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
if ($(this).attr('href')) {
|
||||
element_settings.url = $(this).attr('href');
|
||||
var href = $(this).attr('href');
|
||||
if (href) {
|
||||
element_settings.url = href;
|
||||
element_settings.event = 'click';
|
||||
}
|
||||
element_settings.dialogType = $(this).data('dialog-type');
|
||||
|
@ -81,6 +90,16 @@
|
|||
|
||||
Drupal.ajax(element_settings);
|
||||
});
|
||||
},
|
||||
|
||||
detach: function (context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
Drupal.ajax.expired().forEach(function (instance) {
|
||||
// Set this to null and allow garbage collection to reclaim
|
||||
// the memory.
|
||||
Drupal.ajax.instances[instance.instanceIndex] = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,6 +228,7 @@
|
|||
* event listeners will be bound.
|
||||
*
|
||||
* @return {Drupal.Ajax}
|
||||
* The created Ajax object.
|
||||
*
|
||||
* @see Drupal.AjaxCommands
|
||||
*/
|
||||
|
@ -237,10 +257,65 @@
|
|||
/**
|
||||
* Contains all created Ajax objects.
|
||||
*
|
||||
* @type {Array.<Drupal.Ajax>}
|
||||
* @type {Array.<Drupal.Ajax|null>}
|
||||
*/
|
||||
Drupal.ajax.instances = [];
|
||||
|
||||
/**
|
||||
* List all objects where the associated element is not in the DOM
|
||||
*
|
||||
* This method ignores {@link Drupal.Ajax} objects not bound to DOM elements
|
||||
* when created with {@link Drupal.ajax}.
|
||||
*
|
||||
* @return {Array.<Drupal.Ajax>}
|
||||
* The list of expired {@link Drupal.Ajax} objects.
|
||||
*/
|
||||
Drupal.ajax.expired = function () {
|
||||
return Drupal.ajax.instances.filter(function (instance) {
|
||||
return instance && instance.element !== false && !document.body.contains(instance.element);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Settings for an Ajax object.
|
||||
*
|
||||
* @typedef {object} Drupal.Ajax~element_settings
|
||||
*
|
||||
* @prop {string} url
|
||||
* Target of the Ajax request.
|
||||
* @prop {?string} [event]
|
||||
* Event bound to settings.element which will trigger the Ajax request.
|
||||
* @prop {bool} [keypress=true]
|
||||
* Triggers a request on keypress events.
|
||||
* @prop {?string} selector
|
||||
* jQuery selector targeting the element to bind events to or used with
|
||||
* {@link Drupal.AjaxCommands}.
|
||||
* @prop {string} [effect='none']
|
||||
* Name of the jQuery method to use for displaying new Ajax content.
|
||||
* @prop {string|number} [speed='none']
|
||||
* Speed with which to apply the effect.
|
||||
* @prop {string} [method]
|
||||
* Name of the jQuery method used to insert new content in the targeted
|
||||
* element.
|
||||
* @prop {object} [progress]
|
||||
* Settings for the display of a user-friendly loader.
|
||||
* @prop {string} [progress.type='throbber']
|
||||
* Type of progress element, core provides `'bar'`, `'throbber'` and
|
||||
* `'fullscreen'`.
|
||||
* @prop {string} [progress.message=Drupal.t('Please wait...')]
|
||||
* Custom message to be used with the bar indicator.
|
||||
* @prop {object} [submit]
|
||||
* Extra data to be sent with the Ajax request.
|
||||
* @prop {bool} [submit.js=true]
|
||||
* Allows the PHP side to know this comes from an Ajax request.
|
||||
* @prop {object} [dialog]
|
||||
* Options for {@link Drupal.dialog}.
|
||||
* @prop {string} [dialogType]
|
||||
* One of `'modal'` or `'dialog'`.
|
||||
* @prop {string} [prevent]
|
||||
* List of events on which to stop default action and stop propagation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ajax constructor.
|
||||
*
|
||||
|
@ -258,14 +333,8 @@
|
|||
* @param {HTMLElement} [element]
|
||||
* Element parameter of {@link Drupal.Ajax} constructor, element on which
|
||||
* event listeners will be bound.
|
||||
* @param {object} element_settings
|
||||
* @param {string} element_settings.url
|
||||
* Target of the Ajax request.
|
||||
* @param {string} [element_settings.event]
|
||||
* Event bound to settings.element which will trigger the Ajax request.
|
||||
* @param {string} [element_settings.method]
|
||||
* Name of the jQuery method used to insert new content in the targeted
|
||||
* element.
|
||||
* @param {Drupal.Ajax~element_settings} element_settings
|
||||
* Settings for this Ajax object.
|
||||
*/
|
||||
Drupal.Ajax = function (base, element, element_settings) {
|
||||
var defaults = {
|
||||
|
@ -290,6 +359,10 @@
|
|||
* @type {Drupal.AjaxCommands}
|
||||
*/
|
||||
this.commands = new Drupal.AjaxCommands();
|
||||
|
||||
/**
|
||||
* @type {bool|number}
|
||||
*/
|
||||
this.instanceIndex = false;
|
||||
|
||||
// @todo Remove this after refactoring the PHP code to:
|
||||
|
@ -310,7 +383,7 @@
|
|||
this.element = element;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
* @type {Drupal.Ajax~element_settings}
|
||||
*/
|
||||
this.element_settings = element_settings;
|
||||
|
||||
|
@ -343,6 +416,12 @@
|
|||
// 3. /nojs? - Followed by a query (e.g. path/nojs?destination=foobar).
|
||||
// 4. /nojs# - Followed by a fragment (e.g.: path/nojs#myfragment).
|
||||
var originalUrl = this.url;
|
||||
|
||||
/**
|
||||
* Processed Ajax URL.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.url = this.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1');
|
||||
// If the 'nojs' version of the URL is trusted, also trust the 'ajax'
|
||||
// version.
|
||||
|
@ -355,23 +434,35 @@
|
|||
var ajax = this;
|
||||
|
||||
/**
|
||||
* Options for the ajaxSubmit function.
|
||||
* Options for the jQuery.ajax function.
|
||||
*
|
||||
* @name Drupal.Ajax#options
|
||||
*
|
||||
* @type {object}
|
||||
*
|
||||
* @prop {string} url
|
||||
* Ajax URL to be called.
|
||||
* @prop {object} data
|
||||
* Ajax payload.
|
||||
* @prop {function} beforeSerialize
|
||||
* Implement jQuery beforeSerialize function to call
|
||||
* {@link Drupal.Ajax#beforeSerialize}.
|
||||
* @prop {function} beforeSubmit
|
||||
* Implement jQuery beforeSubmit function to call
|
||||
* {@link Drupal.Ajax#beforeSubmit}.
|
||||
* @prop {function} beforeSend
|
||||
* Implement jQuery beforeSend function to call
|
||||
* {@link Drupal.Ajax#beforeSend}.
|
||||
* @prop {function} success
|
||||
* Implement jQuery success function to call
|
||||
* {@link Drupal.Ajax#success}.
|
||||
* @prop {function} complete
|
||||
* @prop {string} dataType
|
||||
* @prop {object} accepts
|
||||
* @prop {string} accepts.json
|
||||
* @prop {string} type
|
||||
* Implement jQuery success function to clean up ajax state and trigger an
|
||||
* error if needed.
|
||||
* @prop {string} dataType='json'
|
||||
* Type of the response expected.
|
||||
* @prop {string} type='POST'
|
||||
* HTTP method to use for the Ajax request.
|
||||
*/
|
||||
ajax.options = {
|
||||
url: ajax.url,
|
||||
|
@ -469,13 +560,17 @@
|
|||
* modal dialog.
|
||||
*
|
||||
* @const {string}
|
||||
*
|
||||
* @default
|
||||
*/
|
||||
Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format';
|
||||
|
||||
/**
|
||||
* Request parameter to indicate that a request is a Drupal Ajax request.
|
||||
*
|
||||
* @const
|
||||
* @const {string}
|
||||
*
|
||||
* @default
|
||||
*/
|
||||
Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax';
|
||||
|
||||
|
@ -484,6 +579,11 @@
|
|||
*
|
||||
* Allows developers to execute an Ajax request manually without specifying
|
||||
* an event to respond to.
|
||||
*
|
||||
* @return {object}
|
||||
* Returns the jQuery.Deferred object underlying the Ajax request. If
|
||||
* pre-serialization fails, the Deferred will be returned in the rejected
|
||||
* state.
|
||||
*/
|
||||
Drupal.Ajax.prototype.execute = function () {
|
||||
// Do not perform another ajax command if one is already in progress.
|
||||
|
@ -493,13 +593,17 @@
|
|||
|
||||
try {
|
||||
this.beforeSerialize(this.element, this.options);
|
||||
$.ajax(this.options);
|
||||
// Return the jqXHR so that external code can hook into the Deferred API.
|
||||
return $.ajax(this.options);
|
||||
}
|
||||
catch (e) {
|
||||
// Unset the ajax.ajaxing flag here because it won't be unset during
|
||||
// the complete response.
|
||||
this.ajaxing = false;
|
||||
window.alert('An error occurred while attempting to process ' + this.options.url + ': ' + e.message);
|
||||
// For consistency, return a rejected Deferred (i.e., jqXHR's superclass)
|
||||
// so that calling code can take appropriate action.
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -514,7 +618,9 @@
|
|||
* SPACE is often used to activate an element without submitting.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* Element the event was triggered on.
|
||||
* @param {jQuery.Event} event
|
||||
* Triggered event.
|
||||
*/
|
||||
Drupal.Ajax.prototype.keypressResponse = function (element, event) {
|
||||
// Create a synonym for this to reduce code confusion.
|
||||
|
@ -542,7 +648,9 @@
|
|||
* Ajax object.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* Element the event was triggered on.
|
||||
* @param {jQuery.Event} event
|
||||
* Triggered event.
|
||||
*/
|
||||
Drupal.Ajax.prototype.eventResponse = function (element, event) {
|
||||
event.preventDefault();
|
||||
|
@ -589,9 +697,10 @@
|
|||
* Runs before the beforeSend() handler (see below), and unlike that one, runs
|
||||
* before field data is collected.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @param {object} [element]
|
||||
* Ajax object's `element_settings`.
|
||||
* @param {object} options
|
||||
* @param {object} options.data
|
||||
* jQuery.ajax options.
|
||||
*/
|
||||
Drupal.Ajax.prototype.beforeSerialize = function (element, options) {
|
||||
// Allow detaching behaviors to update field values before collecting them.
|
||||
|
@ -621,9 +730,12 @@
|
|||
/**
|
||||
* Modify form values prior to form submission.
|
||||
*
|
||||
* @param {object} form_values
|
||||
* @param {HTMLElement} element
|
||||
* @param {Array.<object>} form_values
|
||||
* Processed form values.
|
||||
* @param {jQuery} element
|
||||
* The form node as a jQuery object.
|
||||
* @param {object} options
|
||||
* jQuery.ajax options.
|
||||
*/
|
||||
Drupal.Ajax.prototype.beforeSubmit = function (form_values, element, options) {
|
||||
// This function is left empty to make it simple to override for modules
|
||||
|
@ -634,8 +746,9 @@
|
|||
* Prepare the Ajax request before it is sent.
|
||||
*
|
||||
* @param {XMLHttpRequest} xmlhttprequest
|
||||
* Native Ajax object.
|
||||
* @param {object} options
|
||||
* @param {object} options.extraData
|
||||
* jQuery.ajax options.
|
||||
*/
|
||||
Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) {
|
||||
// For forms without file inputs, the jQuery Form plugin serializes the
|
||||
|
@ -723,7 +836,9 @@
|
|||
* Handler for the form redirection completion.
|
||||
*
|
||||
* @param {Array.<Drupal.AjaxCommands~commandDefinition>} response
|
||||
* Drupal Ajax response.
|
||||
* @param {number} status
|
||||
* XMLHttpRequest status.
|
||||
*/
|
||||
Drupal.Ajax.prototype.success = function (response, status) {
|
||||
// Remove the progress element.
|
||||
|
@ -786,10 +901,15 @@
|
|||
* Build an effect object to apply an effect when adding new HTML.
|
||||
*
|
||||
* @param {object} response
|
||||
* Drupal Ajax response.
|
||||
* @param {string} [response.effect]
|
||||
* Override the default value of {@link Drupal.Ajax#element_settings}.
|
||||
* @param {string|number} [response.speed]
|
||||
* Override the default value of {@link Drupal.Ajax#element_settings}.
|
||||
*
|
||||
* @return {object}
|
||||
* Returns an object with `showEffect`, `hideEffect` and `showSpeed`
|
||||
* properties.
|
||||
*/
|
||||
Drupal.Ajax.prototype.getEffect = function (response) {
|
||||
var type = response.effect || this.effect;
|
||||
|
@ -819,8 +939,11 @@
|
|||
* Handler for the form redirection error.
|
||||
*
|
||||
* @param {object} xmlhttprequest
|
||||
* Native XMLHttpRequest object.
|
||||
* @param {string} uri
|
||||
* @param {string} customMessage
|
||||
* Ajax Request URI.
|
||||
* @param {string} [customMessage]
|
||||
* Extra message to print with the Ajax error.
|
||||
*/
|
||||
Drupal.Ajax.prototype.error = function (xmlhttprequest, uri, customMessage) {
|
||||
// Remove the progress element.
|
||||
|
@ -877,17 +1000,24 @@
|
|||
* Command to insert new content into the DOM.
|
||||
*
|
||||
* @param {Drupal.Ajax} ajax
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.data
|
||||
* The data to use with the jQuery method.
|
||||
* @param {string} [response.method]
|
||||
* The jQuery DOM manipulation method to be used.
|
||||
* @param {string} [response.selector]
|
||||
* A optional jQuery selector string.
|
||||
* @param {object} [response.settings]
|
||||
* An optional array of settings that will be used.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
insert: function (ajax, response, status) {
|
||||
// Get information from the response. If it is not there, default to
|
||||
// our presets.
|
||||
var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
|
||||
var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
|
||||
var method = response.method || ajax.method;
|
||||
var effect = ajax.getEffect(response);
|
||||
var settings;
|
||||
|
@ -897,11 +1027,11 @@
|
|||
// $(response.data) as new HTML rather than a CSS selector. Also, if
|
||||
// response.data contains top-level text nodes, they get lost with either
|
||||
// $(response.data) or $('<div></div>').replaceWith(response.data).
|
||||
var new_content_wrapped = $('<div></div>').html(response.data);
|
||||
var new_content = new_content_wrapped.contents();
|
||||
var $new_content_wrapped = $('<div></div>').html(response.data);
|
||||
var $new_content = $new_content_wrapped.contents();
|
||||
|
||||
// For legacy reasons, the effects processing code assumes that
|
||||
// new_content consists of a single top-level element. Also, it has not
|
||||
// $new_content consists of a single top-level element. Also, it has not
|
||||
// been sufficiently tested whether attachBehaviors() can be successfully
|
||||
// called with a context object that includes top-level text nodes.
|
||||
// However, to give developers full control of the HTML appearing in the
|
||||
|
@ -911,8 +1041,8 @@
|
|||
// top-level element, and only use the container DIV created above when
|
||||
// it doesn't. For more information, please see
|
||||
// https://www.drupal.org/node/736066.
|
||||
if (new_content.length !== 1 || new_content.get(0).nodeType !== 1) {
|
||||
new_content = new_content_wrapped;
|
||||
if ($new_content.length !== 1 || $new_content.get(0).nodeType !== 1) {
|
||||
$new_content = $new_content_wrapped;
|
||||
}
|
||||
|
||||
// If removing content from the wrapper, detach behaviors first.
|
||||
|
@ -923,35 +1053,35 @@
|
|||
case 'empty':
|
||||
case 'remove':
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.detachBehaviors(wrapper.get(0), settings);
|
||||
Drupal.detachBehaviors($wrapper.get(0), settings);
|
||||
}
|
||||
|
||||
// Add the new content to the page.
|
||||
wrapper[method](new_content);
|
||||
$wrapper[method]($new_content);
|
||||
|
||||
// Immediately hide the new content if we're using any effects.
|
||||
if (effect.showEffect !== 'show') {
|
||||
new_content.hide();
|
||||
$new_content.hide();
|
||||
}
|
||||
|
||||
// Determine which effect to use and what content will receive the
|
||||
// effect, then show the new content.
|
||||
if (new_content.find('.ajax-new-content').length > 0) {
|
||||
new_content.find('.ajax-new-content').hide();
|
||||
new_content.show();
|
||||
new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
if ($new_content.find('.ajax-new-content').length > 0) {
|
||||
$new_content.find('.ajax-new-content').hide();
|
||||
$new_content.show();
|
||||
$new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
else if (effect.showEffect !== 'show') {
|
||||
new_content[effect.showEffect](effect.showSpeed);
|
||||
$new_content[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
|
||||
// Attach all JavaScript behaviors to the new content, if it was
|
||||
// successfully added to the page, this if statement allows
|
||||
// `#ajax['wrapper']` to be optional.
|
||||
if (new_content.parents('html').length > 0) {
|
||||
if ($new_content.parents('html').length > 0) {
|
||||
// Apply any settings from the returned JSON if available.
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(new_content.get(0), settings);
|
||||
Drupal.attachBehaviors($new_content.get(0), settings);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -959,10 +1089,15 @@
|
|||
* Command to remove a chunk from the page.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {object} [response.settings]
|
||||
* An optional array of settings that will be used.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
remove: function (ajax, response, status) {
|
||||
var settings = response.settings || ajax.settings || drupalSettings;
|
||||
|
@ -976,16 +1111,23 @@
|
|||
* Command to mark a chunk changed.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The JSON response object from the Ajax request.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {bool} [response.asterisk]
|
||||
* An optional CSS selector. If specified, an asterisk will be
|
||||
* appended to the HTML inside the provided selector.
|
||||
* @param {number} [status]
|
||||
* The request status.
|
||||
*/
|
||||
changed: function (ajax, response, status) {
|
||||
if (!$(response.selector).hasClass('ajax-changed')) {
|
||||
$(response.selector).addClass('ajax-changed');
|
||||
var $element = $(response.selector);
|
||||
if (!$element.hasClass('ajax-changed')) {
|
||||
$element.addClass('ajax-changed');
|
||||
if (response.asterisk) {
|
||||
$(response.selector).find(response.asterisk).append(' <abbr class="ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr> ');
|
||||
$element.find(response.asterisk).append(' <abbr class="ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr> ');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -994,10 +1136,13 @@
|
|||
* Command to provide an alert.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The JSON response from the Ajax request.
|
||||
* @param {string} response.text
|
||||
* @param {string} response.title
|
||||
* The text that will be displayed in an alert dialog.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
alert: function (ajax, response, status) {
|
||||
window.alert(response.text, response.title);
|
||||
|
@ -1007,9 +1152,13 @@
|
|||
* Command to set the window.location, redirecting the browser.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.url
|
||||
* The URL to redirect to.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
redirect: function (ajax, response, status) {
|
||||
window.location = response.url;
|
||||
|
@ -1019,9 +1168,15 @@
|
|||
* Command to provide the jQuery css() function.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {object} response.argument
|
||||
* An array of key/value pairs to set in the CSS for the selector.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
css: function (ajax, response, status) {
|
||||
$(response.selector).css(response.argument);
|
||||
|
@ -1030,13 +1185,37 @@
|
|||
/**
|
||||
* Command to set the settings used for other commands in this response.
|
||||
*
|
||||
* This method will also remove expired `drupalSettings.ajax` settings.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {bool} response.merge
|
||||
* Determines whether the additional settings should be merged to the
|
||||
* global settings.
|
||||
* @param {object} response.settings
|
||||
* Contains additional settings to add to the global settings.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
settings: function (ajax, response, status) {
|
||||
var ajaxSettings = drupalSettings.ajax;
|
||||
|
||||
// Clean up drupalSettings.ajax.
|
||||
Drupal.ajax.expired().forEach(function (instance) {
|
||||
// If the Ajax object has been created through drupalSettings.ajax
|
||||
// it will have a selector. When there is no selector the object
|
||||
// has been initialized with a special class name picked up by the
|
||||
// Ajax behavior.
|
||||
if (instance.selector) {
|
||||
var selector = instance.selector.replace('#', '');
|
||||
if (selector in ajaxSettings) {
|
||||
delete ajaxSettings[selector];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (response.merge) {
|
||||
$.extend(true, drupalSettings, response.settings);
|
||||
}
|
||||
|
@ -1049,11 +1228,18 @@
|
|||
* Command to attach data using jQuery's data API.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.name
|
||||
* The name or key (in the key value pair) of the data attached to this
|
||||
* selector.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {string|object} response.value
|
||||
* The value of to be attached.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
data: function (ajax, response, status) {
|
||||
$(response.selector).data(response.name, response.value);
|
||||
|
@ -1063,11 +1249,17 @@
|
|||
* Command to apply a jQuery method.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {Array} response.args
|
||||
* An array of arguments to the jQuery method, if any.
|
||||
* @param {string} response.method
|
||||
* The jQuery method to invoke.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
invoke: function (ajax, response, status) {
|
||||
var $element = $(response.selector);
|
||||
|
@ -1078,9 +1270,13 @@
|
|||
* Command to restripe a table.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.selector
|
||||
* A jQuery selector string.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
restripe: function (ajax, response, status) {
|
||||
// :even and :odd are reversed because jQuery counts from 0 and
|
||||
|
@ -1096,10 +1292,15 @@
|
|||
* Command to update a form's build ID.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.old
|
||||
* The old form build ID.
|
||||
* @param {string} response.new
|
||||
* The new form build ID.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
update_build_id: function (ajax, response, status) {
|
||||
$('input[name="form_build_id"][value="' + response.old + '"]').val(response.new);
|
||||
|
@ -1113,9 +1314,13 @@
|
|||
* stylesheets.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* {@link Drupal.Ajax} object created by {@link Drupal.ajax}.
|
||||
* @param {object} response
|
||||
* The response from the Ajax request.
|
||||
* @param {string} response.data
|
||||
* A string that contains the styles to be added.
|
||||
* @param {number} [status]
|
||||
* The XMLHttpRequest status.
|
||||
*/
|
||||
add_css: function (ajax, response, status) {
|
||||
// Add the styles in the normal way.
|
||||
|
@ -1133,4 +1338,4 @@
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery, this, Drupal, drupalSettings);
|
||||
})(jQuery, window, Drupal, drupalSettings);
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
* Builds a div element with the aria-live attribute and add it to the DOM.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the behavior for drupalAnnouce.
|
||||
*/
|
||||
Drupal.behaviors.drupalAnnounce = {
|
||||
attach: function (context) {
|
||||
|
@ -98,6 +101,7 @@
|
|||
* 'polite' or 'assertive'.
|
||||
*
|
||||
* @return {function}
|
||||
* The return of the call to debounce.
|
||||
*
|
||||
* @see http://www.w3.org/WAI/PF/aria-practices/#liveprops
|
||||
*/
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
* @function Drupal.autocomplete.splitValues
|
||||
*
|
||||
* @param {string} value
|
||||
* The value being entered by the user.
|
||||
*
|
||||
* @return {Array}
|
||||
* Array of values, split by comma.
|
||||
*/
|
||||
function autocompleteSplitValues(value) {
|
||||
// We will match the value against comma-separated terms.
|
||||
|
@ -53,8 +55,10 @@
|
|||
* @function Drupal.autocomplete.extractLastTerm
|
||||
*
|
||||
* @param {string} terms
|
||||
* The value of the field.
|
||||
*
|
||||
* @return {string}
|
||||
* The last value of the input field.
|
||||
*/
|
||||
function extractLastTerm(terms) {
|
||||
return autocomplete.splitValues(terms).pop();
|
||||
|
@ -66,8 +70,10 @@
|
|||
* @function Drupal.autocomplete.options.search
|
||||
*
|
||||
* @param {object} event
|
||||
* The event triggered.
|
||||
*
|
||||
* @return {bool}
|
||||
* Whether to perform a search or not.
|
||||
*/
|
||||
function searchHandler(event) {
|
||||
var options = autocomplete.options;
|
||||
|
@ -84,7 +90,9 @@
|
|||
* JQuery UI autocomplete source callback.
|
||||
*
|
||||
* @param {object} request
|
||||
* The request object.
|
||||
* @param {function} response
|
||||
* The function to call with the response.
|
||||
*/
|
||||
function sourceData(request, response) {
|
||||
var elementId = this.element.attr('id');
|
||||
|
@ -98,6 +106,7 @@
|
|||
* display the available terms to the user.
|
||||
*
|
||||
* @param {object} suggestions
|
||||
* Suggestions returned by the server.
|
||||
*/
|
||||
function showSuggestions(suggestions) {
|
||||
var tagged = autocomplete.splitValues(request.term);
|
||||
|
@ -115,6 +124,7 @@
|
|||
* Transforms the data object into an array and update autocomplete results.
|
||||
*
|
||||
* @param {object} data
|
||||
* The data sent back from the server.
|
||||
*/
|
||||
function sourceCallbackHandler(data) {
|
||||
autocomplete.cache[elementId][term] = data;
|
||||
|
@ -140,6 +150,7 @@
|
|||
* Handles an autocompletefocus event.
|
||||
*
|
||||
* @return {bool}
|
||||
* Always returns false.
|
||||
*/
|
||||
function focusHandler() {
|
||||
return false;
|
||||
|
@ -149,9 +160,12 @@
|
|||
* Handles an autocompleteselect event.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
* @param {object} ui
|
||||
* The jQuery UI settings object.
|
||||
*
|
||||
* @return {bool}
|
||||
* Returns false to indicate the event status.
|
||||
*/
|
||||
function selectHandler(event, ui) {
|
||||
var terms = autocomplete.splitValues(event.target.value);
|
||||
|
@ -172,10 +186,13 @@
|
|||
/**
|
||||
* Override jQuery UI _renderItem function to output HTML by default.
|
||||
*
|
||||
* @param {object} ul
|
||||
* @param {jQuery} ul
|
||||
* jQuery collection of the ul element.
|
||||
* @param {object} item
|
||||
* The list item to append.
|
||||
*
|
||||
* @return {object}
|
||||
* @return {jQuery}
|
||||
* jQuery collection of the ul element.
|
||||
*/
|
||||
function renderItem(ul, item) {
|
||||
return $('<li>')
|
||||
|
@ -187,6 +204,11 @@
|
|||
* Attaches the autocomplete behavior to all required fields.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the autocomplete behaviors.
|
||||
* @prop {Drupal~behaviorDetach} detach
|
||||
* Detaches the autocomplete behaviors.
|
||||
*/
|
||||
Drupal.behaviors.autocomplete = {
|
||||
attach: function (context) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* @constructor Drupal.CollapsibleDetails
|
||||
*
|
||||
* @param {HTMLElement} node
|
||||
* The details element.
|
||||
*/
|
||||
function CollapsibleDetails(node) {
|
||||
this.$node = $(node);
|
||||
|
@ -82,6 +83,7 @@
|
|||
* Handle legend clicks.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
onLegendClick: function (e) {
|
||||
this.toggle();
|
||||
|
@ -120,6 +122,9 @@
|
|||
* Polyfill HTML5 details element.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches behavior for the details element.
|
||||
*/
|
||||
Drupal.behaviors.collapse = {
|
||||
attach: function (context) {
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Initialize dialogs for Ajax purposes.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the behaviors for dialog ajax functionality.
|
||||
*/
|
||||
Drupal.behaviors.dialog = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -90,10 +93,14 @@
|
|||
* Command to open a dialog.
|
||||
*
|
||||
* @param {Drupal.Ajax} ajax
|
||||
* The Drupal Ajax object.
|
||||
* @param {object} response
|
||||
* Object holding the server response.
|
||||
* @param {number} [status]
|
||||
* The HTTP status code.
|
||||
*
|
||||
* @return {bool|undefined}
|
||||
* Returns false if there was no selector property in the response object.
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
|
||||
if (!response.selector) {
|
||||
|
@ -146,10 +153,15 @@
|
|||
* If no selector is given, it defaults to trying to close the modal.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* The ajax object.
|
||||
* @param {object} response
|
||||
* Object holding the server response.
|
||||
* @param {string} response.selector
|
||||
* The selector of the dialog.
|
||||
* @param {bool} response.persist
|
||||
* Whether to persist the dialog element or not.
|
||||
* @param {number} [status]
|
||||
* The HTTP status code.
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
|
@ -170,11 +182,17 @@
|
|||
* JQuery UI specific way of setting dialog options.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* The Drupal Ajax object.
|
||||
* @param {object} response
|
||||
* Object holding the server response.
|
||||
* @param {string} response.selector
|
||||
* Selector for the dialog element.
|
||||
* @param {string} response.optionsName
|
||||
* Name of a key to set.
|
||||
* @param {string} response.optionValue
|
||||
* Value to set.
|
||||
* @param {number} [status]
|
||||
* The HTTP status code.
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
|
@ -187,9 +205,13 @@
|
|||
* Binds a listener on dialog creation to handle the cancel link.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
* @param {Drupal.dialog~dialogDefinition} dialog
|
||||
* The dialog instance.
|
||||
* @param {jQuery} $element
|
||||
* @param {object} settings
|
||||
* The jQuery collection of the dialog element.
|
||||
* @param {object} [settings]
|
||||
* Dialog settings.
|
||||
*/
|
||||
$(window).on('dialog:aftercreate', function (e, dialog, $element, settings) {
|
||||
$element.on('click.dialog', '.dialog-cancel', function (e) {
|
||||
|
@ -203,8 +225,11 @@
|
|||
* Removes all 'dialog' listeners.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
* @param {Drupal.dialog~dialogDefinition} dialog
|
||||
* The dialog instance.
|
||||
* @param {jQuery} $element
|
||||
* jQuery collection of the dialog element.
|
||||
*/
|
||||
$(window).on('dialog:beforeclose', function (e, dialog, $element) {
|
||||
$element.off('.dialog');
|
||||
|
|
|
@ -55,10 +55,12 @@
|
|||
* Polyfill HTML5 dialog element with jQueryUI.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* The element that holds the dialog.
|
||||
* @param {object} options
|
||||
* jQuery UI options to be passed to the dialog.
|
||||
*
|
||||
* @return {Drupal.dialog~dialogDefinition}
|
||||
* The dialog instance.
|
||||
*/
|
||||
Drupal.dialog = function (element, options) {
|
||||
var undef;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* @function Drupal.dialog~resetSize
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
*
|
||||
* @fires event:dialogContentResize
|
||||
*/
|
||||
|
@ -67,8 +68,10 @@
|
|||
* @function Drupal.dialog~resetPosition
|
||||
*
|
||||
* @param {object} options
|
||||
* Options object.
|
||||
*
|
||||
* @return {object}
|
||||
* Altered options object.
|
||||
*/
|
||||
function resetPosition(options) {
|
||||
var offsets = displace.offsets;
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Process elements with the .dropbutton class on page load.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches dropButton behaviors.
|
||||
*/
|
||||
Drupal.behaviors.dropButton = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -36,6 +39,7 @@
|
|||
* @function Drupal.DropButton~dropbuttonClickHandler
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
function dropbuttonClickHandler(e) {
|
||||
e.preventDefault();
|
||||
|
@ -190,6 +194,7 @@
|
|||
|
||||
/**
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
focusOut: function (e) {
|
||||
this.hoverOut.call(this, e);
|
||||
|
@ -197,6 +202,7 @@
|
|||
|
||||
/**
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
focusIn: function (e) {
|
||||
this.hoverIn.call(this, e);
|
||||
|
@ -209,6 +215,7 @@
|
|||
* A toggle is an interactive element often bound to a click handler.
|
||||
*
|
||||
* @param {object} options
|
||||
* Options object.
|
||||
* @param {string} [options.title]
|
||||
* The HTML anchor title attribute and text for the inner span element.
|
||||
*
|
||||
|
|
|
@ -273,6 +273,7 @@ if (window.jQuery) {
|
|||
* `{@link Drupal.theme}('placeholder')`).
|
||||
*
|
||||
* @return {string}
|
||||
* The formatted string.
|
||||
*
|
||||
* @see Drupal.t
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Retrieves the summary for the first element.
|
||||
*
|
||||
* @return {string}
|
||||
* The text of the summary.
|
||||
*/
|
||||
$.fn.drupalGetSummary = function () {
|
||||
var callback = this.data('summaryCallback');
|
||||
|
@ -34,6 +35,7 @@
|
|||
* retrieved or a string (which is returned each time).
|
||||
*
|
||||
* @return {jQuery}
|
||||
* jQuery collection of the current element.
|
||||
*
|
||||
* @fires event:summaryUpdated
|
||||
*
|
||||
|
@ -125,6 +127,7 @@
|
|||
* Sends a 'formUpdated' event each time a form element is modified.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* The element to trigger a form updated event on.
|
||||
*
|
||||
* @fires event:formUpdated
|
||||
*/
|
||||
|
@ -136,8 +139,10 @@
|
|||
* Collects the IDs of all form fields in the given form.
|
||||
*
|
||||
* @param {HTMLFormElement} form
|
||||
* The form element to search.
|
||||
*
|
||||
* @return {Array}
|
||||
* Array of IDs for form fields.
|
||||
*/
|
||||
function fieldsList(form) {
|
||||
var $fieldList = $(form).find('[name]').map(function (index, element) {
|
||||
|
@ -154,6 +159,11 @@
|
|||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches formUpdated behaviors.
|
||||
* @prop {Drupal~behaviorDetach} detach
|
||||
* Detaches formUpdated behaviors.
|
||||
*
|
||||
* @fires event:formUpdated
|
||||
*/
|
||||
Drupal.behaviors.formUpdated = {
|
||||
|
@ -208,6 +218,9 @@
|
|||
* Prepopulate form fields with information from the visitor browser.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the behavior for filling user info from browser.
|
||||
*/
|
||||
Drupal.behaviors.fillUserInfoFromBrowser = {
|
||||
attach: function (context, settings) {
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Attach the machine-readable name form element behavior.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches machine-name behaviors.
|
||||
*/
|
||||
Drupal.behaviors.machineName = {
|
||||
|
||||
|
@ -18,7 +21,9 @@
|
|||
* Attaches the behavior.
|
||||
*
|
||||
* @param {Element} context
|
||||
* The context for attaching the behavior.
|
||||
* @param {object} settings
|
||||
* Settings object.
|
||||
* @param {object} settings.machineName
|
||||
* A list of elements to process, keyed by the HTML ID of the form
|
||||
* element containing the human-readable value. Each element is an object
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 126 B |
|
@ -11,6 +11,7 @@
|
|||
* Theme function for the progress bar.
|
||||
*
|
||||
* @param {string} id
|
||||
* The id for the progress bar.
|
||||
*
|
||||
* @return {string}
|
||||
* The HTML for the progress bar.
|
||||
|
@ -38,9 +39,13 @@
|
|||
* @constructor
|
||||
*
|
||||
* @param {string} id
|
||||
* The id for the progressbar.
|
||||
* @param {function} updateCallback
|
||||
* Callback to run on update.
|
||||
* @param {string} method
|
||||
* HTTP method to use.
|
||||
* @param {function} errorCallback
|
||||
* Callback to call on error.
|
||||
*/
|
||||
Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) {
|
||||
this.id = id;
|
||||
|
@ -61,8 +66,11 @@
|
|||
* Set the percentage and status message for the progressbar.
|
||||
*
|
||||
* @param {number} percentage
|
||||
* The progress percentage.
|
||||
* @param {string} message
|
||||
* The message to show the user.
|
||||
* @param {string} label
|
||||
* The text for the progressbar label.
|
||||
*/
|
||||
setProgress: function (percentage, message, label) {
|
||||
if (percentage >= 0 && percentage <= 100) {
|
||||
|
@ -80,7 +88,9 @@
|
|||
* Start monitoring progress via Ajax.
|
||||
*
|
||||
* @param {string} uri
|
||||
* The URI to use for monitoring.
|
||||
* @param {number} delay
|
||||
* The delay for calling the monitoring URI.
|
||||
*/
|
||||
startMonitoring: function (uri, delay) {
|
||||
this.delay = delay;
|
||||
|
@ -144,6 +154,7 @@
|
|||
* Display errors on the page.
|
||||
*
|
||||
* @param {string} string
|
||||
* The error message to show the user.
|
||||
*/
|
||||
displayError: function (string) {
|
||||
var error = $('<div class="messages messages--error"></div>').html(string);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Drupal's states library.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
(function ($, Drupal) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -27,6 +27,9 @@
|
|||
* Attaches the states.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches states behaviors.
|
||||
*/
|
||||
Drupal.behaviors.states = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -329,6 +332,7 @@
|
|||
* @memberof Drupal.states.Dependent#
|
||||
*
|
||||
* @return {object}
|
||||
* An object describing the required triggers.
|
||||
*/
|
||||
getDependees: function () {
|
||||
var cache = {};
|
||||
|
@ -359,6 +363,7 @@
|
|||
* @constructor Drupal.states.Trigger
|
||||
*
|
||||
* @param {object} args
|
||||
* Trigger arguments.
|
||||
*/
|
||||
states.Trigger = function (args) {
|
||||
$.extend(this, args);
|
||||
|
@ -402,7 +407,9 @@
|
|||
* @memberof Drupal.states.Trigger#
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
* @param {function} valueFn
|
||||
* The function to call.
|
||||
*/
|
||||
defaultTrigger: function (event, valueFn) {
|
||||
var oldValue = valueFn.call(this.element);
|
||||
|
@ -498,6 +505,7 @@
|
|||
* @constructor Drupal.states.State
|
||||
*
|
||||
* @param {string} state
|
||||
* The name of the state.
|
||||
*/
|
||||
states.State = function (state) {
|
||||
|
||||
|
@ -531,8 +539,10 @@
|
|||
* @name Drupal.states.State.sanitize
|
||||
*
|
||||
* @param {string|Drupal.states.State} state
|
||||
* A state object or the name of a state.
|
||||
*
|
||||
* @return {Drupal.states.state}
|
||||
* A state object.
|
||||
*/
|
||||
states.State.sanitize = function (state) {
|
||||
if (state instanceof states.State) {
|
||||
|
@ -577,6 +587,7 @@
|
|||
* @memberof Drupal.states.State#
|
||||
*
|
||||
* @return {string}
|
||||
* The name of the state.
|
||||
*/
|
||||
toString: function () {
|
||||
return this.name;
|
||||
|
@ -590,7 +601,8 @@
|
|||
* can override these state change handlers for particular parts of a page.
|
||||
*/
|
||||
|
||||
$(document).on('state:disabled', function (e) {
|
||||
var $document = $(document);
|
||||
$document.on('state:disabled', function (e) {
|
||||
// Only act when this change was triggered by a dependency and not by the
|
||||
// element monitoring itself.
|
||||
if (e.trigger) {
|
||||
|
@ -604,7 +616,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
$(document).on('state:required', function (e) {
|
||||
$document.on('state:required', function (e) {
|
||||
if (e.trigger) {
|
||||
if (e.value) {
|
||||
var label = 'label' + (e.target.id ? '[for=' + e.target.id + ']' : '');
|
||||
|
@ -620,19 +632,19 @@
|
|||
}
|
||||
});
|
||||
|
||||
$(document).on('state:visible', function (e) {
|
||||
$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) {
|
||||
$document.on('state:checked', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).prop('checked', e.value);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('state:collapsed', function (e) {
|
||||
$document.on('state:collapsed', function (e) {
|
||||
if (e.trigger) {
|
||||
if ($(e.target).is('[open]') === e.value) {
|
||||
$(e.target).find('> summary').trigger('click');
|
||||
|
@ -651,9 +663,12 @@
|
|||
* @function Drupal.states~ternary
|
||||
*
|
||||
* @param {*} a
|
||||
* Value a.
|
||||
* @param {*} b
|
||||
* Value b
|
||||
*
|
||||
* @return {bool}
|
||||
* The result.
|
||||
*/
|
||||
function ternary(a, b) {
|
||||
if (typeof a === 'undefined') {
|
||||
|
@ -673,9 +688,12 @@
|
|||
* @function Drupal.states~invert
|
||||
*
|
||||
* @param {*} a
|
||||
* The value to maybe invert.
|
||||
* @param {bool} invertState
|
||||
* Whether to invert state or not.
|
||||
*
|
||||
* @return {bool}
|
||||
* The result.
|
||||
*/
|
||||
function invert(a, invertState) {
|
||||
return (invertState && typeof a !== 'undefined') ? !a : a;
|
||||
|
@ -687,9 +705,12 @@
|
|||
* @function Drupal.states~compare
|
||||
*
|
||||
* @param {*} a
|
||||
* Value a.
|
||||
* @param {*} b
|
||||
* Value b.
|
||||
*
|
||||
* @return {bool}
|
||||
* The comparison result.
|
||||
*/
|
||||
function compare(a, b) {
|
||||
if (a === b) {
|
||||
|
@ -700,4 +721,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal);
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
* be a jQuery-compatible selector string.
|
||||
*
|
||||
* @return {Drupal~TabbingContext}
|
||||
* The TabbingContext instance.
|
||||
*
|
||||
* @fires event:drupalTabbingConstrained
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Attaches sticky table headers.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the sticky table header behavior.
|
||||
*/
|
||||
Drupal.behaviors.tableHeader = {
|
||||
attach: function (context) {
|
||||
|
@ -215,9 +218,12 @@
|
|||
* Set absolute position of sticky.
|
||||
*
|
||||
* @param {number} offsetTop
|
||||
* The top offset for the sticky header.
|
||||
* @param {number} offsetLeft
|
||||
* The left offset for the sticky header.
|
||||
*
|
||||
* @return {jQuery}
|
||||
* The sticky table as a jQuery collection.
|
||||
*/
|
||||
stickyPosition: function (offsetTop, offsetLeft) {
|
||||
var css = {};
|
||||
|
@ -234,6 +240,7 @@
|
|||
* Returns true if sticky is currently visible.
|
||||
*
|
||||
* @return {bool}
|
||||
* The visibility status.
|
||||
*/
|
||||
checkStickyVisible: function () {
|
||||
var scrollTop = scrollValue('scrollTop');
|
||||
|
@ -256,6 +263,7 @@
|
|||
* calls.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The scroll event.
|
||||
*/
|
||||
onScroll: function (e) {
|
||||
this.checkStickyVisible();
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Attach the tableResponsive function to {@link Drupal.behaviors}.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches tableResponsive functionality.
|
||||
*/
|
||||
Drupal.behaviors.tableResponsive = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -37,6 +40,7 @@
|
|||
* @constructor Drupal.TableResponsive
|
||||
*
|
||||
* @param {HTMLElement} table
|
||||
* The table element to initialize the responsive table on.
|
||||
*/
|
||||
function TableResponsive(table) {
|
||||
this.table = table;
|
||||
|
@ -82,6 +86,7 @@
|
|||
|
||||
/**
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
eventhandlerEvaluateColumnVisibility: function (e) {
|
||||
var pegged = parseInt(this.$link.data('pegged'), 10);
|
||||
|
@ -105,6 +110,7 @@
|
|||
* Columns are classed with either 'priority-low' or 'priority-medium'.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* The event triggered.
|
||||
*/
|
||||
eventhandlerToggleColumns: function (e) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
* Initialize tableSelects.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches tableSelect functionality.
|
||||
*/
|
||||
Drupal.behaviors.tableSelect = {
|
||||
attach: function (context, settings) {
|
||||
|
@ -117,8 +120,11 @@
|
|||
|
||||
/**
|
||||
* @param {HTMLElement} from
|
||||
* The HTML element representing the "from" part of the range.
|
||||
* @param {HTMLElement} to
|
||||
* The HTML element representing the "to" part of the range.
|
||||
* @param {bool} state
|
||||
* The state to set on the range.
|
||||
*/
|
||||
Drupal.tableSelectRange = function (from, to, state) {
|
||||
// We determine the looping mode based on the order of from and to.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Timezone detection.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
(function ($, Drupal) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -73,4 +73,4 @@
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @event summaryUpdated
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
|||
* element inside the tab pane.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches behaviors for vertical tabs.
|
||||
*/
|
||||
Drupal.behaviors.verticalTabs = {
|
||||
attach: function (context) {
|
||||
|
@ -99,6 +102,7 @@
|
|||
* @constructor
|
||||
*
|
||||
* @param {object} settings
|
||||
* Settings object.
|
||||
* @param {string} settings.title
|
||||
* The name of the tab.
|
||||
* @param {jQuery} settings.details
|
||||
|
@ -171,6 +175,7 @@
|
|||
* Shows a vertical tab pane.
|
||||
*
|
||||
* @return {Drupal.verticalTab}
|
||||
* The verticalTab instance.
|
||||
*/
|
||||
tabShow: function () {
|
||||
// Display the tab.
|
||||
|
@ -193,6 +198,7 @@
|
|||
* Hides a vertical tab pane.
|
||||
*
|
||||
* @return {Drupal.verticalTab}
|
||||
* The verticalTab instance.
|
||||
*/
|
||||
tabHide: function () {
|
||||
// Hide this tab.
|
||||
|
@ -243,4 +249,4 @@
|
|||
return tab;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
Reference in a new issue