Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
68
core/misc/active-link.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* @file
|
||||
* Attaches behaviors for Drupal's active link marking.
|
||||
*/
|
||||
|
||||
(function (Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Append is-active class.
|
||||
*
|
||||
* The link is only active if its path corresponds to the current path, the
|
||||
* language of the linked path is equal to the current language, and if the
|
||||
* query parameters of the link equal those of the current request, since the
|
||||
* same request with different query parameters may yield a different page
|
||||
* (e.g. pagers, exposed View filters).
|
||||
*
|
||||
* Does not discriminate based on element type, so allows you to set the
|
||||
* is-active class on any element: a, li…
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.activeLinks = {
|
||||
attach: function (context) {
|
||||
// Start by finding all potentially active links.
|
||||
var path = drupalSettings.path;
|
||||
var queryString = JSON.stringify(path.currentQuery);
|
||||
var querySelector = path.currentQuery ? "[data-drupal-link-query='" + queryString + "']" : ':not([data-drupal-link-query])';
|
||||
var originalSelectors = ['[data-drupal-link-system-path="' + path.currentPath + '"]'];
|
||||
var selectors;
|
||||
|
||||
// If this is the front page, we have to check for the <front> path as
|
||||
// well.
|
||||
if (path.isFront) {
|
||||
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
|
||||
}
|
||||
|
||||
// Add language filtering.
|
||||
selectors = [].concat(
|
||||
// Links without any hreflang attributes (most of them).
|
||||
originalSelectors.map(function (selector) { return selector + ':not([hreflang])'; }),
|
||||
// Links with hreflang equals to the current language.
|
||||
originalSelectors.map(function (selector) { return selector + '[hreflang="' + path.currentLanguage + '"]'; })
|
||||
);
|
||||
|
||||
// Add query string selector for pagers, exposed filters.
|
||||
selectors = selectors.map(function (current) { return current + querySelector; });
|
||||
|
||||
// Query the DOM.
|
||||
var activeLinks = context.querySelectorAll(selectors.join(','));
|
||||
var il = activeLinks.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
activeLinks[i].classList.add('is-active');
|
||||
}
|
||||
},
|
||||
detach: function (context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
var activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active');
|
||||
var il = activeLinks.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
activeLinks[i].classList.remove('is-active');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(Drupal, drupalSettings);
|
1077
core/misc/ajax.js
Normal file
116
core/misc/announce.js
Normal file
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* @file
|
||||
* Adds an HTML element and method to trigger audio UAs to read system messages.
|
||||
*
|
||||
* Use {@link Drupal.announce} to indicate to screen reader users that an
|
||||
* element on the page has changed state. For instance, if clicking a link
|
||||
* loads 10 more items into a list, one might announce the change like this.
|
||||
*
|
||||
* @example
|
||||
* $('#search-list')
|
||||
* .on('itemInsert', function (event, data) {
|
||||
* // Insert the new items.
|
||||
* $(data.container.el).append(data.items.el);
|
||||
* // Announce the change to the page contents.
|
||||
* Drupal.announce(Drupal.t('@count items added to @container',
|
||||
* {'@count': data.items.length, '@container': data.container.title}
|
||||
* ));
|
||||
* });
|
||||
*/
|
||||
|
||||
(function (Drupal, debounce) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var liveElement;
|
||||
var announcements = [];
|
||||
|
||||
/**
|
||||
* Builds a div element with the aria-live attribute and add it to the DOM.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.drupalAnnounce = {
|
||||
attach: function (context) {
|
||||
// Create only one aria-live element.
|
||||
if (!liveElement) {
|
||||
liveElement = document.createElement('div');
|
||||
liveElement.id = 'drupal-live-announce';
|
||||
liveElement.className = 'visually-hidden';
|
||||
liveElement.setAttribute('aria-live', 'polite');
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
document.body.appendChild(liveElement);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Concatenates announcements to a single string; appends to the live region.
|
||||
*/
|
||||
function announce() {
|
||||
var text = [];
|
||||
var priority = 'polite';
|
||||
var announcement;
|
||||
|
||||
// Create an array of announcement strings to be joined and appended to the
|
||||
// aria live region.
|
||||
var il = announcements.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
announcement = announcements.pop();
|
||||
text.unshift(announcement.text);
|
||||
// If any of the announcements has a priority of assertive then the group
|
||||
// of joined announcements will have this priority.
|
||||
if (announcement.priority === 'assertive') {
|
||||
priority = 'assertive';
|
||||
}
|
||||
}
|
||||
|
||||
if (text.length) {
|
||||
// Clear the liveElement so that repeated strings will be read.
|
||||
liveElement.innerHTML = '';
|
||||
// Set the busy state to true until the node changes are complete.
|
||||
liveElement.setAttribute('aria-busy', 'true');
|
||||
// Set the priority to assertive, or default to polite.
|
||||
liveElement.setAttribute('aria-live', priority);
|
||||
// Print the text to the live region. Text should be run through
|
||||
// Drupal.t() before being passed to Drupal.announce().
|
||||
liveElement.innerHTML = text.join('\n');
|
||||
// The live text area is updated. Allow the AT to announce the text.
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers audio UAs to read the supplied text.
|
||||
*
|
||||
* The aria-live region will only read the text that currently populates its
|
||||
* text node. Replacing text quickly in rapid calls to announce results in
|
||||
* only the text from the most recent call to {@link Drupal.announce} being
|
||||
* read. By wrapping the call to announce in a debounce function, we allow for
|
||||
* time for multiple calls to {@link Drupal.announce} to queue up their
|
||||
* messages. These messages are then joined and append to the aria-live region
|
||||
* as one text node.
|
||||
*
|
||||
* @param {string} text
|
||||
* A string to be read by the UA.
|
||||
* @param {string} [priority='polite']
|
||||
* A string to indicate the priority of the message. Can be either
|
||||
* 'polite' or 'assertive'.
|
||||
*
|
||||
* @return {function}
|
||||
*
|
||||
* @see http://www.w3.org/WAI/PF/aria-practices/#liveprops
|
||||
*/
|
||||
Drupal.announce = function (text, priority) {
|
||||
// Save the text and priority into a closure variable. Multiple simultaneous
|
||||
// announcements will be concatenated and read in sequence.
|
||||
announcements.push({
|
||||
text: text,
|
||||
priority: priority
|
||||
});
|
||||
// Immediately invoke the function that debounce returns. 200 ms is right at
|
||||
// the cusp where humans notice a pause, so we will wait
|
||||
// at most this much time before the set of queued announcements is read.
|
||||
return (debounce(announce, 200)());
|
||||
};
|
||||
}(Drupal, Drupal.debounce));
|
BIN
core/misc/arrow-asc.png
Normal file
After Width: | Height: | Size: 118 B |
BIN
core/misc/arrow-desc.png
Normal file
After Width: | Height: | Size: 118 B |
250
core/misc/autocomplete.js
Normal file
|
@ -0,0 +1,250 @@
|
|||
/**
|
||||
* @file
|
||||
* Autocomplete based on jQuery UI.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var autocomplete;
|
||||
|
||||
/**
|
||||
* Helper splitting terms from the autocomplete value.
|
||||
*
|
||||
* @function Drupal.autocomplete.splitValues
|
||||
*
|
||||
* @param {string} value
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
function autocompleteSplitValues(value) {
|
||||
// We will match the value against comma-separated terms.
|
||||
var result = [];
|
||||
var quote = false;
|
||||
var current = '';
|
||||
var valueLength = value.length;
|
||||
var character;
|
||||
|
||||
for (var i = 0; i < valueLength; i++) {
|
||||
character = value.charAt(i);
|
||||
if (character === '"') {
|
||||
current += character;
|
||||
quote = !quote;
|
||||
}
|
||||
else if (character === ',' && !quote) {
|
||||
result.push(current.trim());
|
||||
current = '';
|
||||
}
|
||||
else {
|
||||
current += character;
|
||||
}
|
||||
}
|
||||
if (value.length > 0) {
|
||||
result.push($.trim(current));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last value of an multi-value textfield.
|
||||
*
|
||||
* @function Drupal.autocomplete.extractLastTerm
|
||||
*
|
||||
* @param {string} terms
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function extractLastTerm(terms) {
|
||||
return autocomplete.splitValues(terms).pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* The search handler is called before a search is performed.
|
||||
*
|
||||
* @function Drupal.autocomplete.options.search
|
||||
*
|
||||
* @param {object} event
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
function searchHandler(event) {
|
||||
var options = autocomplete.options;
|
||||
var term = autocomplete.extractLastTerm(event.target.value);
|
||||
// Abort search if the first character is in firstCharacterBlacklist.
|
||||
if (term.length > 0 && options.firstCharacterBlacklist.indexOf(term[0]) !== -1) {
|
||||
return false;
|
||||
}
|
||||
// Only search when the term is at least the minimum length.
|
||||
return term.length >= options.minLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* JQuery UI autocomplete source callback.
|
||||
*
|
||||
* @param {object} request
|
||||
* @param {function} response
|
||||
*/
|
||||
function sourceData(request, response) {
|
||||
var elementId = this.element.attr('id');
|
||||
|
||||
if (!(elementId in autocomplete.cache)) {
|
||||
autocomplete.cache[elementId] = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter through the suggestions removing all terms already tagged and
|
||||
* display the available terms to the user.
|
||||
*
|
||||
* @param {object} suggestions
|
||||
*/
|
||||
function showSuggestions(suggestions) {
|
||||
var tagged = autocomplete.splitValues(request.term);
|
||||
var il = tagged.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
var index = suggestions.indexOf(tagged[i]);
|
||||
if (index >= 0) {
|
||||
suggestions.splice(index, 1);
|
||||
}
|
||||
}
|
||||
response(suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the data object into an array and update autocomplete results.
|
||||
*
|
||||
* @param {object} data
|
||||
*/
|
||||
function sourceCallbackHandler(data) {
|
||||
autocomplete.cache[elementId][term] = data;
|
||||
|
||||
// Send the new string array of terms to the jQuery UI list.
|
||||
showSuggestions(data);
|
||||
}
|
||||
|
||||
// Get the desired term and construct the autocomplete URL for it.
|
||||
var term = autocomplete.extractLastTerm(request.term);
|
||||
|
||||
// Check if the term is already cached.
|
||||
if (autocomplete.cache[elementId].hasOwnProperty(term)) {
|
||||
showSuggestions(autocomplete.cache[elementId][term]);
|
||||
}
|
||||
else {
|
||||
var options = $.extend({success: sourceCallbackHandler, data: {q: term}}, autocomplete.ajax);
|
||||
$.ajax(this.element.attr('data-autocomplete-path'), options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an autocompletefocus event.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
function focusHandler() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an autocompleteselect event.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* @param {object} ui
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
function selectHandler(event, ui) {
|
||||
var terms = autocomplete.splitValues(event.target.value);
|
||||
// Remove the current input.
|
||||
terms.pop();
|
||||
// Add the selected item.
|
||||
if (ui.item.value.search(",") > 0) {
|
||||
terms.push('"' + ui.item.value + '"');
|
||||
}
|
||||
else {
|
||||
terms.push(ui.item.value);
|
||||
}
|
||||
event.target.value = terms.join(', ');
|
||||
// Return false to tell jQuery UI that we've filled in the value already.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override jQuery UI _renderItem function to output HTML by default.
|
||||
*
|
||||
* @param {object} ul
|
||||
* @param {object} item
|
||||
*
|
||||
* @return {object}
|
||||
*/
|
||||
function renderItem(ul, item) {
|
||||
return $("<li>")
|
||||
.append($("<a>").html(item.label))
|
||||
.appendTo(ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the autocomplete behavior to all required fields.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.autocomplete = {
|
||||
attach: function (context) {
|
||||
// Act on textfields with the "form-autocomplete" class.
|
||||
var $autocomplete = $(context).find('input.form-autocomplete').once('autocomplete');
|
||||
if ($autocomplete.length) {
|
||||
// Allow options to be overriden per instance.
|
||||
var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist');
|
||||
$.extend(autocomplete.options, {
|
||||
firstCharacterBlacklist: (blacklist) ? blacklist : ''
|
||||
});
|
||||
// Use jQuery UI Autocomplete on the textfield.
|
||||
$autocomplete.autocomplete(autocomplete.options)
|
||||
.data("ui-autocomplete")
|
||||
._renderItem = autocomplete.options.renderItem;
|
||||
}
|
||||
},
|
||||
detach: function (context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
$(context).find('input.form-autocomplete')
|
||||
.removeOnce('autocomplete')
|
||||
.autocomplete('destroy');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Autocomplete object implementation.
|
||||
*
|
||||
* @namespace Drupal.autocomplete
|
||||
*/
|
||||
autocomplete = {
|
||||
cache: {},
|
||||
// Exposes options to allow overriding by contrib.
|
||||
splitValues: autocompleteSplitValues,
|
||||
extractLastTerm: extractLastTerm,
|
||||
// jQuery UI autocomplete options.
|
||||
|
||||
/**
|
||||
* JQuery UI option object.
|
||||
*
|
||||
* @name Drupal.autocomplete.options
|
||||
*/
|
||||
options: {
|
||||
source: sourceData,
|
||||
focus: focusHandler,
|
||||
search: searchHandler,
|
||||
select: selectHandler,
|
||||
renderItem: renderItem,
|
||||
minLength: 1,
|
||||
// Custom options, used by Drupal.autocomplete.
|
||||
firstCharacterBlacklist: ''
|
||||
},
|
||||
ajax: {
|
||||
dataType: 'json'
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.autocomplete = autocomplete;
|
||||
|
||||
})(jQuery, Drupal);
|
46
core/misc/batch.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @file
|
||||
* Drupal's batch API.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Attaches the batch behavior to progress bars.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.batch = {
|
||||
attach: function (context, settings) {
|
||||
var batch = settings.batch;
|
||||
var $progress = $('[data-drupal-progress]').once('batch');
|
||||
var progressBar;
|
||||
|
||||
// Success: redirect to the summary.
|
||||
function updateCallback(progress, status, pb) {
|
||||
if (progress === '100') {
|
||||
pb.stopMonitoring();
|
||||
window.location = batch.uri + '&op=finished';
|
||||
}
|
||||
}
|
||||
|
||||
function errorCallback(pb) {
|
||||
$progress.prepend($('<p class="error"></p>').html(batch.errorMessage));
|
||||
$('#wait').hide();
|
||||
}
|
||||
|
||||
if ($progress.length) {
|
||||
progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback);
|
||||
progressBar.setProgress(-1, batch.initMessage);
|
||||
progressBar.startMonitoring(batch.uri + '&op=do', 10);
|
||||
// Remove HTML from no-js progress bar.
|
||||
$progress.empty();
|
||||
// Append the JS progressbar element.
|
||||
$progress.append(progressBar.element);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal);
|
141
core/misc/collapse.js
Normal file
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
* @file
|
||||
* Polyfill for HTML5 details elements.
|
||||
*/
|
||||
|
||||
(function ($, Modernizr, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* The collapsible details object represents a single details element.
|
||||
*
|
||||
* @constructor Drupal.CollapsibleDetails
|
||||
*
|
||||
* @param {HTMLElement} node
|
||||
*/
|
||||
function CollapsibleDetails(node) {
|
||||
this.$node = $(node);
|
||||
this.$node.data('details', this);
|
||||
// Expand details if there are errors inside, or if it contains an
|
||||
// element that is targeted by the URI fragment identifier.
|
||||
var anchor = location.hash && location.hash !== '#' ? ', ' + location.hash : '';
|
||||
if (this.$node.find('.error' + anchor).length) {
|
||||
this.$node.attr('open', true);
|
||||
}
|
||||
// Initialize and setup the summary,
|
||||
this.setupSummary();
|
||||
// Initialize and setup the legend.
|
||||
this.setupLegend();
|
||||
}
|
||||
|
||||
$.extend(CollapsibleDetails, /** @lends Drupal.CollapsibleDetails */{
|
||||
|
||||
/**
|
||||
* Holds references to instantiated CollapsibleDetails objects.
|
||||
*
|
||||
* @type {Array.<Drupal.CollapsibleDetails>}
|
||||
*/
|
||||
instances: []
|
||||
});
|
||||
|
||||
$.extend(CollapsibleDetails.prototype, /** @lends Drupal.CollapsibleDetails# */{
|
||||
|
||||
/**
|
||||
* Initialize and setup summary events and markup.
|
||||
*
|
||||
* @fires event:summaryUpdated
|
||||
*
|
||||
* @listens event:summaryUpdated
|
||||
*/
|
||||
setupSummary: function () {
|
||||
this.$summary = $('<span class="summary"></span>');
|
||||
this.$node
|
||||
.on('summaryUpdated', $.proxy(this.onSummaryUpdated, this))
|
||||
.trigger('summaryUpdated');
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize and setup legend markup.
|
||||
*/
|
||||
setupLegend: function () {
|
||||
// Turn the summary into a clickable link.
|
||||
var $legend = this.$node.find('> summary');
|
||||
|
||||
$('<span class="details-summary-prefix visually-hidden"></span>')
|
||||
.append(this.$node.attr('open') ? Drupal.t('Hide') : Drupal.t('Show'))
|
||||
.prependTo($legend)
|
||||
.after(document.createTextNode(' '));
|
||||
|
||||
// .wrapInner() does not retain bound events.
|
||||
$('<a class="details-title"></a>')
|
||||
.attr('href', '#' + this.$node.attr('id'))
|
||||
.prepend($legend.contents())
|
||||
.appendTo($legend);
|
||||
|
||||
$legend
|
||||
.append(this.$summary)
|
||||
.on('click', $.proxy(this.onLegendClick, this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle legend clicks.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
*/
|
||||
onLegendClick: function (e) {
|
||||
this.toggle();
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update summary.
|
||||
*/
|
||||
onSummaryUpdated: function () {
|
||||
var text = $.trim(this.$node.drupalGetSummary());
|
||||
this.$summary.html(text ? ' (' + text + ')' : '');
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the visibility of a details element using smooth animations.
|
||||
*/
|
||||
toggle: function () {
|
||||
var isOpen = !!this.$node.attr('open');
|
||||
var $summaryPrefix = this.$node.find('> summary span.details-summary-prefix');
|
||||
if (isOpen) {
|
||||
$summaryPrefix.html(Drupal.t('Show'));
|
||||
}
|
||||
else {
|
||||
$summaryPrefix.html(Drupal.t('Hide'));
|
||||
}
|
||||
// Delay setting the attribute to emulate chrome behavior and make
|
||||
// details-aria.js work as expected with this polyfill.
|
||||
setTimeout(function () {
|
||||
this.$node.attr('open', !isOpen);
|
||||
}.bind(this), 0);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Polyfill HTML5 details element.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.collapse = {
|
||||
attach: function (context) {
|
||||
if (Modernizr.details) {
|
||||
return;
|
||||
}
|
||||
var $collapsibleDetails = $(context).find('details').once('collapse').addClass('collapse-processed');
|
||||
if ($collapsibleDetails.length) {
|
||||
for (var i = 0; i < $collapsibleDetails.length; i++) {
|
||||
CollapsibleDetails.instances.push(new CollapsibleDetails($collapsibleDetails[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Expose constructor in the public space.
|
||||
Drupal.CollapsibleDetails = CollapsibleDetails;
|
||||
|
||||
})(jQuery, Modernizr, Drupal);
|
52
core/misc/debounce.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @file
|
||||
* Adapted from underscore.js with the addition Drupal namespace.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Limits the invocations of a function in a given time frame.
|
||||
*
|
||||
* The debounce function wrapper should be used sparingly. One clear use case
|
||||
* is limiting the invocation of a callback attached to the window resize event.
|
||||
*
|
||||
* Before using the debounce function wrapper, consider first whether the
|
||||
* callback could be attached to an event that fires less frequently or if the
|
||||
* function can be written in such a way that it is only invoked under specific
|
||||
* conditions.
|
||||
*
|
||||
* @param {function} func
|
||||
* The function to be invoked.
|
||||
* @param {number} wait
|
||||
* The time period within which the callback function should only be
|
||||
* invoked once. For example if the wait period is 250ms, then the callback
|
||||
* will only be called at most 4 times per second.
|
||||
* @param {bool} immediate
|
||||
* Whether we wait at the beginning or end to execute the function.
|
||||
*
|
||||
* @return {function}
|
||||
* The debounced function.
|
||||
*/
|
||||
Drupal.debounce = function (func, wait, immediate) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var timeout;
|
||||
var result;
|
||||
return function () {
|
||||
var context = this;
|
||||
var args = arguments;
|
||||
var later = function () {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args);
|
||||
}
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
29
core/misc/details-aria.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* @file
|
||||
* Add aria attribute handling for details and summary elements.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Handles `aria-expanded` and `aria-pressed` attributes on details elements.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.detailsAria = {
|
||||
attach: function () {
|
||||
$('body').once('detailsAria').on('click.detailsAria', 'summary', function (event) {
|
||||
var $summary = $(event.currentTarget);
|
||||
var open = $(event.currentTarget.parentNode).attr('open') === 'open' ? 'false' : 'true';
|
||||
|
||||
$summary.attr({
|
||||
'aria-expanded': open,
|
||||
'aria-pressed': open
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal);
|
71
core/misc/dialog.theme.css
Normal file
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
* Presentational styles for Drupal dialogs.
|
||||
*/
|
||||
|
||||
.ui-dialog {
|
||||
position: absolute;
|
||||
z-index: 1260;
|
||||
overflow: visible;
|
||||
color: #000;
|
||||
background: #fff;
|
||||
border: solid 1px #ccc;
|
||||
padding: 0;
|
||||
}
|
||||
@media all and (max-width: 48em) { /* 768px */
|
||||
.ui-dialog {
|
||||
width: 92% !important;
|
||||
}
|
||||
}
|
||||
.ui-dialog .ui-dialog-titlebar {
|
||||
font-weight: bold;
|
||||
background: #f3f4ee;
|
||||
border-style: solid;
|
||||
border-radius: 0;
|
||||
border-width: 0 0 1px 0;
|
||||
border-color: #ccc;
|
||||
}
|
||||
.ui-dialog .ui-dialog-titlebar-close {
|
||||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane {
|
||||
margin-top: 0;
|
||||
background: #f3f4ee;
|
||||
padding: .3em 1em;
|
||||
border-width: 1px 0 0 0;
|
||||
border-color: #ccc;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-button-text-only .ui-button-text {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Form action buttons are moved in dialogs. Remove empty space. */
|
||||
.ui-dialog .ui-dialog-content .form-actions {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.ui-dialog .ajax-progress-throbber {
|
||||
/* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
|
||||
left: 49%;
|
||||
position: fixed;
|
||||
top: 48.5%;
|
||||
z-index: 1000;
|
||||
background-color: #232323;
|
||||
background-image: url(loading-small.gif);
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
border-radius: 7px;
|
||||
height: 24px;
|
||||
opacity: 0.9;
|
||||
padding: 4px;
|
||||
width: 24px;
|
||||
}
|
||||
.ui-dialog .ajax-progress-throbber .throbber,
|
||||
.ui-dialog .ajax-progress-throbber .message {
|
||||
display: none;
|
||||
}
|
||||
|
212
core/misc/dialog/dialog.ajax.js
Normal file
|
@ -0,0 +1,212 @@
|
|||
/**
|
||||
* @file
|
||||
* Extends the Drupal AJAX functionality to integrate the dialog API.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Initialize dialogs for Ajax purposes.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.dialog = {
|
||||
attach: function (context, settings) {
|
||||
var $context = $(context);
|
||||
|
||||
// Provide a known 'drupal-modal' DOM element for Drupal-based modal
|
||||
// dialogs. Non-modal dialogs are responsible for creating their own
|
||||
// elements, since there can be multiple non-modal dialogs at a time.
|
||||
if (!$('#drupal-modal').length) {
|
||||
// Add 'ui-front' jQuery UI class so jQuery UI widgets like autocomplete
|
||||
// sit on top of dialogs. For more information see
|
||||
// http://api.jqueryui.com/theming/stacking-elements/.
|
||||
$('<div id="drupal-modal" class="ui-front"/>').hide().appendTo('body');
|
||||
}
|
||||
|
||||
// Special behaviors specific when attaching content within a dialog.
|
||||
// These behaviors usually fire after a validation error inside a dialog.
|
||||
var $dialog = $context.closest('.ui-dialog-content');
|
||||
if ($dialog.length) {
|
||||
// Remove and replace the dialog buttons with those from the new form.
|
||||
if ($dialog.dialog('option', 'drupalAutoButtons')) {
|
||||
// Trigger an event to detect/sync changes to buttons.
|
||||
$dialog.trigger('dialogButtonsChange');
|
||||
}
|
||||
|
||||
// Force focus on the modal when the behavior is run.
|
||||
$dialog.dialog('widget').trigger('focus');
|
||||
}
|
||||
|
||||
var originalClose = settings.dialog.close;
|
||||
// Overwrite the close method to remove the dialog on closing.
|
||||
settings.dialog.close = function (event) {
|
||||
originalClose.apply(settings.dialog, arguments);
|
||||
$(event.target).remove();
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Scan a dialog for any primary buttons and move them to the button area.
|
||||
*
|
||||
* @param {jQuery} $dialog
|
||||
* An jQuery object containing the element that is the dialog target.
|
||||
*
|
||||
* @return {Array}
|
||||
* An array of buttons that need to be added to the button area.
|
||||
*/
|
||||
prepareDialogButtons: function ($dialog) {
|
||||
var buttons = [];
|
||||
var $buttons = $dialog.find('.form-actions input[type=submit]');
|
||||
$buttons.each(function () {
|
||||
// Hidden form buttons need special attention. For browser consistency,
|
||||
// the button needs to be "visible" in order to have the enter key fire
|
||||
// the form submit event. So instead of a simple "hide" or
|
||||
// "display: none", we set its dimensions to zero.
|
||||
// See http://mattsnider.com/how-forms-submit-when-pressing-enter/
|
||||
var $originalButton = $(this).css({
|
||||
width: 0,
|
||||
height: 0,
|
||||
padding: 0,
|
||||
border: 0
|
||||
});
|
||||
buttons.push({
|
||||
'text': $originalButton.html() || $originalButton.attr('value'),
|
||||
'class': $originalButton.attr('class'),
|
||||
'click': function (e) {
|
||||
$originalButton.trigger('mousedown').trigger('mouseup').trigger('click');
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Command to open a dialog.
|
||||
*
|
||||
* @param {Drupal.Ajax} ajax
|
||||
* @param {object} response
|
||||
* @param {number} [status]
|
||||
*
|
||||
* @return {bool|undefined}
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
|
||||
if (!response.selector) {
|
||||
return false;
|
||||
}
|
||||
var $dialog = $(response.selector);
|
||||
if (!$dialog.length) {
|
||||
// Create the element if needed.
|
||||
$dialog = $('<div id="' + response.selector.replace(/^#/, '') + '"/>').appendTo('body');
|
||||
}
|
||||
// Set up the wrapper, if there isn't one.
|
||||
if (!ajax.wrapper) {
|
||||
ajax.wrapper = $dialog.attr('id');
|
||||
}
|
||||
|
||||
// Use the ajax.js insert command to populate the dialog contents.
|
||||
response.command = 'insert';
|
||||
response.method = 'html';
|
||||
ajax.commands.insert(ajax, response, status);
|
||||
|
||||
// Move the buttons to the jQuery UI dialog buttons area.
|
||||
if (!response.dialogOptions.buttons) {
|
||||
response.dialogOptions.drupalAutoButtons = true;
|
||||
response.dialogOptions.buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
|
||||
}
|
||||
|
||||
// Bind dialogButtonsChange.
|
||||
$dialog.on('dialogButtonsChange', function () {
|
||||
var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
|
||||
$dialog.dialog('option', 'buttons', buttons);
|
||||
});
|
||||
|
||||
// Open the dialog itself.
|
||||
response.dialogOptions = response.dialogOptions || {};
|
||||
var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
|
||||
if (response.dialogOptions.modal) {
|
||||
dialog.showModal();
|
||||
}
|
||||
else {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
// Add the standard Drupal class for buttons for style consistency.
|
||||
$dialog.parent().find('.ui-dialog-buttonset').addClass('form-actions');
|
||||
};
|
||||
|
||||
/**
|
||||
* Command to close a dialog.
|
||||
*
|
||||
* If no selector is given, it defaults to trying to close the modal.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* @param {object} response
|
||||
* @param {string} response.selector
|
||||
* @param {bool} response.persist
|
||||
* @param {number} [status]
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
if ($dialog.length) {
|
||||
Drupal.dialog($dialog.get(0)).close();
|
||||
if (!response.persist) {
|
||||
$dialog.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Unbind dialogButtonsChange.
|
||||
$dialog.off('dialogButtonsChange');
|
||||
};
|
||||
|
||||
/**
|
||||
* Command to set a dialog property.
|
||||
*
|
||||
* JQuery UI specific way of setting dialog options.
|
||||
*
|
||||
* @param {Drupal.Ajax} [ajax]
|
||||
* @param {object} response
|
||||
* @param {string} response.selector
|
||||
* @param {string} response.optionsName
|
||||
* @param {string} response.optionValue
|
||||
* @param {number} [status]
|
||||
*/
|
||||
Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
if ($dialog.length) {
|
||||
$dialog.dialog('option', response.optionName, response.optionValue);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds a listener on dialog creation to handle the cancel link.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* @param {Drupal.dialog~dialogDefinition} dialog
|
||||
* @param {jQuery} $element
|
||||
* @param {object} settings
|
||||
*/
|
||||
$(window).on('dialog:aftercreate', function (e, dialog, $element, settings) {
|
||||
$element.on('click.dialog', '.dialog-cancel', function (e) {
|
||||
dialog.close('cancel');
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Removes all 'dialog' listeners.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* @param {Drupal.dialog~dialogDefinition} dialog
|
||||
* @param {jQuery} $element
|
||||
*/
|
||||
$(window).on('dialog:beforeclose', function (e, dialog, $element) {
|
||||
$element.off('.dialog');
|
||||
});
|
||||
|
||||
})(jQuery, Drupal);
|
36
core/misc/dialog/dialog.jquery-ui.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @file
|
||||
* Adds default classes to buttons for styling purposes.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
$.widget('ui.dialog', $.ui.dialog, {
|
||||
options: {
|
||||
buttonClass: 'button',
|
||||
buttonPrimaryClass: 'button--primary'
|
||||
},
|
||||
_createButtons: function () {
|
||||
var opts = this.options;
|
||||
var primaryIndex;
|
||||
var $buttons;
|
||||
var index;
|
||||
var il = opts.buttons.length;
|
||||
for (index = 0; index < il; index++) {
|
||||
if (opts.buttons[index].primary && opts.buttons[index].primary === true) {
|
||||
primaryIndex = index;
|
||||
delete opts.buttons[index].primary;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._super();
|
||||
$buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
if (typeof primaryIndex !== 'undefined') {
|
||||
$buttons.eq(index).addClass(opts.buttonPrimaryClass);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
98
core/misc/dialog/dialog.js
Normal file
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* @file
|
||||
* Dialog API inspired by HTML5 dialog element.
|
||||
*
|
||||
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#the-dialog-element
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Default dialog options.
|
||||
*
|
||||
* @type {object}
|
||||
*
|
||||
* @prop {bool} [autoOpen=true]
|
||||
* @prop {string} [dialogClass='']
|
||||
* @prop {string} [buttonClass='button']
|
||||
* @prop {string} [buttonPrimaryClass='button--primary']
|
||||
* @prop {function} close
|
||||
*/
|
||||
drupalSettings.dialog = {
|
||||
autoOpen: true,
|
||||
dialogClass: '',
|
||||
// Drupal-specific extensions: see dialog.jquery-ui.js.
|
||||
buttonClass: 'button',
|
||||
buttonPrimaryClass: 'button--primary',
|
||||
// When using this API directly (when generating dialogs on the client
|
||||
// side), you may want to override this method and do
|
||||
// `jQuery(event.target).remove()` as well, to remove the dialog on
|
||||
// closing.
|
||||
close: function (event) {
|
||||
Drupal.detachBehaviors(event.target, null, 'unload');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} Drupal.dialog~dialogDefinition
|
||||
*
|
||||
* @prop {boolean} open
|
||||
* Is the dialog open or not.
|
||||
* @prop {*} returnValue
|
||||
* Return value of the dialog.
|
||||
* @prop {function} show
|
||||
* Method to display the dialog on the page.
|
||||
* @prop {function} showModal
|
||||
* Method to display the dialog as a modal on the page.
|
||||
* @prop {function} close
|
||||
* Method to hide the dialog from the page.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Polyfill HTML5 dialog element with jQueryUI.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @param {object} options
|
||||
* jQuery UI options to be passed to the dialog.
|
||||
*
|
||||
* @return {Drupal.dialog~dialogDefinition}
|
||||
*/
|
||||
Drupal.dialog = function (element, options) {
|
||||
|
||||
function openDialog(settings) {
|
||||
settings = $.extend({}, drupalSettings.dialog, options, settings);
|
||||
// Trigger a global event to allow scripts to bind events to the dialog.
|
||||
$(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
|
||||
$element.dialog(settings);
|
||||
dialog.open = true;
|
||||
$(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
|
||||
}
|
||||
|
||||
function closeDialog(value) {
|
||||
$(window).trigger('dialog:beforeclose', [dialog, $element]);
|
||||
$element.dialog('close');
|
||||
dialog.returnValue = value;
|
||||
dialog.open = false;
|
||||
$(window).trigger('dialog:afterclose', [dialog, $element]);
|
||||
}
|
||||
|
||||
var undef;
|
||||
var $element = $(element);
|
||||
var dialog = {
|
||||
open: false,
|
||||
returnValue: undef,
|
||||
show: function () {
|
||||
openDialog({modal: false});
|
||||
},
|
||||
showModal: function () {
|
||||
openDialog({modal: true});
|
||||
},
|
||||
close: closeDialog
|
||||
};
|
||||
|
||||
return dialog;
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, drupalSettings);
|
106
core/misc/dialog/dialog.position.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* @file
|
||||
* Positioning extensions for dialogs.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Triggers when content inside a dialog changes.
|
||||
*
|
||||
* @event dialogContentResize
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings, debounce, displace) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// autoResize option will turn off resizable and draggable.
|
||||
drupalSettings.dialog = $.extend({autoResize: true, maxHeight: '95%'}, drupalSettings.dialog);
|
||||
|
||||
/**
|
||||
* Resets the current options for positioning.
|
||||
*
|
||||
* This is used as a window resize and scroll callback to reposition the
|
||||
* jQuery UI dialog. Although not a built-in jQuery UI option, this can
|
||||
* be disabled by setting autoResize: false in the options array when creating
|
||||
* a new {@link Drupal.dialog}.
|
||||
*
|
||||
* @function Drupal.dialog~resetSize
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
*
|
||||
* @fires event:dialogContentResize
|
||||
*/
|
||||
function resetSize(event) {
|
||||
var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position'];
|
||||
var adjustedOptions = {};
|
||||
var windowHeight = $(window).height();
|
||||
var option;
|
||||
var optionValue;
|
||||
var adjustedValue;
|
||||
for (var n = 0; n < positionOptions.length; n++) {
|
||||
option = positionOptions[n];
|
||||
optionValue = event.data.settings[option];
|
||||
if (optionValue) {
|
||||
// jQuery UI does not support percentages on heights, convert to pixels.
|
||||
if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) {
|
||||
// Take offsets in account.
|
||||
windowHeight -= displace.offsets.top + displace.offsets.bottom;
|
||||
adjustedValue = parseInt(0.01 * parseInt(optionValue, 10) * windowHeight, 10);
|
||||
// Don't force the dialog to be bigger vertically than needed.
|
||||
if (option === 'height' && event.data.$element.parent().outerHeight() < adjustedValue) {
|
||||
adjustedValue = 'auto';
|
||||
}
|
||||
adjustedOptions[option] = adjustedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Offset the dialog center to be at the center of Drupal.displace.offsets.
|
||||
adjustedOptions = resetPosition(adjustedOptions);
|
||||
event.data.$element
|
||||
.dialog('option', adjustedOptions)
|
||||
.trigger('dialogContentResize');
|
||||
}
|
||||
|
||||
/**
|
||||
* Position the dialog's center at the center of displace.offsets boundaries.
|
||||
*
|
||||
* @function Drupal.dialog~resetPosition
|
||||
*
|
||||
* @param {object} options
|
||||
*
|
||||
* @return {object}
|
||||
*/
|
||||
function resetPosition(options) {
|
||||
var offsets = displace.offsets;
|
||||
var left = offsets.left - offsets.right;
|
||||
var top = offsets.top - offsets.bottom;
|
||||
|
||||
var leftString = (left > 0 ? '+' : '-') + Math.abs(Math.round(left / 2)) + 'px';
|
||||
var topString = (top > 0 ? '+' : '-') + Math.abs(Math.round(top / 2)) + 'px';
|
||||
options.position = {
|
||||
my: 'center' + (left !== 0 ? leftString : '') + ' center' + (top !== 0 ? topString : ''),
|
||||
of: window
|
||||
};
|
||||
return options;
|
||||
}
|
||||
|
||||
$(window).on({
|
||||
'dialog:aftercreate': function (event, dialog, $element, settings) {
|
||||
var autoResize = debounce(resetSize, 20);
|
||||
var eventData = {settings: settings, $element: $element};
|
||||
if (settings.autoResize === true || settings.autoResize === 'true') {
|
||||
$element
|
||||
.dialog('option', {resizable: false, draggable: false})
|
||||
.dialog('widget').css('position', 'fixed');
|
||||
$(window)
|
||||
.on('resize.dialogResize scroll.dialogResize', eventData, autoResize)
|
||||
.trigger('resize.dialogResize');
|
||||
$(document).on('drupalViewportOffsetChange', eventData, autoResize);
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': function (event, dialog, $element) {
|
||||
$(window).off('.dialogResize');
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery, Drupal, drupalSettings, Drupal.debounce, Drupal.displace);
|
222
core/misc/displace.js
Normal file
|
@ -0,0 +1,222 @@
|
|||
/**
|
||||
* @file
|
||||
* Manages elements that can offset the size of the viewport.
|
||||
*
|
||||
* Measures and reports viewport offset dimensions from elements like the
|
||||
* toolbar that can potentially displace the positioning of other elements.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} Drupal~displaceOffset
|
||||
*
|
||||
* @prop {number} top
|
||||
* @prop {number} left
|
||||
* @prop {number} right
|
||||
* @prop {number} bottom
|
||||
*/
|
||||
|
||||
/**
|
||||
* Triggers when layout of the page changes.
|
||||
*
|
||||
* This is used to position fixed element on the page during page resize and
|
||||
* Toolbar toggling.
|
||||
*
|
||||
* @event drupalViewportOffsetChange
|
||||
*/
|
||||
|
||||
(function ($, Drupal, debounce) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @name Drupal.displace.offsets
|
||||
*
|
||||
* @type {Drupal~displaceOffset}
|
||||
*/
|
||||
var offsets = {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a resize handler on the window.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.drupalDisplace = {
|
||||
attach: function () {
|
||||
// Mark this behavior as processed on the first pass.
|
||||
if (this.displaceProcessed) {
|
||||
return;
|
||||
}
|
||||
this.displaceProcessed = true;
|
||||
|
||||
$(window).on('resize.drupalDisplace', debounce(displace, 200));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Informs listeners of the current offset dimensions.
|
||||
*
|
||||
* @function Drupal.displace
|
||||
*
|
||||
* @prop {Drupal~displaceOffset} offsets
|
||||
*
|
||||
* @param {bool} [broadcast]
|
||||
* When true or undefined, causes the recalculated offsets values to be
|
||||
* broadcast to listeners.
|
||||
*
|
||||
* @return {Drupal~displaceOffset}
|
||||
* An object whose keys are the for sides an element -- top, right, bottom
|
||||
* and left. The value of each key is the viewport displacement distance for
|
||||
* that edge.
|
||||
*
|
||||
* @fires event:drupalViewportOffsetChange
|
||||
*/
|
||||
function displace(broadcast) {
|
||||
offsets = Drupal.displace.offsets = calculateOffsets();
|
||||
if (typeof broadcast === 'undefined' || broadcast) {
|
||||
$(document).trigger('drupalViewportOffsetChange', offsets);
|
||||
}
|
||||
return offsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the viewport offsets.
|
||||
*
|
||||
* @return {Drupal~displaceOffset}
|
||||
* An object whose keys are the for sides an element -- top, right, bottom
|
||||
* and left. The value of each key is the viewport displacement distance for
|
||||
* that edge.
|
||||
*/
|
||||
function calculateOffsets() {
|
||||
return {
|
||||
top: calculateOffset('top'),
|
||||
right: calculateOffset('right'),
|
||||
bottom: calculateOffset('bottom'),
|
||||
left: calculateOffset('left')
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a specific edge's offset.
|
||||
*
|
||||
* Any element with the attribute data-offset-{edge} e.g. data-offset-top will
|
||||
* be considered in the viewport offset calculations. If the attribute has a
|
||||
* numeric value, that value will be used. If no value is provided, one will
|
||||
* be calculated using the element's dimensions and placement.
|
||||
*
|
||||
* @function Drupal.displace.calculateOffset
|
||||
*
|
||||
* @param {string} edge
|
||||
* The name of the edge to calculate. Can be 'top', 'right',
|
||||
* 'bottom' or 'left'.
|
||||
*
|
||||
* @return {number}
|
||||
* The viewport displacement distance for the requested edge.
|
||||
*/
|
||||
function calculateOffset(edge) {
|
||||
var edgeOffset = 0;
|
||||
var displacingElements = document.querySelectorAll('[data-offset-' + edge + ']');
|
||||
var n = displacingElements.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var el = displacingElements[i];
|
||||
// If the element is not visible, do consider its dimensions.
|
||||
if (el.style.display === 'none') {
|
||||
continue;
|
||||
}
|
||||
// If the offset data attribute contains a displacing value, use it.
|
||||
var displacement = parseInt(el.getAttribute('data-offset-' + edge), 10);
|
||||
// If the element's offset data attribute exits
|
||||
// but is not a valid number then get the displacement
|
||||
// dimensions directly from the element.
|
||||
if (isNaN(displacement)) {
|
||||
displacement = getRawOffset(el, edge);
|
||||
}
|
||||
// If the displacement value is larger than the current value for this
|
||||
// edge, use the displacement value.
|
||||
edgeOffset = Math.max(edgeOffset, displacement);
|
||||
}
|
||||
|
||||
return edgeOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates displacement for element based on its dimensions and placement.
|
||||
*
|
||||
* @param {HTMLElement} el
|
||||
* The jQuery element whose dimensions and placement will be measured.
|
||||
*
|
||||
* @param {string} edge
|
||||
* The name of the edge of the viewport that the element is associated
|
||||
* with.
|
||||
*
|
||||
* @return {number}
|
||||
* The viewport displacement distance for the requested edge.
|
||||
*/
|
||||
function getRawOffset(el, edge) {
|
||||
var $el = $(el);
|
||||
var documentElement = document.documentElement;
|
||||
var displacement = 0;
|
||||
var horizontal = (edge === 'left' || edge === 'right');
|
||||
// Get the offset of the element itself.
|
||||
var placement = $el.offset()[horizontal ? 'left' : 'top'];
|
||||
// Subtract scroll distance from placement to get the distance
|
||||
// to the edge of the viewport.
|
||||
placement -= window['scroll' + (horizontal ? 'X' : 'Y')] || document.documentElement['scroll' + (horizontal) ? 'Left' : 'Top'] || 0;
|
||||
// Find the displacement value according to the edge.
|
||||
switch (edge) {
|
||||
// Left and top elements displace as a sum of their own offset value
|
||||
// plus their size.
|
||||
case 'top':
|
||||
// Total displacement is the sum of the elements placement and size.
|
||||
displacement = placement + $el.outerHeight();
|
||||
break;
|
||||
|
||||
case 'left':
|
||||
// Total displacement is the sum of the elements placement and size.
|
||||
displacement = placement + $el.outerWidth();
|
||||
break;
|
||||
|
||||
// Right and bottom elements displace according to their left and
|
||||
// top offset. Their size isn't important.
|
||||
case 'bottom':
|
||||
displacement = documentElement.clientHeight - placement;
|
||||
break;
|
||||
|
||||
case 'right':
|
||||
displacement = documentElement.clientWidth - placement;
|
||||
break;
|
||||
|
||||
default:
|
||||
displacement = 0;
|
||||
}
|
||||
return displacement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign the displace function to a property of the Drupal global object.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
Drupal.displace = displace;
|
||||
$.extend(Drupal.displace, {
|
||||
|
||||
/**
|
||||
* Expose offsets to other scripts to avoid having to recalculate offsets.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
offsets: offsets,
|
||||
|
||||
/**
|
||||
* Expose method to compute a single edge offsets.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
calculateOffset: calculateOffset
|
||||
});
|
||||
|
||||
})(jQuery, Drupal, Drupal.debounce);
|
164
core/misc/dropbutton/dropbutton.css
Normal file
|
@ -0,0 +1,164 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Base styles for dropbuttons.
|
||||
*/
|
||||
|
||||
/**
|
||||
* When a dropbutton has only one option, it is simply a button.
|
||||
*/
|
||||
.dropbutton-wrapper,
|
||||
.dropbutton-wrapper div {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.js .dropbutton-wrapper,
|
||||
.js .dropbutton-widget {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@media screen and (max-width:600px) {
|
||||
.js .dropbutton-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Splitbuttons */
|
||||
@media screen and (min-width:600px) {
|
||||
.form-actions .dropbutton-wrapper {
|
||||
float: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .form-actions .dropbutton-wrapper {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
.js .form-actions .dropbutton-widget {
|
||||
position: static;
|
||||
}
|
||||
.js td .dropbutton-widget {
|
||||
position: absolute;
|
||||
}
|
||||
.js td .dropbutton-wrapper {
|
||||
min-height: 2em;
|
||||
}
|
||||
.js td .dropbutton-multiple {
|
||||
padding-right: 10em; /* LTR */
|
||||
margin-right: 2em; /* LTR */
|
||||
max-width: 100%;
|
||||
}
|
||||
[dir="rtl"].js td .dropbutton-multiple {
|
||||
padding-right: 0;
|
||||
margin-right: 0;
|
||||
padding-left: 10em;
|
||||
margin-left: 2em;
|
||||
}
|
||||
.js td .dropbutton-multiple .dropbutton-action a,
|
||||
.js td .dropbutton-multiple .dropbutton-action input,
|
||||
.js td .dropbutton-multiple .dropbutton-action button {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* UL styles are over-scoped in core, so this selector needs weight parity. */
|
||||
.js .dropbutton-widget .dropbutton {
|
||||
list-style-image: none;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
.js .dropbutton li,
|
||||
.js .dropbutton a {
|
||||
display: block;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.js .dropbutton li:hover,
|
||||
.js .dropbutton li:focus,
|
||||
.js .dropbutton a:hover,
|
||||
.js .dropbutton a:focus {
|
||||
outline: initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* The dropbutton styling.
|
||||
*
|
||||
* A dropbutton is a widget that displays a list of action links as a button
|
||||
* with a primary action. Secondary actions are hidden behind a click on a
|
||||
* twisty arrow.
|
||||
*
|
||||
* The arrow is created using border on a zero-width, zero-height span.
|
||||
* The arrow inherits the link color, but can be overridden with border colors.
|
||||
*/
|
||||
.js .dropbutton-multiple .dropbutton-widget {
|
||||
padding-right: 2em; /* LTR */
|
||||
}
|
||||
.js[dir="rtl"] .dropbutton-multiple .dropbutton-widget {
|
||||
padding-left: 2em;
|
||||
padding-right: 0;
|
||||
}
|
||||
.dropbutton-multiple.open,
|
||||
.dropbutton-multiple.open .dropbutton-widget {
|
||||
max-width: none;
|
||||
}
|
||||
.dropbutton-multiple.open {
|
||||
z-index: 100;
|
||||
}
|
||||
.dropbutton-multiple .dropbutton .secondary-action {
|
||||
display: none;
|
||||
}
|
||||
.dropbutton-multiple.open .dropbutton .secondary-action {
|
||||
display: block;
|
||||
}
|
||||
.dropbutton-toggle {
|
||||
bottom: 0;
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 0; /* LTR */
|
||||
text-indent: 110%;
|
||||
top: 0;
|
||||
white-space: nowrap;
|
||||
width: 2em;
|
||||
}
|
||||
[dir="rtl"] .dropbutton-toggle {
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
.dropbutton-toggle button {
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.dropbutton-toggle button:hover,
|
||||
.dropbutton-toggle button:focus {
|
||||
outline: initial;
|
||||
}
|
||||
.dropbutton-arrow {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
border-style: solid;
|
||||
border-width: 0.3333em 0.3333em 0;
|
||||
display: block;
|
||||
height: 0;
|
||||
line-height: 0;
|
||||
position: absolute;
|
||||
right: 40%; /* 0.6667em; */ /* LTR */
|
||||
top: 50%;
|
||||
margin-top: -0.1666em;
|
||||
width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
[dir="rtl"] .dropbutton-arrow {
|
||||
left: 0.6667em;
|
||||
right: auto;
|
||||
}
|
||||
.dropbutton-multiple.open .dropbutton-arrow {
|
||||
border-bottom: 0.3333em solid;
|
||||
border-top-color: transparent;
|
||||
top: 0.6667em;
|
||||
}
|
226
core/misc/dropbutton/dropbutton.js
Normal file
|
@ -0,0 +1,226 @@
|
|||
/**
|
||||
* @file
|
||||
* Dropbutton feature.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Process elements with the .dropbutton class on page load.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.dropButton = {
|
||||
attach: function (context, settings) {
|
||||
var $dropbuttons = $(context).find('.dropbutton-wrapper').once('dropbutton');
|
||||
if ($dropbuttons.length) {
|
||||
// Adds the delegated handler that will toggle dropdowns on click.
|
||||
var $body = $('body').once('dropbutton-click');
|
||||
if ($body.length) {
|
||||
$body.on('click', '.dropbutton-toggle', dropbuttonClickHandler);
|
||||
}
|
||||
// Initialize all buttons.
|
||||
var il = $dropbuttons.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
DropButton.dropbuttons.push(new DropButton($dropbuttons[i], settings.dropbutton));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegated callback for opening and closing dropbutton secondary actions.
|
||||
*
|
||||
* @function Drupal.DropButton~dropbuttonClickHandler
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
*/
|
||||
function dropbuttonClickHandler(e) {
|
||||
e.preventDefault();
|
||||
$(e.target).closest('.dropbutton-wrapper').toggleClass('open');
|
||||
}
|
||||
|
||||
/**
|
||||
* A DropButton presents an HTML list as a button with a primary action.
|
||||
*
|
||||
* All secondary actions beyond the first in the list are presented in a
|
||||
* dropdown list accessible through a toggle arrow associated with the button.
|
||||
*
|
||||
* @constructor Drupal.DropButton
|
||||
*
|
||||
* @param {HTMLElement} dropbutton
|
||||
* A DOM element.
|
||||
* @param {object} settings
|
||||
* A list of options including:
|
||||
* @param {string} settings.title
|
||||
* The text inside the toggle link element. This text is hidden
|
||||
* from visual UAs.
|
||||
*/
|
||||
function DropButton(dropbutton, settings) {
|
||||
// Merge defaults with settings.
|
||||
var options = $.extend({'title': Drupal.t('List additional actions')}, settings);
|
||||
var $dropbutton = $(dropbutton);
|
||||
|
||||
/**
|
||||
* @type {jQuery}
|
||||
*/
|
||||
this.$dropbutton = $dropbutton;
|
||||
|
||||
/**
|
||||
* @type {jQuery}
|
||||
*/
|
||||
this.$list = $dropbutton.find('.dropbutton');
|
||||
|
||||
/**
|
||||
* Find actions and mark them.
|
||||
*
|
||||
* @type {jQuery}
|
||||
*/
|
||||
this.$actions = this.$list.find('li').addClass('dropbutton-action');
|
||||
|
||||
// Add the special dropdown only if there are hidden actions.
|
||||
if (this.$actions.length > 1) {
|
||||
// Identify the first element of the collection.
|
||||
var $primary = this.$actions.slice(0, 1);
|
||||
// Identify the secondary actions.
|
||||
var $secondary = this.$actions.slice(1);
|
||||
$secondary.addClass('secondary-action');
|
||||
// Add toggle link.
|
||||
$primary.after(Drupal.theme('dropbuttonToggle', options));
|
||||
// Bind mouse events.
|
||||
this.$dropbutton
|
||||
.addClass('dropbutton-multiple')
|
||||
.on({
|
||||
|
||||
/**
|
||||
* Adds a timeout to close the dropdown on mouseleave.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
'mouseleave.dropbutton': $.proxy(this.hoverOut, this),
|
||||
|
||||
/**
|
||||
* Clears timeout when mouseout of the dropdown.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
'mouseenter.dropbutton': $.proxy(this.hoverIn, this),
|
||||
|
||||
/**
|
||||
* Similar to mouseleave/mouseenter, but for keyboard navigation.
|
||||
*
|
||||
* @ignore
|
||||
*/
|
||||
'focusout.dropbutton': $.proxy(this.focusOut, this),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
'focusin.dropbutton': $.proxy(this.focusIn, this)
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.$dropbutton.addClass('dropbutton-single');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the DropButton constructor.
|
||||
*/
|
||||
$.extend(DropButton, /** @lends Drupal.DropButton */{
|
||||
/**
|
||||
* Store all processed DropButtons.
|
||||
*
|
||||
* @type {Array.<Drupal.DropButton>}
|
||||
*/
|
||||
dropbuttons: []
|
||||
});
|
||||
|
||||
/**
|
||||
* Extend the DropButton prototype.
|
||||
*/
|
||||
$.extend(DropButton.prototype, /** @lends Drupal.DropButton# */{
|
||||
|
||||
/**
|
||||
* Toggle the dropbutton open and closed.
|
||||
*
|
||||
* @param {bool} [show]
|
||||
* Force the dropbutton to open by passing true or to close by
|
||||
* passing false.
|
||||
*/
|
||||
toggle: function (show) {
|
||||
var isBool = typeof show === 'boolean';
|
||||
show = isBool ? show : !this.$dropbutton.hasClass('open');
|
||||
this.$dropbutton.toggleClass('open', show);
|
||||
},
|
||||
|
||||
/**
|
||||
* @method
|
||||
*/
|
||||
hoverIn: function () {
|
||||
// Clear any previous timer we were using.
|
||||
if (this.timerID) {
|
||||
window.clearTimeout(this.timerID);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @method
|
||||
*/
|
||||
hoverOut: function () {
|
||||
// Wait half a second before closing.
|
||||
this.timerID = window.setTimeout($.proxy(this, 'close'), 500);
|
||||
},
|
||||
|
||||
/**
|
||||
* @method
|
||||
*/
|
||||
open: function () {
|
||||
this.toggle(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* @method
|
||||
*/
|
||||
close: function () {
|
||||
this.toggle(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {jQuery.Event} e
|
||||
*/
|
||||
focusOut: function (e) {
|
||||
this.hoverOut.call(this, e);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {jQuery.Event} e
|
||||
*/
|
||||
focusIn: function (e) {
|
||||
this.hoverIn.call(this, e);
|
||||
}
|
||||
});
|
||||
|
||||
$.extend(Drupal.theme, /** @lends Drupal.theme */{
|
||||
|
||||
/**
|
||||
* A toggle is an interactive element often bound to a click handler.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {string} [options.title]
|
||||
* The HTML anchor title attribute and text for the inner span element.
|
||||
*
|
||||
* @return {string}
|
||||
* A string representing a DOM fragment.
|
||||
*/
|
||||
dropbuttonToggle: function (options) {
|
||||
return '<li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">' + options.title + '</span></span></button></li>';
|
||||
}
|
||||
});
|
||||
|
||||
// Expose constructor in the public space.
|
||||
Drupal.DropButton = DropButton;
|
||||
|
||||
})(jQuery, Drupal);
|
34
core/misc/dropbutton/dropbutton.theme.css
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* General styles for dropbuttons.
|
||||
*/
|
||||
|
||||
.js .dropbutton-widget {
|
||||
background-color: white;
|
||||
border: 1px solid #cccccc;
|
||||
}
|
||||
.js .dropbutton-widget:hover {
|
||||
border-color: #b8b8b8;
|
||||
}
|
||||
.dropbutton .dropbutton-action > * {
|
||||
padding: 0.1em 0.5em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dropbutton .secondary-action {
|
||||
border-top: 1px solid #e8e8e8;
|
||||
}
|
||||
.dropbutton-multiple .dropbutton {
|
||||
border-right: 1px solid #e8e8e8; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .dropbutton-multiple .dropbutton {
|
||||
border-left: 1px solid #e8e8e8;
|
||||
border-right: 0 none;
|
||||
}
|
||||
.dropbutton-multiple .dropbutton .dropbutton-action > * {
|
||||
margin-right: 0.25em; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .dropbutton-multiple .dropbutton .dropbutton-action > * {
|
||||
margin-left: 0.25em;
|
||||
margin-right: 0;
|
||||
}
|
574
core/misc/drupal.js
Normal file
|
@ -0,0 +1,574 @@
|
|||
/**
|
||||
* @file
|
||||
* Defines the Drupal JS API.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A jQuery object.
|
||||
*
|
||||
* @typedef {object} jQuery
|
||||
*
|
||||
* @prop {number} length=0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Variable generated by Drupal with all the configuration created from PHP.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @var {object} drupalSettings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Variable generated by Drupal that holds all translated strings from PHP.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @var {object} drupalTranslations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Global Drupal object.
|
||||
*
|
||||
* @global
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
window.Drupal = {behaviors: {}, locale: {}};
|
||||
|
||||
// Class indicating that JS is enabled; used for styling purpose.
|
||||
document.documentElement.className += ' js';
|
||||
|
||||
// Allow other JavaScript libraries to use $.
|
||||
if (window.jQuery) {
|
||||
jQuery.noConflict();
|
||||
}
|
||||
|
||||
// JavaScript should be made compatible with libraries other than jQuery by
|
||||
// wrapping it in an anonymous closure.
|
||||
(function (domready, Drupal, drupalSettings, drupalTranslations) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Custom error type thrown after attach/detach if one or more behaviors
|
||||
* failed.
|
||||
*
|
||||
* @memberof Drupal
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* Callback function initializing code run on page load and Ajax requests.
|
||||
*
|
||||
* @callback Drupal~behaviorAttach
|
||||
*
|
||||
* @param {HTMLElement} context
|
||||
* @param {object} settings
|
||||
*
|
||||
* @see Drupal.attachBehaviors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function for reverting and cleaning up behavior initialization.
|
||||
*
|
||||
* @callback Drupal~behaviorDetach
|
||||
*
|
||||
* @param {HTMLElement} context
|
||||
* @param {object} settings
|
||||
* @param {string} trigger
|
||||
* One of 'unload', 'serialize' or 'move'.
|
||||
*
|
||||
* @see Drupal.detachBehaviors
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} Drupal~behavior
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Holds all initialization methods.
|
||||
*
|
||||
* @namespace Drupal.behaviors
|
||||
*
|
||||
* @type {Object.<string, Drupal~behavior>}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attach 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:
|
||||
*
|
||||
* {@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.)
|
||||
*
|
||||
* @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
|
||||
* An object containing settings for the current context. If none is given,
|
||||
* the global drupalSettings object is used.
|
||||
*
|
||||
* @see Drupal~behaviorAttach
|
||||
* @see Drupal.detachBehaviors
|
||||
*
|
||||
* @throws {Drupal~DrupalBehaviorError}
|
||||
*/
|
||||
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) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') {
|
||||
// Don't stop the execution of behaviors in case of an error.
|
||||
try {
|
||||
behaviors[i].attach(context, settings);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push({behavior: i, error: 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* An object containing settings for the current context. If none given,
|
||||
* the global drupalSettings object is used.
|
||||
* @param {string} trigger
|
||||
* 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,
|
||||
* 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
|
||||
* do anything simply in response to the element being moved, but because
|
||||
* 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
|
||||
* 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
|
||||
* that WYSIWYG editors can update the hidden textarea to which they are
|
||||
* bound.
|
||||
*
|
||||
* @throws {Drupal~DrupalBehaviorError}
|
||||
*
|
||||
* @see Drupal~behaviorDetach
|
||||
* @see Drupal.attachBehaviors
|
||||
*/
|
||||
Drupal.detachBehaviors = function (context, settings, trigger) {
|
||||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
trigger = trigger || 'unload';
|
||||
var errors = [];
|
||||
var behaviors = Drupal.behaviors;
|
||||
// Execute all of them.
|
||||
for (var i in behaviors) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function') {
|
||||
// Don't stop the execution of behaviors in case of an error.
|
||||
try {
|
||||
behaviors[i].detach(context, settings, trigger);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push({behavior: i, error: 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.
|
||||
*
|
||||
* @param {number} [width=640]
|
||||
*
|
||||
* @return {bool}
|
||||
*
|
||||
* @deprecated Temporary solution for the mobile initiative.
|
||||
*/
|
||||
Drupal.checkWidthBreakpoint = function (width) {
|
||||
width = width || drupalSettings.widthBreakpoint || 640;
|
||||
return (document.documentElement.clientWidth > width);
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode special characters in a plain-text string for display as HTML.
|
||||
*
|
||||
* @param {string} str
|
||||
* The string to be encoded.
|
||||
*
|
||||
* @return {string}
|
||||
* The encoded string.
|
||||
*
|
||||
* @ingroup sanitization
|
||||
*/
|
||||
Drupal.checkPlain = function (str) {
|
||||
str = str.toString()
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Replace placeholders with sanitized values in a string.
|
||||
*
|
||||
* @param {string} str
|
||||
* A string with placeholders.
|
||||
* @param {object} args
|
||||
* 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'))
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @see Drupal.t
|
||||
*/
|
||||
Drupal.formatString = function (str, args) {
|
||||
// Keep args intact.
|
||||
var processedArgs = {};
|
||||
// Transform arguments before inserting them.
|
||||
for (var key in args) {
|
||||
if (args.hasOwnProperty(key)) {
|
||||
switch (key.charAt(0)) {
|
||||
// Escaped only.
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
|
||||
// Pass-through.
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
|
||||
// Escaped and placeholder.
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Drupal.stringReplace(str, processedArgs, null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Replace substring.
|
||||
*
|
||||
* The longest keys will be tried first. Once a substring has been replaced,
|
||||
* its new value will not be searched again.
|
||||
*
|
||||
* @param {string} str
|
||||
* A string with placeholders.
|
||||
* @param {object} args
|
||||
* Key-value pairs.
|
||||
* @param {Array|null} keys
|
||||
* Array of keys from the "args". Internal use only.
|
||||
*
|
||||
* @return {string}
|
||||
* Returns the replaced string.
|
||||
*/
|
||||
Drupal.stringReplace = function (str, args, keys) {
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
// If the array of keys is not passed then collect the keys from the args.
|
||||
if (!Array.isArray(keys)) {
|
||||
keys = [];
|
||||
for (var k in args) {
|
||||
if (args.hasOwnProperty(k)) {
|
||||
keys.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
// Order the keys by the character length. The shortest one is the first.
|
||||
keys.sort(function (a, b) { return a.length - b.length; });
|
||||
}
|
||||
|
||||
if (keys.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
// Take next longest one from the end.
|
||||
var key = keys.pop();
|
||||
var fragments = str.split(key);
|
||||
|
||||
if (keys.length) {
|
||||
for (var i = 0; i < fragments.length; i++) {
|
||||
// Process each fragment with a copy of remaining keys.
|
||||
fragments[i] = Drupal.stringReplace(fragments[i], args, keys.slice(0));
|
||||
}
|
||||
}
|
||||
|
||||
return fragments.join(args[key]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Translate strings to the page language or a given language.
|
||||
*
|
||||
* See the documentation of the server-side t() function for further details.
|
||||
*
|
||||
* @param {string} str
|
||||
* A string containing the English string to translate.
|
||||
* @param {Object.<string, string>} [args]
|
||||
* An object of replacements pairs to make after translation. Incidences
|
||||
* of any key in this array are replaced with the corresponding value.
|
||||
* See {@link Drupal.formatString}.
|
||||
* @param {object} [options]
|
||||
* @param {string} [options.context='']
|
||||
* The context the source string belongs to.
|
||||
*
|
||||
* @return {string}
|
||||
* The translated string.
|
||||
*/
|
||||
Drupal.t = function (str, args, options) {
|
||||
options = options || {};
|
||||
options.context = options.context || '';
|
||||
|
||||
// Fetch the localized version of the string.
|
||||
if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) {
|
||||
str = drupalTranslations.strings[options.context][str];
|
||||
}
|
||||
|
||||
if (args) {
|
||||
str = Drupal.formatString(str, args);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the URL to a Drupal page.
|
||||
*
|
||||
* @param {string} path
|
||||
* Drupal path to transform to URL.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
Drupal.url = function (path) {
|
||||
return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Format 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
|
||||
* already-localized strings to it.
|
||||
*
|
||||
* See the documentation of the server-side
|
||||
* \Drupal\Core\StringTranslation\TranslationInterface::formatPlural()
|
||||
* function for more details.
|
||||
*
|
||||
* @param {number} count
|
||||
* The item count to display.
|
||||
* @param {string} singular
|
||||
* The string for the singular case. Please make sure it is clear this is
|
||||
* singular, to ease translation (e.g. use "1 new comment" instead of "1
|
||||
* new"). Do not use @count in the singular string.
|
||||
* @param {string} plural
|
||||
* The string for the plural case. Please make sure it is clear this is
|
||||
* plural, to ease translation. Use @count in place of the item count, as in
|
||||
* "@count new comments".
|
||||
* @param {object} [args]
|
||||
* An object of replacements pairs to make after translation. Incidences
|
||||
* of any key in this array are replaced with the corresponding value.
|
||||
* See {@link Drupal.formatString}.
|
||||
* Note that you do not need to include @count in this array.
|
||||
* This replacement is done automatically for the plural case.
|
||||
* @param {object} [options]
|
||||
* The options to pass to the {@link Drupal.t} function.
|
||||
*
|
||||
* @return {string}
|
||||
* A translated string.
|
||||
*/
|
||||
Drupal.formatPlural = function (count, singular, plural, args, options) {
|
||||
args = args || {};
|
||||
args['@count'] = count;
|
||||
|
||||
var pluralDelimiter = drupalSettings.pluralDelimiter;
|
||||
var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter);
|
||||
var index = 0;
|
||||
|
||||
// Determine the index of the plural form.
|
||||
if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) {
|
||||
index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula['default'];
|
||||
}
|
||||
else if (args['@count'] !== 1) {
|
||||
index = 1;
|
||||
}
|
||||
|
||||
return translations[index];
|
||||
};
|
||||
|
||||
/**
|
||||
* Encodes a Drupal path for use in a URL.
|
||||
*
|
||||
* For aesthetic reasons slashes are not escaped.
|
||||
*
|
||||
* @param {string} item
|
||||
* Unencoded path.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
Drupal.encodePath = function (item) {
|
||||
return window.encodeURIComponent(item).replace(/%2F/g, '/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate 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)`.
|
||||
*
|
||||
* @namespace
|
||||
*
|
||||
* @param {function} func
|
||||
* The name of the theme function to call.
|
||||
* @param {...args}
|
||||
* Additional arguments to pass along to the theme function.
|
||||
*
|
||||
* @return {string|object|HTMLElement|jQuery}
|
||||
* Any data the theme function returns. This could be a plain HTML string,
|
||||
* but also a complex object.
|
||||
*/
|
||||
Drupal.theme = function (func) {
|
||||
var args = Array.prototype.slice.apply(arguments, [1]);
|
||||
if (func in Drupal.theme) {
|
||||
return Drupal.theme[func].apply(this, args);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats text for emphasized display in a placeholder inside a sentence.
|
||||
*
|
||||
* @param {string} str
|
||||
* The text to format (plain-text).
|
||||
*
|
||||
* @return {string}
|
||||
* The formatted text (html).
|
||||
*/
|
||||
Drupal.theme.placeholder = function (str) {
|
||||
return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
|
||||
};
|
||||
|
||||
})(domready, Drupal, window.drupalSettings, window.drupalTranslations);
|
BIN
core/misc/druplicon.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
core/misc/favicon.ico
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
core/misc/feed.png
Normal file
After Width: | Height: | Size: 656 B |
237
core/misc/form.js
Normal file
|
@ -0,0 +1,237 @@
|
|||
/**
|
||||
* @file
|
||||
* Form features.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Triggers when a value in the form changed.
|
||||
*
|
||||
* The event triggers when content is typed or pasted in a text field, before
|
||||
* the change event triggers.
|
||||
*
|
||||
* @event formUpdated
|
||||
*/
|
||||
|
||||
(function ($, Drupal, debounce) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Retrieves the summary for the first element.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
$.fn.drupalGetSummary = function () {
|
||||
var callback = this.data('summaryCallback');
|
||||
return (this[0] && callback) ? $.trim(callback(this[0])) : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the summary for all matched elements.
|
||||
*
|
||||
* @param {function} callback
|
||||
* Either a function that will be called each time the summary is
|
||||
* retrieved or a string (which is returned each time).
|
||||
*
|
||||
* @return {jQuery}
|
||||
*
|
||||
* @fires event:summaryUpdated
|
||||
*
|
||||
* @listens event:formUpdated
|
||||
*/
|
||||
$.fn.drupalSetSummary = function (callback) {
|
||||
var self = this;
|
||||
|
||||
// To facilitate things, the callback should always be a function. If it's
|
||||
// not, we wrap it into an anonymous function which just returns the value.
|
||||
if (typeof callback !== 'function') {
|
||||
var val = callback;
|
||||
callback = function () { return val; };
|
||||
}
|
||||
|
||||
return this
|
||||
.data('summaryCallback', callback)
|
||||
// To prevent duplicate events, the handlers are first removed and then
|
||||
// (re-)added.
|
||||
.off('formUpdated.summary')
|
||||
.on('formUpdated.summary', function () {
|
||||
self.trigger('summaryUpdated');
|
||||
})
|
||||
// The actual summaryUpdated handler doesn't fire when the callback is
|
||||
// changed, so we have to do this manually.
|
||||
.trigger('summaryUpdated');
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevents consecutive form submissions of identical form values.
|
||||
*
|
||||
* Repetitive form submissions that would submit the identical form values
|
||||
* are prevented, unless the form values are different to the previously
|
||||
* submitted values.
|
||||
*
|
||||
* This is a simplified re-implementation of a user-agent behavior that
|
||||
* should be natively supported by major web browsers, but at this time, only
|
||||
* Firefox has a built-in protection.
|
||||
*
|
||||
* A form value-based approach ensures that the constraint is triggered for
|
||||
* consecutive, identical form submissions only. Compared to that, a form
|
||||
* button-based approach would (1) rely on [visible] buttons to exist where
|
||||
* technically not required and (2) require more complex state management if
|
||||
* there are multiple buttons in a form.
|
||||
*
|
||||
* This implementation is based on form-level submit events only and relies
|
||||
* on jQuery's serialize() method to determine submitted form values. As such,
|
||||
* the following limitations exist:
|
||||
*
|
||||
* - Event handlers on form buttons that preventDefault() do not receive a
|
||||
* double-submit protection. That is deemed to be fine, since such button
|
||||
* events typically trigger reversible client-side or server-side
|
||||
* operations that are local to the context of a form only.
|
||||
* - Changed values in advanced form controls, such as file inputs, are not
|
||||
* part of the form values being compared between consecutive form submits
|
||||
* (due to limitations of jQuery.serialize()). That is deemed to be
|
||||
* acceptable, because if the user forgot to attach a file, then the size of
|
||||
* HTTP payload will most likely be small enough to be fully passed to the
|
||||
* server endpoint within (milli)seconds. If a user mistakenly attached a
|
||||
* wrong file and is technically versed enough to cancel the form submission
|
||||
* (and HTTP payload) in order to attach a different file, then that
|
||||
* edge-case is not supported here.
|
||||
*
|
||||
* Lastly, all forms submitted via HTTP GET are idempotent by definition of
|
||||
* HTTP standards, so excluded in this implementation.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.formSingleSubmit = {
|
||||
attach: function () {
|
||||
function onFormSubmit(e) {
|
||||
var $form = $(e.currentTarget);
|
||||
var formValues = $form.serialize();
|
||||
var previousValues = $form.attr('data-drupal-form-submit-last');
|
||||
if (previousValues === formValues) {
|
||||
e.preventDefault();
|
||||
}
|
||||
else {
|
||||
$form.attr('data-drupal-form-submit-last', formValues);
|
||||
}
|
||||
}
|
||||
|
||||
$('body').once('form-single-submit')
|
||||
.on('submit.singleSubmit', 'form:not([method~="GET"])', onFormSubmit);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a 'formUpdated' event each time a form element is modified.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
*
|
||||
* @fires event:formUpdated
|
||||
*/
|
||||
function triggerFormUpdated(element) {
|
||||
$(element).trigger('formUpdated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the IDs of all form fields in the given form.
|
||||
*
|
||||
* @param {HTMLFormElement} form
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
function fieldsList(form) {
|
||||
var $fieldList = $(form).find('[name]').map(function (index, element) {
|
||||
// We use id to avoid name duplicates on radio fields and filter out
|
||||
// elements with a name but no id.
|
||||
return element.getAttribute('id');
|
||||
});
|
||||
// Return a true array.
|
||||
return $.makeArray($fieldList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers the 'formUpdated' event on form elements when they are modified.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @fires event:formUpdated
|
||||
*/
|
||||
Drupal.behaviors.formUpdated = {
|
||||
attach: function (context) {
|
||||
var $context = $(context);
|
||||
var contextIsForm = $context.is('form');
|
||||
var $forms = (contextIsForm ? $context : $context.find('form')).once('form-updated');
|
||||
var formFields;
|
||||
|
||||
if ($forms.length) {
|
||||
// Initialize form behaviors, use $.makeArray to be able to use native
|
||||
// forEach array method and have the callback parameters in the right
|
||||
// order.
|
||||
$.makeArray($forms).forEach(function (form) {
|
||||
var events = 'change.formUpdated input.formUpdated ';
|
||||
var eventHandler = debounce(function (event) { triggerFormUpdated(event.target); }, 300);
|
||||
formFields = fieldsList(form).join(',');
|
||||
|
||||
form.setAttribute('data-drupal-form-fields', formFields);
|
||||
$(form).on(events, eventHandler);
|
||||
});
|
||||
}
|
||||
// On ajax requests context is the form element.
|
||||
if (contextIsForm) {
|
||||
formFields = fieldsList(context).join(',');
|
||||
// @todo replace with form.getAttribute() when #1979468 is in.
|
||||
var currentFields = $(context).attr('data-drupal-form-fields');
|
||||
// If there has been a change in the fields or their order, trigger
|
||||
// formUpdated.
|
||||
if (formFields !== currentFields) {
|
||||
triggerFormUpdated(context);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
detach: function (context, settings, trigger) {
|
||||
var $context = $(context);
|
||||
var contextIsForm = $context.is('form');
|
||||
if (trigger === 'unload') {
|
||||
var $forms = (contextIsForm ? $context : $context.find('form')).removeOnce('form-updated');
|
||||
if ($forms.length) {
|
||||
$.makeArray($forms).forEach(function (form) {
|
||||
form.removeAttribute('data-drupal-form-fields');
|
||||
$(form).off('.formUpdated');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Prepopulate form fields with information from the visitor browser.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.fillUserInfoFromBrowser = {
|
||||
attach: function (context, settings) {
|
||||
var userInfo = ['name', 'mail', 'homepage'];
|
||||
var $forms = $('[data-user-info-from-browser]').once('user-info-from-browser');
|
||||
if ($forms.length) {
|
||||
userInfo.map(function (info) {
|
||||
var $element = $forms.find('[name=' + info + ']');
|
||||
var browserData = localStorage.getItem('Drupal.visitor.' + info);
|
||||
var emptyOrDefault = ($element.val() === '' || ($element.attr('data-drupal-default-value') === $element.val()));
|
||||
if ($element.length && emptyOrDefault && browserData) {
|
||||
$element.val(browserData);
|
||||
}
|
||||
});
|
||||
}
|
||||
$forms.on('submit', function () {
|
||||
userInfo.map(function (info) {
|
||||
var $element = $forms.find('[name=' + info + ']');
|
||||
if ($element.length) {
|
||||
localStorage.setItem('Drupal.visitor.' + info, $element.val());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, Drupal.debounce);
|
BIN
core/misc/help.png
Normal file
After Width: | Height: | Size: 294 B |
1
core/misc/icons/000000/barchart.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#000000" d="M4 13.529c0 .275-.225.5-.5.5h-3c-.275 0-.5-.225-.5-.5v-4.25c0-.274.225-.5.5-.5h3c.275 0 .5.226.5.5v4.25zM10.002 13.529c0 .275-.225.5-.5.5h-3.002c-.275 0-.5-.225-.5-.5v-13c0-.275.225-.5.5-.5h3.002c.275 0 .5.225.5.5v13zM16.002 13.529c0 .275-.225.5-.5.5h-3c-.275 0-.5-.225-.5-.5v-9.5c0-.275.225-.5.5-.5h3c.275 0 .5.225.5.5v9.5z"/></g></svg>
|
After Width: | Height: | Size: 428 B |
1
core/misc/icons/000000/chevron-left.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M7.951 7.645c-.193.196-.193.516 0 .71l3.258 3.29c.193.193.191.519-.002.709l-1.371 1.371c-.193.192-.512.191-.707 0l-5.335-5.371c-.194-.194-.194-.514 0-.708l5.335-5.369c.195-.195.514-.195.707-.001l1.371 1.371c.193.194.195.513.002.709l-3.258 3.289z"/></svg>
|
After Width: | Height: | Size: 342 B |
2
core/misc/icons/000000/chevron-right.svg
Normal file
|
@ -0,0 +1,2 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M8.053 8.355c.193-.195.193-.517 0-.711l-3.26-3.289c-.193-.195-.192-.514.002-.709l1.371-1.371c.194-.194.512-.193.706.001l5.335 5.369c.195.195.195.515 0 .708l-5.335 5.37c-.194.192-.512.193-.706.002l-1.371-1.371c-.194-.195-.195-.514-.002-.709l3.26-3.29z"/></svg>
|
||||
|
After Width: | Height: | Size: 348 B |
1
core/misc/icons/000000/ex.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M3.51 13.925c.194.194.512.195.706.001l3.432-3.431c.194-.194.514-.194.708 0l3.432 3.431c.192.194.514.193.707-.001l1.405-1.417c.191-.195.189-.514-.002-.709l-3.397-3.4c-.192-.193-.192-.514-.002-.708l3.401-3.43c.189-.195.189-.515 0-.709l-1.407-1.418c-.195-.195-.513-.195-.707-.001l-3.43 3.431c-.195.194-.516.194-.708 0l-3.432-3.431c-.195-.195-.512-.194-.706.001l-1.407 1.417c-.194.195-.194.515 0 .71l3.403 3.429c.193.195.193.514-.001.708l-3.4 3.399c-.194.195-.195.516-.001.709l1.406 1.419z"/></svg>
|
After Width: | Height: | Size: 582 B |
1
core/misc/icons/000000/file.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#000000" d="M12.502 7h-5c-.276 0-.502-.225-.502-.5v-5c0-.275-.225-.5-.5-.5h-3c-.275 0-.5.225-.5.5v12.029c0 .275.225.5.5.5h9.002c.275 0 .5-.225.5-.5v-6.029c0-.275-.225-.5-.5-.5zM8.502 6h4c.275 0 .34-.159.146-.354l-4.293-4.292c-.195-.195-.353-.129-.353.146v4c0 .275.225.5.5.5z"/></g></svg>
|
After Width: | Height: | Size: 366 B |
1
core/misc/icons/000000/move.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M14.904 7.753l-2.373-2.372c-.291-.292-.529-.193-.529.22v1.399h-3v-3h1.398c.414 0 .512-.239.221-.53l-2.371-2.372c-.137-.136-.36-.136-.497 0l-2.372 2.372c-.292.292-.193.53.22.53h1.399v3h-3v-1.369c0-.413-.239-.511-.53-.22l-2.372 2.372c-.136.136-.136.359 0 .494l2.372 2.372c.291.292.53.192.53-.219v-1.43h3v3h-1.4c-.413 0-.511.238-.22.529l2.374 2.373c.137.137.36.137.495 0l2.373-2.373c.29-.291.19-.529-.222-.529h-1.398v-3h3v1.4c0 .412.238.511.529.219l2.373-2.371c.137-.137.137-.359 0-.495z"/></svg>
|
After Width: | Height: | Size: 581 B |
1
core/misc/icons/000000/orgchart.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path d="M15.002,11.277c0-0.721,0-1.471,0-2.014c0-1.456-0.824-2.25-2.25-2.25c-1.428,0-3.5,0-3.5,0c-0.139,0-0.25-0.112-0.25-0.25v-2.04c0.596-0.346,1-0.984,1-1.723c0-1.104-0.895-2-2-2C6.896,1,6,1.896,6,3c0,0.738,0.405,1.376,1,1.722v2.042c0,0.138-0.112,0.25-0.25,0.25c0,0-2.138,0-3.5,0S1,7.932,1,9.266c0,0.521,0,1.277,0,2.012c-0.595,0.353-1,0.984-1,1.729c0,1.104,0.896,2,2,2s2-0.896,2-2c0-0.732-0.405-1.377-1-1.729V9.266c0-0.139,0.112-0.25,0.25-0.25h3.536C6.904,9.034,7,9.126,7,9.25v2.027C6.405,11.624,6,12.26,6,13c0,1.104,0.896,2,2.002,2c1.105,0,2-0.896,2-2c0-0.738-0.404-1.376-1-1.723V9.25c0-0.124,0.098-0.216,0.215-0.234h3.535c0.137,0,0.25,0.111,0.25,0.25v2.012c-0.596,0.353-1,0.984-1,1.729c0,1.104,0.896,2,2,2s2-0.896,2-2C16.002,12.262,15.598,11.623,15.002,11.277z"/></svg>
|
After Width: | Height: | Size: 842 B |
1
core/misc/icons/000000/paintbrush.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M8.184 7.928l-1.905 1.983-3.538-2.436 4.714-4.713 2.623 3.183-1.894 1.983zm-1.746-7.523c-.236-.416-.803-.649-1.346.083-.259.349-4.727 4.764-4.91 4.983-.182.218-.294.721.044.976.34.258 5.611 3.933 5.611 3.933l-.225.229c.7.729.816.854 1.046.863.75.016 2.035-1.457 2.578-.854.541.604 3.537 3.979 3.537 3.979.51.531 1.305.559 1.815.041.521-.521.541-1.311.025-1.848 0 0-2.742-2.635-3.904-3.619-.578-.479.869-2.051.854-2.839-.008-.238-.125-.361-.823-1.095l-.22.243c0 .003-3.846-4.659-4.082-5.075z"/></svg>
|
After Width: | Height: | Size: 587 B |
1
core/misc/icons/000000/people.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#000000" d="M6.722 11.291l.451-.17-.165-.32c-.536-1.039-.685-1.934-.761-2.672-.082-.808-.144-2.831 1.053-4.189.244-.278.493-.493.743-.675.012-.826-.135-1.766-.646-2.345-.618-.7-1.4-.787-1.4-.787l-.497-.055-.498.055s-.783.087-1.398.787c-.617.702-.717 1.948-.625 2.855.06.583.17 1.263.574 2.05.274.533.341.617.355 1.01.022.595.027 1.153-.671 1.538-.697.383-1.564.508-2.403 1.088-.596.41-.709 1.033-.78 1.459l-.051.41c-.029.273.173.498.448.498h5.012c.457-.24.89-.402 1.259-.537zM5.064 15.096c.07-.427.184-1.05.78-1.46.838-.581 1.708-.706 2.404-1.089.699-.385.693-.943.672-1.537-.014-.393-.08-.477-.354-1.01-.406-.787-.515-1.467-.576-2.049-.093-.909.008-2.155.625-2.856.615-.7 1.398-.787 1.398-.787l.492-.055h.002l.496.055s.781.087 1.396.787c.615.701.72 1.947.623 2.855-.062.583-.172 1.262-.571 2.049-.271.533-.341.617-.354 1.01-.021.595-.062 1.22.637 1.604.697.385 1.604.527 2.438 1.104.923.641.822 1.783.822 1.783-.022.275-.269.5-.542.5h-9.991c-.275 0-.477-.223-.448-.496l.051-.408z"/></g></svg>
|
After Width: | Height: | Size: 1 KiB |
1
core/misc/icons/000000/puzzlepiece.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M11.002 11v2.529c0 .275-.225.471-.5.471h-3c-.827 0-1.112-.754-.604-1.316l.81-.725c.509-.562.513-1.461-.097-2.01-.383-.344-1.027-.728-2.111-.728s-1.727.386-2.109.731c-.609.549-.606 1.45-.097 2.015l.808.717c.509.562.223 1.316-.602 1.316h-3c-.276 0-.5-.193-.5-.471v-9.029c0-.276.224-.5.5-.5h3c.825 0 1.111-.768.602-1.332l-.808-.73c-.51-.563-.513-1.465.097-2.014.382-.344 1.025-.731 2.109-.731s1.728.387 2.111.731c.608.548.606 1.45.097 2.014l-.81.73c-.509.564-.223 1.332.603 1.332h3c.274 0 .5.224.5.5v2.5c0 .825.642 1.111 1.233.602l.771-.808c.599-.51 1.547-.513 2.127.097.364.383.772 1.025.772 2.109s-.408 1.727-.771 2.109c-.58.604-1.529.604-2.127.097l-.77-.808c-.593-.509-1.234-.223-1.234.602z"/></svg>
|
After Width: | Height: | Size: 787 B |
1
core/misc/icons/000000/questionmark-disc.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" 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-7zm3 5c0 .551-.16 1.085-.477 1.586l-.158.22c-.07.093-.189.241-.361.393-.168.148-.35.299-.545.447l-.203.189-.141.129-.096.17-.021.235v.63h-2.001v-.704c.026-.396.078-.73.204-.999.125-.269.271-.498.439-.688l.225-.21-.01-.015.176-.14.137-.128c.186-.139.357-.277.516-.417l.148-.18c.098-.152.168-.323.168-.518 0-.552-.447-1-1-1s-1.002.448-1.002 1h-2c0-1.657 1.343-3 3.002-3 1.656 0 3 1.343 3 3zm-1.75 6.619c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.238c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.238z"/></svg>
|
After Width: | Height: | Size: 709 B |
1
core/misc/icons/000000/wrench.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#000000" d="M14.416 11.586l-.01-.008v-.001l-5.656-5.656c.15-.449.252-.921.252-1.421 0-2.485-2.016-4.5-4.502-4.5-.505 0-.981.102-1.434.255l2.431 2.431-.588 2.196-2.196.588-2.445-2.445c-.162.464-.268.956-.268 1.475 0 2.486 2.014 4.5 4.5 4.5.5 0 .972-.102 1.421-.251l5.667 5.665c.781.781 2.047.781 2.828 0s.781-2.047 0-2.828z"/></svg>
|
After Width: | Height: | Size: 407 B |
1
core/misc/icons/0074bd/chevron-left.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#0074bd" d="M7.951 7.645c-.193.196-.193.516 0 .71l3.258 3.29c.193.193.191.519-.002.709l-1.371 1.371c-.193.192-.512.191-.707 0l-5.335-5.371c-.194-.194-.194-.514 0-.708l5.335-5.369c.195-.195.514-.195.707-.001l1.371 1.371c.193.194.195.513.002.709l-3.258 3.289z"/></svg>
|
After Width: | Height: | Size: 342 B |
1
core/misc/icons/0074bd/chevron-right.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#0074bd" d="M8.053 8.355c.193-.195.193-.517 0-.711l-3.26-3.289c-.193-.195-.192-.514.002-.709l1.371-1.371c.194-.194.512-.193.706.001l5.335 5.369c.195.195.195.515 0 .708l-5.335 5.37c-.194.192-.512.193-.706.002l-1.371-1.371c-.194-.195-.195-.514-.002-.709l3.26-3.29z"/></svg>
|
After Width: | Height: | Size: 347 B |
1
core/misc/icons/333333/caret-down.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#333333" d="M3.8 5.4c-.165-.22-.075-.4.2-.4h8.002c.275 0 .365.18.199.4l-3.898 5.2c-.166.221-.436.221-.6 0l-3.903-5.2z"/></svg>
|
After Width: | Height: | Size: 202 B |
1
core/misc/icons/424242/loupe.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#424242" d="M14.648 12.788l-4.23-4.228c.525-.855.834-1.858.834-2.938 0-3.105-2.52-5.624-5.627-5.624-3.106.002-5.625 2.521-5.625 5.627 0 3.105 2.519 5.625 5.625 5.625 1.076 0 2.08-.309 2.936-.832l4.229 4.229c.194.195.515.195.707 0l1.151-1.146c.194-.2.194-.519 0-.713zm-13.35-7.163c0-2.39 1.938-4.327 4.327-4.327 2.391 0 4.328 1.937 4.328 4.327 0 2.391-1.936 4.327-4.328 4.327-2.39 0-4.327-1.936-4.327-4.327z"/></svg>
|
After Width: | Height: | Size: 491 B |
1
core/misc/icons/505050/loupe.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#505050" d="M14.648 12.788l-4.23-4.228c.525-.855.834-1.858.834-2.938 0-3.105-2.52-5.624-5.627-5.624-3.106.002-5.625 2.521-5.625 5.627 0 3.105 2.519 5.625 5.625 5.625 1.076 0 2.08-.309 2.936-.832l4.229 4.229c.194.195.515.195.707 0l1.151-1.146c.194-.2.194-.519 0-.713zm-13.35-7.163c0-2.39 1.938-4.327 4.327-4.327 2.391 0 4.328 1.937 4.328 4.327 0 2.391-1.936 4.327-4.328 4.327-2.39 0-4.327-1.936-4.327-4.327z"/></svg>
|
After Width: | Height: | Size: 491 B |
1
core/misc/icons/5181c6/chevron-disc-down.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#5181C6" d="M8.002 1c-3.869 0-7.002 3.134-7.002 7s3.133 7 7.002 7c3.865 0 7-3.134 7-7s-3.135-7-7-7zm4.459 6.336l-4.105 4.105c-.196.189-.515.189-.708 0l-4.107-4.105c-.194-.194-.194-.513 0-.707l.977-.978c.194-.194.513-.194.707 0l2.422 2.421c.192.195.513.195.708 0l2.422-2.42c.188-.194.512-.194.707 0l.977.977c.193.194.193.513 0 .707z"/></svg>
|
After Width: | Height: | Size: 416 B |
1
core/misc/icons/5181c6/chevron-disc-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#5181C6" d="M8.002 1c-3.867 0-7.002 3.134-7.002 7s3.135 7 7.002 7 7-3.134 7-7-3.133-7-7-7zm4.462 8.37l-.979.979c-.19.19-.516.19-.707 0l-2.422-2.419c-.196-.194-.515-.194-.708 0l-2.423 2.417c-.194.193-.513.193-.707 0l-.977-.976c-.194-.194-.194-.514 0-.707l4.106-4.106c.193-.194.515-.194.708 0l4.109 4.105c.19.192.19.513 0 .707z"/></svg>
|
After Width: | Height: | Size: 410 B |
1
core/misc/icons/5181c6/pencil.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#5181C6" d="M14.545 3.042l-1.586-1.585c-.389-.389-1.025-.389-1.414 0l-1.293 1.293 3 3 1.293-1.293c.389-.389.389-1.026 0-1.415z"/><rect fill="#5181C6" x="5.129" y="3.8" transform="matrix(-.707 -.707 .707 -.707 6.189 20.064)" width="4.243" height="9.899"/><path fill="#5181C6" d="M.908 14.775c-.087.262.055.397.316.312l2.001-.667-1.65-1.646-.667 2.001z"/></g></svg>
|
After Width: | Height: | Size: 442 B |
1
core/misc/icons/5181c6/twistie-down.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#5181C6" d="M2.611 5.393c-.17-.216-.084-.393.191-.393h10.397c.275 0 .361.177.191.393l-5.08 6.464c-.17.216-.452.216-.622 0l-5.077-6.464z"/></svg>
|
After Width: | Height: | Size: 220 B |
1
core/misc/icons/5181c6/twistie-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#5181C6" d="M13.391 10.607c.17.216.084.393-.191.393h-10.398c-.275 0-.361-.177-.191-.393l5.08-6.464c.17-.216.45-.216.62 0l5.08 6.464z"/></svg>
|
After Width: | Height: | Size: 217 B |
1
core/misc/icons/73b355/check.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#73b355"><path d="M6.464 13.676c-.194.194-.513.194-.707 0l-4.96-4.955c-.194-.193-.194-.513 0-.707l1.405-1.407c.194-.195.512-.195.707 0l2.849 2.848c.194.193.513.193.707 0l6.629-6.626c.195-.194.514-.194.707 0l1.404 1.404c.193.194.193.513 0 .707l-8.741 8.736z"/></svg>
|
After Width: | Height: | Size: 334 B |
1
core/misc/icons/787878/barchart.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M4 13.529c0 .275-.225.5-.5.5h-3c-.275 0-.5-.225-.5-.5v-4.25c0-.274.225-.5.5-.5h3c.275 0 .5.226.5.5v4.25zM10.002 13.529c0 .275-.225.5-.5.5h-3.002c-.275 0-.5-.225-.5-.5v-13c0-.275.225-.5.5-.5h3.002c.275 0 .5.225.5.5v13zM16.002 13.529c0 .275-.225.5-.5.5h-3c-.275 0-.5-.225-.5-.5v-9.5c0-.275.225-.5.5-.5h3c.275 0 .5.225.5.5v9.5z"/></g></svg>
|
After Width: | Height: | Size: 428 B |
1
core/misc/icons/787878/chevron-disc-down.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M8.002 1c-3.869 0-7.002 3.134-7.002 7s3.133 7 7.002 7c3.865 0 7-3.134 7-7s-3.135-7-7-7zm4.459 6.336l-4.105 4.105c-.196.189-.515.189-.708 0l-4.107-4.105c-.194-.194-.194-.513 0-.707l.977-.978c.194-.194.513-.194.707 0l2.422 2.421c.192.195.513.195.708 0l2.422-2.42c.188-.194.512-.194.707 0l.977.977c.193.194.193.513 0 .707z"/></svg>
|
After Width: | Height: | Size: 416 B |
1
core/misc/icons/787878/chevron-disc-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M8.002 1c-3.867 0-7.002 3.134-7.002 7s3.135 7 7.002 7 7-3.134 7-7-3.133-7-7-7zm4.462 8.37l-.979.979c-.19.19-.516.19-.707 0l-2.422-2.419c-.196-.194-.515-.194-.708 0l-2.423 2.417c-.194.193-.513.193-.707 0l-.977-.976c-.194-.194-.194-.514 0-.707l4.106-4.106c.193-.194.515-.194.708 0l4.109 4.105c.19.192.19.513 0 .707z"/></svg>
|
After Width: | Height: | Size: 410 B |
1
core/misc/icons/787878/cog.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M15.176 9.041c.045-.327.076-.658.076-.998 0-.36-.035-.71-.086-1.056l-2.275-.293c-.115-.426-.283-.827-.498-1.201l1.396-1.808c-.416-.551-.906-1.039-1.459-1.452l-1.807 1.391c-.373-.215-.774-.383-1.2-.499l-.292-2.252c-.338-.048-.677-.081-1.029-.081s-.694.033-1.032.082l-.291 2.251c-.426.116-.826.284-1.2.499l-1.805-1.391c-.552.413-1.044.901-1.459 1.452l1.395 1.808c-.215.374-.383.774-.499 1.2l-2.276.294c-.05.346-.085.696-.085 1.056 0 .34.031.671.077.998l2.285.295c.115.426.284.826.499 1.2l-1.417 1.836c.411.55.896 1.038 1.443 1.452l1.842-1.42c.374.215.774.383 1.2.498l.298 2.311c.337.047.677.08 1.025.08s.688-.033 1.021-.08l.299-2.311c.426-.115.826-.283 1.201-.498l1.842 1.42c.547-.414 1.031-.902 1.443-1.452l-1.416-1.837c.215-.373.383-.773.498-1.199l2.286-.295zm-7.174 1.514c-1.406 0-2.543-1.137-2.543-2.541 0-1.402 1.137-2.541 2.543-2.541 1.402 0 2.541 1.138 2.541 2.541 0 1.404-1.139 2.541-2.541 2.541z"/></svg>
|
After Width: | Height: | Size: 999 B |
1
core/misc/icons/787878/ex.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M3.51 13.925c.194.194.512.195.706.001l3.432-3.431c.194-.194.514-.194.708 0l3.432 3.431c.192.194.514.193.707-.001l1.405-1.417c.191-.195.189-.514-.002-.709l-3.397-3.4c-.192-.193-.192-.514-.002-.708l3.401-3.43c.189-.195.189-.515 0-.709l-1.407-1.418c-.195-.195-.513-.195-.707-.001l-3.43 3.431c-.195.194-.516.194-.708 0l-3.432-3.431c-.195-.195-.512-.194-.706.001l-1.407 1.417c-.194.195-.194.515 0 .71l3.403 3.429c.193.195.193.514-.001.708l-3.4 3.399c-.194.195-.195.516-.001.709l1.406 1.419z"/></svg>
|
After Width: | Height: | Size: 582 B |
1
core/misc/icons/787878/file.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M12.502 7h-5c-.276 0-.502-.225-.502-.5v-5c0-.275-.225-.5-.5-.5h-3c-.275 0-.5.225-.5.5v12.029c0 .275.225.5.5.5h9.002c.275 0 .5-.225.5-.5v-6.029c0-.275-.225-.5-.5-.5zM8.502 6h4c.275 0 .34-.159.146-.354l-4.293-4.292c-.195-.195-.353-.129-.353.146v4c0 .275.225.5.5.5z"/></g></svg>
|
After Width: | Height: | Size: 366 B |
1
core/misc/icons/787878/key.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path fill="#787878" d="M13.727,7.714C12.418,6.406,10.479,6.145,8.9,6.896L3.001,1H0v2h1l0,0v1.618L1.378,5H3v1h1v1.622h1.622l0.864,0.862L5.5,9.5l0.992,0.99c-0.062,1.162,0.335,2.346,1.223,3.234c1.66,1.653,4.352,1.653,6.012,0C15.385,12.064,15.385,9.373,13.727,7.714z M12.898,12.896c-0.646,0.646-1.693,0.646-2.338,0c-0.646-0.646-0.646-1.692,0-2.338c0.645-0.646,1.688-0.646,2.338,0C13.543,11.204,13.543,12.252,12.898,12.896z"/></svg>
|
After Width: | Height: | Size: 496 B |
1
core/misc/icons/787878/move.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M14.904 7.753l-2.373-2.372c-.291-.292-.529-.193-.529.22v1.399h-3v-3h1.398c.414 0 .512-.239.221-.53l-2.371-2.372c-.137-.136-.36-.136-.497 0l-2.372 2.372c-.292.292-.193.53.22.53h1.399v3h-3v-1.369c0-.413-.239-.511-.53-.22l-2.372 2.372c-.136.136-.136.359 0 .494l2.372 2.372c.291.292.53.192.53-.219v-1.43h3v3h-1.4c-.413 0-.511.238-.22.529l2.374 2.373c.137.137.36.137.495 0l2.373-2.373c.29-.291.19-.529-.222-.529h-1.398v-3h3v1.4c0 .412.238.511.529.219l2.373-2.371c.137-.137.137-.359 0-.495z"/></svg>
|
After Width: | Height: | Size: 581 B |
1
core/misc/icons/787878/orgchart.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path fill="#787878" d="M15.002,11.277c0-0.721,0-1.471,0-2.014c0-1.456-0.824-2.25-2.25-2.25c-1.428,0-3.5,0-3.5,0c-0.139,0-0.25-0.112-0.25-0.25v-2.04c0.596-0.346,1-0.984,1-1.723c0-1.104-0.895-2-2-2C6.896,1,6,1.896,6,3c0,0.738,0.405,1.376,1,1.722v2.042c0,0.138-0.112,0.25-0.25,0.25c0,0-2.138,0-3.5,0S1,7.932,1,9.266c0,0.521,0,1.277,0,2.012c-0.595,0.353-1,0.984-1,1.729c0,1.104,0.896,2,2,2s2-0.896,2-2c0-0.732-0.405-1.377-1-1.729V9.266c0-0.139,0.112-0.25,0.25-0.25h3.536C6.904,9.034,7,9.126,7,9.25v2.027C6.405,11.624,6,12.26,6,13c0,1.104,0.896,2,2.002,2c1.105,0,2-0.896,2-2c0-0.738-0.404-1.376-1-1.723V9.25c0-0.124,0.098-0.216,0.215-0.234h3.535c0.137,0,0.25,0.111,0.25,0.25v2.012c-0.596,0.353-1,0.984-1,1.729c0,1.104,0.896,2,2,2s2-0.896,2-2C16.002,12.262,15.598,11.623,15.002,11.277z"/></svg>
|
After Width: | Height: | Size: 857 B |
1
core/misc/icons/787878/paintbrush.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M8.184 7.928l-1.905 1.983-3.538-2.436 4.714-4.713 2.623 3.183-1.894 1.983zm-1.746-7.523c-.236-.416-.803-.649-1.346.083-.259.349-4.727 4.764-4.91 4.983-.182.218-.294.721.044.976.34.258 5.611 3.933 5.611 3.933l-.225.229c.7.729.816.854 1.046.863.75.016 2.035-1.457 2.578-.854.541.604 3.537 3.979 3.537 3.979.51.531 1.305.559 1.815.041.521-.521.541-1.311.025-1.848 0 0-2.742-2.635-3.904-3.619-.578-.479.869-2.051.854-2.839-.008-.238-.125-.361-.823-1.095l-.22.243c0 .003-3.846-4.659-4.082-5.075z"/></svg>
|
After Width: | Height: | Size: 587 B |
1
core/misc/icons/787878/pencil.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M14.545 3.042l-1.586-1.585c-.389-.389-1.025-.389-1.414 0l-1.293 1.293 3 3 1.293-1.293c.389-.389.389-1.026 0-1.415z"/><rect fill="#787878" x="5.129" y="3.8" transform="matrix(-.707 -.707 .707 -.707 6.189 20.064)" width="4.243" height="9.899"/><path fill="#787878" d="M.908 14.775c-.087.262.055.397.316.312l2.001-.667-1.65-1.646-.667 2.001z"/></g></svg>
|
After Width: | Height: | Size: 442 B |
1
core/misc/icons/787878/people.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M6.722 11.291l.451-.17-.165-.32c-.536-1.039-.685-1.934-.761-2.672-.082-.808-.144-2.831 1.053-4.189.244-.278.493-.493.743-.675.012-.826-.135-1.766-.646-2.345-.618-.7-1.4-.787-1.4-.787l-.497-.055-.498.055s-.783.087-1.398.787c-.617.702-.717 1.948-.625 2.855.06.583.17 1.263.574 2.05.274.533.341.617.355 1.01.022.595.027 1.153-.671 1.538-.697.383-1.564.508-2.403 1.088-.596.41-.709 1.033-.78 1.459l-.051.41c-.029.273.173.498.448.498h5.012c.457-.24.89-.402 1.259-.537zM5.064 15.096c.07-.427.184-1.05.78-1.46.838-.581 1.708-.706 2.404-1.089.699-.385.693-.943.672-1.537-.014-.393-.08-.477-.354-1.01-.406-.787-.515-1.467-.576-2.049-.093-.909.008-2.155.625-2.856.615-.7 1.398-.787 1.398-.787l.492-.055h.002l.496.055s.781.087 1.396.787c.615.701.72 1.947.623 2.855-.062.583-.172 1.262-.571 2.049-.271.533-.341.617-.354 1.01-.021.595-.062 1.22.637 1.604.697.385 1.604.527 2.438 1.104.923.641.822 1.783.822 1.783-.022.275-.269.5-.542.5h-9.991c-.275 0-.477-.223-.448-.496l.051-.408z"/></g></svg>
|
After Width: | Height: | Size: 1 KiB |
1
core/misc/icons/787878/push-left.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M2.5 2h-2.491v12.029h2.491c.276 0 .5-.225.5-.5v-11.029c0-.276-.224-.5-.5-.5zM14.502 6.029h-4c-.275 0-.5-.225-.5-.5v-1c0-.275-.16-.341-.354-.146l-3.294 3.292c-.194.194-.194.513 0 .708l3.294 3.293c.188.193.354.129.354-.146v-1c0-.271.227-.5.5-.5h4c.275 0 .5-.225.5-.5v-3c0-.276-.225-.501-.5-.501z"/></g></svg>
|
After Width: | Height: | Size: 397 B |
1
core/misc/icons/787878/push-right.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M13.51 2c-.275 0-.5.224-.5.5v11.029c0 .275.225.5.5.5h2.492v-12.029h-2.492zM6.362 4.382c-.194-.194-.353-.128-.353.147v1c0 .275-.225.5-.5.5h-4c-.275 0-.5.225-.5.5v3c0 .271.225.5.5.5h4c.275 0 .5.225.5.5v1c0 .271.159.34.354.146l3.295-3.293c.193-.194.193-.513 0-.708l-3.296-3.292z"/></g></svg>
|
After Width: | Height: | Size: 379 B |
1
core/misc/icons/787878/push-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#787878" d="M1.986.019v2.491c0 .276.225.5.5.5h11.032c.275 0 .5-.224.5-.5v-2.491h-12.032zM8.342 6.334c-.193-.194-.513-.194-.708 0l-3.294 3.293c-.194.195-.129.353.146.353h1c.275 0 .5.227.5.5v4.02c0 .275.225.5.5.5h3.002c.271 0 .5-.225.5-.5v-4.02c0-.274.225-.5.5-.5h1c.271 0 .34-.158.145-.354l-3.291-3.292z"/></g></svg>
|
After Width: | Height: | Size: 394 B |
1
core/misc/icons/787878/puzzlepiece.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M11.002 11v2.529c0 .275-.225.471-.5.471h-3c-.827 0-1.112-.754-.604-1.316l.81-.725c.509-.562.513-1.461-.097-2.01-.383-.344-1.027-.728-2.111-.728s-1.727.386-2.109.731c-.609.549-.606 1.45-.097 2.015l.808.717c.509.562.223 1.316-.602 1.316h-3c-.276 0-.5-.193-.5-.471v-9.029c0-.276.224-.5.5-.5h3c.825 0 1.111-.768.602-1.332l-.808-.73c-.51-.563-.513-1.465.097-2.014.382-.344 1.025-.731 2.109-.731s1.728.387 2.111.731c.608.548.606 1.45.097 2.014l-.81.73c-.509.564-.223 1.332.603 1.332h3c.274 0 .5.224.5.5v2.5c0 .825.642 1.111 1.233.602l.771-.808c.599-.51 1.547-.513 2.127.097.364.383.772 1.025.772 2.109s-.408 1.727-.771 2.109c-.58.604-1.529.604-2.127.097l-.77-.808c-.593-.509-1.234-.223-1.234.602z"/></svg>
|
After Width: | Height: | Size: 787 B |
1
core/misc/icons/787878/questionmark-disc.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" 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-7zm3 5c0 .551-.16 1.085-.477 1.586l-.158.22c-.07.093-.189.241-.361.393-.168.148-.35.299-.545.447l-.203.189-.141.129-.096.17-.021.235v.63h-2.001v-.704c.026-.396.078-.73.204-.999.125-.269.271-.498.439-.688l.225-.21-.01-.015.176-.14.137-.128c.186-.139.357-.277.516-.417l.148-.18c.098-.152.168-.323.168-.518 0-.552-.447-1-1-1s-1.002.448-1.002 1h-2c0-1.657 1.343-3 3.002-3 1.656 0 3 1.343 3 3zm-1.75 6.619c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.238c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.238z"/></svg>
|
After Width: | Height: | Size: 709 B |
1
core/misc/icons/787878/twistie-down.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M2.611 5.393c-.17-.216-.084-.393.191-.393h10.397c.275 0 .361.177.191.393l-5.08 6.464c-.17.216-.452.216-.622 0l-5.077-6.464z"/></svg>
|
After Width: | Height: | Size: 220 B |
1
core/misc/icons/787878/twistie-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M13.391 10.607c.17.216.084.393-.191.393h-10.398c-.275 0-.361-.177-.191-.393l5.08-6.464c.17-.216.45-.216.62 0l5.08 6.464z"/></svg>
|
After Width: | Height: | Size: 217 B |
1
core/misc/icons/787878/wrench.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#787878" d="M14.416 11.586l-.01-.008v-.001l-5.656-5.656c.15-.449.252-.921.252-1.421 0-2.485-2.016-4.5-4.502-4.5-.505 0-.981.102-1.434.255l2.431 2.431-.588 2.196-2.196.588-2.445-2.445c-.162.464-.268.956-.268 1.475 0 2.486 2.014 4.5 4.5 4.5.5 0 .972-.102 1.421-.251l5.667 5.665c.781.781 2.047.781 2.828 0s.781-2.047 0-2.828z"/></svg>
|
After Width: | Height: | Size: 407 B |
1
core/misc/icons/bebebe/chevron-disc-left.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M8.002 1c-3.868 0-7.002 3.133-7.002 7 0 3.865 3.134 7 7.002 7 3.865 0 7-3.135 7-7 0-3.867-3.135-7-7-7zm2.348 10.482l-.977.977c-.195.193-.514.193-.707 0l-4.108-4.105c-.194-.195-.194-.514 0-.708l4.108-4.105c.193-.194.512-.194.707 0l.979.977c.191.194.191.513 0 .707l-2.422 2.421c-.195.194-.195.515 0 .708l2.419 2.421c.196.19.196.512.001.707z"/></svg>
|
After Width: | Height: | Size: 435 B |
1
core/misc/icons/bebebe/chevron-disc-right.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M8.002 1c-3.868 0-7.002 3.135-7.002 7 0 3.867 3.134 7 7.002 7 3.865 0 7-3.133 7-7 0-3.865-3.135-7-7-7zm3.441 7.357l-4.106 4.104c-.194.191-.514.191-.708 0l-.978-.979c-.194-.193-.194-.518 0-.707l2.423-2.421c.195-.195.195-.514 0-.708l-2.422-2.421c-.194-.194-.194-.513 0-.707l.977-.977c.194-.194.514-.194.708 0l4.106 4.108c.191.194.191.515 0 .708z"/></svg>
|
After Width: | Height: | Size: 440 B |
1
core/misc/icons/bebebe/cog.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M15.176 9.041c.045-.327.076-.658.076-.998 0-.36-.035-.71-.086-1.056l-2.275-.293c-.115-.426-.283-.827-.498-1.201l1.396-1.808c-.416-.551-.906-1.039-1.459-1.452l-1.807 1.391c-.373-.215-.774-.383-1.2-.499l-.292-2.252c-.338-.048-.677-.081-1.029-.081s-.694.033-1.032.082l-.291 2.251c-.426.116-.826.284-1.2.499l-1.805-1.391c-.552.413-1.044.901-1.459 1.452l1.395 1.808c-.215.374-.383.774-.499 1.2l-2.276.294c-.05.346-.085.696-.085 1.056 0 .34.031.671.077.998l2.285.295c.115.426.284.826.499 1.2l-1.417 1.836c.411.55.896 1.038 1.443 1.452l1.842-1.42c.374.215.774.383 1.2.498l.298 2.311c.337.047.677.08 1.025.08s.688-.033 1.021-.08l.299-2.311c.426-.115.826-.283 1.201-.498l1.842 1.42c.547-.414 1.031-.902 1.443-1.452l-1.416-1.837c.215-.373.383-.773.498-1.199l2.286-.295zm-7.174 1.514c-1.406 0-2.543-1.137-2.543-2.541 0-1.402 1.137-2.541 2.543-2.541 1.402 0 2.541 1.138 2.541 2.541 0 1.404-1.139 2.541-2.541 2.541z"/></svg>
|
After Width: | Height: | Size: 999 B |
1
core/misc/icons/bebebe/ex.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M3.51 13.925c.194.194.512.195.706.001l3.432-3.431c.194-.194.514-.194.708 0l3.432 3.431c.192.194.514.193.707-.001l1.405-1.417c.191-.195.189-.514-.002-.709l-3.397-3.4c-.192-.193-.192-.514-.002-.708l3.401-3.43c.189-.195.189-.515 0-.709l-1.407-1.418c-.195-.195-.513-.195-.707-.001l-3.43 3.431c-.195.194-.516.194-.708 0l-3.432-3.431c-.195-.195-.512-.194-.706.001l-1.407 1.417c-.194.195-.194.515 0 .71l3.403 3.429c.193.195.193.514-.001.708l-3.4 3.399c-.194.195-.195.516-.001.709l1.406 1.419z"/></svg>
|
After Width: | Height: | Size: 582 B |
1
core/misc/icons/bebebe/hamburger.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#bebebe" d="M14.752 6h-13.502c-.69 0-1.25.56-1.25 1.25v.5c0 .689.56 1.25 1.25 1.25h13.502c.689 0 1.25-.561 1.25-1.25v-.5c0-.69-.561-1.25-1.25-1.25zM14.752 0h-13.502c-.69 0-1.25.56-1.25 1.25v.5c0 .69.56 1.25 1.25 1.25h13.502c.689 0 1.25-.56 1.25-1.25v-.5c0-.69-.561-1.25-1.25-1.25zM14.752 12h-13.502c-.69 0-1.25.561-1.25 1.25v.5c0 .689.56 1.25 1.25 1.25h13.502c.689 0 1.25-.561 1.25-1.25v-.5c0-.689-.561-1.25-1.25-1.25z"/></g></svg>
|
After Width: | Height: | Size: 510 B |
1
core/misc/icons/bebebe/house.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#bebebe" points="8.002,0 0,8 1,9 2,9 2,15 6.5,15 6.5,10 9.502,10 9.502,15 14.002,15 14.002,9 15.002,9 16.002,8"/></svg>
|
After Width: | Height: | Size: 198 B |
1
core/misc/icons/bebebe/key.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path fill="#bebebe" d="M13.727,7.714C12.418,6.406,10.479,6.145,8.9,6.896L3.001,1H0v2h1l0,0v1.618L1.378,5H3v1h1v1.622h1.622l0.864,0.862L5.5,9.5l0.992,0.99c-0.062,1.162,0.335,2.346,1.223,3.234c1.66,1.653,4.352,1.653,6.012,0C15.385,12.064,15.385,9.373,13.727,7.714z M12.898,12.896c-0.646,0.646-1.693,0.646-2.338,0c-0.646-0.646-0.646-1.692,0-2.338c0.645-0.646,1.688-0.646,2.338,0C13.543,11.204,13.543,12.252,12.898,12.896z"/></svg>
|
After Width: | Height: | Size: 496 B |
1
core/misc/icons/bebebe/move.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M14.904 7.753l-2.373-2.372c-.291-.292-.529-.193-.529.22v1.399h-3v-3h1.398c.414 0 .512-.239.221-.53l-2.371-2.372c-.137-.136-.36-.136-.497 0l-2.372 2.372c-.292.292-.193.53.22.53h1.399v3h-3v-1.369c0-.413-.239-.511-.53-.22l-2.372 2.372c-.136.136-.136.359 0 .494l2.372 2.372c.291.292.53.192.53-.219v-1.43h3v3h-1.4c-.413 0-.511.238-.22.529l2.374 2.373c.137.137.36.137.495 0l2.373-2.373c.29-.291.19-.529-.222-.529h-1.398v-3h3v1.4c0 .412.238.511.529.219l2.373-2.371c.137-.137.137-.359 0-.495z"/></svg>
|
After Width: | Height: | Size: 581 B |
1
core/misc/icons/bebebe/pencil.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#bebebe" d="M14.545 3.042l-1.586-1.585c-.389-.389-1.025-.389-1.414 0l-1.293 1.293 3 3 1.293-1.293c.389-.389.389-1.026 0-1.415z"/><rect fill="#bebebe" x="5.129" y="3.8" transform="matrix(-.707 -.707 .707 -.707 6.189 20.064)" width="4.243" height="9.899"/><path fill="#bebebe" d="M.908 14.775c-.087.262.055.397.316.312l2.001-.667-1.65-1.646-.667 2.001z"/></g></svg>
|
After Width: | Height: | Size: 442 B |
1
core/misc/icons/bebebe/person.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M1 15c-.275 0-.498-.225-.496-.5 0 0 .007-.746 1.071-1.512 1.138-.818 2.347-.969 3.308-1.498s.954-1.299.925-2.115c-.019-.543-.112-.657-.489-1.392-.556-1.084-.709-2.021-.791-2.823-.127-1.252.011-3.035.86-4.001.847-.964 2.114-1.104 2.114-1.104l.5-.055.498.055s1.266.14 2.113 1.104c.85.966.988 2.75.859 4.001-.08.802-.234 1.739-.791 2.823-.377.734-.476.849-.488 1.392-.029.816-.035 1.586.926 2.115s2.17.68 3.307 1.498c1.064.766 1.072 1.512 1.072 1.512.002.275-.221.5-.496.5h-14.002z"/></svg>
|
After Width: | Height: | Size: 575 B |
1
core/misc/icons/bebebe/push-left.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#bebebe" d="M2.5 2h-2.491v12.029h2.491c.276 0 .5-.225.5-.5v-11.029c0-.276-.224-.5-.5-.5zM14.502 6.029h-4c-.275 0-.5-.225-.5-.5v-1c0-.275-.16-.341-.354-.146l-3.294 3.292c-.194.194-.194.513 0 .708l3.294 3.293c.188.193.354.129.354-.146v-1c0-.271.227-.5.5-.5h4c.275 0 .5-.225.5-.5v-3c0-.276-.225-.501-.5-.501z"/></g></svg>
|
After Width: | Height: | Size: 397 B |
1
core/misc/icons/bebebe/push-right.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#bebebe" d="M13.51 2c-.275 0-.5.224-.5.5v11.029c0 .275.225.5.5.5h2.492v-12.029h-2.492zM6.362 4.382c-.194-.194-.353-.128-.353.147v1c0 .275-.225.5-.5.5h-4c-.275 0-.5.225-.5.5v3c0 .271.225.5.5.5h4c.275 0 .5.225.5.5v1c0 .271.159.34.354.146l3.295-3.293c.193-.194.193-.513 0-.708l-3.296-3.292z"/></g></svg>
|
After Width: | Height: | Size: 379 B |
1
core/misc/icons/bebebe/push-up.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#bebebe" d="M1.986.019v2.491c0 .276.225.5.5.5h11.032c.275 0 .5-.224.5-.5v-2.491h-12.032zM8.342 6.334c-.193-.194-.513-.194-.708 0l-3.294 3.293c-.194.195-.129.353.146.353h1c.275 0 .5.227.5.5v4.02c0 .275.225.5.5.5h3.002c.271 0 .5-.225.5-.5v-4.02c0-.274.225-.5.5-.5h1c.271 0 .34-.158.145-.354l-3.291-3.292z"/></g></svg>
|
After Width: | Height: | Size: 394 B |
1
core/misc/icons/bebebe/questionmark-disc.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" 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-7zm3 5c0 .551-.16 1.085-.477 1.586l-.158.22c-.07.093-.189.241-.361.393-.168.148-.35.299-.545.447l-.203.189-.141.129-.096.17-.021.235v.63h-2.001v-.704c.026-.396.078-.73.204-.999.125-.269.271-.498.439-.688l.225-.21-.01-.015.176-.14.137-.128c.186-.139.357-.277.516-.417l.148-.18c.098-.152.168-.323.168-.518 0-.552-.447-1-1-1s-1.002.448-1.002 1h-2c0-1.657 1.343-3 3.002-3 1.656 0 3 1.343 3 3zm-1.75 6.619c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.238c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.238z"/></svg>
|
After Width: | Height: | Size: 709 B |
1
core/misc/icons/bebebe/star-empty.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M15.455 5.468c-.107-.282-.377-.468-.68-.468h-4.26l-1.841-4.542c-.108-.277-.375-.458-.672-.458s-.565.181-.674.458l-1.843 4.542h-4.259c-.301 0-.571.186-.678.468-.108.282-.029.6.196.8l3.438 3.107-1.122 4.73c-.07.291.046.595.292.766.124.086.269.129.413.129.142 0 .283-.041.406-.124l3.831-2.583 3.828 2.583c.123.083.264.124.406.124.145 0 .289-.043.412-.129.246-.171.356-.475.293-.766l-1.121-4.73 3.438-3.107c.224-.2.304-.519.197-.8zm-5.021 3.475l.982 4.146-3.414-2.304-3.416 2.304.982-4.146-2.98-2.693h3.739l1.675-4.128 1.672 4.128h3.74l-2.98 2.693z"/></svg>
|
After Width: | Height: | Size: 641 B |
1
core/misc/icons/bebebe/star.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#bebebe" d="M12.236 15c-.146 0-.283-.041-.406-.124l-3.828-2.583-3.83 2.583c-.123.083-.265.124-.406.124-.145 0-.289-.043-.413-.129-.246-.171-.362-.475-.292-.766l1.122-4.73-3.439-3.107c-.225-.2-.303-.519-.196-.8.106-.282.376-.468.678-.468h4.259l1.843-4.542c.109-.277.377-.458.674-.458.297 0 .564.181.674.458l1.84 4.542h4.262c.306 0 .57.186.683.468.104.281.024.601-.196.8l-3.439 3.107 1.121 4.73c.065.291-.047.595-.293.766-.129.086-.273.129-.418.129z"/></svg>
|
After Width: | Height: | Size: 532 B |
1
core/misc/icons/e29700/warning.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#e29700"><path d="M14.66 12.316l-5.316-10.633c-.738-1.476-1.946-1.476-2.685 0l-5.317 10.633c-.738 1.477.008 2.684 1.658 2.684h10.002c1.65 0 2.396-1.207 1.658-2.684zm-7.66-8.316h2.002v5h-2.002v-5zm2.252 8.615c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.239c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.239z"/></svg>
|
After Width: | Height: | Size: 412 B |
1
core/misc/icons/ea2800/error.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#ea2800"><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: 678 B |
1
core/misc/icons/ee0000/required.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#EE0000" d="M0,7.562l1.114-3.438c2.565,0.906,4.43,1.688,5.59,2.35C6.398,3.553,6.237,1.544,6.22,0.447h3.511 c-0.05,1.597-0.234,3.6-0.558,6.003c1.664-0.838,3.566-1.613,5.714-2.325L16,7.562c-2.05,0.678-4.06,1.131-6.028,1.356 c0.984,0.856,2.372,2.381,4.166,4.575l-2.906,2.059c-0.935-1.274-2.041-3.009-3.316-5.206c-1.194,2.275-2.244,4.013-3.147,5.206 l-2.856-2.059c1.872-2.307,3.211-3.832,4.017-4.575C3.849,8.516,1.872,8.062,0,7.562"/></svg>
|
After Width: | Height: | Size: 513 B |
1
core/misc/icons/ffffff/ex.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ffffff" d="M3.51 13.925c.194.194.512.195.706.001l3.432-3.431c.194-.194.514-.194.708 0l3.432 3.431c.192.194.514.193.707-.001l1.405-1.417c.191-.195.189-.514-.002-.709l-3.397-3.4c-.192-.193-.192-.514-.002-.708l3.401-3.43c.189-.195.189-.515 0-.709l-1.407-1.418c-.195-.195-.513-.195-.707-.001l-3.43 3.431c-.195.194-.516.194-.708 0l-3.432-3.431c-.195-.195-.512-.194-.706.001l-1.407 1.417c-.194.195-.194.515 0 .71l3.403 3.429c.193.195.193.514-.001.708l-3.4 3.399c-.194.195-.195.516-.001.709l1.406 1.419z"/></svg>
|
After Width: | Height: | Size: 582 B |
1
core/misc/icons/ffffff/hamburger.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#ffffff" d="M14.752 6h-13.502c-.69 0-1.25.56-1.25 1.25v.5c0 .689.56 1.25 1.25 1.25h13.502c.689 0 1.25-.561 1.25-1.25v-.5c0-.69-.561-1.25-1.25-1.25zM14.752 0h-13.502c-.69 0-1.25.56-1.25 1.25v.5c0 .69.56 1.25 1.25 1.25h13.502c.689 0 1.25-.56 1.25-1.25v-.5c0-.69-.561-1.25-1.25-1.25zM14.752 12h-13.502c-.69 0-1.25.561-1.25 1.25v.5c0 .689.56 1.25 1.25 1.25h13.502c.689 0 1.25-.561 1.25-1.25v-.5c0-.689-.561-1.25-1.25-1.25z"/></g></svg>
|
After Width: | Height: | Size: 510 B |
1
core/misc/icons/ffffff/house.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#ffffff" points="8.002,0 0,8 1,9 2,9 2,15 6.5,15 6.5,10 9.502,10 9.502,15 14.002,15 14.002,9 15.002,9 16.002,8"/></svg>
|
After Width: | Height: | Size: 198 B |
1
core/misc/icons/ffffff/pencil.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g><path fill="#ffffff" d="M14.545 3.042l-1.586-1.585c-.389-.389-1.025-.389-1.414 0l-1.293 1.293 3 3 1.293-1.293c.389-.389.389-1.026 0-1.415z"/><rect fill="#ffffff" x="5.129" y="3.8" transform="matrix(-.707 -.707 .707 -.707 6.189 20.064)" width="4.243" height="9.899"/><path fill="#ffffff" d="M.908 14.775c-.087.262.055.397.316.312l2.001-.667-1.65-1.646-.667 2.001z"/></g></svg>
|
After Width: | Height: | Size: 442 B |
1
core/misc/icons/ffffff/person.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ffffff" d="M1 15c-.275 0-.498-.225-.496-.5 0 0 .007-.746 1.071-1.512 1.138-.818 2.347-.969 3.308-1.498s.954-1.299.925-2.115c-.019-.543-.112-.657-.489-1.392-.556-1.084-.709-2.021-.791-2.823-.127-1.252.011-3.035.86-4.001.847-.964 2.114-1.104 2.114-1.104l.5-.055.498.055s1.266.14 2.113 1.104c.85.966.988 2.75.859 4.001-.08.802-.234 1.739-.791 2.823-.377.734-.476.849-.488 1.392-.029.816-.035 1.586.926 2.115s2.17.68 3.307 1.498c1.064.766 1.072 1.512 1.072 1.512.002.275-.221.5-.496.5h-14.002z"/></svg>
|
After Width: | Height: | Size: 575 B |
1
core/misc/icons/ffffff/questionmark-disc.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ffffff" 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-7zm3 5c0 .551-.16 1.085-.477 1.586l-.158.22c-.07.093-.189.241-.361.393-.168.148-.35.299-.545.447l-.203.189-.141.129-.096.17-.021.235v.63h-2.001v-.704c.026-.396.078-.73.204-.999.125-.269.271-.498.439-.688l.225-.21-.01-.015.176-.14.137-.128c.186-.139.357-.277.516-.417l.148-.18c.098-.152.168-.323.168-.518 0-.552-.447-1-1-1s-1.002.448-1.002 1h-2c0-1.657 1.343-3 3.002-3 1.656 0 3 1.343 3 3zm-1.75 6.619c0 .344-.281.625-.625.625h-1.25c-.345 0-.626-.281-.626-.625v-1.238c0-.344.281-.625.626-.625h1.25c.344 0 .625.281.625.625v1.238z"/></svg>
|
After Width: | Height: | Size: 709 B |
1
core/misc/icons/ffffff/star-empty.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ffffff" d="M15.455 5.468c-.107-.282-.377-.468-.68-.468h-4.26l-1.841-4.542c-.108-.277-.375-.458-.672-.458s-.565.181-.674.458l-1.843 4.542h-4.259c-.301 0-.571.186-.678.468-.108.282-.029.6.196.8l3.438 3.107-1.122 4.73c-.07.291.046.595.292.766.124.086.269.129.413.129.142 0 .283-.041.406-.124l3.831-2.583 3.828 2.583c.123.083.264.124.406.124.145 0 .289-.043.412-.129.246-.171.356-.475.293-.766l-1.121-4.73 3.438-3.107c.224-.2.304-.519.197-.8zm-5.021 3.475l.982 4.146-3.414-2.304-3.416 2.304.982-4.146-2.98-2.693h3.739l1.675-4.128 1.672 4.128h3.74l-2.98 2.693z"/></svg>
|
After Width: | Height: | Size: 641 B |
1
core/misc/icons/ffffff/star.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#ffffff" d="M12.236 15c-.146 0-.283-.041-.406-.124l-3.828-2.583-3.83 2.583c-.123.083-.265.124-.406.124-.145 0-.289-.043-.413-.129-.246-.171-.362-.475-.292-.766l1.122-4.73-3.439-3.107c-.225-.2-.303-.519-.196-.8.106-.282.376-.468.678-.468h4.259l1.843-4.542c.109-.277.377-.458.674-.458.297 0 .564.181.674.458l1.84 4.542h4.262c.306 0 .57.186.683.468.104.281.024.601-.196.8l-3.439 3.107 1.121 4.73c.065.291-.047.595-.293.766-.129.086-.273.129-.418.129z"/></svg>
|
After Width: | Height: | Size: 532 B |
9
core/misc/icons/license.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Ryan Frederick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
core/misc/loading-small.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
core/misc/loading.gif
Normal file
After Width: | Height: | Size: 6.6 KiB |
203
core/misc/machine-name.js
Normal file
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
* @file
|
||||
* Machine name functionality.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Attach the machine-readable name form element behavior.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.machineName = {
|
||||
|
||||
/**
|
||||
* Attaches the behavior.
|
||||
*
|
||||
* @param {Element} context
|
||||
* @param {object} settings
|
||||
* @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
|
||||
* defining the following properties:
|
||||
* - target: The HTML ID of the machine name form element.
|
||||
* - suffix: The HTML ID of a container to show the machine name preview
|
||||
* in (usually a field suffix after the human-readable name
|
||||
* form element).
|
||||
* - label: The label to show for the machine name preview.
|
||||
* - replace_pattern: A regular expression (without modifiers) matching
|
||||
* disallowed characters in the machine name; e.g., '[^a-z0-9]+'.
|
||||
* - replace: A character to replace disallowed characters with; e.g.,
|
||||
* '_' or '-'.
|
||||
* - standalone: Whether the preview should stay in its own element
|
||||
* rather than the suffix of the source element.
|
||||
* - field_prefix: The #field_prefix of the form element.
|
||||
* - field_suffix: The #field_suffix of the form element.
|
||||
*/
|
||||
attach: function (context, settings) {
|
||||
var self = this;
|
||||
var $context = $(context);
|
||||
var timeout = null;
|
||||
var xhr = null;
|
||||
|
||||
function clickEditHandler(e) {
|
||||
var data = e.data;
|
||||
data.$wrapper.removeClass('visually-hidden');
|
||||
data.$target.trigger('focus');
|
||||
data.$suffix.hide();
|
||||
data.$source.off('.machineName');
|
||||
}
|
||||
|
||||
function machineNameHandler(e) {
|
||||
var data = e.data;
|
||||
var options = data.options;
|
||||
var baseValue = $(e.target).val();
|
||||
|
||||
var rx = new RegExp(options.replace_pattern, 'g');
|
||||
var expected = baseValue.toLowerCase().replace(rx, options.replace).substr(0, options.maxlength);
|
||||
|
||||
// Abort the last pending request because the label has changed and it
|
||||
// is no longer valid.
|
||||
if (xhr && xhr.readystate !== 4) {
|
||||
xhr.abort();
|
||||
xhr = null;
|
||||
}
|
||||
|
||||
// Wait 300 milliseconds since the last event to update the machine name
|
||||
// i.e., after the user has stopped typing.
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
timeout = setTimeout(function () {
|
||||
if (baseValue.toLowerCase() !== expected) {
|
||||
xhr = self.transliterate(baseValue, options).done(function (machine) {
|
||||
self.showMachineName(machine.substr(0, options.maxlength), data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
self.showMachineName(expected, data);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
Object.keys(settings.machineName).forEach(function (source_id) {
|
||||
var machine = '';
|
||||
var eventData;
|
||||
var options = settings.machineName[source_id];
|
||||
|
||||
var $source = $context.find(source_id).addClass('machine-name-source').once('machine-name');
|
||||
var $target = $context.find(options.target).addClass('machine-name-target');
|
||||
var $suffix = $context.find(options.suffix);
|
||||
var $wrapper = $target.closest('.form-item');
|
||||
// All elements have to exist.
|
||||
if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) {
|
||||
return;
|
||||
}
|
||||
// Skip processing upon a form validation error on the machine name.
|
||||
if ($target.hasClass('error')) {
|
||||
return;
|
||||
}
|
||||
// Figure out the maximum length for the machine name.
|
||||
options.maxlength = $target.attr('maxlength');
|
||||
// Hide the form item container of the machine name form element.
|
||||
$wrapper.addClass('visually-hidden');
|
||||
// Determine the initial machine name value. Unless the machine name
|
||||
// form element is disabled or not empty, the initial default value is
|
||||
// based on the human-readable form element value.
|
||||
if ($target.is(':disabled') || $target.val() !== '') {
|
||||
machine = $target.val();
|
||||
}
|
||||
else if ($source.val() !== '') {
|
||||
machine = self.transliterate($source.val(), options);
|
||||
}
|
||||
// Append the machine name preview to the source field.
|
||||
var $preview = $('<span class="machine-name-value">' + options.field_prefix + Drupal.checkPlain(machine) + options.field_suffix + '</span>');
|
||||
$suffix.empty();
|
||||
if (options.label) {
|
||||
$suffix.append('<span class="machine-name-label">' + options.label + ': </span>');
|
||||
}
|
||||
$suffix.append($preview);
|
||||
|
||||
// If the machine name cannot be edited, stop further processing.
|
||||
if ($target.is(':disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventData = {
|
||||
$source: $source,
|
||||
$target: $target,
|
||||
$suffix: $suffix,
|
||||
$wrapper: $wrapper,
|
||||
$preview: $preview,
|
||||
options: options
|
||||
};
|
||||
// If it is editable, append an edit link.
|
||||
var $link = $('<span class="admin-link"><button type="button" class="link">' + Drupal.t('Edit') + '</button></span>').on('click', eventData, clickEditHandler);
|
||||
$suffix.append($link);
|
||||
|
||||
// Preview the machine name in realtime when the human-readable name
|
||||
// changes, but only if there is no machine name yet; i.e., only upon
|
||||
// initial creation, not when editing.
|
||||
if ($target.val() === '') {
|
||||
$source.on('formUpdated.machineName', eventData, machineNameHandler)
|
||||
// Initialize machine name preview.
|
||||
.trigger('formUpdated.machineName');
|
||||
}
|
||||
|
||||
// Add a listener for an invalid event on the machine name input
|
||||
// to show its container and focus it.
|
||||
$target.on('invalid', eventData, clickEditHandler);
|
||||
});
|
||||
},
|
||||
|
||||
showMachineName: function (machine, data) {
|
||||
var settings = data.options;
|
||||
// Set the machine name to the transliterated value.
|
||||
if (machine !== '') {
|
||||
if (machine !== settings.replace) {
|
||||
data.$target.val(machine);
|
||||
data.$preview.html(settings.field_prefix + Drupal.checkPlain(machine) + settings.field_suffix);
|
||||
}
|
||||
data.$suffix.show();
|
||||
}
|
||||
else {
|
||||
data.$suffix.hide();
|
||||
data.$target.val(machine);
|
||||
data.$preview.empty();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Transliterate a human-readable name to a machine name.
|
||||
*
|
||||
* @param {string} source
|
||||
* A string to transliterate.
|
||||
* @param {object} settings
|
||||
* The machine name settings for the corresponding field.
|
||||
* @param {string} settings.replace_pattern
|
||||
* A regular expression (without modifiers) matching disallowed characters
|
||||
* in the machine name; e.g., '[^a-z0-9]+'.
|
||||
* @param {string} settings.replace
|
||||
* A character to replace disallowed characters with; e.g., '_' or '-'.
|
||||
* @param {number} settings.maxlength
|
||||
* The maximum length of the machine name.
|
||||
*
|
||||
* @return {jQuery}
|
||||
* The transliterated source string.
|
||||
*/
|
||||
transliterate: function (source, settings) {
|
||||
return $.get(Drupal.url('machine_name/transliterate'), {
|
||||
text: source,
|
||||
langcode: drupalSettings.langcode,
|
||||
replace_pattern: settings.replace_pattern,
|
||||
replace: settings.replace,
|
||||
lowercase: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, drupalSettings);
|
BIN
core/misc/menu-collapsed-rtl.png
Normal file
After Width: | Height: | Size: 107 B |