Better handle cannot when we cannot swap checkboxes, added scroll, added swap/scroll to duplicate review
This commit is contained in:
parent
648f18dae1
commit
f6d2a132a4
@ -44,20 +44,32 @@
|
||||
var that = $(this);
|
||||
var tr = that.closest('tr');
|
||||
|
||||
['duplicate','remove'].forEach(function(item) {
|
||||
var items = tr.find('input[name^="'+item+'\["]');
|
||||
try {
|
||||
['duplicate','remove'].forEach(function(item) {
|
||||
var items = tr.find('input[name^="'+item+'\["]');
|
||||
|
||||
if (items.length !== 2) {
|
||||
alert('cannot swap');
|
||||
return false;
|
||||
}
|
||||
if (items.length !== 2) {
|
||||
alert('cannot swap');
|
||||
throw new Error('CANNOT SWAP');
|
||||
}
|
||||
|
||||
var rotate = items[0].checked;
|
||||
$(items[0]).prop('checked',items[1].checked);
|
||||
$(items[1]).prop('checked',rotate);
|
||||
var rotate = items[0].checked;
|
||||
$(items[0]).prop('checked',items[1].checked);
|
||||
$(items[1]).prop('checked',rotate);
|
||||
|
||||
that.removeData();
|
||||
});
|
||||
that.removeData();
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
// NOOP
|
||||
}
|
||||
});
|
||||
|
||||
$('span.scroll').on('click',function() {
|
||||
var next = $(this).closest('div.card').closest('tr').next();
|
||||
|
||||
if (next.length)
|
||||
$('html,body').animate({scrollTop: next.offset().top},'fast');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -35,4 +35,42 @@
|
||||
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');
|
||||
|
||||
try {
|
||||
['duplicate','remove'].forEach(function(item) {
|
||||
var items = tr.find('input[name^="'+item+'\["]');
|
||||
|
||||
if (items.length !== 2) {
|
||||
alert('cannot swap');
|
||||
throw new Error('CANNOT SWAP');
|
||||
}
|
||||
|
||||
var rotate = items[0].checked;
|
||||
$(items[0]).prop('checked',items[1].checked);
|
||||
$(items[1]).prop('checked',rotate);
|
||||
|
||||
that.removeData();
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
// NOOP
|
||||
}
|
||||
});
|
||||
|
||||
$('span.scroll').on('click',function() {
|
||||
var next = $(this).closest('div.card').closest('tr').next();
|
||||
|
||||
if (next.length)
|
||||
$('html,body').animate({scrollTop: next.offset().top},'fast');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@ -22,6 +22,7 @@
|
||||
|
||||
<div class="card-body">
|
||||
<x-photo.thumbnail :id="$o->id" :css="$css ?? NULL"/>
|
||||
<span class="btn btn-sm float-right scroll"> <i class="fas fa-fw fa-level-down-alt"></i></span>
|
||||
<span class="btn btn-sm btn-outline-dark float-right swap">SWAP</span>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user