Add a swap button to make it easier to swap the selection of duplicate/delete images

This commit is contained in:
Deon George 2024-10-04 21:45:50 +10:00
parent 861cefb2db
commit 648f18dae1
2 changed files with 28 additions and 1 deletions

View File

@ -35,4 +35,30 @@
NONE!
@endif
</div>
@endsection
@endsection
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('span.swap').on('click',function() {
var that = $(this);
var tr = that.closest('tr');
['duplicate','remove'].forEach(function(item) {
var items = tr.find('input[name^="'+item+'\["]');
if (items.length !== 2) {
alert('cannot swap');
return false;
}
var rotate = items[0].checked;
$(items[0]).prop('checked',items[1].checked);
$(items[1]).prop('checked',rotate);
that.removeData();
});
});
});
</script>
@append

View File

@ -22,6 +22,7 @@
<div class="card-body">
<x-photo.thumbnail :id="$o->id" :css="$css ?? NULL"/>
<span class="btn btn-sm btn-outline-dark float-right swap">SWAP</span>
</div>
<div class="card-footer card-comments">