Webform module and config export
This commit is contained in:
parent
3e6a5cbed2
commit
0e15467384
1040 changed files with 117682 additions and 0 deletions
102
web/modules/contrib/webform/js/webform.element.details.save.js
Normal file
102
web/modules/contrib/webform/js/webform.element.details.save.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* @file
|
||||
* Javascript behaviors for details element.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Attach handler to save details open/close state.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*/
|
||||
Drupal.behaviors.webformDetailsSave = {
|
||||
attach: function (context) {
|
||||
if (!window.localStorage) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Summary click event handler.
|
||||
$('details > summary', context).once('webform-details-summary-save').click(function () {
|
||||
var $details = $(this).parent();
|
||||
|
||||
var name = Drupal.webformDetailsSaveGetName($details);
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
var open = ($details.attr('open') != 'open') ? 1 : 0;
|
||||
localStorage.setItem(name, open);
|
||||
});
|
||||
|
||||
// Initialize details open state via local storage.
|
||||
$('details', context).once('webform-details-save').each(function () {
|
||||
var $details = $(this);
|
||||
|
||||
var name = Drupal.webformDetailsSaveGetName($details);
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
var open = localStorage.getItem(name);
|
||||
if (open === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (open == 1) {
|
||||
$details.attr('open', 'open');
|
||||
}
|
||||
else {
|
||||
$details.removeAttr('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the name used to store the state of details element.
|
||||
*
|
||||
* @param $details
|
||||
* A details element.
|
||||
*
|
||||
* @returns string
|
||||
* The name used to store the state of details element.
|
||||
*/
|
||||
Drupal.webformDetailsSaveGetName = function ($details) {
|
||||
if (!window.localStorage) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Any details element not included a webform must have define its own id.
|
||||
var webformId = $details.attr('data-webform-element-id');
|
||||
if (webformId) {
|
||||
return 'Drupal.webform.' + webformId.replace('--', '.');
|
||||
}
|
||||
|
||||
var detailsId = $details.attr('id');
|
||||
if (!detailsId) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var $form = $details.parents('form');
|
||||
if (!$form.length || !$form.attr('id')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var formId = $form.attr('id');
|
||||
if (!formId) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// ISSUE: When Drupal renders a webform in a modal dialog it appends a unique
|
||||
// identifier to webform ids and details ids. (ie my-form--FeSFISegTUI)
|
||||
// WORKAROUND: Remove the unique id that delimited using double dashes.
|
||||
formId = formId.replace(/--.+?$/, '').replace(/-/g, '_');
|
||||
detailsId = detailsId.replace(/--.+?$/, '').replace(/-/g, '_');
|
||||
return 'Drupal.webform.' + formId + '.' + detailsId;
|
||||
}
|
||||
|
||||
})(jQuery, Drupal);
|
Reference in a new issue