xref: /webtrees/resources/views/edit/reorder-card-header.phtml (revision 92044e0d3ee7691ad1433867c218bd41de68960e)
1*92044e0dSGreg Roach<?php
2*92044e0dSGreg Roach
3*92044e0dSGreg Roachuse Fisharebest\Webtrees\I18N;
4*92044e0dSGreg Roachuse Fisharebest\Webtrees\View;
5*92044e0dSGreg Roach
6*92044e0dSGreg Roach/**
7*92044e0dSGreg Roach * @var string $title
8*92044e0dSGreg Roach */
9*92044e0dSGreg Roach
10*92044e0dSGreg Roach?>
11*92044e0dSGreg Roach<div class="d-flex">
12*92044e0dSGreg Roach    <button class="btn btn-outline-secondary btn-sm drag-handle">
13*92044e0dSGreg Roach        <?= view('icons/drag-handle') ?>
14*92044e0dSGreg Roach    </button>
15*92044e0dSGreg Roach
16*92044e0dSGreg Roach    <div class="ml-2 mr-auto">
17*92044e0dSGreg Roach        <?= $title ?>
18*92044e0dSGreg Roach    </div>
19*92044e0dSGreg Roach
20*92044e0dSGreg Roach    <div class="btn-group">
21*92044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-first" type="button">
22*92044e0dSGreg Roach            <?= I18N::translate('first') ?>
23*92044e0dSGreg Roach        </button>
24*92044e0dSGreg Roach
25*92044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-previous" type="button">
26*92044e0dSGreg Roach            <?= I18N::translate('up') ?>
27*92044e0dSGreg Roach        </button>
28*92044e0dSGreg Roach
29*92044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-next" type="button">
30*92044e0dSGreg Roach            <?= I18N::translate('down') ?>
31*92044e0dSGreg Roach        </button>
32*92044e0dSGreg Roach
33*92044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-last" type="button">
34*92044e0dSGreg Roach            <?= I18N::translate('last') ?>
35*92044e0dSGreg Roach        </button>
36*92044e0dSGreg Roach    </div>
37*92044e0dSGreg Roach</div>
38*92044e0dSGreg Roach
39*92044e0dSGreg Roach<?php View::pushunique('javascript') ?>
40*92044e0dSGreg Roach<script>
41*92044e0dSGreg Roach    document.body.addEventListener('click', function(event) {
42*92044e0dSGreg Roach        let target = event.target;
43*92044e0dSGreg Roach
44*92044e0dSGreg Roach        if (target.matches('.wt-btn-reorder')) {
45*92044e0dSGreg Roach            let item = target.closest('.wt-sortable-item');
46*92044e0dSGreg Roach            let list = target.closest('.wt-sortable-list');
47*92044e0dSGreg Roach
48*92044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-first')) {
49*92044e0dSGreg Roach                list.insertBefore(item, list.childNodes[0]);
50*92044e0dSGreg Roach            }
51*92044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-previous') && item.previousElementSibling) {
52*92044e0dSGreg Roach                list.insertBefore(item, item.previousElementSibling);
53*92044e0dSGreg Roach            }
54*92044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-next') && item.nextElementSibling) {
55*92044e0dSGreg Roach                list.insertBefore(item.nextElementSibling, item);
56*92044e0dSGreg Roach            }
57*92044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-last')) {
58*92044e0dSGreg Roach                list.insertBefore(item, null);
59*92044e0dSGreg Roach            }
60*92044e0dSGreg Roach        }
61*92044e0dSGreg Roach    });
62*92044e0dSGreg Roach</script>
63*92044e0dSGreg Roach<?php View::endpushunique() ?>
64