Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -7,6 +7,11 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
// @see http://api.jqueryui.com/datepicker/
|
||||
Drupal.webform = Drupal.webform || {};
|
||||
Drupal.webform.datePicker = Drupal.webform.datePicker || {};
|
||||
Drupal.webform.datePicker.options = Drupal.webform.datePicker.options || {};
|
||||
|
||||
/**
|
||||
* Attach datepicker fallback on date elements.
|
||||
*
|
||||
|
@ -22,48 +27,70 @@
|
|||
Drupal.behaviors.date = {
|
||||
attach: function (context, settings) {
|
||||
var $context = $(context);
|
||||
// Skip if date are supported by the browser.
|
||||
if (Modernizr.inputtypes.date === true) {
|
||||
return;
|
||||
}
|
||||
$context.find('input[data-drupal-date-format]').once('datePicker').each(function () {
|
||||
var $input = $(this);
|
||||
var datepickerSettings = {};
|
||||
|
||||
// Skip if date inputs are supported by the browser and input is not a text field.
|
||||
// @see \Drupal\webform\Element\WebformDatetime
|
||||
if (window.Modernizr && Modernizr.inputtypes.date === true && $input.attr('type') !== 'text') {
|
||||
return;
|
||||
}
|
||||
|
||||
var options = $.extend({
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
}, Drupal.webform.datePicker.options);
|
||||
|
||||
var dateFormat = $input.data('drupalDateFormat');
|
||||
|
||||
// The date format is saved in PHP style, we need to convert to jQuery
|
||||
// datepicker.
|
||||
// @see http://stackoverflow.com/questions/16702398/convert-a-php-date-format-to-a-jqueryui-datepicker-date-format
|
||||
datepickerSettings.dateFormat = dateFormat
|
||||
// Year.
|
||||
.replace('Y', 'yy')
|
||||
// @see http://php.net/manual/en/function.date.php
|
||||
options.dateFormat = dateFormat
|
||||
// Year.
|
||||
.replace('Y', 'yy') // A full numeric representation of a year, 4 digits (1999 or 2003)
|
||||
.replace('y', 'y') // A two digit representation of a year (99 or 03)
|
||||
// Month.
|
||||
.replace('F', 'MM')
|
||||
.replace('m', 'mm')
|
||||
.replace('n', 'm')
|
||||
// Date.
|
||||
.replace('d', 'dd');
|
||||
.replace('F', 'MM') // A full textual representation of a month, such as January or March (January through December)
|
||||
.replace('m', 'mm') // Numeric representation of a month, with leading zeros (01 through 12)
|
||||
.replace('M', 'M') // A short textual representation of a month, three letters (Jan through Dec)
|
||||
.replace('n', 'm') // Numeric representation of a month, without leading zeros (1 through 12)
|
||||
// Day.
|
||||
.replace('d', 'dd') // Day of the month, 2 digits with leading zeros (01 to 31)
|
||||
.replace('D', 'D') // A textual representation of a day, three letters (Mon through Sun)
|
||||
.replace('j', 'd') // Day of the month without leading zeros (1 to 31)
|
||||
.replace('l', 'DD'); // A full textual representation of the day of the week (Sunday through Saturday)
|
||||
|
||||
// Add min and max date if set on the input.
|
||||
if ($input.attr('min')) {
|
||||
datepickerSettings.minDate = $.datepicker.formatDate(datepickerSettings.dateFormat, $.datepicker.parseDate('yy-mm-dd', $input.attr('min')));
|
||||
options.minDate = $input.attr('min');
|
||||
}
|
||||
if ($input.attr('max')) {
|
||||
datepickerSettings.maxDate = $.datepicker.formatDate(datepickerSettings.dateFormat, $.datepicker.parseDate('yy-mm-dd', $input.attr('max')));
|
||||
options.maxDate = $input.attr('max');
|
||||
}
|
||||
|
||||
// Format default value.
|
||||
if ($input.val()) {
|
||||
$input.val($.datepicker.formatDate(datepickerSettings.dateFormat, $.datepicker.parseDate('yy-mm-dd', $input.val())));
|
||||
// Add min/max year to data range.
|
||||
if (!options.yearRange && $input.data('min-year') && $input.data('max-year')) {
|
||||
options.yearRange = $input.data('min-year') + ':' + $input.attr('data-max-year');
|
||||
}
|
||||
|
||||
$input.datepicker(datepickerSettings);
|
||||
// First day of the week.
|
||||
options.firstDay = settings.webform.dateFirstDay;
|
||||
|
||||
$input.datepicker(options);
|
||||
});
|
||||
}
|
||||
// Issue #2983363: Datepicker is being detached when multiple files are
|
||||
// uploaded.
|
||||
/*
|
||||
},
|
||||
detach: function (context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
$(context).find('input[data-drupal-date-format]').findOnce('datePicker').datepicker('destroy');
|
||||
}
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
})(jQuery, Modernizr, Drupal);
|
||||
|
|
Reference in a new issue