updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
+109
-89
@@ -28,64 +28,41 @@
|
||||
Drupal.behaviors.AJAX = {
|
||||
attach(context, settings) {
|
||||
function loadAjaxBehavior(base) {
|
||||
const element_settings = settings.ajax[base];
|
||||
if (typeof element_settings.selector === 'undefined') {
|
||||
element_settings.selector = `#${base}`;
|
||||
const elementSettings = settings.ajax[base];
|
||||
if (typeof elementSettings.selector === 'undefined') {
|
||||
elementSettings.selector = `#${base}`;
|
||||
}
|
||||
$(element_settings.selector).once('drupal-ajax').each(function () {
|
||||
element_settings.element = this;
|
||||
element_settings.base = base;
|
||||
Drupal.ajax(element_settings);
|
||||
$(elementSettings.selector).once('drupal-ajax').each(function () {
|
||||
elementSettings.element = this;
|
||||
elementSettings.base = base;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
}
|
||||
|
||||
// Load all Ajax behaviors specified in the settings.
|
||||
for (const base in settings.ajax) {
|
||||
if (settings.ajax.hasOwnProperty(base)) {
|
||||
loadAjaxBehavior(base);
|
||||
}
|
||||
}
|
||||
Object.keys(settings.ajax || {}).forEach(base => loadAjaxBehavior(base));
|
||||
|
||||
// Bind Ajax behaviors to all items showing the class.
|
||||
$('.use-ajax').once('ajax').each(function () {
|
||||
const element_settings = {};
|
||||
// Clicked links look better with the throbber than the progress bar.
|
||||
element_settings.progress = { type: 'throbber' };
|
||||
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
const href = $(this).attr('href');
|
||||
if (href) {
|
||||
element_settings.url = href;
|
||||
element_settings.event = 'click';
|
||||
}
|
||||
element_settings.dialogType = $(this).data('dialog-type');
|
||||
element_settings.dialogRenderer = $(this).data('dialog-renderer');
|
||||
element_settings.dialog = $(this).data('dialog-options');
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
Drupal.ajax(element_settings);
|
||||
});
|
||||
Drupal.ajax.bindAjaxLinks(document.body);
|
||||
|
||||
// This class means to submit the form to the action using Ajax.
|
||||
$('.use-ajax-submit').once('ajax').each(function () {
|
||||
const element_settings = {};
|
||||
const elementSettings = {};
|
||||
|
||||
// Ajax submits specified in this manner automatically submit to the
|
||||
// normal form action.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
elementSettings.url = $(this.form).attr('action');
|
||||
// Form submit button clicks need to tell the form what was clicked so
|
||||
// it gets passed in the POST request.
|
||||
element_settings.setClick = true;
|
||||
elementSettings.setClick = true;
|
||||
// Form buttons use the 'click' event rather than mousedown.
|
||||
element_settings.event = 'click';
|
||||
elementSettings.event = 'click';
|
||||
// Clicked form buttons look better with the throbber than the progress
|
||||
// bar.
|
||||
element_settings.progress = { type: 'throbber' };
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
elementSettings.progress = { type: 'throbber' };
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
Drupal.ajax(element_settings);
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -117,9 +94,7 @@
|
||||
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
|
||||
let statusCode;
|
||||
let statusText;
|
||||
let pathText;
|
||||
let responseText;
|
||||
let readyStateText;
|
||||
if (xmlhttp.status) {
|
||||
statusCode = `\n${Drupal.t('An AJAX HTTP error occurred.')}\n${Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status })}`;
|
||||
}
|
||||
@@ -127,7 +102,7 @@
|
||||
statusCode = `\n${Drupal.t('An AJAX HTTP request terminated abnormally.')}`;
|
||||
}
|
||||
statusCode += `\n${Drupal.t('Debugging information follows.')}`;
|
||||
pathText = `\n${Drupal.t('Path: !uri', { '!uri': uri })}`;
|
||||
const pathText = `\n${Drupal.t('Path: !uri', { '!uri': uri })}`;
|
||||
statusText = '';
|
||||
// In some cases, when statusCode === 0, xmlhttp.statusText may not be
|
||||
// defined. Unfortunately, testing for it with typeof, etc, doesn't seem to
|
||||
@@ -155,7 +130,7 @@
|
||||
responseText = responseText.replace(/[\n]+\s+/g, '\n');
|
||||
|
||||
// We don't need readyState except for status == 0.
|
||||
readyStateText = xmlhttp.status === 0 ? (`\n${Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState })}`) : '';
|
||||
const readyStateText = xmlhttp.status === 0 ? (`\n${Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState })}`) : '';
|
||||
|
||||
customMessage = customMessage ? (`\n${Drupal.t('CustomMessage: !customMessage', { '!customMessage': customMessage })}`) : '';
|
||||
|
||||
@@ -270,10 +245,43 @@
|
||||
return Drupal.ajax.instances.filter(instance => instance && instance.element !== false && !document.body.contains(instance.element));
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind Ajax functionality to links that use the 'use-ajax' class.
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* Element to enable Ajax functionality for.
|
||||
*/
|
||||
Drupal.ajax.bindAjaxLinks = (element) => {
|
||||
// Bind Ajax behaviors to all items showing the class.
|
||||
$(element).find('.use-ajax').once('ajax').each((i, ajaxLink) => {
|
||||
const $linkElement = $(ajaxLink);
|
||||
|
||||
const elementSettings = {
|
||||
// Clicked links look better with the throbber than the progress bar.
|
||||
progress: { type: 'throbber' },
|
||||
dialogType: $linkElement.data('dialog-type'),
|
||||
dialog: $linkElement.data('dialog-options'),
|
||||
dialogRenderer: $linkElement.data('dialog-renderer'),
|
||||
base: $linkElement.attr('id'),
|
||||
element: ajaxLink,
|
||||
};
|
||||
const href = $linkElement.attr('href');
|
||||
/**
|
||||
* For anchor tags, these will go to the target of the anchor rather
|
||||
* than the usual location.
|
||||
*/
|
||||
if (href) {
|
||||
elementSettings.url = href;
|
||||
elementSettings.event = 'click';
|
||||
}
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Settings for an Ajax object.
|
||||
*
|
||||
* @typedef {object} Drupal.Ajax~element_settings
|
||||
* @typedef {object} Drupal.Ajax~elementSettings
|
||||
*
|
||||
* @prop {string} url
|
||||
* Target of the Ajax request.
|
||||
@@ -327,10 +335,10 @@
|
||||
* @param {HTMLElement} [element]
|
||||
* Element parameter of {@link Drupal.Ajax} constructor, element on which
|
||||
* event listeners will be bound.
|
||||
* @param {Drupal.Ajax~element_settings} element_settings
|
||||
* @param {Drupal.Ajax~elementSettings} elementSettings
|
||||
* Settings for this Ajax object.
|
||||
*/
|
||||
Drupal.Ajax = function (base, element, element_settings) {
|
||||
Drupal.Ajax = function (base, element, elementSettings) {
|
||||
const defaults = {
|
||||
event: element ? 'mousedown' : null,
|
||||
keypress: true,
|
||||
@@ -347,7 +355,7 @@
|
||||
},
|
||||
};
|
||||
|
||||
$.extend(this, defaults, element_settings);
|
||||
$.extend(this, defaults, elementSettings);
|
||||
|
||||
/**
|
||||
* @type {Drupal.AjaxCommands}
|
||||
@@ -376,9 +384,17 @@
|
||||
this.element = element;
|
||||
|
||||
/**
|
||||
* @type {Drupal.Ajax~element_settings}
|
||||
* @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
|
||||
* Use elementSettings.
|
||||
*
|
||||
* @type {Drupal.Ajax~elementSettings}
|
||||
*/
|
||||
this.element_settings = element_settings;
|
||||
this.element_settings = elementSettings;
|
||||
|
||||
/**
|
||||
* @type {Drupal.Ajax~elementSettings}
|
||||
*/
|
||||
this.elementSettings = elementSettings;
|
||||
|
||||
// If there isn't a form, jQuery.ajax() will be used instead, allowing us to
|
||||
// bind Ajax to links as well.
|
||||
@@ -459,12 +475,12 @@
|
||||
ajax.options = {
|
||||
url: ajax.url,
|
||||
data: ajax.submit,
|
||||
beforeSerialize(element_settings, options) {
|
||||
return ajax.beforeSerialize(element_settings, options);
|
||||
beforeSerialize(elementSettings, options) {
|
||||
return ajax.beforeSerialize(elementSettings, options);
|
||||
},
|
||||
beforeSubmit(form_values, element_settings, options) {
|
||||
beforeSubmit(formValues, elementSettings, options) {
|
||||
ajax.ajaxing = true;
|
||||
return ajax.beforeSubmit(form_values, element_settings, options);
|
||||
return ajax.beforeSubmit(formValues, elementSettings, options);
|
||||
},
|
||||
beforeSend(xmlhttprequest, options) {
|
||||
ajax.ajaxing = true;
|
||||
@@ -506,8 +522,8 @@
|
||||
type: 'POST',
|
||||
};
|
||||
|
||||
if (element_settings.dialog) {
|
||||
ajax.options.data.dialogOptions = element_settings.dialog;
|
||||
if (elementSettings.dialog) {
|
||||
ajax.options.data.dialogOptions = elementSettings.dialog;
|
||||
}
|
||||
|
||||
// Ensure that we have a valid URL by adding ? when no query parameter is
|
||||
@@ -519,15 +535,15 @@
|
||||
ajax.options.url += '&';
|
||||
}
|
||||
// If this element has a dialog type use if for the wrapper if not use 'ajax'.
|
||||
let wrapper = `drupal_${(element_settings.dialogType || 'ajax')}`;
|
||||
if (element_settings.dialogRenderer) {
|
||||
wrapper += `.${element_settings.dialogRenderer}`;
|
||||
let wrapper = `drupal_${(elementSettings.dialogType || 'ajax')}`;
|
||||
if (elementSettings.dialogRenderer) {
|
||||
wrapper += `.${elementSettings.dialogRenderer}`;
|
||||
}
|
||||
ajax.options.url += `${Drupal.ajax.WRAPPER_FORMAT}=${wrapper}`;
|
||||
|
||||
|
||||
// Bind the ajaxSubmit function to the element event.
|
||||
$(ajax.element).on(element_settings.event, function (event) {
|
||||
$(ajax.element).on(elementSettings.event, function (event) {
|
||||
if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) {
|
||||
throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', { '!url': ajax.url }));
|
||||
}
|
||||
@@ -537,7 +553,7 @@
|
||||
// If necessary, enable keyboard submission so that Ajax behaviors
|
||||
// can be triggered through keyboard input as well as e.g. a mousedown
|
||||
// action.
|
||||
if (element_settings.keypress) {
|
||||
if (elementSettings.keypress) {
|
||||
$(ajax.element).on('keypress', function (event) {
|
||||
return ajax.keypressResponse(this, event);
|
||||
});
|
||||
@@ -546,8 +562,8 @@
|
||||
// If necessary, prevent the browser default action of an additional event.
|
||||
// For example, prevent the browser default action of a click, even if the
|
||||
// Ajax behavior binds to mousedown.
|
||||
if (element_settings.prevent) {
|
||||
$(ajax.element).on(element_settings.prevent, false);
|
||||
if (elementSettings.prevent) {
|
||||
$(ajax.element).on(elementSettings.prevent, false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -633,7 +649,7 @@
|
||||
element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number')) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$(element).trigger(ajax.element_settings.event);
|
||||
$(element).trigger(ajax.elementSettings.event);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -696,7 +712,7 @@
|
||||
* before field data is collected.
|
||||
*
|
||||
* @param {object} [element]
|
||||
* Ajax object's `element_settings`.
|
||||
* Ajax object's `elementSettings`.
|
||||
* @param {object} options
|
||||
* jQuery.ajax options.
|
||||
*/
|
||||
@@ -728,14 +744,14 @@
|
||||
/**
|
||||
* Modify form values prior to form submission.
|
||||
*
|
||||
* @param {Array.<object>} form_values
|
||||
* @param {Array.<object>} formValues
|
||||
* Processed form values.
|
||||
* @param {jQuery} element
|
||||
* The form node as a jQuery object.
|
||||
* @param {object} options
|
||||
* jQuery.ajax options.
|
||||
*/
|
||||
Drupal.Ajax.prototype.beforeSubmit = function (form_values, element, options) {
|
||||
Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) {
|
||||
// This function is left empty to make it simple to override for modules
|
||||
// that wish to add functionality here.
|
||||
};
|
||||
@@ -857,14 +873,14 @@
|
||||
// Track if any command is altering the focus so we can avoid changing the
|
||||
// focus set by the Ajax command.
|
||||
let focusChanged = false;
|
||||
for (const i in response) {
|
||||
if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) {
|
||||
Object.keys(response || {}).forEach((i) => {
|
||||
if (response[i].command && this.commands[response[i].command]) {
|
||||
this.commands[response[i].command](this, response[i], status);
|
||||
if (response[i].command === 'invoke' && response[i].method === 'focus') {
|
||||
focusChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// If the focus hasn't be changed by the ajax commands, try to refocus the
|
||||
// triggering element or one of its parents if that element does not exist
|
||||
@@ -901,9 +917,9 @@
|
||||
* @param {object} response
|
||||
* Drupal Ajax response.
|
||||
* @param {string} [response.effect]
|
||||
* Override the default value of {@link Drupal.Ajax#element_settings}.
|
||||
* Override the default value of {@link Drupal.Ajax#elementSettings}.
|
||||
* @param {string|number} [response.speed]
|
||||
* Override the default value of {@link Drupal.Ajax#element_settings}.
|
||||
* Override the default value of {@link Drupal.Ajax#elementSettings}.
|
||||
*
|
||||
* @return {object}
|
||||
* Returns an object with `showEffect`, `hideEffect` and `showSpeed`
|
||||
@@ -1025,11 +1041,11 @@
|
||||
// $(response.data) as new HTML rather than a CSS selector. Also, if
|
||||
// response.data contains top-level text nodes, they get lost with either
|
||||
// $(response.data) or $('<div></div>').replaceWith(response.data).
|
||||
const $new_content_wrapped = $('<div></div>').html(response.data);
|
||||
let $new_content = $new_content_wrapped.contents();
|
||||
const $newContentWrapped = $('<div></div>').html(response.data);
|
||||
let $newContent = $newContentWrapped.contents();
|
||||
|
||||
// For legacy reasons, the effects processing code assumes that
|
||||
// $new_content consists of a single top-level element. Also, it has not
|
||||
// $newContent consists of a single top-level element. Also, it has not
|
||||
// been sufficiently tested whether attachBehaviors() can be successfully
|
||||
// called with a context object that includes top-level text nodes.
|
||||
// However, to give developers full control of the HTML appearing in the
|
||||
@@ -1039,8 +1055,8 @@
|
||||
// of a single top-level element, and only use the container <div> created
|
||||
// above when it doesn't. For more information, please see
|
||||
// https://www.drupal.org/node/736066.
|
||||
if ($new_content.length !== 1 || $new_content.get(0).nodeType !== 1) {
|
||||
$new_content = $new_content_wrapped;
|
||||
if ($newContent.length !== 1 || $newContent.get(0).nodeType !== 1) {
|
||||
$newContent = $newContentWrapped;
|
||||
}
|
||||
|
||||
// If removing content from the wrapper, detach behaviors first.
|
||||
@@ -1055,31 +1071,31 @@
|
||||
}
|
||||
|
||||
// Add the new content to the page.
|
||||
$wrapper[method]($new_content);
|
||||
$wrapper[method]($newContent);
|
||||
|
||||
// Immediately hide the new content if we're using any effects.
|
||||
if (effect.showEffect !== 'show') {
|
||||
$new_content.hide();
|
||||
$newContent.hide();
|
||||
}
|
||||
|
||||
// Determine which effect to use and what content will receive the
|
||||
// effect, then show the new content.
|
||||
if ($new_content.find('.ajax-new-content').length > 0) {
|
||||
$new_content.find('.ajax-new-content').hide();
|
||||
$new_content.show();
|
||||
$new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
if ($newContent.find('.ajax-new-content').length > 0) {
|
||||
$newContent.find('.ajax-new-content').hide();
|
||||
$newContent.show();
|
||||
$newContent.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
else if (effect.showEffect !== 'show') {
|
||||
$new_content[effect.showEffect](effect.showSpeed);
|
||||
$newContent[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
|
||||
// Attach all JavaScript behaviors to the new content, if it was
|
||||
// successfully added to the page, this if statement allows
|
||||
// `#ajax['wrapper']` to be optional.
|
||||
if ($new_content.parents('html').length > 0) {
|
||||
if ($newContent.parents('html').length > 0) {
|
||||
// Apply any settings from the returned JSON if available.
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.attachBehaviors($new_content.get(0), settings);
|
||||
Drupal.attachBehaviors($newContent.get(0), settings);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1283,10 +1299,14 @@
|
||||
// :even and :odd are reversed because jQuery counts from 0 and
|
||||
// we count from 1, so we're out of sync.
|
||||
// Match immediate children of the parent element to allow nesting.
|
||||
$(response.selector).find('> tbody > tr:visible, > tr:visible')
|
||||
$(response.selector)
|
||||
.find('> tbody > tr:visible, > tr:visible')
|
||||
.removeClass('odd even')
|
||||
.filter(':even').addClass('odd').end()
|
||||
.filter(':odd').addClass('even');
|
||||
.filter(':even')
|
||||
.addClass('odd')
|
||||
.end()
|
||||
.filter(':odd')
|
||||
.addClass('even');
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+82
-76
@@ -10,55 +10,37 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
Drupal.behaviors.AJAX = {
|
||||
attach: function attach(context, settings) {
|
||||
function loadAjaxBehavior(base) {
|
||||
var element_settings = settings.ajax[base];
|
||||
if (typeof element_settings.selector === 'undefined') {
|
||||
element_settings.selector = '#' + base;
|
||||
var elementSettings = settings.ajax[base];
|
||||
if (typeof elementSettings.selector === 'undefined') {
|
||||
elementSettings.selector = '#' + base;
|
||||
}
|
||||
$(element_settings.selector).once('drupal-ajax').each(function () {
|
||||
element_settings.element = this;
|
||||
element_settings.base = base;
|
||||
Drupal.ajax(element_settings);
|
||||
$(elementSettings.selector).once('drupal-ajax').each(function () {
|
||||
elementSettings.element = this;
|
||||
elementSettings.base = base;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
}
|
||||
|
||||
for (var base in settings.ajax) {
|
||||
if (settings.ajax.hasOwnProperty(base)) {
|
||||
loadAjaxBehavior(base);
|
||||
}
|
||||
}
|
||||
|
||||
$('.use-ajax').once('ajax').each(function () {
|
||||
var element_settings = {};
|
||||
|
||||
element_settings.progress = { type: 'throbber' };
|
||||
|
||||
var href = $(this).attr('href');
|
||||
if (href) {
|
||||
element_settings.url = href;
|
||||
element_settings.event = 'click';
|
||||
}
|
||||
element_settings.dialogType = $(this).data('dialog-type');
|
||||
element_settings.dialogRenderer = $(this).data('dialog-renderer');
|
||||
element_settings.dialog = $(this).data('dialog-options');
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
Drupal.ajax(element_settings);
|
||||
Object.keys(settings.ajax || {}).forEach(function (base) {
|
||||
return loadAjaxBehavior(base);
|
||||
});
|
||||
|
||||
Drupal.ajax.bindAjaxLinks(document.body);
|
||||
|
||||
$('.use-ajax-submit').once('ajax').each(function () {
|
||||
var element_settings = {};
|
||||
var elementSettings = {};
|
||||
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
elementSettings.url = $(this.form).attr('action');
|
||||
|
||||
element_settings.setClick = true;
|
||||
elementSettings.setClick = true;
|
||||
|
||||
element_settings.event = 'click';
|
||||
elementSettings.event = 'click';
|
||||
|
||||
element_settings.progress = { type: 'throbber' };
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
elementSettings.progress = { type: 'throbber' };
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
Drupal.ajax(element_settings);
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
},
|
||||
detach: function detach(context, settings, trigger) {
|
||||
@@ -73,16 +55,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
|
||||
var statusCode = void 0;
|
||||
var statusText = void 0;
|
||||
var pathText = void 0;
|
||||
var responseText = void 0;
|
||||
var readyStateText = void 0;
|
||||
if (xmlhttp.status) {
|
||||
statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status });
|
||||
} else {
|
||||
statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.');
|
||||
}
|
||||
statusCode += '\n' + Drupal.t('Debugging information follows.');
|
||||
pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri });
|
||||
var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri });
|
||||
statusText = '';
|
||||
|
||||
try {
|
||||
@@ -98,7 +78,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, '');
|
||||
responseText = responseText.replace(/[\n]+\s+/g, '\n');
|
||||
|
||||
readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState }) : '';
|
||||
var readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', { '!readyState': xmlhttp.readyState }) : '';
|
||||
|
||||
customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', { '!customMessage': customMessage }) : '';
|
||||
|
||||
@@ -139,7 +119,29 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.Ajax = function (base, element, element_settings) {
|
||||
Drupal.ajax.bindAjaxLinks = function (element) {
|
||||
$(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) {
|
||||
var $linkElement = $(ajaxLink);
|
||||
|
||||
var elementSettings = {
|
||||
progress: { type: 'throbber' },
|
||||
dialogType: $linkElement.data('dialog-type'),
|
||||
dialog: $linkElement.data('dialog-options'),
|
||||
dialogRenderer: $linkElement.data('dialog-renderer'),
|
||||
base: $linkElement.attr('id'),
|
||||
element: ajaxLink
|
||||
};
|
||||
var href = $linkElement.attr('href');
|
||||
|
||||
if (href) {
|
||||
elementSettings.url = href;
|
||||
elementSettings.event = 'click';
|
||||
}
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.Ajax = function (base, element, elementSettings) {
|
||||
var defaults = {
|
||||
event: element ? 'mousedown' : null,
|
||||
keypress: true,
|
||||
@@ -156,7 +158,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(this, defaults, element_settings);
|
||||
$.extend(this, defaults, elementSettings);
|
||||
|
||||
this.commands = new Drupal.AjaxCommands();
|
||||
|
||||
@@ -168,7 +170,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
|
||||
this.element = element;
|
||||
|
||||
this.element_settings = element_settings;
|
||||
this.element_settings = elementSettings;
|
||||
|
||||
this.elementSettings = elementSettings;
|
||||
|
||||
if (this.element && this.element.form) {
|
||||
this.$form = $(this.element.form);
|
||||
@@ -196,12 +200,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
ajax.options = {
|
||||
url: ajax.url,
|
||||
data: ajax.submit,
|
||||
beforeSerialize: function beforeSerialize(element_settings, options) {
|
||||
return ajax.beforeSerialize(element_settings, options);
|
||||
beforeSerialize: function beforeSerialize(elementSettings, options) {
|
||||
return ajax.beforeSerialize(elementSettings, options);
|
||||
},
|
||||
beforeSubmit: function beforeSubmit(form_values, element_settings, options) {
|
||||
beforeSubmit: function beforeSubmit(formValues, elementSettings, options) {
|
||||
ajax.ajaxing = true;
|
||||
return ajax.beforeSubmit(form_values, element_settings, options);
|
||||
return ajax.beforeSubmit(formValues, elementSettings, options);
|
||||
},
|
||||
beforeSend: function beforeSend(xmlhttprequest, options) {
|
||||
ajax.ajaxing = true;
|
||||
@@ -232,8 +236,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
type: 'POST'
|
||||
};
|
||||
|
||||
if (element_settings.dialog) {
|
||||
ajax.options.data.dialogOptions = element_settings.dialog;
|
||||
if (elementSettings.dialog) {
|
||||
ajax.options.data.dialogOptions = elementSettings.dialog;
|
||||
}
|
||||
|
||||
if (ajax.options.url.indexOf('?') === -1) {
|
||||
@@ -242,27 +246,27 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
ajax.options.url += '&';
|
||||
}
|
||||
|
||||
var wrapper = 'drupal_' + (element_settings.dialogType || 'ajax');
|
||||
if (element_settings.dialogRenderer) {
|
||||
wrapper += '.' + element_settings.dialogRenderer;
|
||||
var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax');
|
||||
if (elementSettings.dialogRenderer) {
|
||||
wrapper += '.' + elementSettings.dialogRenderer;
|
||||
}
|
||||
ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=' + wrapper;
|
||||
|
||||
$(ajax.element).on(element_settings.event, function (event) {
|
||||
$(ajax.element).on(elementSettings.event, function (event) {
|
||||
if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) {
|
||||
throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', { '!url': ajax.url }));
|
||||
}
|
||||
return ajax.eventResponse(this, event);
|
||||
});
|
||||
|
||||
if (element_settings.keypress) {
|
||||
if (elementSettings.keypress) {
|
||||
$(ajax.element).on('keypress', function (event) {
|
||||
return ajax.keypressResponse(this, event);
|
||||
});
|
||||
}
|
||||
|
||||
if (element_settings.prevent) {
|
||||
$(ajax.element).on(element_settings.prevent, false);
|
||||
if (elementSettings.prevent) {
|
||||
$(ajax.element).on(elementSettings.prevent, false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -293,7 +297,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
if (event.which === 13 || event.which === 32 && element.type !== 'text' && element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$(element).trigger(ajax.element_settings.event);
|
||||
$(element).trigger(ajax.elementSettings.event);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -338,7 +342,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
options.data['ajax_page_state[libraries]'] = pageState.libraries;
|
||||
};
|
||||
|
||||
Drupal.Ajax.prototype.beforeSubmit = function (form_values, element, options) {};
|
||||
Drupal.Ajax.prototype.beforeSubmit = function (formValues, element, options) {};
|
||||
|
||||
Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) {
|
||||
if (this.$form) {
|
||||
@@ -391,6 +395,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
};
|
||||
|
||||
Drupal.Ajax.prototype.success = function (response, status) {
|
||||
var _this = this;
|
||||
|
||||
if (this.progress.element) {
|
||||
$(this.progress.element).remove();
|
||||
}
|
||||
@@ -402,14 +408,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray();
|
||||
|
||||
var focusChanged = false;
|
||||
for (var i in response) {
|
||||
if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) {
|
||||
this.commands[response[i].command](this, response[i], status);
|
||||
Object.keys(response || {}).forEach(function (i) {
|
||||
if (response[i].command && _this.commands[response[i].command]) {
|
||||
_this.commands[response[i].command](_this, response[i], status);
|
||||
if (response[i].command === 'invoke' && response[i].method === 'focus') {
|
||||
focusChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!focusChanged && this.element && !$(this.element).data('disable-refocus')) {
|
||||
var target = false;
|
||||
@@ -480,11 +486,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
var effect = ajax.getEffect(response);
|
||||
var settings = void 0;
|
||||
|
||||
var $new_content_wrapped = $('<div></div>').html(response.data);
|
||||
var $new_content = $new_content_wrapped.contents();
|
||||
var $newContentWrapped = $('<div></div>').html(response.data);
|
||||
var $newContent = $newContentWrapped.contents();
|
||||
|
||||
if ($new_content.length !== 1 || $new_content.get(0).nodeType !== 1) {
|
||||
$new_content = $new_content_wrapped;
|
||||
if ($newContent.length !== 1 || $newContent.get(0).nodeType !== 1) {
|
||||
$newContent = $newContentWrapped;
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
@@ -497,23 +503,23 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
||||
Drupal.detachBehaviors($wrapper.get(0), settings);
|
||||
}
|
||||
|
||||
$wrapper[method]($new_content);
|
||||
$wrapper[method]($newContent);
|
||||
|
||||
if (effect.showEffect !== 'show') {
|
||||
$new_content.hide();
|
||||
$newContent.hide();
|
||||
}
|
||||
|
||||
if ($new_content.find('.ajax-new-content').length > 0) {
|
||||
$new_content.find('.ajax-new-content').hide();
|
||||
$new_content.show();
|
||||
$new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
if ($newContent.find('.ajax-new-content').length > 0) {
|
||||
$newContent.find('.ajax-new-content').hide();
|
||||
$newContent.show();
|
||||
$newContent.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
|
||||
} else if (effect.showEffect !== 'show') {
|
||||
$new_content[effect.showEffect](effect.showSpeed);
|
||||
$newContent[effect.showEffect](effect.showSpeed);
|
||||
}
|
||||
|
||||
if ($new_content.parents('html').length > 0) {
|
||||
if ($newContent.parents('html').length > 0) {
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.attachBehaviors($new_content.get(0), settings);
|
||||
Drupal.attachBehaviors($newContent.get(0), settings);
|
||||
}
|
||||
},
|
||||
remove: function remove(ajax, response, status) {
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
}
|
||||
|
||||
// Get the desired term and construct the autocomplete URL for it.
|
||||
var term = autocomplete.extractLastTerm(request.term);
|
||||
const term = autocomplete.extractLastTerm(request.term);
|
||||
|
||||
// Check if the term is already cached.
|
||||
if (autocomplete.cache[elementId].hasOwnProperty(term)) {
|
||||
|
||||
@@ -29,9 +29,8 @@
|
||||
Drupal.debounce = function (func, wait, immediate) {
|
||||
let timeout;
|
||||
let result;
|
||||
return function () {
|
||||
return function (...args) {
|
||||
const context = this;
|
||||
const args = arguments;
|
||||
const later = function () {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
|
||||
@@ -9,8 +9,11 @@ Drupal.debounce = function (func, wait, immediate) {
|
||||
var timeout = void 0;
|
||||
var result = void 0;
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var context = this;
|
||||
var args = arguments;
|
||||
var later = function later() {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
const originalClose = settings.dialog.close;
|
||||
// Overwrite the close method to remove the dialog on closing.
|
||||
settings.dialog.close = function (event) {
|
||||
originalClose.apply(settings.dialog, arguments);
|
||||
settings.dialog.close = function (event, ...args) {
|
||||
originalClose.apply(settings.dialog, [event, ...args]);
|
||||
$(event.target).remove();
|
||||
};
|
||||
},
|
||||
|
||||
@@ -26,7 +26,11 @@
|
||||
var originalClose = settings.dialog.close;
|
||||
|
||||
settings.dialog.close = function (event) {
|
||||
originalClose.apply(settings.dialog, arguments);
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
originalClose.apply(settings.dialog, [event].concat(args));
|
||||
$(event.target).remove();
|
||||
};
|
||||
},
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
_createButtons() {
|
||||
const opts = this.options;
|
||||
let primaryIndex;
|
||||
let $buttons;
|
||||
let index;
|
||||
const il = opts.buttons.length;
|
||||
for (index = 0; index < il; index++) {
|
||||
@@ -23,7 +22,7 @@
|
||||
}
|
||||
}
|
||||
this._super();
|
||||
$buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
const $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
if (typeof primaryIndex !== 'undefined') {
|
||||
$buttons.eq(index).addClass(opts.buttonPrimaryClass);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
_createButtons: function _createButtons() {
|
||||
var opts = this.options;
|
||||
var primaryIndex = void 0;
|
||||
var $buttons = void 0;
|
||||
var index = void 0;
|
||||
var il = opts.buttons.length;
|
||||
for (index = 0; index < il; index++) {
|
||||
@@ -25,7 +24,7 @@
|
||||
}
|
||||
}
|
||||
this._super();
|
||||
$buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
var $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
if (typeof primaryIndex !== 'undefined') {
|
||||
$buttons.eq(index).addClass(opts.buttonPrimaryClass);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* @file
|
||||
* Set base styles for the off-canvas dialog.
|
||||
*/
|
||||
|
||||
/* Set some global attributes. */
|
||||
#drupal-off-canvas *,
|
||||
#drupal-off-canvas *:not(div) {
|
||||
background: #444;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
/* Generic elements. */
|
||||
#drupal-off-canvas a,
|
||||
#drupal-off-canvas .link {
|
||||
border-bottom: none;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
font-size: inherit;
|
||||
font-weight: normal;
|
||||
color: #85bef4;
|
||||
text-decoration: none;
|
||||
transition: color 0.5s ease;
|
||||
}
|
||||
|
||||
#drupal-off-canvas a:focus,
|
||||
#drupal-off-canvas .link:focus,
|
||||
#drupal-off-canvas a:hover,
|
||||
#drupal-off-canvas .link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#drupal-off-canvas hr {
|
||||
height: 1px;
|
||||
background: #ccc;
|
||||
}
|
||||
#drupal-off-canvas summary,
|
||||
#drupal-off-canvas .fieldgroup:not(.form-composite) > legend {
|
||||
font-weight: bold;
|
||||
}
|
||||
#drupal-off-canvas h1,
|
||||
#drupal-off-canvas .heading-a {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
font-size: 1.625em;
|
||||
line-height: 1.875em;
|
||||
}
|
||||
#drupal-off-canvas h2,
|
||||
#drupal-off-canvas .heading-b {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
font-size: 1.385em;
|
||||
}
|
||||
#drupal-off-canvas h3,
|
||||
#drupal-off-canvas .heading-c {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
font-size: 1.231em;
|
||||
}
|
||||
#drupal-off-canvas h4,
|
||||
#drupal-off-canvas .heading-d {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
font-size: 1.154em;
|
||||
}
|
||||
#drupal-off-canvas h5,
|
||||
#drupal-off-canvas .heading-e {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
font-size: 1.077em;
|
||||
}
|
||||
#drupal-off-canvas h6,
|
||||
#drupal-off-canvas .heading-f {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
font-size: 1.077em;
|
||||
}
|
||||
#drupal-off-canvas p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
#drupal-off-canvas dl {
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
#drupal-off-canvas dl dd,
|
||||
#drupal-off-canvas dl dl {
|
||||
margin-left: 20px; /* LTR */
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas dl dd,
|
||||
[dir="rtl"] #drupal-off-canvas dl dl {
|
||||
margin-right: 20px;
|
||||
}
|
||||
#drupal-off-canvas blockquote {
|
||||
margin: 1em 40px;
|
||||
}
|
||||
#drupal-off-canvas address {
|
||||
font-style: italic;
|
||||
}
|
||||
#drupal-off-canvas u,
|
||||
#drupal-off-canvas ins {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#drupal-off-canvas s,
|
||||
#drupal-off-canvas strike,
|
||||
#drupal-off-canvas del {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
#drupal-off-canvas big {
|
||||
font-size: larger;
|
||||
}
|
||||
#drupal-off-canvas small {
|
||||
font-size: smaller;
|
||||
}
|
||||
#drupal-off-canvas sub {
|
||||
vertical-align: sub;
|
||||
font-size: smaller;
|
||||
line-height: normal;
|
||||
}
|
||||
#drupal-off-canvas sup {
|
||||
vertical-align: super;
|
||||
font-size: smaller;
|
||||
line-height: normal;
|
||||
}
|
||||
#drupal-off-canvas abbr,
|
||||
#drupal-off-canvas acronym {
|
||||
border-bottom: dotted 1px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#drupal-off-canvas ul {
|
||||
list-style-type: disc;
|
||||
list-style-image: none;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .messages__list {
|
||||
margin-right: 0;
|
||||
}
|
||||
#drupal-off-canvas ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
#drupal-off-canvas ul li,
|
||||
#drupal-off-canvas ol li {
|
||||
display: block;
|
||||
}
|
||||
#drupal-off-canvas blockquote,
|
||||
#drupal-off-canvas code {
|
||||
margin: 20px 0;
|
||||
}
|
||||
#drupal-off-canvas pre {
|
||||
margin: 20px 0;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* Classes for hidden and visually hidden elements. See hidden.module.css. */
|
||||
#drupal-off-canvas .hidden {
|
||||
display: none;
|
||||
}
|
||||
#drupal-off-canvas .visually-hidden {
|
||||
position: absolute !important;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
overflow: hidden;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
word-wrap: normal;
|
||||
}
|
||||
#drupal-off-canvas .visually-hidden.focusable:active,
|
||||
#drupal-off-canvas .visually-hidden.focusable:focus {
|
||||
position: static !important;
|
||||
clip: auto;
|
||||
overflow: visible;
|
||||
height: auto;
|
||||
width: auto;
|
||||
}
|
||||
#drupal-off-canvas .invisible {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* Some system classes. See system.admin.css. */
|
||||
#drupal-off-canvas .panel {
|
||||
padding: 5px 5px 15px;
|
||||
}
|
||||
#drupal-off-canvas .panel__description {
|
||||
margin: 0 0 3px;
|
||||
padding: 2px 0 3px 0;
|
||||
}
|
||||
#drupal-off-canvas .compact-link {
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
#drupal-off-canvas small .admin-link:before {
|
||||
content: ' [';
|
||||
}
|
||||
#drupal-off-canvas small .admin-link:after {
|
||||
content: ']';
|
||||
}
|
||||
|
||||
/* Override jQuery UI */
|
||||
#drupal-off-canvas .ui-widget-content a {
|
||||
color: #85bef4 !important;
|
||||
}
|
||||
|
||||
/* Message styles */
|
||||
#drupal-off-canvas .messages {
|
||||
background: no-repeat 10px 17px;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .messages {
|
||||
background-position: right 10px top 17px;
|
||||
}
|
||||
#drupal-off-canvas .messages abbr {
|
||||
color: #444;
|
||||
}
|
||||
#drupal-off-canvas .messages--status {
|
||||
background-color: #f3faef;
|
||||
background-image: url(../icons/73b355/check.svg);
|
||||
color: #325e1c;
|
||||
}
|
||||
#drupal-off-canvas .messages--warning {
|
||||
background-color: #fdf8ed;
|
||||
background-image: url(../icons/e29700/warning.svg);
|
||||
color: #734c00;
|
||||
}
|
||||
|
||||
#drupal-off-canvas .messages--error {
|
||||
background-color: #fcf4f2;
|
||||
background-image: url(../icons/e32700/error.svg);
|
||||
color: #a51b00;
|
||||
}
|
||||
|
||||
#drupal-off-canvas .messages--error div[role="alert"] {
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @file
|
||||
* Visual styling for buttons in the off-canvas dialog.
|
||||
*
|
||||
* @see seven/css/components/buttons.css
|
||||
*/
|
||||
|
||||
#drupal-off-canvas button,
|
||||
#drupal-off-canvas .button {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
line-height: normal;
|
||||
text-transform: none;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
#drupal-off-canvas button.link {
|
||||
display: inline;
|
||||
background: transparent;
|
||||
font-size: 14px;
|
||||
color: #85bef4;
|
||||
transition: color 0.5s ease;
|
||||
}
|
||||
#drupal-off-canvas button.link:hover,
|
||||
#drupal-off-canvas button.link:focus {
|
||||
color: #46a0f5;
|
||||
text-decoration: none;
|
||||
}
|
||||
#drupal-off-canvas input[type="submit"].button {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
padding: 4px 20px;
|
||||
border: 0;
|
||||
border-radius: 20em;
|
||||
background: #777;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: #f5f5f5;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: background 0.5s ease;
|
||||
}
|
||||
#drupal-off-canvas input[type="submit"].button:hover,
|
||||
#drupal-off-canvas input[type="submit"].button:focus,
|
||||
#drupal-off-canvas input[type="submit"].button:active {
|
||||
border: 0;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
z-index: 10;
|
||||
}
|
||||
#drupal-off-canvas input[type="submit"].button:focus,
|
||||
#drupal-off-canvas input[type="submit"].button:active {
|
||||
box-shadow: 0 3px 3px 2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
#drupal-off-canvas input[type="submit"].button--primary {
|
||||
border: 0;
|
||||
background: #277abd;
|
||||
color: #fff;
|
||||
margin-top: 15px;
|
||||
}
|
||||
#drupal-off-canvas input[type="submit"].button--primary:hover,
|
||||
#drupal-off-canvas input[type="submit"].button--primary:focus,
|
||||
#drupal-off-canvas input[type="submit"].button--primary:active {
|
||||
background: #236aaf;
|
||||
outline: none;
|
||||
}
|
||||
#drupal-off-canvas .button-action:before {
|
||||
margin-left: -0.2em; /* LTR */
|
||||
padding-right: 0.2em; /* LTR */
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .button-action:before {
|
||||
margin-right: -0.2em;
|
||||
margin-left: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0.2em;
|
||||
}
|
||||
#drupal-off-canvas .no-touchevents .button--small {
|
||||
font-size: 13px;
|
||||
padding: 2px 1em;
|
||||
}
|
||||
#drupal-off-canvas .button:disabled,
|
||||
#drupal-off-canvas .button:disabled:active,
|
||||
#drupal-off-canvas .button.is-disabled,
|
||||
#drupal-off-canvas .button.is-disabled:active {
|
||||
border: 0;
|
||||
background: #555;
|
||||
color: #5c5c5c;
|
||||
font-weight: normal;
|
||||
cursor: default;
|
||||
}
|
||||
#drupal-off-canvas .button--danger {
|
||||
border-radius: 0;
|
||||
color: #c72100;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
}
|
||||
#drupal-off-canvas .button--danger:hover,
|
||||
#drupal-off-canvas .button--danger:focus,
|
||||
#drupal-off-canvas .button--danger:active {
|
||||
color: #ff2a00;
|
||||
text-decoration: none;
|
||||
text-shadow: none;
|
||||
}
|
||||
#drupal-off-canvas .button--danger:disabled,
|
||||
#drupal-off-canvas .button--danger.is-disabled {
|
||||
color: #737373;
|
||||
cursor: default;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @file
|
||||
* CSS for off-canvas dialog.
|
||||
*/
|
||||
|
||||
/* Position the off-canvas dialog container outside the right of the viewport. */
|
||||
.ui-dialog-off-canvas {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Wrap the form that's inside the off-canvas dialog. */
|
||||
.ui-dialog-off-canvas .ui-dialog-content {
|
||||
padding: 0 20px;
|
||||
/* Prevent horizontal scrollbar. */
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
[dir="rtl"] .ui-dialog-off-canvas .ui-dialog-content {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Position the off-canvas dialog container outside the right of the viewport. */
|
||||
.ui-dialog-off-canvas {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Wrap the form that's inside the off-canvas dialog. */
|
||||
.ui-dialog-off-canvas #drupal-off-canvas {
|
||||
padding: 0 20px;
|
||||
/* Prevent horizontal scrollbar. */
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
[dir="rtl"] .ui-dialog-off-canvas #drupal-off-canvas {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/*
|
||||
* Force the off-canvas dialog to be 100% width at the same breakpoint the
|
||||
* dialog system uses to expand dialog widths.
|
||||
*/
|
||||
@media all and (max-width: 48em) { /* 768px */
|
||||
.ui-dialog.ui-dialog-off-canvas {
|
||||
width: 100% !important;
|
||||
}
|
||||
/* When off-canvas dialog is at 100% width stop the body from scrolling */
|
||||
.js-off-canvas-dialog-open {
|
||||
height: 100%;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file
|
||||
* Visual styling for summary and details in the off-canvas dialog.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas details,
|
||||
#drupal-off-canvas summary {
|
||||
display: block;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
}
|
||||
#drupal-off-canvas details,
|
||||
#drupal-off-canvas summary,
|
||||
#drupal-off-canvas .ui-dialog-content {
|
||||
background: #474747;
|
||||
color: #ddd;
|
||||
}
|
||||
#drupal-off-canvas summary a {
|
||||
color: #ddd;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
#drupal-off-canvas summary a:hover,
|
||||
#drupal-off-canvas summary a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
#drupal-off-canvas details,
|
||||
#drupal-off-canvas summary,
|
||||
#drupal-off-canvas .details-wrapper {
|
||||
border-width: 0;
|
||||
/* Cancel out the padding of the parent. */
|
||||
margin: 0 -20px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
#drupal-off-canvas summary {
|
||||
text-shadow: none;
|
||||
padding: 10px 20px;
|
||||
font-size: 14px;
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
#drupal-off-canvas summary:hover,
|
||||
#drupal-off-canvas summary:focus {
|
||||
background-color: #222;
|
||||
}
|
||||
#drupal-off-canvas details[open] {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
#drupal-off-canvas details[open] > summary {
|
||||
background-color: #333;
|
||||
color: #eee;
|
||||
}
|
||||
#drupal-off-canvas details[open] > summary:hover {
|
||||
background-color: #222;
|
||||
color: #fff;
|
||||
}
|
||||
#drupal-off-canvas details .placeholder {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
font-style: italic;
|
||||
background: transparent;
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
/**
|
||||
* @file
|
||||
* Styles for dropbuttons in the off-canvas dialog.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas .dropbutton-wrapper,
|
||||
#drupal-off-canvas .dropbutton-widget {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
display: block;
|
||||
position: static;
|
||||
transition: none;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-widget {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: #277abd;
|
||||
border-radius: 1em;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
text-transform: none;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
line-height: normal;
|
||||
cursor: pointer;
|
||||
transition: background 0.5s ease;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-widget:hover {
|
||||
background: #2b8bd8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Style dropbutton single.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas .dropbutton-single .dropbutton-action a {
|
||||
padding: 0;
|
||||
/* Overlap icon for trigger. */
|
||||
margin-top: -2em;
|
||||
height: 2.2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-single .dropbutton-action:hover,
|
||||
#drupal-off-canvas .dropbutton-single .dropbutton-action:focus,
|
||||
#drupal-off-canvas .dropbutton-single .dropbutton-action a:hover,
|
||||
#drupal-off-canvas .dropbutton-single .dropbutton-action a:focus {
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-widget .dropbutton {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton li,
|
||||
#drupal-off-canvas .dropbutton a {
|
||||
display: block;
|
||||
width: auto;
|
||||
padding: 4px 0;
|
||||
text-align: left;
|
||||
color: #555;
|
||||
outline: none;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton li:hover,
|
||||
#drupal-off-canvas .dropbutton li:focus,
|
||||
#drupal-off-canvas .dropbutton a:hover,
|
||||
#drupal-off-canvas .dropbutton a:focus {
|
||||
background: transparent;
|
||||
color: #333;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/*
|
||||
* Style dropbutton multiple.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas .dropbutton-multiple .dropbutton-widget {
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-multiple .dropbutton-widget:hover {
|
||||
background-color: #2b8bd8;
|
||||
}
|
||||
|
||||
/* Hide the other actions until the dropbutton is triggered. */
|
||||
#drupal-off-canvas .dropbutton-multiple .dropbutton .secondary-action {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The toggle to expand the button. */
|
||||
#drupal-off-canvas .dropbutton-toggle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0; /* LTR */
|
||||
bottom: 0;
|
||||
display: block;
|
||||
width: 2em;
|
||||
color: #fff;
|
||||
text-indent: 110%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-toggle button {
|
||||
display: block;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0 solid transparent;
|
||||
border-bottom-right-radius: 1em; /* LTR */
|
||||
border-top-right-radius: 1em; /* LTR */
|
||||
cursor: pointer;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-toggle button:hover,
|
||||
#drupal-off-canvas .dropbutton-toggle button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* The toggle arrow. */
|
||||
#drupal-off-canvas .dropbutton-arrow {
|
||||
position: absolute;
|
||||
display: block;
|
||||
height: 0;
|
||||
width: 0;
|
||||
margin-top: 0;
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
border-style: solid;
|
||||
border-width: 0.3333em 0.3333em 0;
|
||||
color: #fff;
|
||||
line-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#drupal-off-canvas span.dropbutton-arrow {
|
||||
top: 7px;
|
||||
right: 7px; /* LTR */
|
||||
background: transparent;
|
||||
}
|
||||
#drupal-off-canvas span.dropbutton-arrow:hover {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#drupal-off-canvas .dropbutton-action > .js-form-submit.form-submit,
|
||||
#drupal-off-canvas .dropbutton-toggle button {
|
||||
position: relative;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dropbuttons when in a table cell.
|
||||
*/
|
||||
|
||||
/* Make sure table cell doesn't collapse around absolute positioned dropbutton. */
|
||||
#drupal-off-canvas td .dropbutton-single {
|
||||
min-width: 2em;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-multiple {
|
||||
min-width: 2em;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
border: 0;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-multiple .dropbutton-action a,
|
||||
#drupal-off-canvas td .dropbutton-multiple .dropbutton-action input,
|
||||
#drupal-off-canvas td .dropbutton-multiple .dropbutton-action button {
|
||||
width: auto;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-wrapper {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Push the widget to the right so text expands left. */
|
||||
#drupal-off-canvas td .dropbutton-widget {
|
||||
position: absolute;
|
||||
right: 12px; /* LTR */
|
||||
padding: 0;
|
||||
background: #277abd none;
|
||||
}
|
||||
|
||||
/* Push the wrapper to the right edge of the td. */
|
||||
#drupal-off-canvas td .dropbutton-single,
|
||||
#drupal-off-canvas td .dropbutton-multiple {
|
||||
float: right; /* LTR */
|
||||
padding-right: 0;
|
||||
margin-right: 0;
|
||||
max-width: initial;
|
||||
min-width: initial;
|
||||
position: relative;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-widget .dropbutton {
|
||||
margin: 0;
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* Push text out of the way. */
|
||||
#drupal-off-canvas td .dropbutton-multiple li,
|
||||
#drupal-off-canvas td .dropbutton-multiple a {
|
||||
margin-left: -9999px;
|
||||
background: transparent;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-multiple.open .dropbutton li,
|
||||
#drupal-off-canvas td .dropbutton-multiple.open .dropbutton a {
|
||||
margin-left: 0;
|
||||
width: auto;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Collapse the button to a circle. */
|
||||
#drupal-off-canvas td .dropbutton-toggle {
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
border-radius: 1em;
|
||||
}
|
||||
#drupal-off-canvas td .dropbutton-wrapper .dropbutton-widget .dropbutton-toggle button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* Prevent list item from expanding its container. */
|
||||
#drupal-off-canvas td ul.dropbutton li.edit {
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
/* Make li text transparent above icon so it's clickable. */
|
||||
#drupal-off-canvas td .dropbutton-single li.edit.dropbutton-action > a {
|
||||
color: transparent;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* Put pencil icon in place of hidden 'edit' text on single buttons. */
|
||||
#drupal-off-canvas td .dropbutton-single .edit:before {
|
||||
content: '.';
|
||||
display: block;
|
||||
color: transparent;
|
||||
background: transparent url(../icons/ffffff/pencil.svg) no-repeat center;
|
||||
background-size: 14px;
|
||||
}
|
||||
|
||||
/* Dropbutton when triggered expands to show secondary items. */
|
||||
#drupal-off-canvas .dropbutton-multiple.open {
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
/* Create visual separation if there is an adjacent button. */
|
||||
#drupal-off-canvas .dropbutton-multiple.open .dropbutton-widget {
|
||||
box-shadow: 0 3px 3px 2px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* Triggered dropbutton expands to show secondary items. */
|
||||
#drupal-off-canvas .dropbutton-multiple.open,
|
||||
#drupal-off-canvas .dropbutton-multiple.open .dropbutton-widget {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Triggered dropbutton in td expands to show secondary items. */
|
||||
#drupal-off-canvas td .dropbutton-multiple.open .dropbutton,
|
||||
#drupal-off-canvas .dropbutton-multiple.open .dropbutton .secondary-action {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: auto;
|
||||
padding-right: 1em; /* LTR */
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas td .dropbutton-multiple.open .dropbutton {
|
||||
padding-left: 1em;
|
||||
padding-right: inherit;
|
||||
}
|
||||
#drupal-off-canvas .dropbutton-multiple.open .dropbutton li a {
|
||||
padding: 2px 1em;
|
||||
}
|
||||
|
||||
/* When open, the toggle arrow points upward. */
|
||||
#drupal-off-canvas .dropbutton-multiple.open span.dropbutton-arrow {
|
||||
border-bottom: 0.3333em solid;
|
||||
border-top-color: transparent;
|
||||
top: 2px;
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* @file
|
||||
* Drupal's off-canvas library.
|
||||
*/
|
||||
|
||||
(($, Drupal, debounce, displace) => {
|
||||
/**
|
||||
* Off-canvas dialog implementation using jQuery Dialog.
|
||||
*
|
||||
* Transforms the regular dialogs created using Drupal.dialog when the dialog
|
||||
* element equals '#drupal-off-canvas' into an side-loading dialog.
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
Drupal.offCanvas = {
|
||||
|
||||
/**
|
||||
* The minimum width to use body displace needs to match the width at which
|
||||
* the tray will be 100% width. @see core/misc/dialog/off-canvas.css
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
minDisplaceWidth: 768,
|
||||
|
||||
/**
|
||||
* Wrapper used to position off-canvas dialog.
|
||||
*
|
||||
* @type {jQuery}
|
||||
*/
|
||||
$mainCanvasWrapper: $('[data-off-canvas-main-canvas]'),
|
||||
|
||||
/**
|
||||
* Determines if an element is an off-canvas dialog.
|
||||
*
|
||||
* @param {jQuery} $element
|
||||
* The dialog element.
|
||||
*
|
||||
* @return {bool}
|
||||
* True this is currently an off-canvas dialog.
|
||||
*/
|
||||
isOffCanvas($element) {
|
||||
return $element.is('#drupal-off-canvas');
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove off-canvas dialog events.
|
||||
*
|
||||
* @param {jQuery} $element
|
||||
* The target element.
|
||||
*/
|
||||
removeOffCanvasEvents($element) {
|
||||
$element.off('.off-canvas');
|
||||
$(document).off('.off-canvas');
|
||||
$(window).off('.off-canvas');
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler fired before an off-canvas dialog has been opened.
|
||||
*
|
||||
* @param {Object} settings
|
||||
* Settings related to the composition of the dialog.
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
beforeCreate({ settings, $element }) {
|
||||
// Clean up previous dialog event handlers.
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
|
||||
$('body').addClass('js-off-canvas-dialog-open');
|
||||
// @see http://api.jqueryui.com/position/
|
||||
settings.position = {
|
||||
my: 'left top',
|
||||
at: `${Drupal.offCanvas.getEdge()} top`,
|
||||
of: window,
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies initial height to dialog based on window height.
|
||||
* @see http://api.jqueryui.com/dialog for all dialog options.
|
||||
*/
|
||||
settings.height = $(window).height();
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler fired after an off-canvas dialog has been closed.
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
beforeClose({ $element }) {
|
||||
$('body').removeClass('js-off-canvas-dialog-open');
|
||||
// Remove all *.off-canvas events
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
|
||||
Drupal.offCanvas.$mainCanvasWrapper.css(`padding-${Drupal.offCanvas.getEdge()}`, 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler fired when an off-canvas dialog has been opened.
|
||||
*
|
||||
* @param {jQuery} $element
|
||||
* The off-canvas dialog element.
|
||||
* @param {Object} settings
|
||||
* Settings related to the composition of the dialog.
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
afterCreate({ $element, settings }) {
|
||||
const eventData = { settings, $element, offCanvasDialog: this };
|
||||
|
||||
$element
|
||||
.on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.handleDialogResize)
|
||||
.on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.bodyPadding);
|
||||
|
||||
Drupal.offCanvas.getContainer($element).attr(`data-offset-${Drupal.offCanvas.getEdge()}`, '');
|
||||
|
||||
$(window)
|
||||
.on('resize.off-canvas', eventData, debounce(Drupal.offCanvas.resetSize, 100))
|
||||
.trigger('resize.off-canvas');
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle classes based on title existence.
|
||||
* Called with Drupal.offCanvas.afterCreate.
|
||||
*
|
||||
* @param {Object} settings
|
||||
* Settings related to the composition of the dialog.
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
render({ settings }) {
|
||||
$('.ui-dialog-off-canvas, .ui-dialog-off-canvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adjusts the dialog on resize.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
* @param {object} event.data
|
||||
* Data attached to the event.
|
||||
*/
|
||||
handleDialogResize(event) {
|
||||
const $element = event.data.$element;
|
||||
const $container = Drupal.offCanvas.getContainer($element);
|
||||
|
||||
const $offsets = $container.find('> :not(#drupal-off-canvas, .ui-resizable-handle)');
|
||||
let offset = 0;
|
||||
|
||||
// Let scroll element take all the height available.
|
||||
$element.css({ height: 'auto' });
|
||||
const modalHeight = $container.height();
|
||||
|
||||
$offsets.each((i, e) => {
|
||||
offset += $(e).outerHeight();
|
||||
});
|
||||
|
||||
// Take internal padding into account.
|
||||
const scrollOffset = $element.outerHeight() - $element.height();
|
||||
$element.height(modalHeight - offset - scrollOffset);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets the size of the dialog.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
* @param {object} event.data
|
||||
* Data attached to the event.
|
||||
*/
|
||||
resetSize(event) {
|
||||
const offsets = displace.offsets;
|
||||
const $element = event.data.$element;
|
||||
const container = Drupal.offCanvas.getContainer($element);
|
||||
|
||||
const topPosition = (offsets.top !== 0 ? `+${offsets.top}` : '');
|
||||
const adjustedOptions = {
|
||||
// @see http://api.jqueryui.com/position/
|
||||
position: {
|
||||
my: `${Drupal.offCanvas.getEdge()} top`,
|
||||
at: `${Drupal.offCanvas.getEdge()} top${topPosition}`,
|
||||
of: window,
|
||||
},
|
||||
};
|
||||
|
||||
container.css({
|
||||
position: 'fixed',
|
||||
height: `${$(window).height() - (offsets.top + offsets.bottom)}px`,
|
||||
});
|
||||
|
||||
$element
|
||||
.dialog('option', adjustedOptions)
|
||||
.trigger('dialogContentResize.off-canvas');
|
||||
},
|
||||
|
||||
/**
|
||||
* Adjusts the body padding when the dialog is resized.
|
||||
*
|
||||
* @param {jQuery.Event} event
|
||||
* The event triggered.
|
||||
* @param {object} event.data
|
||||
* Data attached to the event.
|
||||
*/
|
||||
bodyPadding(event) {
|
||||
if ($('body').outerWidth() < Drupal.offCanvas.minDisplaceWidth) {
|
||||
return;
|
||||
}
|
||||
const $element = event.data.$element;
|
||||
const $container = Drupal.offCanvas.getContainer($element);
|
||||
const $mainCanvasWrapper = Drupal.offCanvas.$mainCanvasWrapper;
|
||||
|
||||
const width = $container.outerWidth();
|
||||
const mainCanvasPadding = $mainCanvasWrapper.css(`padding-${Drupal.offCanvas.getEdge()}`);
|
||||
if (width !== mainCanvasPadding) {
|
||||
$mainCanvasWrapper.css(`padding-${Drupal.offCanvas.getEdge()}`, `${width}px`);
|
||||
$container.attr(`data-offset-${Drupal.offCanvas.getEdge()}`, width);
|
||||
displace();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The HTML element that surrounds the dialog.
|
||||
* @param {HTMLElement} $element
|
||||
* The dialog element.
|
||||
*
|
||||
* @return {HTMLElement}
|
||||
* The containing element.
|
||||
*/
|
||||
getContainer($element) {
|
||||
return $element.dialog('widget');
|
||||
},
|
||||
|
||||
/**
|
||||
* The edge of the screen that the dialog should appear on.
|
||||
*
|
||||
* @return {string}
|
||||
* The edge the tray will be shown on, left or right.
|
||||
*/
|
||||
getEdge() {
|
||||
return document.documentElement.dir === 'rtl' ? 'left' : 'right';
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Attaches off-canvas dialog behaviors.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches event listeners for off-canvas dialogs.
|
||||
*/
|
||||
Drupal.behaviors.offCanvasEvents = {
|
||||
attach: () => {
|
||||
$(window).once('off-canvas').on({
|
||||
'dialog:beforecreate': (event, dialog, $element, settings) => {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeCreate({ dialog, $element, settings });
|
||||
}
|
||||
},
|
||||
'dialog:aftercreate': (event, dialog, $element, settings) => {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.render({ dialog, $element, settings });
|
||||
Drupal.offCanvas.afterCreate({ $element, settings });
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': (event, dialog, $element) => {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeClose({ dialog, $element });
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, Drupal.debounce, Drupal.displace);
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* @file
|
||||
* Visual styling for forms in the off-canvas dialog.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas form {
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
color: #ddd;
|
||||
}
|
||||
#drupal-off-canvas input[type="checkbox"] {
|
||||
-webkit-appearance: checkbox;
|
||||
}
|
||||
#drupal-off-canvas input[type="radio"] {
|
||||
-webkit-appearance: radio;
|
||||
}
|
||||
#drupal-off-canvas select {
|
||||
-webkit-appearance: menulist;
|
||||
-moz-appearance: menulist;
|
||||
}
|
||||
#drupal-off-canvas option {
|
||||
display: block;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
}
|
||||
#drupal-off-canvas label {
|
||||
line-height: normal;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #ddd;
|
||||
}
|
||||
#drupal-off-canvas .visually-hidden {
|
||||
opacity: 0;
|
||||
height: 0;
|
||||
width: 0;
|
||||
letter-spacing: -2em;
|
||||
}
|
||||
#drupal-off-canvas .description,
|
||||
#drupal-off-canvas .form-item .description,
|
||||
#drupal-off-canvas .details-description {
|
||||
color: #ddd;
|
||||
margin-top: 5px;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
}
|
||||
#drupal-off-canvas .form-item {
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
/* Set size and position for all inputs. */
|
||||
#drupal-off-canvas .form-select,
|
||||
#drupal-off-canvas .form-text,
|
||||
#drupal-off-canvas .form-tel,
|
||||
#drupal-off-canvas .form-email,
|
||||
#drupal-off-canvas .form-url,
|
||||
#drupal-off-canvas .form-search,
|
||||
#drupal-off-canvas .form-number,
|
||||
#drupal-off-canvas .form-color,
|
||||
#drupal-off-canvas .form-file,
|
||||
#drupal-off-canvas .form-textarea,
|
||||
#drupal-off-canvas .form-date,
|
||||
#drupal-off-canvas .form-time {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
padding: 6px;
|
||||
margin: 5px 0 0 0;
|
||||
border-width: 1px;
|
||||
border-radius: 2px;
|
||||
display: block;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
line-height: 16px;
|
||||
}
|
||||
/* Reduce contrast for fields against dark background. */
|
||||
#drupal-off-canvas .form-text,
|
||||
#drupal-off-canvas .form-tel,
|
||||
#drupal-off-canvas .form-email,
|
||||
#drupal-off-canvas .form-url,
|
||||
#drupal-off-canvas .form-search,
|
||||
#drupal-off-canvas .form-number,
|
||||
#drupal-off-canvas .form-color,
|
||||
#drupal-off-canvas .form-file,
|
||||
#drupal-off-canvas .form-textarea,
|
||||
#drupal-off-canvas .form-date,
|
||||
#drupal-off-canvas .form-time {
|
||||
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.125);
|
||||
background-color: #eee;
|
||||
border-color: #333;
|
||||
color: #595959;
|
||||
}
|
||||
#drupal-off-canvas .form-text:focus,
|
||||
#drupal-off-canvas .form-tel:focus,
|
||||
#drupal-off-canvas .form-email:focus,
|
||||
#drupal-off-canvas .form-url:focus,
|
||||
#drupal-off-canvas .form-search:focus,
|
||||
#drupal-off-canvas .form-number:focus,
|
||||
#drupal-off-canvas .form-color:focus,
|
||||
#drupal-off-canvas .form-file:focus,
|
||||
#drupal-off-canvas .form-textarea:focus,
|
||||
#drupal-off-canvas .form-date:focus,
|
||||
#drupal-off-canvas .form-time:focus {
|
||||
border-color: #40b6ff;
|
||||
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.125), 0 0 8px #40b6ff;
|
||||
background-color: #fff;
|
||||
}
|
||||
#drupal-off-canvas td .form-item,
|
||||
#drupal-off-canvas td .form-select {
|
||||
margin: 0;
|
||||
}
|
||||
#drupal-off-canvas .form-file {
|
||||
margin-bottom: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
#drupal-off-canvas .form-actions {
|
||||
text-align: center;
|
||||
margin: 10px 0;
|
||||
}
|
||||
#drupal-off-canvas .ui-autocomplete {
|
||||
background-color: white;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: default;
|
||||
}
|
||||
#drupal-off-canvas .ui-autocomplete li {
|
||||
display: block;
|
||||
}
|
||||
#drupal-off-canvas .ui-autocomplete li a {
|
||||
color: #595959 !important;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, debounce, displace) {
|
||||
Drupal.offCanvas = {
|
||||
minDisplaceWidth: 768,
|
||||
|
||||
$mainCanvasWrapper: $('[data-off-canvas-main-canvas]'),
|
||||
|
||||
isOffCanvas: function isOffCanvas($element) {
|
||||
return $element.is('#drupal-off-canvas');
|
||||
},
|
||||
removeOffCanvasEvents: function removeOffCanvasEvents($element) {
|
||||
$element.off('.off-canvas');
|
||||
$(document).off('.off-canvas');
|
||||
$(window).off('.off-canvas');
|
||||
},
|
||||
beforeCreate: function beforeCreate(_ref) {
|
||||
var settings = _ref.settings,
|
||||
$element = _ref.$element;
|
||||
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
|
||||
$('body').addClass('js-off-canvas-dialog-open');
|
||||
|
||||
settings.position = {
|
||||
my: 'left top',
|
||||
at: Drupal.offCanvas.getEdge() + ' top',
|
||||
of: window
|
||||
};
|
||||
|
||||
settings.height = $(window).height();
|
||||
},
|
||||
beforeClose: function beforeClose(_ref2) {
|
||||
var $element = _ref2.$element;
|
||||
|
||||
$('body').removeClass('js-off-canvas-dialog-open');
|
||||
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
|
||||
Drupal.offCanvas.$mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge(), 0);
|
||||
},
|
||||
afterCreate: function afterCreate(_ref3) {
|
||||
var $element = _ref3.$element,
|
||||
settings = _ref3.settings;
|
||||
|
||||
var eventData = { settings: settings, $element: $element, offCanvasDialog: this };
|
||||
|
||||
$element.on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.handleDialogResize).on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.bodyPadding);
|
||||
|
||||
Drupal.offCanvas.getContainer($element).attr('data-offset-' + Drupal.offCanvas.getEdge(), '');
|
||||
|
||||
$(window).on('resize.off-canvas', eventData, debounce(Drupal.offCanvas.resetSize, 100)).trigger('resize.off-canvas');
|
||||
},
|
||||
render: function render(_ref4) {
|
||||
var settings = _ref4.settings;
|
||||
|
||||
$('.ui-dialog-off-canvas, .ui-dialog-off-canvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
|
||||
},
|
||||
handleDialogResize: function handleDialogResize(event) {
|
||||
var $element = event.data.$element;
|
||||
var $container = Drupal.offCanvas.getContainer($element);
|
||||
|
||||
var $offsets = $container.find('> :not(#drupal-off-canvas, .ui-resizable-handle)');
|
||||
var offset = 0;
|
||||
|
||||
$element.css({ height: 'auto' });
|
||||
var modalHeight = $container.height();
|
||||
|
||||
$offsets.each(function (i, e) {
|
||||
offset += $(e).outerHeight();
|
||||
});
|
||||
|
||||
var scrollOffset = $element.outerHeight() - $element.height();
|
||||
$element.height(modalHeight - offset - scrollOffset);
|
||||
},
|
||||
resetSize: function resetSize(event) {
|
||||
var offsets = displace.offsets;
|
||||
var $element = event.data.$element;
|
||||
var container = Drupal.offCanvas.getContainer($element);
|
||||
|
||||
var topPosition = offsets.top !== 0 ? '+' + offsets.top : '';
|
||||
var adjustedOptions = {
|
||||
position: {
|
||||
my: Drupal.offCanvas.getEdge() + ' top',
|
||||
at: Drupal.offCanvas.getEdge() + ' top' + topPosition,
|
||||
of: window
|
||||
}
|
||||
};
|
||||
|
||||
container.css({
|
||||
position: 'fixed',
|
||||
height: $(window).height() - (offsets.top + offsets.bottom) + 'px'
|
||||
});
|
||||
|
||||
$element.dialog('option', adjustedOptions).trigger('dialogContentResize.off-canvas');
|
||||
},
|
||||
bodyPadding: function bodyPadding(event) {
|
||||
if ($('body').outerWidth() < Drupal.offCanvas.minDisplaceWidth) {
|
||||
return;
|
||||
}
|
||||
var $element = event.data.$element;
|
||||
var $container = Drupal.offCanvas.getContainer($element);
|
||||
var $mainCanvasWrapper = Drupal.offCanvas.$mainCanvasWrapper;
|
||||
|
||||
var width = $container.outerWidth();
|
||||
var mainCanvasPadding = $mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge());
|
||||
if (width !== mainCanvasPadding) {
|
||||
$mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge(), width + 'px');
|
||||
$container.attr('data-offset-' + Drupal.offCanvas.getEdge(), width);
|
||||
displace();
|
||||
}
|
||||
},
|
||||
getContainer: function getContainer($element) {
|
||||
return $element.dialog('widget');
|
||||
},
|
||||
getEdge: function getEdge() {
|
||||
return document.documentElement.dir === 'rtl' ? 'left' : 'right';
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.offCanvasEvents = {
|
||||
attach: function attach() {
|
||||
$(window).once('off-canvas').on({
|
||||
'dialog:beforecreate': function dialogBeforecreate(event, dialog, $element, settings) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeCreate({ dialog: dialog, $element: $element, settings: settings });
|
||||
}
|
||||
},
|
||||
'dialog:aftercreate': function dialogAftercreate(event, dialog, $element, settings) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.render({ dialog: dialog, $element: $element, settings: settings });
|
||||
Drupal.offCanvas.afterCreate({ $element: $element, settings: settings });
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': function dialogBeforeclose(event, dialog, $element) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeClose({ dialog: dialog, $element: $element });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, Drupal.debounce, Drupal.displace);
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* Visual styling for layouts in the off-canvas dialog.
|
||||
*
|
||||
* See seven/css/layout/layout.css
|
||||
*/
|
||||
|
||||
.layout-icon__region {
|
||||
fill: #f5f5f2;
|
||||
stroke: #666;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* Motion effects for off-canvas dialog.
|
||||
*
|
||||
* Motion effects are in a separate file so that they can be easily turned off
|
||||
* to improve performance if desired.
|
||||
*/
|
||||
|
||||
.dialog-off-canvas-main-canvas {
|
||||
transition: all 0.7s ease;
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
/**
|
||||
* @file
|
||||
* Reset most HTML elements styles for the off-canvas dialog.
|
||||
*
|
||||
* This is a generic reset. Drupal-specific classes are reset in components.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Do not include div in then initial overrides because including div will
|
||||
* cause the need for many more overrides in this file.
|
||||
*/
|
||||
#drupal-off-canvas *:not(div),
|
||||
#drupal-off-canvas *:not(svg *),
|
||||
#drupal-off-canvas *:after,
|
||||
#drupal-off-canvas *:before {
|
||||
all: initial;
|
||||
box-sizing: border-box;
|
||||
text-shadow: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-tap-highlight-color: initial;
|
||||
}
|
||||
|
||||
/* Reset size and position on elements. */
|
||||
#drupal-off-canvas a,
|
||||
#drupal-off-canvas abbr,
|
||||
#drupal-off-canvas acronym,
|
||||
#drupal-off-canvas address,
|
||||
#drupal-off-canvas applet,
|
||||
#drupal-off-canvas article,
|
||||
#drupal-off-canvas aside,
|
||||
#drupal-off-canvas audio,
|
||||
#drupal-off-canvas b,
|
||||
#drupal-off-canvas big,
|
||||
#drupal-off-canvas blockquote,
|
||||
#drupal-off-canvas body,
|
||||
#drupal-off-canvas canvas,
|
||||
#drupal-off-canvas caption,
|
||||
#drupal-off-canvas cite,
|
||||
#drupal-off-canvas code,
|
||||
#drupal-off-canvas dd,
|
||||
#drupal-off-canvas del,
|
||||
#drupal-off-canvas dfn,
|
||||
#drupal-off-canvas dialog,
|
||||
#drupal-off-canvas dl,
|
||||
#drupal-off-canvas dt,
|
||||
#drupal-off-canvas em,
|
||||
#drupal-off-canvas embed,
|
||||
#drupal-off-canvas fieldset,
|
||||
#drupal-off-canvas figcaption,
|
||||
#drupal-off-canvas figure,
|
||||
#drupal-off-canvas footer,
|
||||
#drupal-off-canvas form,
|
||||
#drupal-off-canvas h1,
|
||||
#drupal-off-canvas h2,
|
||||
#drupal-off-canvas h3,
|
||||
#drupal-off-canvas h4,
|
||||
#drupal-off-canvas h5,
|
||||
#drupal-off-canvas h6,
|
||||
#drupal-off-canvas header,
|
||||
#drupal-off-canvas hgroup,
|
||||
#drupal-off-canvas hr,
|
||||
#drupal-off-canvas html,
|
||||
#drupal-off-canvas i,
|
||||
#drupal-off-canvas iframe,
|
||||
#drupal-off-canvas img,
|
||||
#drupal-off-canvas ins,
|
||||
#drupal-off-canvas kbd,
|
||||
#drupal-off-canvas label,
|
||||
#drupal-off-canvas legend,
|
||||
#drupal-off-canvas li,
|
||||
#drupal-off-canvas main,
|
||||
#drupal-off-canvas mark,
|
||||
#drupal-off-canvas menu,
|
||||
#drupal-off-canvas meter,
|
||||
#drupal-off-canvas nav,
|
||||
#drupal-off-canvas object,
|
||||
#drupal-off-canvas ol,
|
||||
#drupal-off-canvas output,
|
||||
#drupal-off-canvas p,
|
||||
#drupal-off-canvas pre,
|
||||
#drupal-off-canvas progress,
|
||||
#drupal-off-canvas q,
|
||||
#drupal-off-canvas rp,
|
||||
#drupal-off-canvas rt,
|
||||
#drupal-off-canvas s,
|
||||
#drupal-off-canvas samp,
|
||||
#drupal-off-canvas section,
|
||||
#drupal-off-canvas small,
|
||||
#drupal-off-canvas span,
|
||||
#drupal-off-canvas strike,
|
||||
#drupal-off-canvas strong,
|
||||
#drupal-off-canvas sub,
|
||||
#drupal-off-canvas sup,
|
||||
#drupal-off-canvas table,
|
||||
#drupal-off-canvas tbody,
|
||||
#drupal-off-canvas td,
|
||||
#drupal-off-canvas tfoot,
|
||||
#drupal-off-canvas th,
|
||||
#drupal-off-canvas thead,
|
||||
#drupal-off-canvas time,
|
||||
#drupal-off-canvas tr,
|
||||
#drupal-off-canvas tt,
|
||||
#drupal-off-canvas u,
|
||||
#drupal-off-canvas ul,
|
||||
#drupal-off-canvas var,
|
||||
#drupal-off-canvas video,
|
||||
#drupal-off-canvas xmp {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
/*
|
||||
* Override the default (display: inline) for browsers that do not recognize HTML5 tags.
|
||||
* IE8 (and lower) requires a shiv: http://ejohn.org/blog/html5-shiv
|
||||
*/
|
||||
#drupal-off-canvas article,
|
||||
#drupal-off-canvas aside,
|
||||
#drupal-off-canvas figcaption,
|
||||
#drupal-off-canvas figure,
|
||||
#drupal-off-canvas footer,
|
||||
#drupal-off-canvas header,
|
||||
#drupal-off-canvas hgroup,
|
||||
#drupal-off-canvas main,
|
||||
#drupal-off-canvas menu,
|
||||
#drupal-off-canvas nav,
|
||||
#drupal-off-canvas section {
|
||||
display: block;
|
||||
line-height: normal;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Makes browsers agree.
|
||||
* IE + Opera = font-weight: bold.
|
||||
* Gecko + WebKit = font-weight: bolder.
|
||||
*/
|
||||
#drupal-off-canvas b,
|
||||
#drupal-off-canvas strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#drupal-off-canvas em,
|
||||
#drupal-off-canvas i {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#drupal-off-canvas img {
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#drupal-off-canvas ul,
|
||||
#drupal-off-canvas ol {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* reset table styling. */
|
||||
#drupal-off-canvas table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
#drupal-off-canvas table thead,
|
||||
#drupal-off-canvas table tbody,
|
||||
#drupal-off-canvas table tbody tr:nth-child(even),
|
||||
#drupal-off-canvas table tbody tr:nth-child(odd),
|
||||
#drupal-off-canvas table tfoot {
|
||||
border: 0;
|
||||
background: transparent none;
|
||||
}
|
||||
#drupal-off-canvas th,
|
||||
#drupal-off-canvas td,
|
||||
#drupal-off-canvas caption {
|
||||
font-weight: normal;
|
||||
}
|
||||
#drupal-off-canvas q {
|
||||
quotes: none;
|
||||
}
|
||||
#drupal-off-canvas q:before,
|
||||
#drupal-off-canvas q:after {
|
||||
content: none;
|
||||
}
|
||||
#drupal-off-canvas sub,
|
||||
#drupal-off-canvas sup,
|
||||
#drupal-off-canvas small {
|
||||
font-size: 75%;
|
||||
}
|
||||
#drupal-off-canvas sub,
|
||||
#drupal-off-canvas sup {
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
#drupal-off-canvas sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
#drupal-off-canvas sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/*
|
||||
* For IE9. Without, occasionally draws shapes
|
||||
* outside the boundaries of <svg> rectangle.
|
||||
*/
|
||||
#drupal-off-canvas svg {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Specific resets for inputs. */
|
||||
#drupal-off-canvas input[type="search"]::-webkit-search-decoration {
|
||||
display: none;
|
||||
}
|
||||
#drupal-off-canvas input {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#drupal-off-canvas input[type="checkbox"],
|
||||
#drupal-off-canvas input[type="radio"] {
|
||||
position: static;
|
||||
margin: 0;
|
||||
}
|
||||
#drupal-off-canvas input:invalid,
|
||||
#drupal-off-canvas button:invalid,
|
||||
#drupal-off-canvas select:invalid,
|
||||
#drupal-off-canvas textarea:invalid,
|
||||
#drupal-off-canvas input:focus,
|
||||
#drupal-off-canvas button:focus,
|
||||
#drupal-off-canvas select:focus,
|
||||
#drupal-off-canvas textarea:focus,
|
||||
#drupal-off-canvas input[type="file"]:focus,
|
||||
#drupal-off-canvas input[type="file"]:active,
|
||||
#drupal-off-canvas input[type="radio"]:focus,
|
||||
#drupal-off-canvas input[type="radio"]:active,
|
||||
#drupal-off-canvas input[type="checkbox"]:focus,
|
||||
#drupal-off-canvas input[type="checkbox"]:active {
|
||||
box-shadow: none;
|
||||
z-index: 1;
|
||||
}
|
||||
#drupal-off-canvas input[role="button"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
#drupal-off-canvas button,
|
||||
#drupal-off-canvas input[type="reset"],
|
||||
#drupal-off-canvas input[type="submit"],
|
||||
#drupal-off-canvas input[type="button"] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
display: inline-block;
|
||||
background-image: none;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
overflow: visible;
|
||||
text-shadow: none;
|
||||
text-decoration: none;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
}
|
||||
#drupal-off-canvas button:hover,
|
||||
#drupal-off-canvas input[type="reset"]:hover,
|
||||
#drupal-off-canvas input[type="submit"]:hover,
|
||||
#drupal-off-canvas input[type="button"]:hover {
|
||||
background-image: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
#drupal-off-canvas button:active,
|
||||
#drupal-off-canvas input[type="reset"]:active,
|
||||
#drupal-off-canvas input[type="submit"]:active,
|
||||
#drupal-off-canvas input[type="button"]:active {
|
||||
background-image: none;
|
||||
box-shadow: none;
|
||||
border-color: grey;
|
||||
}
|
||||
#drupal-off-canvas button::-moz-focus-inner,
|
||||
#drupal-off-canvas input[type="reset"]::-moz-focus-inner,
|
||||
#drupal-off-canvas input[type="submit"]::-moz-focus-inner,
|
||||
#drupal-off-canvas input[type="button"]::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#drupal-off-canvas textarea,
|
||||
#drupal-off-canvas select,
|
||||
#drupal-off-canvas input[type="date"],
|
||||
#drupal-off-canvas input[type="datetime"],
|
||||
#drupal-off-canvas input[type="datetime-local"],
|
||||
#drupal-off-canvas input[type="email"],
|
||||
#drupal-off-canvas input[type="month"],
|
||||
#drupal-off-canvas input[type="number"],
|
||||
#drupal-off-canvas input[type="password"],
|
||||
#drupal-off-canvas input[type="search"],
|
||||
#drupal-off-canvas input[type="tel"],
|
||||
#drupal-off-canvas input[type="text"],
|
||||
#drupal-off-canvas input[type="time"],
|
||||
#drupal-off-canvas input[type="url"],
|
||||
#drupal-off-canvas input[type="week"] {
|
||||
height: auto;
|
||||
vertical-align: middle;
|
||||
border-radius: 0;
|
||||
}
|
||||
#drupal-off-canvas textarea[disabled],
|
||||
#drupal-off-canvas select[disabled],
|
||||
#drupal-off-canvas input[type="date"][disabled],
|
||||
#drupal-off-canvas input[type="datetime"][disabled],
|
||||
#drupal-off-canvas input[type="datetime-local"][disabled],
|
||||
#drupal-off-canvas input[type="email"][disabled],
|
||||
#drupal-off-canvas input[type="month"][disabled],
|
||||
#drupal-off-canvas input[type="number"][disabled],
|
||||
#drupal-off-canvas input[type="password"][disabled],
|
||||
#drupal-off-canvas input[type="search"][disabled],
|
||||
#drupal-off-canvas input[type="tel"][disabled],
|
||||
#drupal-off-canvas input[type="text"][disabled],
|
||||
#drupal-off-canvas input[type="time"][disabled],
|
||||
#drupal-off-canvas input[type="url"][disabled],
|
||||
#drupal-off-canvas input[type="week"][disabled] {
|
||||
background-color: grey;
|
||||
}
|
||||
#drupal-off-canvas input[type="hidden"] {
|
||||
visibility: hidden;
|
||||
}
|
||||
#drupal-off-canvas button[disabled],
|
||||
#drupal-off-canvas input[disabled],
|
||||
#drupal-off-canvas select[disabled],
|
||||
#drupal-off-canvas select[disabled] option,
|
||||
#drupal-off-canvas select[disabled] optgroup,
|
||||
#drupal-off-canvas textarea[disabled] {
|
||||
box-shadow: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
cursor: default;
|
||||
}
|
||||
#drupal-off-canvas input:placeholder,
|
||||
#drupal-off-canvas textarea:placeholder {
|
||||
color: grey;
|
||||
}
|
||||
#drupal-off-canvas textarea,
|
||||
#drupal-off-canvas select[size],
|
||||
#drupal-off-canvas select[multiple] {
|
||||
height: auto;
|
||||
}
|
||||
#drupal-off-canvas select[size="0"],
|
||||
#drupal-off-canvas select[size="1"] {
|
||||
height: auto;
|
||||
}
|
||||
#drupal-off-canvas textarea {
|
||||
min-height: 40px;
|
||||
overflow: auto;
|
||||
resize: vertical;
|
||||
width: 100%;
|
||||
}
|
||||
#drupal-off-canvas optgroup {
|
||||
color: black;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
#drupal-off-canvas optgroup::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#drupal-off-canvas * button {
|
||||
background: none;
|
||||
border: 1px solid grey;
|
||||
color: black;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
overflow: visible;
|
||||
vertical-align: middle;
|
||||
width: auto;
|
||||
}
|
||||
#drupal-off-canvas * textarea,
|
||||
#drupal-off-canvas * select,
|
||||
#drupal-off-canvas *:not(div) textarea,
|
||||
#drupal-off-canvas *:not(div) select {
|
||||
background: white;
|
||||
border: 1px solid grey;
|
||||
color: black;
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* To standardize off-canvas selection color. */
|
||||
#drupal-off-canvas ::-moz-selection,
|
||||
#drupal-off-canvas ::selection {
|
||||
background-color: rgba(175, 175, 175, 0.5);
|
||||
color: inherit;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @file
|
||||
* Visual styling for tables in the off-canvas dialog.
|
||||
*/
|
||||
|
||||
#drupal-off-canvas table * {
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
}
|
||||
#drupal-off-canvas table {
|
||||
display: table;
|
||||
width: 100%;
|
||||
min-width: calc(100% + 40px);
|
||||
/* Cancel out the padding of the parent to make the table full width. */
|
||||
margin: 0 -20px -10px -20px;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
color: #ddd;
|
||||
}
|
||||
#drupal-off-canvas table thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
#drupal-off-canvas table tbody {
|
||||
display: table-row-group;
|
||||
}
|
||||
#drupal-off-canvas tr {
|
||||
display: table-row;
|
||||
}
|
||||
#drupal-off-canvas tr:hover td {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#drupal-off-canvas td,
|
||||
#drupal-off-canvas th {
|
||||
display: table-cell;
|
||||
height: auto;
|
||||
width: auto;
|
||||
padding: 2px 8px;
|
||||
vertical-align: middle;
|
||||
border-bottom: 1px solid #777;
|
||||
background-color: transparent;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas th,
|
||||
[dir="rtl"] #drupal-off-canvas td {
|
||||
text-align: right;
|
||||
}
|
||||
#drupal-off-canvas th {
|
||||
font-weight: bold;
|
||||
}
|
||||
#drupal-off-canvas th.checkbox,
|
||||
#drupal-off-canvas td.checkbox {
|
||||
width: 20px;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
#drupal-off-canvas div.checkbox.menu-enabled {
|
||||
position: static;
|
||||
display: inline;
|
||||
width: auto;
|
||||
}
|
||||
#drupal-off-canvas th:first-child,
|
||||
#drupal-off-canvas td:first-child {
|
||||
width: 150px;
|
||||
}
|
||||
/* For lack of a better class, using this to grab the operations th. */
|
||||
#drupal-off-canvas .tabledrag-has-colspan {
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
}
|
||||
#drupal-off-canvas td {
|
||||
padding: 6px 8px;
|
||||
color: #ddd;
|
||||
}
|
||||
/* Hide overflow with ellipsis for links. */
|
||||
#drupal-off-canvas td a {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
background: transparent;
|
||||
}
|
||||
#drupal-off-canvas tr td:first-child,
|
||||
#drupal-off-canvas tr th:first-child {
|
||||
padding-left: 20px; /* LTR */
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas tr td:first-child,
|
||||
[dir="rtl"] #drupal-off-canvas tr th:first-child {
|
||||
padding-right: 20px;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @file
|
||||
* Table drag behavior for off-canvas dialog.
|
||||
*
|
||||
* @see tabledrag.js
|
||||
*/
|
||||
|
||||
#drupal-off-canvas .drag {
|
||||
cursor: move;
|
||||
}
|
||||
#drupal-off-canvas tr.region-title {
|
||||
font-weight: normal;
|
||||
}
|
||||
#drupal-off-canvas table .region-message {
|
||||
color: #fff;
|
||||
}
|
||||
#drupal-off-canvas table .region-populated {
|
||||
display: none;
|
||||
}
|
||||
#drupal-off-canvas .add-new .tabledrag-changed {
|
||||
display: none;
|
||||
}
|
||||
#drupal-off-canvas .draggable a.tabledrag-handle {
|
||||
background-image: none;
|
||||
margin: 0 5px 0 0;
|
||||
height: auto;
|
||||
min-width: 20px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
float: left; /* LTR */
|
||||
text-decoration: none;
|
||||
cursor: move;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .draggable a.tabledrag-handle {
|
||||
float: right;
|
||||
margin-right: 0;
|
||||
margin-left: 5px;
|
||||
}
|
||||
#drupal-off-canvas a.tabledrag-handle .handle {
|
||||
/* Use lighter drag icon against dark background. */
|
||||
background-color: transparent;
|
||||
background-image: url(../icons/bebebe/move.svg);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: auto;
|
||||
}
|
||||
#drupal-off-canvas .draggable a.tabledrag-handle:hover .handle,
|
||||
#drupal-off-canvas .draggable a.tabledrag-handle:focus .handle {
|
||||
background-image: url(../icons/787878/move.svg);
|
||||
text-decoration: none;
|
||||
}
|
||||
#drupal-off-canvas tr td {
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
#drupal-off-canvas tr td abbr {
|
||||
margin-left: 5px; /* LTR */
|
||||
}
|
||||
|
||||
[dir="rtl"] #drupal-off-canvas tr td abbr {
|
||||
margin-left: 0;
|
||||
margin-right: 5px;
|
||||
}
|
||||
#drupal-off-canvas tr:hover td {
|
||||
background: #222;
|
||||
}
|
||||
#drupal-off-canvas tr.drag td {
|
||||
background: #111;
|
||||
}
|
||||
#drupal-off-canvas tr.drag-previous td {
|
||||
background: #000;
|
||||
}
|
||||
#drupal-off-canvas tr.drag-previous:hover td {
|
||||
background: #222;
|
||||
}
|
||||
body div.tabledrag-changed-warning {
|
||||
margin-bottom: 0.5em;
|
||||
font-size: 14px;
|
||||
}
|
||||
#drupal-off-canvas .touchevents .draggable td {
|
||||
padding: 0 10px;
|
||||
}
|
||||
#drupal-off-canvas .touchevents .draggable .menu-item__link {
|
||||
display: inline-block;
|
||||
padding: 10px 0;
|
||||
}
|
||||
#drupal-off-canvas .touchevents a.tabledrag-handle {
|
||||
height: 44px;
|
||||
width: 40px;
|
||||
}
|
||||
#drupal-off-canvas .touchevents a.tabledrag-handle .handle {
|
||||
background-position: 40% 19px; /* LTR */
|
||||
height: 21px;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .touch a.tabledrag-handle .handle {
|
||||
background-position: right 40% top 19px;
|
||||
}
|
||||
#drupal-off-canvas .touchevents .draggable.drag a.tabledrag-handle .handle {
|
||||
background-position: 50% -32px;
|
||||
}
|
||||
#drupal-off-canvas .tabledrag-toggle-weight-wrapper {
|
||||
padding-top: 10px;
|
||||
text-align: right; /* LTR */
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .tabledrag-toggle-weight-wrapper {
|
||||
text-align: left;
|
||||
}
|
||||
#drupal-off-canvas .indentation {
|
||||
float: left; /* LTR */
|
||||
height: auto;
|
||||
margin: 0 3px 0 -10px; /* LTR */
|
||||
padding: 0 0 0 10px; /* LTR */
|
||||
width: auto;
|
||||
}
|
||||
[dir="rtl"] #drupal-off-canvas .indentation {
|
||||
float: right;
|
||||
margin: 0 -10px 0 3px;
|
||||
padding: 0 10px 0 0;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @file
|
||||
* Styling for the off-canvas ui dialog. Including overrides for jQuery UI.
|
||||
*/
|
||||
|
||||
/* Style the dialog-off-canvas container. */
|
||||
.ui-dialog.ui-dialog-off-canvas {
|
||||
background: #444;
|
||||
border: 0 solid transparent;
|
||||
border-radius: 0;
|
||||
box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.3333);
|
||||
padding: 0;
|
||||
color: #ddd;
|
||||
/* Layer the dialog just under the toolbar. */
|
||||
z-index: 501;
|
||||
}
|
||||
|
||||
/* Style the off-canvas dialog header. */
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar {
|
||||
padding: 1em;
|
||||
background: #2d2d2d;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #000;
|
||||
border-radius: 0;
|
||||
font-weight: normal;
|
||||
color: #fff;
|
||||
}
|
||||
/* Hide the default jQuery UI dialog close button. */
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar-close .ui-icon {
|
||||
visibility: hidden;
|
||||
}
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar-close {
|
||||
background-image: url(../icons/bebebe/ex.svg);
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
background-color: transparent;
|
||||
border: 3px solid transparent;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
position: absolute;
|
||||
top: calc(50% - 6px);
|
||||
right: 1em;
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar-close:hover,
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar-close:focus {
|
||||
background-image: url(../icons/ffffff/ex.svg);
|
||||
border: 3px solid #fff;
|
||||
}
|
||||
[dir="rtl"] .ui-dialog.ui-dialog-off-canvas .ui-dialog-titlebar-close {
|
||||
left: 1em;
|
||||
right: auto;
|
||||
}
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-title {
|
||||
margin: 0;
|
||||
/* Push the text away from the icon. */
|
||||
padding-left: 30px; /* LTR */
|
||||
padding-right: 0; /* LTR */
|
||||
/* Ensure that long titles do not overlap the close button. */
|
||||
max-width: 210px;
|
||||
font-size: 16px;
|
||||
font-family: "Lucida Grande", 'Lucida Sans Unicode', 'liberation sans', sans-serif;
|
||||
text-align: left; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .ui-dialog.ui-dialog-off-canvas .ui-dialog-title {
|
||||
float: right;
|
||||
text-align: right;
|
||||
padding-left: 0;
|
||||
padding-right: 30px;
|
||||
}
|
||||
.ui-dialog.ui-dialog-off-canvas .ui-dialog-title:before {
|
||||
background: transparent url(../icons/ffffff/pencil.svg) no-repeat scroll center center;
|
||||
background-size: 100% auto;
|
||||
content: '';
|
||||
display: block;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
left: 1em; /* LTR */
|
||||
top: 0;
|
||||
width: 20px;
|
||||
}
|
||||
[dir="rtl"] .ui-dialog.ui-dialog-off-canvas .ui-dialog-title:before {
|
||||
left: auto;
|
||||
right: 1em;
|
||||
}
|
||||
|
||||
/* Override default styling from jQuery UI. */
|
||||
#drupal-off-canvas .ui-state-default,
|
||||
#drupal-off-canvas .ui-widget-content .ui-state-default,
|
||||
#drupal-off-canvas .ui-widget-header .ui-state-default {
|
||||
border: 0;
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
#drupal-off-canvas .ui-widget-content a {
|
||||
color: #85bef4;
|
||||
}
|
||||
@@ -73,7 +73,8 @@
|
||||
* @fires event:drupalViewportOffsetChange
|
||||
*/
|
||||
function displace(broadcast) {
|
||||
offsets = Drupal.displace.offsets = calculateOffsets();
|
||||
offsets = calculateOffsets();
|
||||
Drupal.displace.offsets = offsets;
|
||||
if (typeof broadcast === 'undefined' || broadcast) {
|
||||
$(document).trigger('drupalViewportOffsetChange', offsets);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
};
|
||||
|
||||
function displace(broadcast) {
|
||||
offsets = Drupal.displace.offsets = calculateOffsets();
|
||||
offsets = calculateOffsets();
|
||||
Drupal.displace.offsets = offsets;
|
||||
if (typeof broadcast === 'undefined' || broadcast) {
|
||||
$(document).trigger('drupalViewportOffsetChange', offsets);
|
||||
}
|
||||
|
||||
+27
-34
@@ -152,8 +152,8 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
settings = settings || drupalSettings;
|
||||
const behaviors = Drupal.behaviors;
|
||||
// Execute all of them.
|
||||
for (const i in behaviors) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') {
|
||||
Object.keys(behaviors || {}).forEach((i) => {
|
||||
if (typeof behaviors[i].attach === 'function') {
|
||||
// Don't stop the execution of behaviors in case of an error.
|
||||
try {
|
||||
behaviors[i].attach(context, settings);
|
||||
@@ -162,7 +162,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -212,8 +212,8 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
trigger = trigger || 'unload';
|
||||
const behaviors = Drupal.behaviors;
|
||||
// Execute all of them.
|
||||
for (const i in behaviors) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function') {
|
||||
Object.keys(behaviors || {}).forEach((i) => {
|
||||
if (typeof behaviors[i].detach === 'function') {
|
||||
// Don't stop the execution of behaviors in case of an error.
|
||||
try {
|
||||
behaviors[i].detach(context, settings, trigger);
|
||||
@@ -222,7 +222,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -239,9 +239,10 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
Drupal.checkPlain = function (str) {
|
||||
str = str.toString()
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
return str;
|
||||
};
|
||||
|
||||
@@ -269,26 +270,24 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
// Keep args intact.
|
||||
const processedArgs = {};
|
||||
// Transform arguments before inserting them.
|
||||
for (const key in args) {
|
||||
if (args.hasOwnProperty(key)) {
|
||||
switch (key.charAt(0)) {
|
||||
// Escaped only.
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
Object.keys(args || {}).forEach((key) => {
|
||||
switch (key.charAt(0)) {
|
||||
// Escaped only.
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
|
||||
// Pass-through.
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
// Pass-through.
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
|
||||
// Escaped and placeholder.
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
// Escaped and placeholder.
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Drupal.stringReplace(str, processedArgs, null);
|
||||
};
|
||||
@@ -316,12 +315,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
|
||||
// If the array of keys is not passed then collect the keys from the args.
|
||||
if (!Array.isArray(keys)) {
|
||||
keys = [];
|
||||
for (const k in args) {
|
||||
if (args.hasOwnProperty(k)) {
|
||||
keys.push(k);
|
||||
}
|
||||
}
|
||||
keys = Object.keys(args || {});
|
||||
|
||||
// Order the keys by the character length. The shortest one is the first.
|
||||
keys.sort((a, b) => a.length - b.length);
|
||||
@@ -559,10 +553,9 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
* Any data the theme function returns. This could be a plain HTML string,
|
||||
* but also a complex object.
|
||||
*/
|
||||
Drupal.theme = function (func) {
|
||||
const args = Array.prototype.slice.apply(arguments, [1]);
|
||||
Drupal.theme = function (func, ...args) {
|
||||
if (func in Drupal.theme) {
|
||||
return Drupal.theme[func].apply(this, args);
|
||||
return Drupal.theme[func](...args);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+27
-29
@@ -19,15 +19,15 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
settings = settings || drupalSettings;
|
||||
var behaviors = Drupal.behaviors;
|
||||
|
||||
for (var i in behaviors) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') {
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].attach === 'function') {
|
||||
try {
|
||||
behaviors[i].attach(context, settings);
|
||||
} catch (e) {
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.detachBehaviors = function (context, settings, trigger) {
|
||||
@@ -36,42 +36,40 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
trigger = trigger || 'unload';
|
||||
var behaviors = Drupal.behaviors;
|
||||
|
||||
for (var i in behaviors) {
|
||||
if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function') {
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].detach === 'function') {
|
||||
try {
|
||||
behaviors[i].detach(context, settings, trigger);
|
||||
} catch (e) {
|
||||
Drupal.throwError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.checkPlain = function (str) {
|
||||
str = str.toString().replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||
str = str.toString().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
return str;
|
||||
};
|
||||
|
||||
Drupal.formatString = function (str, args) {
|
||||
var processedArgs = {};
|
||||
|
||||
for (var key in args) {
|
||||
if (args.hasOwnProperty(key)) {
|
||||
switch (key.charAt(0)) {
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
Object.keys(args || {}).forEach(function (key) {
|
||||
switch (key.charAt(0)) {
|
||||
case '@':
|
||||
processedArgs[key] = Drupal.checkPlain(args[key]);
|
||||
break;
|
||||
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
case '!':
|
||||
processedArgs[key] = args[key];
|
||||
break;
|
||||
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Drupal.stringReplace(str, processedArgs, null);
|
||||
};
|
||||
@@ -82,12 +80,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
}
|
||||
|
||||
if (!Array.isArray(keys)) {
|
||||
keys = [];
|
||||
for (var k in args) {
|
||||
if (args.hasOwnProperty(k)) {
|
||||
keys.push(k);
|
||||
}
|
||||
}
|
||||
keys = Object.keys(args || {});
|
||||
|
||||
keys.sort(function (a, b) {
|
||||
return a.length - b.length;
|
||||
@@ -181,9 +174,14 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||
};
|
||||
|
||||
Drupal.theme = function (func) {
|
||||
var args = Array.prototype.slice.apply(arguments, [1]);
|
||||
if (func in Drupal.theme) {
|
||||
return Drupal.theme[func].apply(this, args);
|
||||
var _Drupal$theme;
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
return (_Drupal$theme = Drupal.theme)[func].apply(_Drupal$theme, args);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
const userInfo = ['name', 'mail', 'homepage'];
|
||||
const $forms = $('[data-user-info-from-browser]').once('user-info-from-browser');
|
||||
if ($forms.length) {
|
||||
userInfo.map((info) => {
|
||||
userInfo.forEach((info) => {
|
||||
const $element = $forms.find(`[name=${info}]`);
|
||||
const browserData = localStorage.getItem(`Drupal.visitor.${info}`);
|
||||
const emptyOrDefault = ($element.val() === '' || ($element.attr('data-drupal-default-value') === $element.val()));
|
||||
@@ -246,7 +246,7 @@
|
||||
});
|
||||
}
|
||||
$forms.on('submit', () => {
|
||||
userInfo.map((info) => {
|
||||
userInfo.forEach((info) => {
|
||||
const $element = $forms.find(`[name=${info}]`);
|
||||
if ($element.length) {
|
||||
localStorage.setItem(`Drupal.visitor.${info}`, $element.val());
|
||||
@@ -297,5 +297,4 @@
|
||||
* is already in the URL.
|
||||
*/
|
||||
$(document).on('click.form-fragment', 'a[href*="#"]', debouncedHandleFragmentLinkClickOrHashChange);
|
||||
|
||||
}(jQuery, Drupal, Drupal.debounce));
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@
|
||||
var userInfo = ['name', 'mail', 'homepage'];
|
||||
var $forms = $('[data-user-info-from-browser]').once('user-info-from-browser');
|
||||
if ($forms.length) {
|
||||
userInfo.map(function (info) {
|
||||
userInfo.forEach(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();
|
||||
@@ -115,7 +115,7 @@
|
||||
});
|
||||
}
|
||||
$forms.on('submit', function () {
|
||||
userInfo.map(function (info) {
|
||||
userInfo.forEach(function (info) {
|
||||
var $element = $forms.find('[name=' + info + ']');
|
||||
if ($element.length) {
|
||||
localStorage.setItem('Drupal.visitor.' + info, $element.val());
|
||||
|
||||
@@ -86,12 +86,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(settings.machineName).forEach((source_id) => {
|
||||
Object.keys(settings.machineName).forEach((sourceId) => {
|
||||
let machine = '';
|
||||
let eventData;
|
||||
const options = settings.machineName[source_id];
|
||||
const options = settings.machineName[sourceId];
|
||||
|
||||
const $source = $context.find(source_id).addClass('machine-name-source').once('machine-name');
|
||||
const $source = $context.find(sourceId).addClass('machine-name-source').once('machine-name');
|
||||
const $target = $context.find(options.target).addClass('machine-name-target');
|
||||
const $suffix = $context.find(options.suffix);
|
||||
const $wrapper = $target.closest('.js-form-item');
|
||||
@@ -129,7 +128,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
eventData = {
|
||||
const eventData = {
|
||||
$source,
|
||||
$target,
|
||||
$suffix,
|
||||
|
||||
@@ -49,12 +49,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(settings.machineName).forEach(function (source_id) {
|
||||
Object.keys(settings.machineName).forEach(function (sourceId) {
|
||||
var machine = '';
|
||||
var eventData = void 0;
|
||||
var options = settings.machineName[source_id];
|
||||
var options = settings.machineName[sourceId];
|
||||
|
||||
var $source = $context.find(source_id).addClass('machine-name-source').once('machine-name');
|
||||
var $source = $context.find(sourceId).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('.js-form-item');
|
||||
@@ -88,7 +87,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
eventData = {
|
||||
var eventData = {
|
||||
$source: $source,
|
||||
$target: $target,
|
||||
$suffix: $suffix,
|
||||
|
||||
+30
-27
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* @namespace Drupal.states
|
||||
*/
|
||||
const states = Drupal.states = {
|
||||
const states = {
|
||||
|
||||
/**
|
||||
* An array of functions that should be postponed.
|
||||
@@ -20,6 +20,8 @@
|
||||
postponed: [],
|
||||
};
|
||||
|
||||
Drupal.states = states;
|
||||
|
||||
/**
|
||||
* Attaches the states.
|
||||
*
|
||||
@@ -31,20 +33,16 @@
|
||||
Drupal.behaviors.states = {
|
||||
attach(context, settings) {
|
||||
const $states = $(context).find('[data-drupal-states]');
|
||||
let config;
|
||||
let state;
|
||||
const il = $states.length;
|
||||
for (let i = 0; i < il; i++) {
|
||||
config = JSON.parse($states[i].getAttribute('data-drupal-states'));
|
||||
for (state in config) {
|
||||
if (config.hasOwnProperty(state)) {
|
||||
new states.Dependent({
|
||||
element: $($states[i]),
|
||||
state: states.State.sanitize(state),
|
||||
constraints: config[state],
|
||||
});
|
||||
}
|
||||
}
|
||||
const config = JSON.parse($states[i].getAttribute('data-drupal-states'));
|
||||
Object.keys(config || {}).forEach((state) => {
|
||||
new states.Dependent({
|
||||
element: $($states[i]),
|
||||
state: states.State.sanitize(state),
|
||||
constraints: config[state],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Execute all postponed functions now.
|
||||
@@ -74,11 +72,9 @@
|
||||
$.extend(this, { values: {}, oldValue: null }, args);
|
||||
|
||||
this.dependees = this.getDependees();
|
||||
for (const selector in this.dependees) {
|
||||
if (this.dependees.hasOwnProperty(selector)) {
|
||||
this.initializeDependee(selector, this.dependees[selector]);
|
||||
}
|
||||
}
|
||||
Object.keys(this.dependees || {}).forEach((selector) => {
|
||||
this.initializeDependee(selector, this.dependees[selector]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -134,6 +130,7 @@
|
||||
// Cache for the states of this dependee.
|
||||
this.values[selector] = {};
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const i in dependeeStates) {
|
||||
if (dependeeStates.hasOwnProperty(i)) {
|
||||
state = dependeeStates[i];
|
||||
@@ -265,6 +262,7 @@
|
||||
// bogus, we don't want to end up with an infinite loop.
|
||||
else if ($.isPlainObject(constraints)) {
|
||||
// This constraint is an object (AND).
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const n in constraints) {
|
||||
if (constraints.hasOwnProperty(n)) {
|
||||
result = ternary(result, this.checkConstraints(constraints[n], selector, n));
|
||||
@@ -389,11 +387,9 @@
|
||||
trigger.call(window, this.element);
|
||||
}
|
||||
else {
|
||||
for (const event in trigger) {
|
||||
if (trigger.hasOwnProperty(event)) {
|
||||
this.defaultTrigger(event, trigger[event]);
|
||||
}
|
||||
}
|
||||
Object.keys(trigger || {}).forEach((event) => {
|
||||
this.defaultTrigger(event, trigger[event]);
|
||||
});
|
||||
}
|
||||
|
||||
// Mark this trigger as initialized for this element.
|
||||
@@ -508,7 +504,8 @@
|
||||
/**
|
||||
* Original unresolved name.
|
||||
*/
|
||||
this.pristine = this.name = state;
|
||||
this.pristine = state;
|
||||
this.name = state;
|
||||
|
||||
// Normalize the state name.
|
||||
let process = true;
|
||||
@@ -603,8 +600,10 @@
|
||||
if (e.trigger) {
|
||||
$(e.target)
|
||||
.prop('disabled', e.value)
|
||||
.closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggleClass('form-disabled', e.value)
|
||||
.find('select, input, textarea').prop('disabled', e.value);
|
||||
.closest('.js-form-item, .js-form-submit, .js-form-wrapper')
|
||||
.toggleClass('form-disabled', e.value)
|
||||
.find('select, input, textarea')
|
||||
.prop('disabled', e.value);
|
||||
|
||||
// Note: WebKit nightlies don't reflect that change correctly.
|
||||
// See https://bugs.webkit.org/show_bug.cgi?id=23789
|
||||
@@ -622,7 +621,11 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(e.target).removeAttr('required aria-required').closest('.js-form-item, .js-form-wrapper').find('label.js-form-required').removeClass('js-form-required form-required');
|
||||
$(e.target)
|
||||
.removeAttr('required aria-required')
|
||||
.closest('.js-form-item, .js-form-wrapper')
|
||||
.find('label.js-form-required')
|
||||
.removeClass('js-form-required form-required');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+28
-24
@@ -6,27 +6,30 @@
|
||||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
var states = Drupal.states = {
|
||||
var states = {
|
||||
postponed: []
|
||||
};
|
||||
|
||||
Drupal.states = states;
|
||||
|
||||
Drupal.behaviors.states = {
|
||||
attach: function attach(context, settings) {
|
||||
var $states = $(context).find('[data-drupal-states]');
|
||||
var config = void 0;
|
||||
var state = void 0;
|
||||
var il = $states.length;
|
||||
|
||||
var _loop = function _loop(i) {
|
||||
var config = JSON.parse($states[i].getAttribute('data-drupal-states'));
|
||||
Object.keys(config || {}).forEach(function (state) {
|
||||
new states.Dependent({
|
||||
element: $($states[i]),
|
||||
state: states.State.sanitize(state),
|
||||
constraints: config[state]
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
config = JSON.parse($states[i].getAttribute('data-drupal-states'));
|
||||
for (state in config) {
|
||||
if (config.hasOwnProperty(state)) {
|
||||
new states.Dependent({
|
||||
element: $($states[i]),
|
||||
state: states.State.sanitize(state),
|
||||
constraints: config[state]
|
||||
});
|
||||
}
|
||||
}
|
||||
_loop(i);
|
||||
}
|
||||
|
||||
while (states.postponed.length) {
|
||||
@@ -36,14 +39,14 @@
|
||||
};
|
||||
|
||||
states.Dependent = function (args) {
|
||||
var _this = this;
|
||||
|
||||
$.extend(this, { values: {}, oldValue: null }, args);
|
||||
|
||||
this.dependees = this.getDependees();
|
||||
for (var selector in this.dependees) {
|
||||
if (this.dependees.hasOwnProperty(selector)) {
|
||||
this.initializeDependee(selector, this.dependees[selector]);
|
||||
}
|
||||
}
|
||||
Object.keys(this.dependees || {}).forEach(function (selector) {
|
||||
_this.initializeDependee(selector, _this.dependees[selector]);
|
||||
});
|
||||
};
|
||||
|
||||
states.Dependent.comparisons = {
|
||||
@@ -185,16 +188,16 @@
|
||||
|
||||
states.Trigger.prototype = {
|
||||
initialize: function initialize() {
|
||||
var _this2 = this;
|
||||
|
||||
var trigger = states.Trigger.states[this.state];
|
||||
|
||||
if (typeof trigger === 'function') {
|
||||
trigger.call(window, this.element);
|
||||
} else {
|
||||
for (var event in trigger) {
|
||||
if (trigger.hasOwnProperty(event)) {
|
||||
this.defaultTrigger(event, trigger[event]);
|
||||
}
|
||||
}
|
||||
Object.keys(trigger || {}).forEach(function (event) {
|
||||
_this2.defaultTrigger(event, trigger[event]);
|
||||
});
|
||||
}
|
||||
|
||||
this.element.data('trigger:' + this.state, true);
|
||||
@@ -259,7 +262,8 @@
|
||||
};
|
||||
|
||||
states.State = function (state) {
|
||||
this.pristine = this.name = state;
|
||||
this.pristine = state;
|
||||
this.name = state;
|
||||
|
||||
var process = true;
|
||||
do {
|
||||
|
||||
+91
-94
@@ -41,11 +41,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
for (const base in settings.tableDrag) {
|
||||
if (settings.tableDrag.hasOwnProperty(base)) {
|
||||
initTableDrag($(context).find(`#${base}`).once('tabledrag'), base);
|
||||
}
|
||||
}
|
||||
Object.keys(settings.tableDrag || {}).forEach((base) => {
|
||||
initTableDrag($(context).find(`#${base}`).once('tabledrag'), base);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -172,20 +170,16 @@
|
||||
* @type {bool}
|
||||
*/
|
||||
this.indentEnabled = false;
|
||||
for (const group in tableSettings) {
|
||||
if (tableSettings.hasOwnProperty(group)) {
|
||||
for (const n in tableSettings[group]) {
|
||||
if (tableSettings[group].hasOwnProperty(n)) {
|
||||
if (tableSettings[group][n].relationship === 'parent') {
|
||||
this.indentEnabled = true;
|
||||
}
|
||||
if (tableSettings[group][n].limit > 0) {
|
||||
this.maxDepth = tableSettings[group][n].limit;
|
||||
}
|
||||
}
|
||||
Object.keys(tableSettings || {}).forEach((group) => {
|
||||
Object.keys(tableSettings[group] || {}).forEach((n) => {
|
||||
if (tableSettings[group][n].relationship === 'parent') {
|
||||
this.indentEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tableSettings[group][n].limit > 0) {
|
||||
this.maxDepth = tableSettings[group][n].limit;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (this.indentEnabled) {
|
||||
/**
|
||||
* Total width of indents, set in makeDraggable.
|
||||
@@ -264,30 +258,29 @@
|
||||
let hidden;
|
||||
let cell;
|
||||
let columnIndex;
|
||||
for (const group in this.tableSettings) {
|
||||
if (this.tableSettings.hasOwnProperty(group)) {
|
||||
// Find the first field in this group.
|
||||
for (const d in this.tableSettings[group]) {
|
||||
if (this.tableSettings[group].hasOwnProperty(d)) {
|
||||
const field = $table.find(`.${this.tableSettings[group][d].target}`).eq(0);
|
||||
if (field.length && this.tableSettings[group][d].hidden) {
|
||||
hidden = this.tableSettings[group][d].hidden;
|
||||
cell = field.closest('td');
|
||||
break;
|
||||
}
|
||||
Object.keys(this.tableSettings || {}).forEach((group) => {
|
||||
// Find the first field in this group.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const d in this.tableSettings[group]) {
|
||||
if (this.tableSettings[group].hasOwnProperty(d)) {
|
||||
const field = $table.find(`.${this.tableSettings[group][d].target}`).eq(0);
|
||||
if (field.length && this.tableSettings[group][d].hidden) {
|
||||
hidden = this.tableSettings[group][d].hidden;
|
||||
cell = field.closest('td');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the column containing this field so it can be hidden.
|
||||
if (hidden && cell[0]) {
|
||||
// Add 1 to our indexes. The nth-child selector is 1 based, not 0
|
||||
// based. Match immediate children of the parent element to allow
|
||||
// nesting.
|
||||
columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
|
||||
$table.find('> thead > tr, > tbody > tr, > tr').each(this.addColspanClass(columnIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the column containing this field so it can be hidden.
|
||||
if (hidden && cell[0]) {
|
||||
// Add 1 to our indexes. The nth-child selector is 1 based, not 0
|
||||
// based. Match immediate children of the parent element to allow
|
||||
// nesting.
|
||||
columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
|
||||
$table.find('> thead > tr, > tbody > tr, > tr').each(this.addColspanClass(columnIndex));
|
||||
}
|
||||
});
|
||||
this.displayColumns(showWeight);
|
||||
};
|
||||
|
||||
@@ -419,12 +412,14 @@
|
||||
Drupal.tableDrag.prototype.rowSettings = function (group, row) {
|
||||
const field = $(row).find(`.${group}`);
|
||||
const tableSettingsGroup = this.tableSettings[group];
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const delta in tableSettingsGroup) {
|
||||
if (tableSettingsGroup.hasOwnProperty(delta)) {
|
||||
const targetClass = tableSettingsGroup[delta].target;
|
||||
if (field.is(`.${targetClass}`)) {
|
||||
// Return a copy of the row settings.
|
||||
const rowSettings = {};
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const n in tableSettingsGroup[delta]) {
|
||||
if (tableSettingsGroup[delta].hasOwnProperty(n)) {
|
||||
rowSettings[n] = tableSettingsGroup[delta][n];
|
||||
@@ -510,9 +505,9 @@
|
||||
// Up arrow.
|
||||
case 38:
|
||||
// Safari up arrow.
|
||||
case 63232:
|
||||
var $previousRow = $(self.rowObject.element).prev('tr:first-of-type');
|
||||
var previousRow = $previousRow.get(0);
|
||||
case 63232: {
|
||||
let $previousRow = $(self.rowObject.element).prev('tr:first-of-type');
|
||||
let previousRow = $previousRow.get(0);
|
||||
while (previousRow && $previousRow.is(':hidden')) {
|
||||
$previousRow = $(previousRow).prev('tr:first-of-type');
|
||||
previousRow = $previousRow.get(0);
|
||||
@@ -549,7 +544,7 @@
|
||||
handle.trigger('focus');
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
// Right arrow.
|
||||
case 39:
|
||||
// Safari right arrow.
|
||||
@@ -561,9 +556,9 @@
|
||||
// Down arrow.
|
||||
case 40:
|
||||
// Safari down arrow.
|
||||
case 63233:
|
||||
var $nextRow = $(self.rowObject.group).eq(-1).next('tr:first-of-type');
|
||||
var nextRow = $nextRow.get(0);
|
||||
case 63233: {
|
||||
let $nextRow = $(self.rowObject.group).eq(-1).next('tr:first-of-type');
|
||||
let nextRow = $nextRow.get(0);
|
||||
while (nextRow && $nextRow.is(':hidden')) {
|
||||
$nextRow = $(nextRow).next('tr:first-of-type');
|
||||
nextRow = $nextRow.get(0);
|
||||
@@ -599,6 +594,7 @@
|
||||
handle.trigger('focus');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable no-fallthrough */
|
||||
@@ -712,7 +708,8 @@
|
||||
// Stop any current scrolling.
|
||||
clearInterval(self.scrollInterval);
|
||||
// Continue scrolling if the mouse has moved in the scroll direction.
|
||||
if (scrollAmount > 0 && self.rowObject.direction === 'down' || scrollAmount < 0 && self.rowObject.direction === 'up') {
|
||||
if ((scrollAmount > 0 && self.rowObject.direction === 'down')
|
||||
|| (scrollAmount < 0 && self.rowObject.direction === 'up')) {
|
||||
self.setScroll(scrollAmount);
|
||||
}
|
||||
|
||||
@@ -772,18 +769,14 @@
|
||||
|
||||
// If a setting exists for affecting the entire group, update all the
|
||||
// fields in the entire dragged group.
|
||||
for (const group in self.tableSettings) {
|
||||
if (self.tableSettings.hasOwnProperty(group)) {
|
||||
const rowSettings = self.rowSettings(group, droppedRow);
|
||||
if (rowSettings.relationship === 'group') {
|
||||
for (const n in self.rowObject.children) {
|
||||
if (self.rowObject.children.hasOwnProperty(n)) {
|
||||
self.updateField(self.rowObject.children[n], group);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.keys(self.tableSettings || {}).forEach((group) => {
|
||||
const rowSettings = self.rowSettings(group, droppedRow);
|
||||
if (rowSettings.relationship === 'group') {
|
||||
Object.keys(self.rowObject.children || {}).forEach((n) => {
|
||||
self.updateField(self.rowObject.children[n], group);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.rowObject.markChanged();
|
||||
if (self.changed === false) {
|
||||
@@ -826,8 +819,8 @@
|
||||
return { x: event.pageX, y: event.pageY };
|
||||
}
|
||||
return {
|
||||
x: event.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y: event.clientY + document.body.scrollTop - document.body.clientTop,
|
||||
x: (event.clientX + document.body.scrollLeft) - document.body.clientLeft,
|
||||
y: (event.clientY + document.body.scrollTop) - document.body.clientTop,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -870,7 +863,7 @@
|
||||
let row = rows[n];
|
||||
let $row = $(row);
|
||||
const rowY = $row.offset().top;
|
||||
var rowHeight;
|
||||
let rowHeight;
|
||||
// Because Safari does not report offsetHeight on table rows, but does on
|
||||
// table cells, grab the firstChild of the row and use that instead.
|
||||
// http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari.
|
||||
@@ -886,17 +879,16 @@
|
||||
if ((y > (rowY - rowHeight)) && (y < (rowY + rowHeight))) {
|
||||
if (this.indentEnabled) {
|
||||
// Check that this row is not a child of the row being dragged.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (n in this.rowObject.group) {
|
||||
if (this.rowObject.group[n] === row) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Do not allow a row to be swapped with itself.
|
||||
if (row === this.rowObject.element) {
|
||||
return null;
|
||||
}
|
||||
// Do not allow a row to be swapped with itself.
|
||||
else if (row === this.rowObject.element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that swapping with this row is allowed.
|
||||
@@ -924,13 +916,11 @@
|
||||
* DOM object for the row that was just dropped.
|
||||
*/
|
||||
Drupal.tableDrag.prototype.updateFields = function (changedRow) {
|
||||
for (const group in this.tableSettings) {
|
||||
if (this.tableSettings.hasOwnProperty(group)) {
|
||||
// Each group may have a different setting for relationship, so we find
|
||||
// the source rows for each separately.
|
||||
this.updateField(changedRow, group);
|
||||
}
|
||||
}
|
||||
Object.keys(this.tableSettings || {}).forEach((group) => {
|
||||
// Each group may have a different setting for relationship, so we find
|
||||
// the source rows for each separately.
|
||||
this.updateField(changedRow, group);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1037,8 +1027,8 @@
|
||||
targetElement.value = sourceElement.value;
|
||||
break;
|
||||
|
||||
case 'order':
|
||||
var siblings = this.rowObject.findSiblings(rowSettings);
|
||||
case 'order': {
|
||||
const siblings = this.rowObject.findSiblings(rowSettings);
|
||||
if ($(targetElement).is('select')) {
|
||||
// Get a list of acceptable values.
|
||||
const values = [];
|
||||
@@ -1067,6 +1057,7 @@
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1106,20 +1097,22 @@
|
||||
const de = document.documentElement;
|
||||
const b = document.body;
|
||||
|
||||
const windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
|
||||
const windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
|
||||
this.windowHeight = windowHeight;
|
||||
let scrollY;
|
||||
if (document.all) {
|
||||
scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
|
||||
scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
|
||||
}
|
||||
else {
|
||||
scrollY = this.scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
|
||||
scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
|
||||
}
|
||||
this.scrollY = scrollY;
|
||||
const trigger = this.scrollSettings.trigger;
|
||||
let delta = 0;
|
||||
|
||||
// Return a scroll speed relative to the edge of the screen.
|
||||
if (cursorY - scrollY > windowHeight - trigger) {
|
||||
delta = trigger / (windowHeight + scrollY - cursorY);
|
||||
delta = trigger / ((windowHeight + scrollY) - cursorY);
|
||||
delta = (delta > 0 && delta < trigger) ? delta : trigger;
|
||||
return delta * this.scrollSettings.amount;
|
||||
}
|
||||
@@ -1144,7 +1137,8 @@
|
||||
self.checkScroll(self.currentPointerCoords.y);
|
||||
const aboveTable = self.scrollY > self.table.topY;
|
||||
const belowTable = self.scrollY + self.windowHeight < self.table.bottomY;
|
||||
if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) {
|
||||
if ((scrollAmount > 0 && belowTable)
|
||||
|| (scrollAmount < 0 && aboveTable)) {
|
||||
window.scrollBy(0, scrollAmount);
|
||||
}
|
||||
}, this.scrollSettings.interval);
|
||||
@@ -1157,10 +1151,16 @@
|
||||
// :even and :odd are reversed because jQuery counts from 0 and
|
||||
// we count from 1, so we're out of sync.
|
||||
// Match immediate children of the parent element to allow nesting.
|
||||
$(this.table).find('> tbody > tr.draggable, > tr.draggable')
|
||||
$(this.table)
|
||||
.find('> tbody > tr.draggable, > tr.draggable')
|
||||
.filter(':visible')
|
||||
.filter(':odd').removeClass('odd').addClass('even').end()
|
||||
.filter(':even').removeClass('even').addClass('odd');
|
||||
.filter(':odd')
|
||||
.removeClass('odd')
|
||||
.addClass('even')
|
||||
.end()
|
||||
.filter(':even')
|
||||
.removeClass('even')
|
||||
.addClass('odd');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1348,12 +1348,11 @@
|
||||
*/
|
||||
Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
|
||||
const $prevRow = $(prevRow);
|
||||
let minIndent;
|
||||
let maxIndent;
|
||||
|
||||
// Minimum indentation:
|
||||
// Do not orphan the next row.
|
||||
minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
|
||||
const minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
|
||||
|
||||
// Maximum indentation:
|
||||
if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
|
||||
@@ -1477,15 +1476,13 @@
|
||||
* Remove indentation helper classes from the current row group.
|
||||
*/
|
||||
Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
|
||||
for (const n in this.children) {
|
||||
if (this.children.hasOwnProperty(n)) {
|
||||
$(this.children[n]).find('.js-indentation')
|
||||
.removeClass('tree-child')
|
||||
.removeClass('tree-child-first')
|
||||
.removeClass('tree-child-last')
|
||||
.removeClass('tree-child-horizontal');
|
||||
}
|
||||
}
|
||||
Object.keys(this.children || {}).forEach((n) => {
|
||||
$(this.children[n]).find('.js-indentation')
|
||||
.removeClass('tree-child')
|
||||
.removeClass('tree-child-first')
|
||||
.removeClass('tree-child-last')
|
||||
.removeClass('tree-child-horizontal');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+144
-145
@@ -16,15 +16,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
for (var base in settings.tableDrag) {
|
||||
if (settings.tableDrag.hasOwnProperty(base)) {
|
||||
initTableDrag($(context).find('#' + base).once('tabledrag'), base);
|
||||
}
|
||||
}
|
||||
Object.keys(settings.tableDrag || {}).forEach(function (base) {
|
||||
initTableDrag($(context).find('#' + base).once('tabledrag'), base);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.tableDrag = function (table, tableSettings) {
|
||||
var _this = this;
|
||||
|
||||
var self = this;
|
||||
var $table = $(table);
|
||||
|
||||
@@ -59,20 +59,16 @@
|
||||
this.windowHeight = 0;
|
||||
|
||||
this.indentEnabled = false;
|
||||
for (var group in tableSettings) {
|
||||
if (tableSettings.hasOwnProperty(group)) {
|
||||
for (var n in tableSettings[group]) {
|
||||
if (tableSettings[group].hasOwnProperty(n)) {
|
||||
if (tableSettings[group][n].relationship === 'parent') {
|
||||
this.indentEnabled = true;
|
||||
}
|
||||
if (tableSettings[group][n].limit > 0) {
|
||||
this.maxDepth = tableSettings[group][n].limit;
|
||||
}
|
||||
}
|
||||
Object.keys(tableSettings || {}).forEach(function (group) {
|
||||
Object.keys(tableSettings[group] || {}).forEach(function (n) {
|
||||
if (tableSettings[group][n].relationship === 'parent') {
|
||||
_this.indentEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tableSettings[group][n].limit > 0) {
|
||||
_this.maxDepth = tableSettings[group][n].limit;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (this.indentEnabled) {
|
||||
this.indentCount = 1;
|
||||
|
||||
@@ -118,29 +114,29 @@
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.initColumns = function () {
|
||||
var _this2 = this;
|
||||
|
||||
var $table = this.$table;
|
||||
var hidden = void 0;
|
||||
var cell = void 0;
|
||||
var columnIndex = void 0;
|
||||
for (var group in this.tableSettings) {
|
||||
if (this.tableSettings.hasOwnProperty(group)) {
|
||||
for (var d in this.tableSettings[group]) {
|
||||
if (this.tableSettings[group].hasOwnProperty(d)) {
|
||||
var field = $table.find('.' + this.tableSettings[group][d].target).eq(0);
|
||||
if (field.length && this.tableSettings[group][d].hidden) {
|
||||
hidden = this.tableSettings[group][d].hidden;
|
||||
cell = field.closest('td');
|
||||
break;
|
||||
}
|
||||
Object.keys(this.tableSettings || {}).forEach(function (group) {
|
||||
for (var d in _this2.tableSettings[group]) {
|
||||
if (_this2.tableSettings[group].hasOwnProperty(d)) {
|
||||
var field = $table.find('.' + _this2.tableSettings[group][d].target).eq(0);
|
||||
if (field.length && _this2.tableSettings[group][d].hidden) {
|
||||
hidden = _this2.tableSettings[group][d].hidden;
|
||||
cell = field.closest('td');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hidden && cell[0]) {
|
||||
columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
|
||||
$table.find('> thead > tr, > tbody > tr, > tr').each(this.addColspanClass(columnIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hidden && cell[0]) {
|
||||
columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
|
||||
$table.find('> thead > tr, > tbody > tr, > tr').each(_this2.addColspanClass(columnIndex));
|
||||
}
|
||||
});
|
||||
this.displayColumns(showWeight);
|
||||
};
|
||||
|
||||
@@ -217,11 +213,13 @@
|
||||
Drupal.tableDrag.prototype.rowSettings = function (group, row) {
|
||||
var field = $(row).find('.' + group);
|
||||
var tableSettingsGroup = this.tableSettings[group];
|
||||
|
||||
for (var delta in tableSettingsGroup) {
|
||||
if (tableSettingsGroup.hasOwnProperty(delta)) {
|
||||
var targetClass = tableSettingsGroup[delta].target;
|
||||
if (field.is('.' + targetClass)) {
|
||||
var rowSettings = {};
|
||||
|
||||
for (var n in tableSettingsGroup[delta]) {
|
||||
if (tableSettingsGroup[delta].hasOwnProperty(n)) {
|
||||
rowSettings[n] = tableSettingsGroup[delta][n];
|
||||
@@ -289,39 +287,41 @@
|
||||
|
||||
case 38:
|
||||
case 63232:
|
||||
var $previousRow = $(self.rowObject.element).prev('tr:first-of-type');
|
||||
var previousRow = $previousRow.get(0);
|
||||
while (previousRow && $previousRow.is(':hidden')) {
|
||||
$previousRow = $(previousRow).prev('tr:first-of-type');
|
||||
previousRow = $previousRow.get(0);
|
||||
}
|
||||
if (previousRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'up';
|
||||
keyChange = true;
|
||||
|
||||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
while (previousRow && $previousRow.find('.js-indentation').length) {
|
||||
$previousRow = $(previousRow).prev('tr:first-of-type');
|
||||
previousRow = $previousRow.get(0);
|
||||
groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
|
||||
}
|
||||
if (previousRow) {
|
||||
self.rowObject.swap('before', previousRow);
|
||||
|
||||
window.scrollBy(0, -groupHeight);
|
||||
}
|
||||
} else if (self.table.tBodies[0].rows[0] !== previousRow || $previousRow.is('.draggable')) {
|
||||
self.rowObject.swap('before', previousRow);
|
||||
self.rowObject.interval = null;
|
||||
self.rowObject.indent(0);
|
||||
window.scrollBy(0, -parseInt(item.offsetHeight, 10));
|
||||
{
|
||||
var $previousRow = $(self.rowObject.element).prev('tr:first-of-type');
|
||||
var previousRow = $previousRow.get(0);
|
||||
while (previousRow && $previousRow.is(':hidden')) {
|
||||
$previousRow = $(previousRow).prev('tr:first-of-type');
|
||||
previousRow = $previousRow.get(0);
|
||||
}
|
||||
if (previousRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'up';
|
||||
keyChange = true;
|
||||
|
||||
handle.trigger('focus');
|
||||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
while (previousRow && $previousRow.find('.js-indentation').length) {
|
||||
$previousRow = $(previousRow).prev('tr:first-of-type');
|
||||
previousRow = $previousRow.get(0);
|
||||
groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
|
||||
}
|
||||
if (previousRow) {
|
||||
self.rowObject.swap('before', previousRow);
|
||||
|
||||
window.scrollBy(0, -groupHeight);
|
||||
}
|
||||
} else if (self.table.tBodies[0].rows[0] !== previousRow || $previousRow.is('.draggable')) {
|
||||
self.rowObject.swap('before', previousRow);
|
||||
self.rowObject.interval = null;
|
||||
self.rowObject.indent(0);
|
||||
window.scrollBy(0, -parseInt(item.offsetHeight, 10));
|
||||
}
|
||||
|
||||
handle.trigger('focus');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 39:
|
||||
case 63235:
|
||||
@@ -331,39 +331,41 @@
|
||||
|
||||
case 40:
|
||||
case 63233:
|
||||
var $nextRow = $(self.rowObject.group).eq(-1).next('tr:first-of-type');
|
||||
var nextRow = $nextRow.get(0);
|
||||
while (nextRow && $nextRow.is(':hidden')) {
|
||||
$nextRow = $(nextRow).next('tr:first-of-type');
|
||||
nextRow = $nextRow.get(0);
|
||||
}
|
||||
if (nextRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'down';
|
||||
keyChange = true;
|
||||
|
||||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
|
||||
if (nextGroup) {
|
||||
$(nextGroup.group).each(function () {
|
||||
groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
|
||||
});
|
||||
var nextGroupRow = $(nextGroup.group).eq(-1).get(0);
|
||||
self.rowObject.swap('after', nextGroupRow);
|
||||
|
||||
window.scrollBy(0, parseInt(groupHeight, 10));
|
||||
}
|
||||
} else {
|
||||
self.rowObject.swap('after', nextRow);
|
||||
self.rowObject.interval = null;
|
||||
self.rowObject.indent(0);
|
||||
window.scrollBy(0, parseInt(item.offsetHeight, 10));
|
||||
{
|
||||
var $nextRow = $(self.rowObject.group).eq(-1).next('tr:first-of-type');
|
||||
var nextRow = $nextRow.get(0);
|
||||
while (nextRow && $nextRow.is(':hidden')) {
|
||||
$nextRow = $(nextRow).next('tr:first-of-type');
|
||||
nextRow = $nextRow.get(0);
|
||||
}
|
||||
if (nextRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'down';
|
||||
keyChange = true;
|
||||
|
||||
handle.trigger('focus');
|
||||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
|
||||
if (nextGroup) {
|
||||
$(nextGroup.group).each(function () {
|
||||
groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
|
||||
});
|
||||
var nextGroupRow = $(nextGroup.group).eq(-1).get(0);
|
||||
self.rowObject.swap('after', nextGroupRow);
|
||||
|
||||
window.scrollBy(0, parseInt(groupHeight, 10));
|
||||
}
|
||||
} else {
|
||||
self.rowObject.swap('after', nextRow);
|
||||
self.rowObject.interval = null;
|
||||
self.rowObject.indent(0);
|
||||
window.scrollBy(0, parseInt(item.offsetHeight, 10));
|
||||
}
|
||||
|
||||
handle.trigger('focus');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (self.rowObject && self.rowObject.changed === true) {
|
||||
@@ -478,18 +480,14 @@
|
||||
if (self.rowObject.changed === true) {
|
||||
self.updateFields(droppedRow);
|
||||
|
||||
for (var group in self.tableSettings) {
|
||||
if (self.tableSettings.hasOwnProperty(group)) {
|
||||
var rowSettings = self.rowSettings(group, droppedRow);
|
||||
if (rowSettings.relationship === 'group') {
|
||||
for (var n in self.rowObject.children) {
|
||||
if (self.rowObject.children.hasOwnProperty(n)) {
|
||||
self.updateField(self.rowObject.children[n], group);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.keys(self.tableSettings || {}).forEach(function (group) {
|
||||
var rowSettings = self.rowSettings(group, droppedRow);
|
||||
if (rowSettings.relationship === 'group') {
|
||||
Object.keys(self.rowObject.children || {}).forEach(function (n) {
|
||||
self.updateField(self.rowObject.children[n], group);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self.rowObject.markChanged();
|
||||
if (self.changed === false) {
|
||||
@@ -539,7 +537,7 @@
|
||||
var row = rows[n];
|
||||
var $row = $(row);
|
||||
var rowY = $row.offset().top;
|
||||
var rowHeight;
|
||||
var rowHeight = void 0;
|
||||
|
||||
if (row.offsetHeight === 0) {
|
||||
rowHeight = parseInt(row.firstChild.offsetHeight, 10) / 2;
|
||||
@@ -554,11 +552,9 @@
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (row === this.rowObject.element) {
|
||||
} else if (row === this.rowObject.element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.rowObject.isValidSwap(row)) {
|
||||
return null;
|
||||
@@ -575,11 +571,11 @@
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.updateFields = function (changedRow) {
|
||||
for (var group in this.tableSettings) {
|
||||
if (this.tableSettings.hasOwnProperty(group)) {
|
||||
this.updateField(changedRow, group);
|
||||
}
|
||||
}
|
||||
var _this3 = this;
|
||||
|
||||
Object.keys(this.tableSettings || {}).forEach(function (group) {
|
||||
_this3.updateField(changedRow, group);
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
|
||||
@@ -658,29 +654,31 @@
|
||||
break;
|
||||
|
||||
case 'order':
|
||||
var siblings = this.rowObject.findSiblings(rowSettings);
|
||||
if ($(targetElement).is('select')) {
|
||||
var values = [];
|
||||
$(targetElement).find('option').each(function () {
|
||||
values.push(this.value);
|
||||
});
|
||||
var maxVal = values[values.length - 1];
|
||||
{
|
||||
var siblings = this.rowObject.findSiblings(rowSettings);
|
||||
if ($(targetElement).is('select')) {
|
||||
var values = [];
|
||||
$(targetElement).find('option').each(function () {
|
||||
values.push(this.value);
|
||||
});
|
||||
var maxVal = values[values.length - 1];
|
||||
|
||||
$(siblings).find(targetClass).each(function () {
|
||||
if (values.length > 0) {
|
||||
this.value = values.shift();
|
||||
} else {
|
||||
this.value = maxVal;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var weight = parseInt($(siblings[0]).find(targetClass).val(), 10) || 0;
|
||||
$(siblings).find(targetClass).each(function () {
|
||||
this.value = weight;
|
||||
weight++;
|
||||
});
|
||||
$(siblings).find(targetClass).each(function () {
|
||||
if (values.length > 0) {
|
||||
this.value = values.shift();
|
||||
} else {
|
||||
this.value = maxVal;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var weight = parseInt($(siblings[0]).find(targetClass).val(), 10) || 0;
|
||||
$(siblings).find(targetClass).each(function () {
|
||||
this.value = weight;
|
||||
weight++;
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -697,13 +695,15 @@
|
||||
var de = document.documentElement;
|
||||
var b = document.body;
|
||||
|
||||
var windowHeight = this.windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
|
||||
var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
|
||||
this.windowHeight = windowHeight;
|
||||
var scrollY = void 0;
|
||||
if (document.all) {
|
||||
scrollY = this.scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
|
||||
scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
|
||||
} else {
|
||||
scrollY = this.scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
|
||||
scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
|
||||
}
|
||||
this.scrollY = scrollY;
|
||||
var trigger = this.scrollSettings.trigger;
|
||||
var delta = 0;
|
||||
|
||||
@@ -844,10 +844,9 @@
|
||||
|
||||
Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
|
||||
var $prevRow = $(prevRow);
|
||||
var minIndent = void 0;
|
||||
var maxIndent = void 0;
|
||||
|
||||
minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
|
||||
var minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
|
||||
|
||||
if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
|
||||
maxIndent = 0;
|
||||
@@ -927,11 +926,11 @@
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
|
||||
for (var n in this.children) {
|
||||
if (this.children.hasOwnProperty(n)) {
|
||||
$(this.children[n]).find('.js-indentation').removeClass('tree-child').removeClass('tree-child-first').removeClass('tree-child-last').removeClass('tree-child-horizontal');
|
||||
}
|
||||
}
|
||||
var _this4 = this;
|
||||
|
||||
Object.keys(this.children || {}).forEach(function (n) {
|
||||
$(_this4.children[n]).find('.js-indentation').removeClass('tree-child').removeClass('tree-child-first').removeClass('tree-child-last').removeClass('tree-child-horizontal');
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
// should be returned to the same state it was in before the columns
|
||||
// were revealed, so it is necessary to remove the display none value
|
||||
// from the style attribute.
|
||||
const match = /^display\s*\:\s*none$/;
|
||||
const match = /^display\s*:\s*none$/;
|
||||
for (let i = 0; i < properties.length; i++) {
|
||||
const prop = properties[i];
|
||||
prop.trim();
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
var properties = $cell.attr('style').split(';');
|
||||
var newProps = [];
|
||||
|
||||
var match = /^display\s*\:\s*none$/;
|
||||
var match = /^display\s*:\s*none$/;
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
var prop = properties[i];
|
||||
prop.trim();
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
Drupal.behaviors.tableSelect = {
|
||||
attach(context, settings) {
|
||||
// Select the inner-most table in case of nested tables.
|
||||
$(context).find('th.select-all').closest('table').once('table-select').each(Drupal.tableSelect);
|
||||
$(context)
|
||||
.find('th.select-all')
|
||||
.closest('table')
|
||||
.once('table-select')
|
||||
.each(Drupal.tableSelect);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -129,12 +133,11 @@
|
||||
|
||||
// Traverse through the sibling nodes.
|
||||
for (let i = from[mode]; i; i = i[mode]) {
|
||||
var $i;
|
||||
const $i = $(i);
|
||||
// Make sure that we're only dealing with elements.
|
||||
if (i.nodeType !== 1) {
|
||||
continue;
|
||||
}
|
||||
$i = $(i);
|
||||
// Either add or remove the selected class based on the state of the
|
||||
// target checkbox.
|
||||
$i.toggleClass('selected', state);
|
||||
|
||||
@@ -74,12 +74,11 @@
|
||||
var mode = from.rowIndex > to.rowIndex ? 'previousSibling' : 'nextSibling';
|
||||
|
||||
for (var i = from[mode]; i; i = i[mode]) {
|
||||
var $i;
|
||||
var $i = $(i);
|
||||
|
||||
if (i.nodeType !== 1) {
|
||||
continue;
|
||||
}
|
||||
$i = $(i);
|
||||
|
||||
$i.toggleClass('selected', state);
|
||||
$i.find('input[type="checkbox"]').prop('checked', state);
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
|
||||
const $this = $(this).addClass('vertical-tabs__panes');
|
||||
const focusID = $this.find(':hidden.vertical-tabs__active-tab').val();
|
||||
let tab_focus;
|
||||
let tabFocus;
|
||||
|
||||
// Check if there are some details that can be converted to
|
||||
// vertical-tabs.
|
||||
@@ -71,45 +71,45 @@
|
||||
}
|
||||
|
||||
// Create the tab column.
|
||||
const tab_list = $('<ul class="vertical-tabs__menu"></ul>');
|
||||
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
|
||||
const tabList = $('<ul class="vertical-tabs__menu"></ul>');
|
||||
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
|
||||
|
||||
// Transform each details into a tab.
|
||||
$details.each(function () {
|
||||
const $that = $(this);
|
||||
const vertical_tab = new Drupal.verticalTab({
|
||||
const verticalTab = new Drupal.verticalTab({
|
||||
title: $that.find('> summary').text(),
|
||||
details: $that,
|
||||
});
|
||||
tab_list.append(vertical_tab.item);
|
||||
tabList.append(verticalTab.item);
|
||||
$that
|
||||
.removeClass('collapsed')
|
||||
// prop() can't be used on browsers not supporting details element,
|
||||
// the style won't apply to them if prop() is used.
|
||||
.attr('open', true)
|
||||
.addClass('vertical-tabs__pane')
|
||||
.data('verticalTab', vertical_tab);
|
||||
.data('verticalTab', verticalTab);
|
||||
if (this.id === focusID) {
|
||||
tab_focus = $that;
|
||||
tabFocus = $that;
|
||||
}
|
||||
});
|
||||
|
||||
$(tab_list).find('> li').eq(0).addClass('first');
|
||||
$(tab_list).find('> li').eq(-1).addClass('last');
|
||||
$(tabList).find('> li').eq(0).addClass('first');
|
||||
$(tabList).find('> li').eq(-1).addClass('last');
|
||||
|
||||
if (!tab_focus) {
|
||||
if (!tabFocus) {
|
||||
// If the current URL has a fragment and one of the tabs contains an
|
||||
// element that matches the URL fragment, activate that tab.
|
||||
const $locationHash = $this.find(window.location.hash);
|
||||
if (window.location.hash && $locationHash.length) {
|
||||
tab_focus = $locationHash.closest('.vertical-tabs__pane');
|
||||
tabFocus = $locationHash.closest('.vertical-tabs__pane');
|
||||
}
|
||||
else {
|
||||
tab_focus = $this.find('> .vertical-tabs__pane').eq(0);
|
||||
tabFocus = $this.find('> .vertical-tabs__pane').eq(0);
|
||||
}
|
||||
}
|
||||
if (tab_focus.length) {
|
||||
tab_focus.data('verticalTab').focus();
|
||||
if (tabFocus.length) {
|
||||
tabFocus.data('verticalTab').focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -204,8 +204,13 @@
|
||||
// Update .first marker for items. We need recurse from parent to retain
|
||||
// the actual DOM element order as jQuery implements sortOrder, but not
|
||||
// as public method.
|
||||
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first')
|
||||
.filter(':visible').eq(0).addClass('first');
|
||||
this.item
|
||||
.parent()
|
||||
.children('.vertical-tabs__menu-item')
|
||||
.removeClass('first')
|
||||
.filter(':visible')
|
||||
.eq(0)
|
||||
.addClass('first');
|
||||
// Display the details element.
|
||||
this.details.removeClass('vertical-tab--hidden').show();
|
||||
// Focus this tab.
|
||||
@@ -225,8 +230,13 @@
|
||||
// Update .first marker for items. We need recurse from parent to retain
|
||||
// the actual DOM element order as jQuery implements sortOrder, but not
|
||||
// as public method.
|
||||
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first')
|
||||
.filter(':visible').eq(0).addClass('first');
|
||||
this.item
|
||||
.parent()
|
||||
.children('.vertical-tabs__menu-item')
|
||||
.removeClass('first')
|
||||
.filter(':visible')
|
||||
.eq(0)
|
||||
.addClass('first');
|
||||
// Hide the details element.
|
||||
this.details.addClass('vertical-tab--hidden').hide();
|
||||
// Focus the first visible tab (if there is one).
|
||||
|
||||
+14
-14
@@ -26,42 +26,42 @@
|
||||
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
|
||||
var $this = $(this).addClass('vertical-tabs__panes');
|
||||
var focusID = $this.find(':hidden.vertical-tabs__active-tab').val();
|
||||
var tab_focus = void 0;
|
||||
var tabFocus = void 0;
|
||||
|
||||
var $details = $this.find('> details');
|
||||
if ($details.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tab_list = $('<ul class="vertical-tabs__menu"></ul>');
|
||||
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
|
||||
var tabList = $('<ul class="vertical-tabs__menu"></ul>');
|
||||
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
|
||||
|
||||
$details.each(function () {
|
||||
var $that = $(this);
|
||||
var vertical_tab = new Drupal.verticalTab({
|
||||
var verticalTab = new Drupal.verticalTab({
|
||||
title: $that.find('> summary').text(),
|
||||
details: $that
|
||||
});
|
||||
tab_list.append(vertical_tab.item);
|
||||
$that.removeClass('collapsed').attr('open', true).addClass('vertical-tabs__pane').data('verticalTab', vertical_tab);
|
||||
tabList.append(verticalTab.item);
|
||||
$that.removeClass('collapsed').attr('open', true).addClass('vertical-tabs__pane').data('verticalTab', verticalTab);
|
||||
if (this.id === focusID) {
|
||||
tab_focus = $that;
|
||||
tabFocus = $that;
|
||||
}
|
||||
});
|
||||
|
||||
$(tab_list).find('> li').eq(0).addClass('first');
|
||||
$(tab_list).find('> li').eq(-1).addClass('last');
|
||||
$(tabList).find('> li').eq(0).addClass('first');
|
||||
$(tabList).find('> li').eq(-1).addClass('last');
|
||||
|
||||
if (!tab_focus) {
|
||||
if (!tabFocus) {
|
||||
var $locationHash = $this.find(window.location.hash);
|
||||
if (window.location.hash && $locationHash.length) {
|
||||
tab_focus = $locationHash.closest('.vertical-tabs__pane');
|
||||
tabFocus = $locationHash.closest('.vertical-tabs__pane');
|
||||
} else {
|
||||
tab_focus = $this.find('> .vertical-tabs__pane').eq(0);
|
||||
tabFocus = $this.find('> .vertical-tabs__pane').eq(0);
|
||||
}
|
||||
}
|
||||
if (tab_focus.length) {
|
||||
tab_focus.data('verticalTab').focus();
|
||||
if (tabFocus.length) {
|
||||
tabFocus.data('verticalTab').focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user