1a45ad69dSGreg Roach<?php 2a45ad69dSGreg Roach 3a45ad69dSGreg Roachuse Fisharebest\Webtrees\I18N; 4a45ad69dSGreg Roach 5*7c2c99faSGreg Roach/** 6*7c2c99faSGreg Roach * @var string $id 7*7c2c99faSGreg Roach */ 8*7c2c99faSGreg Roach 9a45ad69dSGreg Roach?> 10a45ad69dSGreg Roach 11a45ad69dSGreg Roach<div class="input-group-prepend"> 12a45ad69dSGreg Roach <span class="input-group-text"> 13a45ad69dSGreg Roach <a id="<?= e($id) ?>-edit" href="#" title="<?= I18N::translate('Edit the name') ?>"> 14a45ad69dSGreg Roach <?= view('icons/edit') ?> 15a45ad69dSGreg Roach <span class="sr-only"> 16a45ad69dSGreg Roach <?= I18N::translate('Edit the name') ?> 17a45ad69dSGreg Roach </span> 18a45ad69dSGreg Roach </a> 19a45ad69dSGreg Roach </span> 20a45ad69dSGreg Roach</div> 21a45ad69dSGreg Roach<script> 22a45ad69dSGreg Roach document.getElementById('<?= e($id) ?>-edit').addEventListener('click', function (event) { 23a45ad69dSGreg Roach event.preventDefault(); 24a45ad69dSGreg Roach let element = document.getElementById('<?= e($id) ?>'); 25a45ad69dSGreg Roach element.readOnly = false; 26a45ad69dSGreg Roach element.focus(); 27a45ad69dSGreg Roach 28a45ad69dSGreg Roach let input_addon = this.parentNode.parentNode; 29a45ad69dSGreg Roach input_addon.parentNode.removeChild(input_addon); 30a45ad69dSGreg Roach }); 31a45ad69dSGreg Roach document.addEventListener('DOMContentLoaded', function () { 32a45ad69dSGreg Roach let container = document.getElementById('<?= e($id) ?>').parentNode.parentNode.parentNode.parentNode; 33a45ad69dSGreg Roach let NAME = container.querySelector('[id$="INDI:NAME"]'); 34a45ad69dSGreg Roach let NPFX = container.querySelector('[id$="INDI:NAME:NPFX"]'); 35a45ad69dSGreg Roach let GIVN = container.querySelector('[id$="INDI:NAME:GIVN"]'); 36a45ad69dSGreg Roach let SPFX = container.querySelector('[id$="INDI:NAME:SPFX"]'); 37a45ad69dSGreg Roach let SURN = container.querySelector('[id$="INDI:NAME:SURN"]'); 38a45ad69dSGreg Roach let NSFX = container.querySelector('[id$="INDI:NAME:NSFX"]'); 39a45ad69dSGreg Roach 40a45ad69dSGreg Roach if (NAME.value !== webtrees.buildNameFromParts( 41a45ad69dSGreg Roach NPFX ? NPFX.value : '', 42a45ad69dSGreg Roach GIVN ? GIVN.value : '', 43a45ad69dSGreg Roach SPFX ? SPFX.value : '', 44a45ad69dSGreg Roach SURN ? SURN.value : '', 45a45ad69dSGreg Roach NSFX ? NSFX.value : '', 46a45ad69dSGreg Roach 'U' 47a45ad69dSGreg Roach )) { 48a45ad69dSGreg Roach document.getElementById('<?= e($id) ?>-edit').click(); 49a45ad69dSGreg Roach } else { 50a45ad69dSGreg Roach let fn = function () { 51a45ad69dSGreg Roach if (NAME.readOnly === true) { 52a45ad69dSGreg Roach NAME.value = webtrees.buildNameFromParts( 53a45ad69dSGreg Roach NPFX ? NPFX.value : '', 54a45ad69dSGreg Roach GIVN ? GIVN.value : '', 55a45ad69dSGreg Roach SPFX ? SPFX.value : '', 56a45ad69dSGreg Roach SURN ? SURN.value : '', 57a45ad69dSGreg Roach NSFX ? NSFX.value : '', 58a45ad69dSGreg Roach 'U' 59a45ad69dSGreg Roach ); 60a45ad69dSGreg Roach } 61a45ad69dSGreg Roach } 62a45ad69dSGreg Roach NPFX.addEventListener('input', fn); 63a45ad69dSGreg Roach GIVN.addEventListener('input', fn); 64a45ad69dSGreg Roach SPFX.addEventListener('input', fn); 65a45ad69dSGreg Roach SURN.addEventListener('input', fn); 66a45ad69dSGreg Roach SURN.addEventListener('blur', fn); // For autocompleted entries 67a45ad69dSGreg Roach NSFX.addEventListener('input', fn); 68a45ad69dSGreg Roach } 69a45ad69dSGreg Roach }); 70a45ad69dSGreg Roach</script> 71