From f6d2a132a4f667d35ec562860b93183adaa55c9d Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 4 Oct 2024 22:21:59 +1000 Subject: [PATCH] Better handle cannot when we cannot swap checkboxes, added scroll, added swap/scroll to duplicate review --- .../views/catalog/deletereview.blade.php | 34 +++++++++++----- .../views/catalog/duplicatereview.blade.php | 40 ++++++++++++++++++- .../views/photo/widgets/thumbnail.blade.php | 1 + 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/resources/views/catalog/deletereview.blade.php b/resources/views/catalog/deletereview.blade.php index 3d0f7cf..44afc44 100644 --- a/resources/views/catalog/deletereview.blade.php +++ b/resources/views/catalog/deletereview.blade.php @@ -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'); }); }); diff --git a/resources/views/catalog/duplicatereview.blade.php b/resources/views/catalog/duplicatereview.blade.php index 6231882..a80b26c 100644 --- a/resources/views/catalog/duplicatereview.blade.php +++ b/resources/views/catalog/duplicatereview.blade.php @@ -35,4 +35,42 @@ NONE! @endif -@endsection \ No newline at end of file +@endsection + +@section('page-scripts') + +@append \ No newline at end of file diff --git a/resources/views/photo/widgets/thumbnail.blade.php b/resources/views/photo/widgets/thumbnail.blade.php index 5bf90c6..613f3a8 100644 --- a/resources/views/photo/widgets/thumbnail.blade.php +++ b/resources/views/photo/widgets/thumbnail.blade.php @@ -22,6 +22,7 @@
+ SWAP