xref: /webtrees/resources/views/modules/descendancy/sidebar.phtml (revision ad7270802ba57a28d195fc58fcc55f26458a779a)
1<?php use Fisharebest\Webtrees\I18N; ?>
2<?php use Fisharebest\Webtrees\View; ?>
3
4<form method="post" action="<?= e(route('module', ['module' => 'descendancy', 'action' => 'Descendants', 'ged' => $tree->name()])) ?>" onsubmit="return false;">
5    <input type="search" name="sb_desc_name" id="sb_desc_name" placeholder="<?= I18N::translate('Search') ?>">
6</form>
7
8<div id="sb_desc_content">
9    <ul>
10        <?= $individual_list ?>
11    </ul>
12</div>
13
14<?php View::push('javascript') ?>
15<script>
16  function dsearchQ() {
17    var query = $("#sb_desc_name").val();
18    if (query.length>1) {
19      $("#sb_desc_content").load(<?= json_encode(route('module', ['module' => 'descendancy', 'action' => 'Search', 'ged' => $tree->name()])) ?> + "&search=" + encodeURIComponent(query));
20    }
21  }
22
23  $("#sb_desc_name").focus(function(){this.select();});
24  $("#sb_desc_name").blur(function(){if (this.value === "") this.value="<?= I18N::translate('Search') ?>";});
25  var dtimerid = null;
26  $("#sb_desc_name").keyup(function(e) {
27    if (dtimerid) window.clearTimeout(dtimerid);
28    dtimerid = window.setTimeout("dsearchQ()", 500);
29  });
30
31  $("#sb_desc_content").on("click", ".sb_desc_indi", function() {
32    var self = $(this),
33        state = self.children(".plusminus"),
34        target = self.siblings("div");
35    if(state.hasClass("icon-plus")) {
36      if (jQuery.trim(target.html())) {
37        target.show("fast"); // already got content so just show it
38      } else {
39        target
40          .hide()
41          .load(self.attr("href"), function(response, status, xhr) {
42            if(status === "success" && response !== "") {
43              target.show("fast");
44            }
45          })
46      }
47    } else {
48      target.hide("fast");
49    }
50    state.toggleClass("icon-minus icon-plus");
51    return false;
52  });
53</script>
54<?php View::endpush() ?>
55