Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -1,12 +1,17 @@
/**
* @file
* Javascript behaviors for toggle integration.
* JavaScript behaviors for toggle integration.
*/
(function ($, Drupal) {
'use strict';
// @see https://github.com/simontabor/jquery-toggles
Drupal.webform = Drupal.webform || {};
Drupal.webform.toggles = Drupal.webform.toggles || {};
Drupal.webform.toggles.options = Drupal.webform.toggles.options || {};
/**
* Initialize toggle element using Toggles.
*
@ -14,13 +19,17 @@
*/
Drupal.behaviors.webformToggle = {
attach: function (context) {
if (!$.fn.toggles) {
return;
}
$(context).find('.js-webform-toggle').once('webform-toggle').each(function () {
var $toggle = $(this);
var $wrapper = $toggle.parent();
var $checkbox = $wrapper.find('input[type="checkbox"]');
var $label = $wrapper.find('label');
$toggle.toggles({
var options = $.extend({
checkbox: $checkbox,
on: $checkbox.is(':checked'),
clicker: $label,
@ -28,6 +37,14 @@
on: $toggle.attr('data-toggle-text-on') || '',
off: $toggle.attr('data-toggle-text-off') || ''
}
}, Drupal.webform.toggles.options);
$toggle.toggles(options);
// Trigger change event for #states API.
// @see Drupal.states.Trigger.states.checked.change
$toggle.on('toggle', function () {
$checkbox.trigger('change');
});
// If checkbox is disabled then add the .disabled class to the toggle.
@ -36,21 +53,22 @@
}
// Add .clearfix to the wrapper.
$wrapper.addClass('clearfix')
$wrapper.addClass('clearfix');
});
}
};
// Track the disabling of a toggle's checkbox using states.
$(document).on('state:disabled', function (event) {
$('.js-webform-toggle').each(function () {
var $toggle = $(this);
var $wrapper = $toggle.parent();
var $checkbox = $wrapper.find('input[type="checkbox"]');
var isDisabled = ($checkbox.attr('disabled') || $checkbox.attr('readonly'));
(isDisabled) ? $toggle.addClass('disabled') : $toggle.removeClass('disabled');
if ($.fn.toggles) {
$(document).on('state:disabled', function (event) {
$('.js-webform-toggle').each(function () {
var $toggle = $(this);
var $wrapper = $toggle.parent();
var $checkbox = $wrapper.find('input[type="checkbox"]');
var isDisabled = ($checkbox.attr('disabled') || $checkbox.attr('readonly'));
$toggle[isDisabled ? 'disabled' : 'disabled']();
});
});
});
}
})(jQuery, Drupal);