From 46a127934968fff1015de80fde6c943719962d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wojnowski?= Date: Fri, 1 May 2015 18:45:25 +0200 Subject: [PATCH 1/3] Fix for #26 - indexing of queued items The problem is that marking anchor as ignored results in not adding it to the images queue, hence the queue is shorter than total number of images. The initial processing goes through images and creates a function that trigger opening an image by its initial index, but the index is different in the queue due to ignored images. --- jquery.poptrox.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.poptrox.js b/jquery.poptrox.js index 215a8c9..e82b9b4 100644 --- a/jquery.poptrox.js +++ b/jquery.poptrox.js @@ -860,7 +860,7 @@ e.preventDefault(); e.stopPropagation(); - $popup.trigger('poptrox_open', [index]); + $popup.trigger('poptrox_open', [queue.length-1]); }); @@ -870,4 +870,4 @@ }; -})(jQuery); \ No newline at end of file +})(jQuery); From 29f6fa9c23cce8b6d0b7102cf10469e36ed87bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wojnowski?= Date: Fri, 8 May 2015 09:09:35 +0200 Subject: [PATCH 2/3] Fix for #26 - indexing of queued items --- jquery.poptrox.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jquery.poptrox.js b/jquery.poptrox.js index e82b9b4..0c1f52d 100644 --- a/jquery.poptrox.js +++ b/jquery.poptrox.js @@ -619,6 +619,14 @@ }); + function createImageOnClickHandler(index) { + return function(e) { + e.preventDefault(); + e.stopPropagation(); + $popup.trigger('poptrox_open', [index]); + }; + } + $this.find(settings.selector).each(function(index) { var x, tmp, a = $(this), i = a.find('img'), data = a.data('poptrox'); @@ -860,7 +868,7 @@ e.preventDefault(); e.stopPropagation(); - $popup.trigger('poptrox_open', [queue.length-1]); + $popup.trigger('poptrox_open', createImageOnClickHandler(queue.length-1)); }); From e3fdfa5a4e0ebd019af776b5f603a970fd5ec9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Wojnowski?= Date: Sat, 9 May 2015 22:13:45 +0200 Subject: [PATCH 3/3] Fix for #26 - indexing of queued items --- jquery.poptrox.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/jquery.poptrox.js b/jquery.poptrox.js index 0c1f52d..1878538 100644 --- a/jquery.poptrox.js +++ b/jquery.poptrox.js @@ -863,14 +863,7 @@ a .attr('href', '') .css('outline', 0) - .on('click', function(e) { - - e.preventDefault(); - e.stopPropagation(); - - $popup.trigger('poptrox_open', createImageOnClickHandler(queue.length-1)); - - }); + .on('click', createImageOnClickHandler(queue.length-1)); });