Webform module and config export
This commit is contained in:
parent
3e6a5cbed2
commit
0e15467384
1040 changed files with 117682 additions and 0 deletions
57
web/modules/contrib/webform/js/webform.element.time.js
Normal file
57
web/modules/contrib/webform/js/webform.element.time.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @file
|
||||
* Javascript behaviors for time integration.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Attach timepicker fallback on time elements.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the behavior to time elements.
|
||||
*/
|
||||
Drupal.behaviors.webformTime = {
|
||||
attach: function (context, settings) {
|
||||
var $context = $(context);
|
||||
// Skip if time inputs are supported by the browser.
|
||||
if (Modernizr.inputtypes.time === true) {
|
||||
return;
|
||||
}
|
||||
$context.find('input[type="time"]').once('timePicker').each(function () {
|
||||
var $input = $(this);
|
||||
|
||||
var options = {};
|
||||
if ($input.data('webformTimeFormat')) {
|
||||
options.timeFormat = $input.data('webformTimeFormat');
|
||||
}
|
||||
if ($input.attr('min')) {
|
||||
options.minTime = $input.attr('min');
|
||||
}
|
||||
if ($input.attr('max')) {
|
||||
options.maxTime = $input.attr('max');
|
||||
}
|
||||
|
||||
// HTML5 time element steps is in seconds but for the timepicker
|
||||
// fallback it needs to be in minutes.
|
||||
// Note: The 'datetime' element uses the #date_increment which defaults
|
||||
// to 1 (second).
|
||||
// @see \Drupal\Core\Datetime\Element\Datetime::processDatetime
|
||||
// Only use step if it is greater than 60 seconds.
|
||||
if ($input.attr('step') && ($input.attr('step') > 60)) {
|
||||
options.step = Math.round($input.attr('step') / 60);
|
||||
}
|
||||
else {
|
||||
options.step = 1;
|
||||
}
|
||||
|
||||
$input.timepicker(options);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery, Drupal);
|
Reference in a new issue