Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -46,7 +46,7 @@
|
|||
$('.use-ajax').once('ajax').each(function () {
|
||||
var element_settings = {};
|
||||
// Clicked links look better with the throbber than the progress bar.
|
||||
element_settings.progress = {'type': 'throbber'};
|
||||
element_settings.progress = {type: 'throbber'};
|
||||
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
|
@ -75,7 +75,7 @@
|
|||
element_settings.event = 'click';
|
||||
// Clicked form buttons look better with the throbber than the progress
|
||||
// bar.
|
||||
element_settings.progress = {'type': 'throbber'};
|
||||
element_settings.progress = {type: 'throbber'};
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
|
||||
|
@ -95,8 +95,10 @@
|
|||
* XMLHttpRequest object used for the failed request.
|
||||
* @param {string} uri
|
||||
* The URI where the error occurred.
|
||||
* @param {string} customMessage
|
||||
* The custom message.
|
||||
*/
|
||||
Drupal.AjaxError = function (xmlhttp, uri) {
|
||||
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
|
||||
|
||||
var statusCode;
|
||||
var statusText;
|
||||
|
@ -140,12 +142,14 @@
|
|||
// We don't need readyState except for status == 0.
|
||||
readyStateText = xmlhttp.status === 0 ? ("\n" + Drupal.t("ReadyState: !readyState", {'!readyState': xmlhttp.readyState})) : "";
|
||||
|
||||
customMessage = customMessage ? ("\n" + Drupal.t("CustomMessage: !customMessage", {'!customMessage': customMessage})) : "";
|
||||
|
||||
/**
|
||||
* Formatted and translated error message.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.message = statusCode + pathText + statusText + responseText + readyStateText;
|
||||
this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
|
||||
|
||||
/**
|
||||
* Used by some browsers to display a more accurate stack trace.
|
||||
|
@ -276,7 +280,7 @@
|
|||
message: Drupal.t('Please wait...')
|
||||
},
|
||||
submit: {
|
||||
'js': true
|
||||
js: true
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -338,7 +342,13 @@
|
|||
// 2. /nojs$ - The end of a URL string.
|
||||
// 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;
|
||||
this.url = this.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1');
|
||||
// If the 'nojs' version of the URL is trusted, also trust the 'ajax'
|
||||
// version.
|
||||
if (drupalSettings.ajaxTrustedUrl[originalUrl]) {
|
||||
drupalSettings.ajaxTrustedUrl[this.url] = true;
|
||||
}
|
||||
|
||||
// Set the options for the ajaxSubmit function.
|
||||
// The 'this' variable will not persist inside of the options object.
|
||||
|
@ -377,18 +387,36 @@
|
|||
ajax.ajaxing = true;
|
||||
return ajax.beforeSend(xmlhttprequest, options);
|
||||
},
|
||||
success: function (response, status) {
|
||||
success: function (response, status, xmlhttprequest) {
|
||||
// Sanity check for browser support (object expected).
|
||||
// When using iFrame uploads, responses must be returned as a string.
|
||||
if (typeof response === 'string') {
|
||||
response = $.parseJSON(response);
|
||||
}
|
||||
|
||||
// Prior to invoking the response's commands, verify that they can be
|
||||
// trusted by checking for a response header. See
|
||||
// \Drupal\Core\EventSubscriber\AjaxResponseSubscriber for details.
|
||||
// - Empty responses are harmless so can bypass verification. This
|
||||
// avoids an alert message for server-generated no-op responses that
|
||||
// skip Ajax rendering.
|
||||
// - Ajax objects with trusted URLs (e.g., ones defined server-side via
|
||||
// #ajax) can bypass header verification. This is especially useful
|
||||
// for Ajax with multipart forms. Because IFRAME transport is used,
|
||||
// the response headers cannot be accessed for verification.
|
||||
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 ajax.success(response, status);
|
||||
},
|
||||
complete: function (response, status) {
|
||||
complete: function (xmlhttprequest, status) {
|
||||
ajax.ajaxing = false;
|
||||
if (status === 'error' || status === 'parsererror') {
|
||||
return ajax.error(response, ajax.url);
|
||||
return ajax.error(xmlhttprequest, ajax.url);
|
||||
}
|
||||
},
|
||||
dataType: 'json',
|
||||
|
@ -411,6 +439,9 @@
|
|||
|
||||
// Bind the ajaxSubmit function to the element event.
|
||||
$(ajax.element).on(element_settings.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);
|
||||
});
|
||||
|
||||
|
@ -760,10 +791,11 @@
|
|||
/**
|
||||
* Handler for the form redirection error.
|
||||
*
|
||||
* @param {object} response
|
||||
* @param {object} xmlhttprequest
|
||||
* @param {string} uri
|
||||
* @param {string} customMessage
|
||||
*/
|
||||
Drupal.Ajax.prototype.error = function (response, uri) {
|
||||
Drupal.Ajax.prototype.error = function (xmlhttprequest, uri, customMessage) {
|
||||
// Remove the progress element.
|
||||
if (this.progress.element) {
|
||||
$(this.progress.element).remove();
|
||||
|
@ -777,10 +809,10 @@
|
|||
$(this.element).prop('disabled', false);
|
||||
// Reattach behaviors, if they were detached in beforeSerialize().
|
||||
if (this.$form) {
|
||||
var settings = response.settings || this.settings || drupalSettings;
|
||||
var settings = this.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(this.$form.get(0), settings);
|
||||
}
|
||||
throw new Drupal.AjaxError(response, uri);
|
||||
throw new Drupal.AjaxError(xmlhttprequest, uri, customMessage);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,9 +74,9 @@
|
|||
border: 0
|
||||
});
|
||||
buttons.push({
|
||||
'text': $originalButton.html() || $originalButton.attr('value'),
|
||||
'class': $originalButton.attr('class'),
|
||||
'click': function (e) {
|
||||
text: $originalButton.html() || $originalButton.attr('value'),
|
||||
class: $originalButton.attr('class'),
|
||||
click: function (e) {
|
||||
$originalButton.trigger('mousedown').trigger('mouseup').trigger('click');
|
||||
e.preventDefault();
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
*/
|
||||
function DropButton(dropbutton, settings) {
|
||||
// Merge defaults with settings.
|
||||
var options = $.extend({'title': Drupal.t('List additional actions')}, settings);
|
||||
var options = $.extend({title: Drupal.t('List additional actions')}, settings);
|
||||
var $dropbutton = $(dropbutton);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,27 +1,29 @@
|
|||
/**
|
||||
* @file
|
||||
* Defines the Drupal JS API.
|
||||
* Defines the Drupal JavaScript API.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A jQuery object.
|
||||
* A jQuery object, typically the return value from a `$(selector)` call.
|
||||
*
|
||||
* Holds an HTMLElement or a collection of HTMLElements.
|
||||
*
|
||||
* @typedef {object} jQuery
|
||||
*
|
||||
* @prop {number} length=0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Variable generated by Drupal with all the configuration created from PHP.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @var {object} drupalSettings
|
||||
* Number of elements contained in the jQuery object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Variable generated by Drupal that holds all translated strings from PHP.
|
||||
*
|
||||
* Content of this variable is automatically created by Drupal when using the
|
||||
* Interface Translation module. It holds the translation of strings used on
|
||||
* the page.
|
||||
*
|
||||
* This variable is used to pass data from the backend to the frontend. Data
|
||||
* contained in `drupalSettings` is used during behavior initialization.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @var {object} drupalTranslations
|
||||
|
@ -30,13 +32,15 @@
|
|||
/**
|
||||
* Global Drupal object.
|
||||
*
|
||||
* All Drupal JavaScript APIs are contained in this namespace.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
window.Drupal = {behaviors: {}, locale: {}};
|
||||
|
||||
// Class indicating that JS is enabled; used for styling purpose.
|
||||
// Class indicating that JavaScript is enabled; used for styling purpose.
|
||||
document.documentElement.className += ' js';
|
||||
|
||||
// Allow other JavaScript libraries to use $.
|
||||
|
@ -51,82 +55,43 @@ if (window.jQuery) {
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Custom error type thrown after attach/detach if one or more behaviors
|
||||
* failed.
|
||||
* Helper to rethrow errors asynchronously.
|
||||
*
|
||||
* @memberof Drupal
|
||||
* This way Errors bubbles up outside of the original callstack, making it
|
||||
* easier to debug errors in the browser.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @augments Error
|
||||
*
|
||||
* @param {Array} list
|
||||
* An array of errors thrown during attach/detach.
|
||||
* @param {string} event
|
||||
* A string containing either 'attach' or 'detach'.
|
||||
*
|
||||
* @inner
|
||||
* @param {Error|string} error
|
||||
* The error to be thrown.
|
||||
*/
|
||||
function DrupalBehaviorError(list, event) {
|
||||
|
||||
/**
|
||||
* Setting name helps debuggers.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = 'DrupalBehaviorError';
|
||||
|
||||
/**
|
||||
* Execution phase errors were triggered.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.event = event || 'attach';
|
||||
|
||||
/**
|
||||
* All thrown errors.
|
||||
*
|
||||
* @type {Array.<Error>}
|
||||
*/
|
||||
this.list = list;
|
||||
// Makes the list of errors readable.
|
||||
var messageList = [];
|
||||
messageList.push(this.event);
|
||||
var il = this.list.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
messageList.push(this.list[i].behavior + ': ' + this.list[i].error.message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Final message to send to debuggers.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.message = messageList.join(' ; ');
|
||||
}
|
||||
|
||||
DrupalBehaviorError.prototype = new Error();
|
||||
Drupal.throwError = function (error) {
|
||||
setTimeout(function () { throw error; }, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback function initializing code run on page load and Ajax requests.
|
||||
* Custom error thrown after attach/detach if one or more behaviors failed.
|
||||
* Initializes the JavaScript behaviors for page loads and Ajax requests.
|
||||
*
|
||||
* @callback Drupal~behaviorAttach
|
||||
*
|
||||
* @param {HTMLElement} context
|
||||
* @param {object} settings
|
||||
* @param {HTMLDocument|HTMLElement} context
|
||||
* An element to detach behaviors from.
|
||||
* @param {?object} settings
|
||||
* An object containing settings for the current context. It is rarely used.
|
||||
*
|
||||
* @see Drupal.attachBehaviors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function for reverting and cleaning up behavior initialization.
|
||||
* Reverts and cleans up JavaScript behavior initialization.
|
||||
*
|
||||
* @callback Drupal~behaviorDetach
|
||||
*
|
||||
* @param {HTMLElement} context
|
||||
* @param {HTMLDocument|HTMLElement} context
|
||||
* An element to attach behaviors to.
|
||||
* @param {object} settings
|
||||
* An object containing settings for the current context.
|
||||
* @param {string} trigger
|
||||
* One of 'unload', 'serialize' or 'move'.
|
||||
* One of `'unload'`, `'move'`, or `'serialize'`.
|
||||
*
|
||||
* @see Drupal.detachBehaviors
|
||||
*/
|
||||
|
@ -135,7 +100,7 @@ if (window.jQuery) {
|
|||
* @typedef {object} Drupal~behavior
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Function run on page load and after an AJAX call.
|
||||
* Function run on page load and after an Ajax call.
|
||||
* @prop {Drupal~behaviorDetach} detach
|
||||
* Function run when content is serialized or removed from the page.
|
||||
*/
|
||||
|
@ -149,42 +114,42 @@ if (window.jQuery) {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Attach all registered behaviors to a page element.
|
||||
* Defines a behavior to be run during attach and detach phases.
|
||||
*
|
||||
* Attaches all registered behaviors to a page element.
|
||||
*
|
||||
* Behaviors are event-triggered actions that attach to page elements,
|
||||
* enhancing default non-JavaScript UIs. Behaviors are registered in the
|
||||
* {@link Drupal.behaviors} object using the method 'attach' and optionally
|
||||
* also 'detach' as follows:
|
||||
* also 'detach'.
|
||||
*
|
||||
* {@link Drupal.attachBehaviors} is added below to the jQuery.ready event and
|
||||
* therefore runs on initial page load. Developers implementing Ajax in their
|
||||
* solutions should also call this function after new page content has been
|
||||
* loaded, feeding in an element to be processed, in order to attach all
|
||||
* {@link Drupal.attachBehaviors} is added below to the `jQuery.ready` event
|
||||
* and therefore runs on initial page load. Developers implementing Ajax in
|
||||
* their solutions should also call this function after new page content has
|
||||
* been loaded, feeding in an element to be processed, in order to attach all
|
||||
* behaviors to the new content.
|
||||
*
|
||||
* Behaviors should use
|
||||
* `var elements = $(context).find(selector).once('behavior-name');`
|
||||
* to ensure the behavior is attached only once to a given element. (Doing so
|
||||
* enables the reprocessing of given elements, which may be needed on
|
||||
* occasion despite the ability to limit behavior attachment to a particular
|
||||
* element.)
|
||||
* Behaviors should use `var elements =
|
||||
* $(context).find(selector).once('behavior-name');` to ensure the behavior is
|
||||
* attached only once to a given element. (Doing so enables the reprocessing
|
||||
* of given elements, which may be needed on occasion despite the ability to
|
||||
* limit behavior attachment to a particular element.)
|
||||
*
|
||||
* @example
|
||||
* Drupal.behaviors.behaviorName = {
|
||||
* attach: function (context, settings) {
|
||||
* ...
|
||||
* // ...
|
||||
* },
|
||||
* detach: function (context, settings, trigger) {
|
||||
* ...
|
||||
* // ...
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* @param {Element} context
|
||||
* An element to attach behaviors to. If none is given, the document
|
||||
* element is used.
|
||||
* @param {object} settings
|
||||
* @param {HTMLDocument|HTMLElement} [context=document]
|
||||
* An element to attach behaviors to.
|
||||
* @param {object} [settings=drupalSettings]
|
||||
* An object containing settings for the current context. If none is given,
|
||||
* the global drupalSettings object is used.
|
||||
* the global {@link drupalSettings} object is used.
|
||||
*
|
||||
* @see Drupal~behaviorAttach
|
||||
* @see Drupal.detachBehaviors
|
||||
|
@ -194,7 +159,6 @@ if (window.jQuery) {
|
|||
Drupal.attachBehaviors = function (context, settings) {
|
||||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
var errors = [];
|
||||
var behaviors = Drupal.behaviors;
|
||||
// Execute all of them.
|
||||
for (var i in behaviors) {
|
||||
|
@ -204,43 +168,37 @@ if (window.jQuery) {
|
|||
behaviors[i].attach(context, settings);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push({behavior: i, error: e});
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Once all behaviors have been processed, inform the user about errors.
|
||||
if (errors.length) {
|
||||
throw new DrupalBehaviorError(errors, 'attach');
|
||||
}
|
||||
};
|
||||
|
||||
// Attach all behaviors.
|
||||
domready(function () { Drupal.attachBehaviors(document, drupalSettings); });
|
||||
|
||||
/**
|
||||
* Detach registered behaviors from a page element.
|
||||
* Detaches registered behaviors from a page element.
|
||||
*
|
||||
* Developers implementing AHAH/Ajax in their solutions should call this
|
||||
* function before page content is about to be removed, feeding in an element
|
||||
* to be processed, in order to allow special behaviors to detach from the
|
||||
* content.
|
||||
* Developers implementing Ajax in their solutions should call this function
|
||||
* before page content is about to be removed, feeding in an element to be
|
||||
* processed, in order to allow special behaviors to detach from the content.
|
||||
*
|
||||
* Such implementations should use .findOnce() and .removeOnce() to find
|
||||
* elements with their corresponding Drupal.behaviors.behaviorName.attach
|
||||
* implementation, i.e. .removeOnce('behaviorName'), to ensure the behavior
|
||||
* Such implementations should use `.findOnce()` and `.removeOnce()` to find
|
||||
* elements with their corresponding `Drupal.behaviors.behaviorName.attach`
|
||||
* implementation, i.e. `.removeOnce('behaviorName')`, to ensure the behavior
|
||||
* is detached only from previously processed elements.
|
||||
*
|
||||
* @param {Element} context
|
||||
* An element to detach behaviors from. If none is given, the document
|
||||
* element is used.
|
||||
* @param {object} settings
|
||||
* @param {HTMLDocument|HTMLElement} [context=document]
|
||||
* An element to detach behaviors from.
|
||||
* @param {object} [settings=drupalSettings]
|
||||
* An object containing settings for the current context. If none given,
|
||||
* the global drupalSettings object is used.
|
||||
* @param {string} trigger
|
||||
* the global {@link drupalSettings} object is used.
|
||||
* @param {string} [trigger='unload']
|
||||
* A string containing what's causing the behaviors to be detached. The
|
||||
* possible triggers are:
|
||||
* - unload: (default) The context element is being removed from the DOM.
|
||||
* - move: The element is about to be moved within the DOM (for example,
|
||||
* - `'unload'`: The context element is being removed from the DOM.
|
||||
* - `'move'`: The element is about to be moved within the DOM (for example,
|
||||
* during a tabledrag row swap). After the move is completed,
|
||||
* {@link Drupal.attachBehaviors} is called, so that the behavior can undo
|
||||
* whatever it did in response to the move. Many behaviors won't need to
|
||||
|
@ -248,7 +206,7 @@ if (window.jQuery) {
|
|||
* IFRAME elements reload their "src" when being moved within the DOM,
|
||||
* behaviors bound to IFRAME elements (like WYSIWYG editors) may need to
|
||||
* take some action.
|
||||
* - serialize: When an Ajax form is submitted, this is called with the
|
||||
* - `'serialize'`: When an Ajax form is submitted, this is called with the
|
||||
* form as the context. This provides every behavior within the form an
|
||||
* opportunity to ensure that the field elements have correct content
|
||||
* in them before the form is serialized. The canonical use-case is so
|
||||
|
@ -264,7 +222,6 @@ if (window.jQuery) {
|
|||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
trigger = trigger || 'unload';
|
||||
var errors = [];
|
||||
var behaviors = Drupal.behaviors;
|
||||
// Execute all of them.
|
||||
for (var i in behaviors) {
|
||||
|
@ -274,22 +231,21 @@ if (window.jQuery) {
|
|||
behaviors[i].detach(context, settings, trigger);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push({behavior: i, error: e});
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Once all behaviors have been processed, inform the user about errors.
|
||||
if (errors.length) {
|
||||
throw new DrupalBehaviorError(errors, 'detach:' + trigger);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to test document width for mobile configurations.
|
||||
* Tests the document width for mobile configurations.
|
||||
*
|
||||
* @param {number} [width=640]
|
||||
* Value of the width to check for.
|
||||
*
|
||||
* @return {bool}
|
||||
* true if the document's `clientWidth` is bigger than `width`, returns
|
||||
* false otherwise.
|
||||
*
|
||||
* @deprecated Temporary solution for the mobile initiative.
|
||||
*/
|
||||
|
@ -299,7 +255,7 @@ if (window.jQuery) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Encode special characters in a plain-text string for display as HTML.
|
||||
* Encodes special characters in a plain-text string for display as HTML.
|
||||
*
|
||||
* @param {string} str
|
||||
* The string to be encoded.
|
||||
|
@ -319,7 +275,7 @@ if (window.jQuery) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Replace placeholders with sanitized values in a string.
|
||||
* Replaces placeholders with sanitized values in a string.
|
||||
*
|
||||
* @param {string} str
|
||||
* A string with placeholders.
|
||||
|
@ -327,11 +283,11 @@ if (window.jQuery) {
|
|||
* An object of replacements pairs to make. Incidences of any key in this
|
||||
* array are replaced with the corresponding value. Based on the first
|
||||
* character of the key, the value is escaped and/or themed:
|
||||
* - !variable: inserted as is
|
||||
* - @variable: escape plain text to HTML ({@link Drupal.checkPlain})
|
||||
* - %variable: escape text and theme as a placeholder for user-submitted
|
||||
* content ({@link Drupal.checkPlain} +
|
||||
* {@link Drupal.theme}('placeholder'))
|
||||
* - `'!variable'`: inserted as is.
|
||||
* - `'@variable'`: escape plain text to HTML ({@link Drupal.checkPlain}).
|
||||
* - `'%variable'`: escape text and theme as a placeholder for user-
|
||||
* submitted content ({@link Drupal.checkPlain} +
|
||||
* `{@link Drupal.theme}('placeholder')`).
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
|
@ -366,7 +322,7 @@ if (window.jQuery) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Replace substring.
|
||||
* Replaces substring.
|
||||
*
|
||||
* The longest keys will be tried first. Once a substring has been replaced,
|
||||
* its new value will not be searched again.
|
||||
|
@ -376,10 +332,10 @@ if (window.jQuery) {
|
|||
* @param {object} args
|
||||
* Key-value pairs.
|
||||
* @param {Array|null} keys
|
||||
* Array of keys from the "args". Internal use only.
|
||||
* Array of keys from `args`. Internal use only.
|
||||
*
|
||||
* @return {string}
|
||||
* Returns the replaced string.
|
||||
* The replaced string.
|
||||
*/
|
||||
Drupal.stringReplace = function (str, args, keys) {
|
||||
if (str.length === 0) {
|
||||
|
@ -418,7 +374,7 @@ if (window.jQuery) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Translate strings to the page language or a given language.
|
||||
* Translates strings to the page language, or a given language.
|
||||
*
|
||||
* See the documentation of the server-side t() function for further details.
|
||||
*
|
||||
|
@ -429,10 +385,12 @@ if (window.jQuery) {
|
|||
* of any key in this array are replaced with the corresponding value.
|
||||
* See {@link Drupal.formatString}.
|
||||
* @param {object} [options]
|
||||
* Additional options for translation.
|
||||
* @param {string} [options.context='']
|
||||
* The context the source string belongs to.
|
||||
*
|
||||
* @return {string}
|
||||
* The formatted string.
|
||||
* The translated string.
|
||||
*/
|
||||
Drupal.t = function (str, args, options) {
|
||||
|
@ -457,13 +415,89 @@ if (window.jQuery) {
|
|||
* Drupal path to transform to URL.
|
||||
*
|
||||
* @return {string}
|
||||
* The full URL.
|
||||
*/
|
||||
Drupal.url = function (path) {
|
||||
return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Format a string containing a count of items.
|
||||
* Returns the passed in URL as an absolute URL.
|
||||
*
|
||||
* @param {string} url
|
||||
* The URL string to be normalized to an absolute URL.
|
||||
*
|
||||
* @return {string}
|
||||
* The normalized, absolute URL.
|
||||
*
|
||||
* @see https://github.com/angular/angular.js/blob/v1.4.4/src/ng/urlUtils.js
|
||||
* @see https://grack.com/blog/2009/11/17/absolutizing-url-in-javascript
|
||||
* @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L53
|
||||
*/
|
||||
Drupal.url.toAbsolute = function (url) {
|
||||
var urlParsingNode = document.createElement('a');
|
||||
|
||||
// Decode the URL first; this is required by IE <= 6. Decoding non-UTF-8
|
||||
// strings may throw an exception.
|
||||
try {
|
||||
url = decodeURIComponent(url);
|
||||
}
|
||||
catch (e) {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
urlParsingNode.setAttribute('href', url);
|
||||
|
||||
// IE <= 7 normalizes the URL when assigned to the anchor node similar to
|
||||
// the other browsers.
|
||||
return urlParsingNode.cloneNode(false).href;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the URL is within Drupal's base path.
|
||||
*
|
||||
* @param {string} url
|
||||
* The URL string to be tested.
|
||||
*
|
||||
* @return {bool}
|
||||
* `true` if local.
|
||||
*
|
||||
* @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L58
|
||||
*/
|
||||
Drupal.url.isLocal = function (url) {
|
||||
// Always use browser-derived absolute URLs in the comparison, to avoid
|
||||
// attempts to break out of the base path using directory traversal.
|
||||
var absoluteUrl = Drupal.url.toAbsolute(url);
|
||||
var protocol = location.protocol;
|
||||
|
||||
// Consider URLs that match this site's base URL but use HTTPS instead of HTTP
|
||||
// as local as well.
|
||||
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
||||
protocol = 'https:';
|
||||
}
|
||||
var baseUrl = protocol + '//' + location.host + drupalSettings.path.baseUrl.slice(0, -1);
|
||||
|
||||
// Decoding non-UTF-8 strings may throw an exception.
|
||||
try {
|
||||
absoluteUrl = decodeURIComponent(absoluteUrl);
|
||||
}
|
||||
catch (e) {
|
||||
// Empty.
|
||||
}
|
||||
try {
|
||||
baseUrl = decodeURIComponent(baseUrl);
|
||||
}
|
||||
catch (e) {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
// The given URL matches the site's base URL, or has a path under the site's
|
||||
// base URL.
|
||||
return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a string containing a count of items.
|
||||
*
|
||||
* This function ensures that the string is pluralized correctly. Since
|
||||
* {@link Drupal.t} is called by this function, make sure not to pass
|
||||
|
@ -523,22 +557,24 @@ if (window.jQuery) {
|
|||
* Unencoded path.
|
||||
*
|
||||
* @return {string}
|
||||
* The encoded path.
|
||||
*/
|
||||
Drupal.encodePath = function (item) {
|
||||
return window.encodeURIComponent(item).replace(/%2F/g, '/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the themed representation of a Drupal object.
|
||||
* Generates the themed representation of a Drupal object.
|
||||
*
|
||||
* All requests for themed output must go through this function. It examines
|
||||
* the request and routes it to the appropriate theme function. If the current
|
||||
* theme does not provide an override function, the generic theme function is
|
||||
* called.
|
||||
*
|
||||
* For example, to retrieve the HTML for text that should be emphasized and
|
||||
* displayed as a placeholder inside a sentence, call
|
||||
* `Drupal.theme('placeholder', text)`.
|
||||
* @example
|
||||
* <caption>To retrieve the HTML for text that should be emphasized and
|
||||
* displayed as a placeholder inside a sentence.</caption>
|
||||
* Drupal.theme('placeholder', text);
|
||||
*
|
||||
* @namespace
|
||||
*
|
||||
|
|
24
core/misc/drupalSettingsLoader.js
Normal file
24
core/misc/drupalSettingsLoader.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* @file
|
||||
* Parse inline JSON and initialize the drupalSettings global object.
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
var settingsElement = document.querySelector('script[type="application/json"][data-drupal-selector="drupal-settings-json"]');
|
||||
|
||||
/**
|
||||
* Variable generated by Drupal with all the configuration created from PHP.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
window.drupalSettings = {};
|
||||
|
||||
if (settingsElement !== null) {
|
||||
window.drupalSettings = JSON.parse(settingsElement.textContent);
|
||||
}
|
||||
})();
|
8
core/misc/feed.svg
Normal file
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 |
1
core/misc/icons/e32700/error.svg
Normal file
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 |
|
@ -93,14 +93,14 @@
|
|||
* @prop {function} Number
|
||||
*/
|
||||
states.Dependent.comparisons = {
|
||||
'RegExp': function (reference, value) {
|
||||
RegExp: function (reference, value) {
|
||||
return reference.test(value);
|
||||
},
|
||||
'Function': function (reference, value) {
|
||||
Function: function (reference, value) {
|
||||
// The "reference" variable is a comparison function.
|
||||
return reference(value);
|
||||
},
|
||||
'Number': function (reference, value) {
|
||||
Number: function (reference, value) {
|
||||
// If "reference" is a number and "value" is a string, then cast
|
||||
// reference as a string before applying the strict comparison in
|
||||
// compare().
|
||||
|
@ -441,15 +441,15 @@
|
|||
// 'empty' describes the state to be monitored.
|
||||
empty: {
|
||||
// 'keyup' is the (native DOM) event that we watch for.
|
||||
'keyup': function () {
|
||||
// The function associated to that trigger returns the new value for the
|
||||
// state.
|
||||
keyup: function () {
|
||||
// The function associated with that trigger returns the new value for
|
||||
// the state.
|
||||
return this.val() === '';
|
||||
}
|
||||
},
|
||||
|
||||
checked: {
|
||||
'change': function () {
|
||||
change: function () {
|
||||
// prop() and attr() only takes the first element into account. To
|
||||
// support selectors matching multiple checkboxes, iterate over all and
|
||||
// return whether any is checked.
|
||||
|
@ -467,7 +467,7 @@
|
|||
|
||||
// For radio buttons, only return the value if the radio button is selected.
|
||||
value: {
|
||||
'keyup': function () {
|
||||
keyup: function () {
|
||||
// Radio buttons share the same :input[name="key"] selector.
|
||||
if (this.length > 1) {
|
||||
// Initial checked value of radios is undefined, so we return false.
|
||||
|
@ -475,7 +475,7 @@
|
|||
}
|
||||
return this.val();
|
||||
},
|
||||
'change': function () {
|
||||
change: function () {
|
||||
// Radio buttons share the same :input[name="key"] selector.
|
||||
if (this.length > 1) {
|
||||
// Initial checked value of radios is undefined, so we return false.
|
||||
|
@ -486,7 +486,7 @@
|
|||
},
|
||||
|
||||
collapsed: {
|
||||
'collapsed': function (e) {
|
||||
collapsed: function (e) {
|
||||
return (typeof e !== 'undefined' && 'value' in e) ? e.value : !this.is('[open]');
|
||||
}
|
||||
}
|
||||
|
@ -550,18 +550,18 @@
|
|||
* @name Drupal.states.State.aliases
|
||||
*/
|
||||
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'
|
||||
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 = {
|
||||
|
@ -609,12 +609,12 @@
|
|||
if (e.value) {
|
||||
var $label = $(e.target).attr({'required': 'required', 'aria-required': 'aria-required'}).closest('.form-item, .js-form-wrapper').find('label');
|
||||
// Avoids duplicate required markers on initialization.
|
||||
if (!$label.hasClass('form-required').length) {
|
||||
$label.addClass('form-required');
|
||||
if (!$label.hasClass('js-form-required').length) {
|
||||
$label.addClass('js-form-required form-required');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(e.target).removeAttr('required aria-required').closest('.form-item, .js-form-wrapper').find('label.form-required').removeClass('form-required');
|
||||
$(e.target).removeAttr('required aria-required').closest('.form-item, .js-form-wrapper').find('label.js-form-required').removeClass('js-form-required form-required');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1341,7 +1341,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
return {'min': minIndent, 'max': maxIndent};
|
||||
return {min: minIndent, max: maxIndent};
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -292,7 +292,7 @@
|
|||
$stickyCell = this.$stickyHeaderCells.eq($that.index());
|
||||
display = $that.css('display');
|
||||
if (display !== 'none') {
|
||||
$stickyCell.css({'width': $that.css('width'), 'display': display});
|
||||
$stickyCell.css({width: $that.css('width'), display: display});
|
||||
}
|
||||
else {
|
||||
$stickyCell.css('display', 'none');
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
var checkboxes;
|
||||
var lastChecked;
|
||||
var $table = $(table);
|
||||
var strings = {'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table')};
|
||||
var strings = {
|
||||
selectAll: Drupal.t('Select all rows in this table'),
|
||||
selectNone: Drupal.t('Deselect all rows in this table')
|
||||
};
|
||||
var updateSelectAll = function (state) {
|
||||
// Update table's select-all checkbox (and sticky header's if available).
|
||||
$table.prev('table.sticky-header').addBack().find('th.select-all input[type="checkbox"]').each(function () {
|
||||
|
|
Reference in a new issue