From b34f0cbe01b05b971aad0ec36b8bf2438c45b111 Mon Sep 17 00:00:00 2001 From: Guillaume Calmettes Date: Sat, 28 Jul 2018 19:26:56 -0700 Subject: compute correct indexing of children items when multiple og-grid on the same page --- layouts/partials/scripts.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 93a33ef..4c95802 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -124,7 +124,7 @@ var Grid = (function() { - var $grid = $( '#og-grid' ), + var $grid = $( '*#og-grid' ), $items = $grid.children( 'li' ), current = -1, previewPos = -1, @@ -260,7 +260,7 @@ function Preview( $item ) { this.$item = $item; - this.expandedIdx = this.$item.index(); + this.expandedIdx = Array.from($items).findIndex(d => d == this.$item[0]); this.create(); this.update(); } -- cgit v1.2.3 From 1ce51aff424151bfba325b0f8dbfbb23b9a0949b Mon Sep 17 00:00:00 2001 From: Guillaume Calmettes Date: Sat, 28 Jul 2018 20:25:44 -0700 Subject: correctly hide preview if item is the one being previewed --- layouts/partials/scripts.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 4c95802..d0d1427 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -213,7 +213,7 @@ } ).children( 'a' ).on( 'click', function(e) { var $item = $( this ).parent(); - current === $item.index() ? hidePreview() : showPreview( $item ); + current === Array.from($items).findIndex(d => d == $item[0]) ? hidePreview() : showPreview( $item ); return false; } ); -- cgit v1.2.3