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