1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Fix image prev/next cycling in lightboxes

Summary:
See <https://discourse.phabricator-community.org/t/lightbox-not-working/1201/3>. The lightbox code is fragile and currently relies on simulating a click on the actual "<a />" tag surrounding other images in the document.

This breaks the prev/next links which ignore the event because it there's no "<img />".

Instead, don't simulate clicks and just call the code we want directly.

Test Plan: Added several images to a page, used lightbox prev/next buttons to cycle between them.

Differential Revision: https://secure.phabricator.com/D19197
This commit is contained in:
epriestley 2018-03-08 08:22:16 -08:00
parent 98cac2cc29
commit e83cfa295b
2 changed files with 18 additions and 14 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => 'c218ed53',
'core.pkg.js' => '32bb68e9',
'core.pkg.js' => '8b7400e7',
'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '113e692c',
'differential.pkg.js' => 'f6d809c0',
@ -494,7 +494,7 @@ return array(
'rsrc/js/core/behavior-hovercard.js' => 'bcaccd64',
'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0',
'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0',
'rsrc/js/core/behavior-lightbox-attachments.js' => '562bcce0',
'rsrc/js/core/behavior-lightbox-attachments.js' => '6b31879a',
'rsrc/js/core/behavior-line-linker.js' => 'a9b946f8',
'rsrc/js/core/behavior-more.js' => 'a80d0378',
'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0',
@ -644,7 +644,7 @@ return array(
'javelin-behavior-history-install' => '7ee2b591',
'javelin-behavior-icon-composer' => '8499b6ab',
'javelin-behavior-launch-icon-composer' => '48086888',
'javelin-behavior-lightbox-attachments' => '562bcce0',
'javelin-behavior-lightbox-attachments' => '6b31879a',
'javelin-behavior-line-chart' => 'e4232876',
'javelin-behavior-load-blame' => '42126667',
'javelin-behavior-maniphest-batch-selector' => 'ad54037e',
@ -1362,15 +1362,6 @@ return array(
'javelin-vector',
'javelin-dom',
),
'562bcce0' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-mask',
'javelin-util',
'phuix-icon-view',
'phabricator-busy',
),
'58dea2fa' => array(
'javelin-install',
'javelin-util',
@ -1463,6 +1454,15 @@ return array(
'69adf288' => array(
'javelin-install',
),
'6b31879a' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-mask',
'javelin-util',
'phuix-icon-view',
'phabricator-busy',
),
'6b8ef10b' => array(
'javelin-install',
),

View file

@ -56,6 +56,10 @@ JX.behavior('lightbox-attachments', function() {
e.kill();
activateLightbox(e.getNode('lightboxable'));
}
function activateLightbox(target) {
var mainFrame = JX.$('main-page-frame');
var links = JX.DOM.scry(mainFrame, '*', 'lightboxable');
var phids = {};
@ -68,7 +72,6 @@ JX.behavior('lightbox-attachments', function() {
// Now that we have the big picture phid situation sorted out, figure
// out how the actual node the user clicks fits into that big picture
// and build some pretty UI to show the attachment.
var target = e.getNode('lightboxable');
var target_data = JX.Stratcom.getData(target);
var total = JX.keys(phids).length;
var current = 1;
@ -324,7 +327,8 @@ JX.behavior('lightbox-attachments', function() {
}
e.prevent();
closeLightBox(e);
el.click();
activateLightbox(el);
}
// Only look for lightboxable inside the main page, not other lightboxes.