xref: /webtrees/resources/views/edit/reorder-card-header.phtml (revision 315eb31683006273e24c08b447e6e1095d6f2147)
192044e0dSGreg Roach<?php
292044e0dSGreg Roach
392044e0dSGreg Roachuse Fisharebest\Webtrees\I18N;
492044e0dSGreg Roachuse Fisharebest\Webtrees\View;
592044e0dSGreg Roach
692044e0dSGreg Roach/**
792044e0dSGreg Roach * @var string $title
892044e0dSGreg Roach */
992044e0dSGreg Roach
1092044e0dSGreg Roach?>
1192044e0dSGreg Roach<div class="d-flex">
1292044e0dSGreg Roach    <button class="btn btn-outline-secondary btn-sm drag-handle">
1392044e0dSGreg Roach        <?= view('icons/drag-handle') ?>
1492044e0dSGreg Roach    </button>
1592044e0dSGreg Roach
16*315eb316SGreg Roach    <div class="ms-2 me-auto">
1792044e0dSGreg Roach        <?= $title ?>
1892044e0dSGreg Roach    </div>
1992044e0dSGreg Roach
2092044e0dSGreg Roach    <div class="btn-group">
2192044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-first" type="button">
2292044e0dSGreg Roach            <?= I18N::translate('first') ?>
2392044e0dSGreg Roach        </button>
2492044e0dSGreg Roach
2592044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-previous" type="button">
2692044e0dSGreg Roach            <?= I18N::translate('up') ?>
2792044e0dSGreg Roach        </button>
2892044e0dSGreg Roach
2992044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-next" type="button">
3092044e0dSGreg Roach            <?= I18N::translate('down') ?>
3192044e0dSGreg Roach        </button>
3292044e0dSGreg Roach
3392044e0dSGreg Roach        <button class="btn btn-outline-secondary btn-sm wt-btn-reorder wt-btn-reorder-last" type="button">
3492044e0dSGreg Roach            <?= I18N::translate('last') ?>
3592044e0dSGreg Roach        </button>
3692044e0dSGreg Roach    </div>
3792044e0dSGreg Roach</div>
3892044e0dSGreg Roach
3992044e0dSGreg Roach<?php View::pushunique('javascript') ?>
4092044e0dSGreg Roach<script>
4192044e0dSGreg Roach    document.body.addEventListener('click', function(event) {
4292044e0dSGreg Roach        let target = event.target;
4392044e0dSGreg Roach
4492044e0dSGreg Roach        if (target.matches('.wt-btn-reorder')) {
4592044e0dSGreg Roach            let item = target.closest('.wt-sortable-item');
4692044e0dSGreg Roach            let list = target.closest('.wt-sortable-list');
4792044e0dSGreg Roach
4892044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-first')) {
4992044e0dSGreg Roach                list.insertBefore(item, list.childNodes[0]);
5092044e0dSGreg Roach            }
5192044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-previous') && item.previousElementSibling) {
5292044e0dSGreg Roach                list.insertBefore(item, item.previousElementSibling);
5392044e0dSGreg Roach            }
5492044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-next') && item.nextElementSibling) {
5592044e0dSGreg Roach                list.insertBefore(item.nextElementSibling, item);
5692044e0dSGreg Roach            }
5792044e0dSGreg Roach            if (target.matches('.wt-btn-reorder-last')) {
5892044e0dSGreg Roach                list.insertBefore(item, null);
5992044e0dSGreg Roach            }
6092044e0dSGreg Roach        }
6192044e0dSGreg Roach    });
6292044e0dSGreg Roach</script>
6392044e0dSGreg Roach<?php View::endpushunique() ?>
64