1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Improve Lightbox behavior for nonstandard clicks

Summary:
When users middle click or command-click an image, we should open it in a new tab, not open a lightbox.

See https://github.com/facebook/phabricator/issues/234

Test Plan: Left, middle, and command-clicked a lightbox image.

Reviewers: vrana, chad, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4020
This commit is contained in:
epriestley 2012-11-22 08:25:13 -08:00
parent 3ceaad1aa8
commit d9fd43704f
5 changed files with 116 additions and 105 deletions

2
externals/javelin vendored

@ -1 +1 @@
Subproject commit d1586fc8ce044663f0e8e13aa124a2b41c243b57
Subproject commit a2672d329212c90bda4f7979400a5149f9e967d2

View file

@ -4096,7 +4096,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-lightbox-attachments' =>
array(
'uri' => '/res/1c9104e2/rsrc/js/application/core/behavior-lightbox-attachments.js',
'uri' => '/res/5efba371/rsrc/js/application/core/behavior-lightbox-attachments.js',
'type' => 'js',
'requires' =>
array(
@ -4518,7 +4518,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-workflow' =>
array(
'uri' => '/res/86814563/rsrc/js/application/core/behavior-workflow.js',
'uri' => '/res/2b0e2754/rsrc/js/application/core/behavior-workflow.js',
'type' => 'js',
'requires' =>
array(
@ -4579,7 +4579,7 @@ celerity_register_resource_map(array(
),
'javelin-event' =>
array(
'uri' => '/res/f42fa6ea/rsrc/js/javelin/core/Event.js',
'uri' => '/res/3815b473/rsrc/js/javelin/core/Event.js',
'type' => 'js',
'requires' =>
array(
@ -5120,7 +5120,7 @@ celerity_register_resource_map(array(
),
'phabricator-core-css' =>
array(
'uri' => '/res/63d9b2eb/rsrc/css/core/core.css',
'uri' => '/res/a6bafd6e/rsrc/css/core/core.css',
'type' => 'css',
'requires' =>
array(
@ -5427,7 +5427,7 @@ celerity_register_resource_map(array(
),
'phabricator-property-list-view-css' =>
array(
'uri' => '/res/eb7962d9/rsrc/css/layout/phabricator-property-list-view.css',
'uri' => '/res/da1e1227/rsrc/css/layout/phabricator-property-list-view.css',
'type' => 'css',
'requires' =>
array(
@ -5501,6 +5501,15 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/TextAreaUtils.js',
),
'phabricator-timeline-view-css' =>
array(
'uri' => '/res/aa995c54/rsrc/css/layout/phabricator-timeline-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/layout/phabricator-timeline-view.css',
),
'phabricator-tooltip' =>
array(
'uri' => '/res/bcddf5de/rsrc/js/application/core/ToolTip.js',
@ -5794,7 +5803,7 @@ celerity_register_resource_map(array(
), array(
'packages' =>
array(
'9541e1c0' =>
'8f8908d2' =>
array(
'name' => 'core.pkg.css',
'symbols' =>
@ -5832,10 +5841,10 @@ celerity_register_resource_map(array(
30 => 'phabricator-filetree-view-css',
31 => 'phabricator-nav-view-css',
),
'uri' => '/res/pkg/9541e1c0/core.pkg.css',
'uri' => '/res/pkg/8f8908d2/core.pkg.css',
'type' => 'css',
),
'dc2e64a4' =>
'd223b82c' =>
array(
'name' => 'core.pkg.js',
'symbols' =>
@ -5872,7 +5881,7 @@ celerity_register_resource_map(array(
29 => 'phabricator-textareautils',
30 => 'phabricator-file-upload',
),
'uri' => '/res/pkg/dc2e64a4/core.pkg.js',
'uri' => '/res/pkg/d223b82c/core.pkg.js',
'type' => 'js',
),
'3c5efda9' =>
@ -5961,7 +5970,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/5e68be89/diffusion.pkg.js',
'type' => 'js',
),
'2e81a7e8' =>
20727878 =>
array(
'name' => 'javelin.pkg.js',
'symbols' =>
@ -5988,7 +5997,7 @@ celerity_register_resource_map(array(
19 => 'javelin-fx',
20 => 'javelin-color',
),
'uri' => '/res/pkg/2e81a7e8/javelin.pkg.js',
'uri' => '/res/pkg/20727878/javelin.pkg.js',
'type' => 'js',
),
'7839ae2d' =>
@ -6022,21 +6031,21 @@ celerity_register_resource_map(array(
'reverse' =>
array(
'aphront-attached-file-view-css' => '7839ae2d',
'aphront-crumbs-view-css' => '9541e1c0',
'aphront-dialog-view-css' => '9541e1c0',
'aphront-error-view-css' => '9541e1c0',
'aphront-form-view-css' => '9541e1c0',
'aphront-crumbs-view-css' => '8f8908d2',
'aphront-dialog-view-css' => '8f8908d2',
'aphront-error-view-css' => '8f8908d2',
'aphront-form-view-css' => '8f8908d2',
'aphront-headsup-action-list-view-css' => '47549184',
'aphront-headsup-view-css' => '9541e1c0',
'aphront-list-filter-view-css' => '9541e1c0',
'aphront-pager-view-css' => '9541e1c0',
'aphront-panel-view-css' => '9541e1c0',
'aphront-side-nav-view-css' => '9541e1c0',
'aphront-table-view-css' => '9541e1c0',
'aphront-tokenizer-control-css' => '9541e1c0',
'aphront-tooltip-css' => '9541e1c0',
'aphront-typeahead-control-css' => '9541e1c0',
'autosprite-css' => '9541e1c0',
'aphront-headsup-view-css' => '8f8908d2',
'aphront-list-filter-view-css' => '8f8908d2',
'aphront-pager-view-css' => '8f8908d2',
'aphront-panel-view-css' => '8f8908d2',
'aphront-side-nav-view-css' => '8f8908d2',
'aphront-table-view-css' => '8f8908d2',
'aphront-tokenizer-control-css' => '8f8908d2',
'aphront-tooltip-css' => '8f8908d2',
'aphront-typeahead-control-css' => '8f8908d2',
'autosprite-css' => '8f8908d2',
'differential-changeset-view-css' => '47549184',
'differential-core-view-css' => '47549184',
'differential-inline-comment-editor' => '7ecd31fa',
@ -6051,18 +6060,18 @@ celerity_register_resource_map(array(
'diffusion-commit-view-css' => 'c8ce2d88',
'diffusion-icons-css' => 'c8ce2d88',
'inline-comment-summary-css' => '47549184',
'javelin-aphlict' => 'dc2e64a4',
'javelin-behavior' => '2e81a7e8',
'javelin-behavior-aphlict-dropdown' => 'dc2e64a4',
'javelin-behavior-aphlict-listen' => 'dc2e64a4',
'javelin-behavior-aphront-basic-tokenizer' => 'dc2e64a4',
'javelin-aphlict' => 'd223b82c',
'javelin-behavior' => '20727878',
'javelin-behavior-aphlict-dropdown' => 'd223b82c',
'javelin-behavior-aphlict-listen' => 'd223b82c',
'javelin-behavior-aphront-basic-tokenizer' => 'd223b82c',
'javelin-behavior-aphront-drag-and-drop' => '7ecd31fa',
'javelin-behavior-aphront-drag-and-drop-textarea' => '7ecd31fa',
'javelin-behavior-aphront-form-disable-on-submit' => 'dc2e64a4',
'javelin-behavior-aphront-form-disable-on-submit' => 'd223b82c',
'javelin-behavior-audit-preview' => '5e68be89',
'javelin-behavior-dark-console' => '3c5efda9',
'javelin-behavior-dark-console-ajax' => '3c5efda9',
'javelin-behavior-device' => 'dc2e64a4',
'javelin-behavior-device' => 'd223b82c',
'javelin-behavior-differential-accept-with-errors' => '7ecd31fa',
'javelin-behavior-differential-add-reviewers-and-ccs' => '7ecd31fa',
'javelin-behavior-differential-comment-jump' => '7ecd31fa',
@ -6078,82 +6087,82 @@ celerity_register_resource_map(array(
'javelin-behavior-diffusion-commit-graph' => '5e68be89',
'javelin-behavior-diffusion-pull-lastmodified' => '5e68be89',
'javelin-behavior-error-log' => '3c5efda9',
'javelin-behavior-konami' => 'dc2e64a4',
'javelin-behavior-lightbox-attachments' => 'dc2e64a4',
'javelin-behavior-konami' => 'd223b82c',
'javelin-behavior-lightbox-attachments' => 'd223b82c',
'javelin-behavior-maniphest-batch-selector' => '7707de41',
'javelin-behavior-maniphest-subpriority-editor' => '7707de41',
'javelin-behavior-maniphest-transaction-controls' => '7707de41',
'javelin-behavior-maniphest-transaction-expand' => '7707de41',
'javelin-behavior-maniphest-transaction-preview' => '7707de41',
'javelin-behavior-phabricator-active-nav' => 'dc2e64a4',
'javelin-behavior-phabricator-autofocus' => 'dc2e64a4',
'javelin-behavior-phabricator-keyboard-shortcuts' => 'dc2e64a4',
'javelin-behavior-phabricator-nav' => 'dc2e64a4',
'javelin-behavior-phabricator-active-nav' => 'd223b82c',
'javelin-behavior-phabricator-autofocus' => 'd223b82c',
'javelin-behavior-phabricator-keyboard-shortcuts' => 'd223b82c',
'javelin-behavior-phabricator-nav' => 'd223b82c',
'javelin-behavior-phabricator-object-selector' => '7ecd31fa',
'javelin-behavior-phabricator-oncopy' => 'dc2e64a4',
'javelin-behavior-phabricator-remarkup-assist' => 'dc2e64a4',
'javelin-behavior-phabricator-search-typeahead' => 'dc2e64a4',
'javelin-behavior-phabricator-tooltips' => 'dc2e64a4',
'javelin-behavior-phabricator-watch-anchor' => 'dc2e64a4',
'javelin-behavior-refresh-csrf' => 'dc2e64a4',
'javelin-behavior-phabricator-oncopy' => 'd223b82c',
'javelin-behavior-phabricator-remarkup-assist' => 'd223b82c',
'javelin-behavior-phabricator-search-typeahead' => 'd223b82c',
'javelin-behavior-phabricator-tooltips' => 'd223b82c',
'javelin-behavior-phabricator-watch-anchor' => 'd223b82c',
'javelin-behavior-refresh-csrf' => 'd223b82c',
'javelin-behavior-repository-crossreference' => '7ecd31fa',
'javelin-behavior-toggle-class' => 'dc2e64a4',
'javelin-behavior-workflow' => 'dc2e64a4',
'javelin-color' => '2e81a7e8',
'javelin-dom' => '2e81a7e8',
'javelin-event' => '2e81a7e8',
'javelin-fx' => '2e81a7e8',
'javelin-install' => '2e81a7e8',
'javelin-json' => '2e81a7e8',
'javelin-mask' => '2e81a7e8',
'javelin-request' => '2e81a7e8',
'javelin-resource' => '2e81a7e8',
'javelin-stratcom' => '2e81a7e8',
'javelin-tokenizer' => '2e81a7e8',
'javelin-typeahead' => '2e81a7e8',
'javelin-typeahead-normalizer' => '2e81a7e8',
'javelin-typeahead-ondemand-source' => '2e81a7e8',
'javelin-typeahead-preloaded-source' => '2e81a7e8',
'javelin-typeahead-source' => '2e81a7e8',
'javelin-uri' => '2e81a7e8',
'javelin-util' => '2e81a7e8',
'javelin-vector' => '2e81a7e8',
'javelin-workflow' => '2e81a7e8',
'lightbox-attachment-css' => '9541e1c0',
'javelin-behavior-toggle-class' => 'd223b82c',
'javelin-behavior-workflow' => 'd223b82c',
'javelin-color' => '20727878',
'javelin-dom' => '20727878',
'javelin-event' => '20727878',
'javelin-fx' => '20727878',
'javelin-install' => '20727878',
'javelin-json' => '20727878',
'javelin-mask' => '20727878',
'javelin-request' => '20727878',
'javelin-resource' => '20727878',
'javelin-stratcom' => '20727878',
'javelin-tokenizer' => '20727878',
'javelin-typeahead' => '20727878',
'javelin-typeahead-normalizer' => '20727878',
'javelin-typeahead-ondemand-source' => '20727878',
'javelin-typeahead-preloaded-source' => '20727878',
'javelin-typeahead-source' => '20727878',
'javelin-uri' => '20727878',
'javelin-util' => '20727878',
'javelin-vector' => '20727878',
'javelin-workflow' => '20727878',
'lightbox-attachment-css' => '8f8908d2',
'maniphest-task-summary-css' => '7839ae2d',
'maniphest-transaction-detail-css' => '7839ae2d',
'phabricator-app-buttons-css' => '9541e1c0',
'phabricator-busy' => 'dc2e64a4',
'phabricator-app-buttons-css' => '8f8908d2',
'phabricator-busy' => 'd223b82c',
'phabricator-content-source-view-css' => '47549184',
'phabricator-core-buttons-css' => '9541e1c0',
'phabricator-core-css' => '9541e1c0',
'phabricator-directory-css' => '9541e1c0',
'phabricator-core-buttons-css' => '8f8908d2',
'phabricator-core-css' => '8f8908d2',
'phabricator-directory-css' => '8f8908d2',
'phabricator-drag-and-drop-file-upload' => '7ecd31fa',
'phabricator-dropdown-menu' => 'dc2e64a4',
'phabricator-file-upload' => 'dc2e64a4',
'phabricator-filetree-view-css' => '9541e1c0',
'phabricator-flag-css' => '9541e1c0',
'phabricator-form-view-css' => '9541e1c0',
'phabricator-header-view-css' => '9541e1c0',
'phabricator-jump-nav' => '9541e1c0',
'phabricator-keyboard-shortcut' => 'dc2e64a4',
'phabricator-keyboard-shortcut-manager' => 'dc2e64a4',
'phabricator-main-menu-view' => '9541e1c0',
'phabricator-menu-item' => 'dc2e64a4',
'phabricator-nav-view-css' => '9541e1c0',
'phabricator-notification' => 'dc2e64a4',
'phabricator-notification-css' => '9541e1c0',
'phabricator-notification-menu-css' => '9541e1c0',
'phabricator-dropdown-menu' => 'd223b82c',
'phabricator-file-upload' => 'd223b82c',
'phabricator-filetree-view-css' => '8f8908d2',
'phabricator-flag-css' => '8f8908d2',
'phabricator-form-view-css' => '8f8908d2',
'phabricator-header-view-css' => '8f8908d2',
'phabricator-jump-nav' => '8f8908d2',
'phabricator-keyboard-shortcut' => 'd223b82c',
'phabricator-keyboard-shortcut-manager' => 'd223b82c',
'phabricator-main-menu-view' => '8f8908d2',
'phabricator-menu-item' => 'd223b82c',
'phabricator-nav-view-css' => '8f8908d2',
'phabricator-notification' => 'd223b82c',
'phabricator-notification-css' => '8f8908d2',
'phabricator-notification-menu-css' => '8f8908d2',
'phabricator-object-selector-css' => '47549184',
'phabricator-paste-file-upload' => 'dc2e64a4',
'phabricator-prefab' => 'dc2e64a4',
'phabricator-paste-file-upload' => 'd223b82c',
'phabricator-prefab' => 'd223b82c',
'phabricator-project-tag-css' => '7839ae2d',
'phabricator-remarkup-css' => '9541e1c0',
'phabricator-remarkup-css' => '8f8908d2',
'phabricator-shaped-request' => '7ecd31fa',
'phabricator-standard-page-view' => '9541e1c0',
'phabricator-textareautils' => 'dc2e64a4',
'phabricator-tooltip' => 'dc2e64a4',
'phabricator-transaction-view-css' => '9541e1c0',
'syntax-highlighting-css' => '9541e1c0',
'phabricator-standard-page-view' => '8f8908d2',
'phabricator-textareautils' => 'd223b82c',
'phabricator-tooltip' => 'd223b82c',
'phabricator-transaction-view-css' => '8f8908d2',
'syntax-highlighting-css' => '8f8908d2',
),
));

View file

@ -110,7 +110,7 @@ final class PhabricatorRemarkupRuleEmbedFile
$embed = javelin_render_tag(
'a',
array(
'href' => '#',
'href' => $meta['uri'],
'class' => $options['image_class'],
'sigil' => 'lightboxable',
'mustcapture' => true,

View file

@ -18,6 +18,10 @@ JX.behavior('lightbox-attachments', function (config) {
var downloadForm = JX.$H(config.downloadForm);
function loadLightBox(e) {
if (!e.isNormalClick()) {
return;
}
if (JX.Stratcom.pass()) {
return;
}
@ -234,15 +238,12 @@ JX.behavior('lightbox-attachments', function (config) {
JX.Stratcom.listen(
'click',
['lightboxable', 'tag:a'],
loadLightBox
);
loadLightBox);
JX.Stratcom.listen(
'keydown',
null,
lightBoxHandleKeyDown
);
lightBoxHandleKeyDown);
// When the user clicks the background, close the lightbox.
JX.Stratcom.listen(

View file

@ -22,9 +22,10 @@ JX.behavior('workflow', function() {
'click',
['workflow', 'tag:a'],
function(e) {
if (JX.Stratcom.pass()) {
if (!e.isNormalClick()) {
return;
}
var target = e.getNode('workflow');
if (!JX.DOM.isType(target, 'a')) {
// This covers the case of an <a /> without workflow inside a <form />
@ -32,10 +33,10 @@ JX.behavior('workflow', function() {
return;
}
var raw = e.getRawEvent();
if (raw.altKey || raw.ctrlKey || raw.metaKey || raw.shiftKey) {
if (JX.Stratcom.pass()) {
return;
}
e.prevent();
JX.Workflow.newFromLink(target).start();
});