171378461SGreg Roach<?php 271378461SGreg Roach 3*10e06497SGreg Roachdeclare(strict_types=1); 4*10e06497SGreg Roach 571378461SGreg Roachuse Fisharebest\Webtrees\I18N; 67c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree; 771378461SGreg Roachuse Fisharebest\Webtrees\View; 871378461SGreg Roach 97c2c99faSGreg Roach/** 107c2c99faSGreg Roach * @var string $individual_list 117c2c99faSGreg Roach * @var Tree $tree 127c2c99faSGreg Roach */ 137c2c99faSGreg Roach 1471378461SGreg Roach?> 15dd6b2bfcSGreg Roach 16d72b284aSGreg Roach<form method="post" action="<?= e(route('module', ['module' => 'descendancy', 'action' => 'Descendants', 'tree' => $tree->name()])) ?>" onsubmit="return false;"> 17dd6b2bfcSGreg Roach <input type="search" name="sb_desc_name" id="sb_desc_name" placeholder="<?= I18N::translate('Search') ?>"> 1881443e3cSGreg Roach 1981443e3cSGreg Roach <?= csrf_field() ?> 20dd6b2bfcSGreg Roach</form> 21dd6b2bfcSGreg Roach 22dd6b2bfcSGreg Roach<div id="sb_desc_content"> 23dd6b2bfcSGreg Roach <ul> 24dd6b2bfcSGreg Roach <?= $individual_list ?> 25dd6b2bfcSGreg Roach </ul> 26dd6b2bfcSGreg Roach</div> 27dd6b2bfcSGreg Roach 28dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 29dd6b2bfcSGreg Roach<script> 30dd6b2bfcSGreg Roach function dsearchQ() { 31dd6b2bfcSGreg Roach var query = $("#sb_desc_name").val(); 32dd6b2bfcSGreg Roach if (query.length>1) { 33728c8c27SGreg Roach $("#sb_desc_content").load(<?= json_encode(route('module', ['module' => 'descendancy', 'action' => 'Search', 'tree' => $tree->name(), 'search' => '']), JSON_THROW_ON_ERROR) ?> + encodeURIComponent(query)); 34dd6b2bfcSGreg Roach } 35dd6b2bfcSGreg Roach } 36dd6b2bfcSGreg Roach 37dd6b2bfcSGreg Roach $("#sb_desc_name").focus(function(){this.select();}); 38dd6b2bfcSGreg Roach $("#sb_desc_name").blur(function(){if (this.value === "") this.value="<?= I18N::translate('Search') ?>";}); 39dd6b2bfcSGreg Roach var dtimerid = null; 40dd6b2bfcSGreg Roach $("#sb_desc_name").keyup(function(e) { 41dd6b2bfcSGreg Roach if (dtimerid) window.clearTimeout(dtimerid); 42dd6b2bfcSGreg Roach dtimerid = window.setTimeout("dsearchQ()", 500); 43dd6b2bfcSGreg Roach }); 44dd6b2bfcSGreg Roach 45dd6b2bfcSGreg Roach $("#sb_desc_content").on("click", ".sb_desc_indi", function() { 46dd6b2bfcSGreg Roach var self = $(this), 47dd6b2bfcSGreg Roach state = self.children(".plusminus"), 48dd6b2bfcSGreg Roach target = self.siblings("div"); 49dd6b2bfcSGreg Roach if(state.hasClass("icon-plus")) { 50dd6b2bfcSGreg Roach if (jQuery.trim(target.html())) { 51dd6b2bfcSGreg Roach target.show("fast"); // already got content so just show it 52d4786c66SGreg Roach } else if (this.dataset.wtHref !== "#") { 53dd6b2bfcSGreg Roach target 54dd6b2bfcSGreg Roach .hide() 55d4786c66SGreg Roach .load(this.dataset.wtHref, function(response, status, xhr) { 56dd6b2bfcSGreg Roach if(status === "success" && response !== "") { 57dd6b2bfcSGreg Roach target.show("fast"); 58dd6b2bfcSGreg Roach } 59dd6b2bfcSGreg Roach }) 60dd6b2bfcSGreg Roach } 61dd6b2bfcSGreg Roach } else { 62dd6b2bfcSGreg Roach target.hide("fast"); 63dd6b2bfcSGreg Roach } 64dd6b2bfcSGreg Roach state.toggleClass("icon-minus icon-plus"); 65dd6b2bfcSGreg Roach return false; 66dd6b2bfcSGreg Roach }); 67dd6b2bfcSGreg Roach</script> 68dd6b2bfcSGreg Roach<?php View::endpush() ?> 69