mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Stop using forms to download files in file embed and lightbox elements
Summary: Depends on D19156. Ref T13094. This replaces the remaining forms in the file embed view and lightbox with normal download links. Test Plan: Clicked "Download" and lightbox -> download for embedded files. Maniphest Tasks: T13094 Differential Revision: https://secure.phabricator.com/D19157
This commit is contained in:
parent
ab579f2511
commit
a2fdf14275
4 changed files with 47 additions and 86 deletions
|
@ -10,7 +10,7 @@ return array(
|
|||
'conpherence.pkg.css' => 'e68cf1fa',
|
||||
'conpherence.pkg.js' => '15191c65',
|
||||
'core.pkg.css' => '2fa91e14',
|
||||
'core.pkg.js' => 'e7ce7bba',
|
||||
'core.pkg.js' => 'a3ceffdb',
|
||||
'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' => '560f41da',
|
||||
'rsrc/js/core/behavior-lightbox-attachments.js' => 'e31fad01',
|
||||
'rsrc/js/core/behavior-line-linker.js' => '1499a8cb',
|
||||
'rsrc/js/core/behavior-more.js' => 'a80d0378',
|
||||
'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0',
|
||||
|
@ -642,7 +642,7 @@ return array(
|
|||
'javelin-behavior-history-install' => '7ee2b591',
|
||||
'javelin-behavior-icon-composer' => '8499b6ab',
|
||||
'javelin-behavior-launch-icon-composer' => '48086888',
|
||||
'javelin-behavior-lightbox-attachments' => '560f41da',
|
||||
'javelin-behavior-lightbox-attachments' => 'e31fad01',
|
||||
'javelin-behavior-line-chart' => 'e4232876',
|
||||
'javelin-behavior-load-blame' => '42126667',
|
||||
'javelin-behavior-maniphest-batch-selector' => 'ad54037e',
|
||||
|
@ -1359,15 +1359,6 @@ return array(
|
|||
'javelin-vector',
|
||||
'javelin-dom',
|
||||
),
|
||||
'560f41da' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-mask',
|
||||
'javelin-util',
|
||||
'phuix-icon-view',
|
||||
'phabricator-busy',
|
||||
),
|
||||
'58dea2fa' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
|
@ -2070,6 +2061,15 @@ return array(
|
|||
'javelin-dom',
|
||||
'phabricator-draggable-list',
|
||||
),
|
||||
'e31fad01' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'javelin-mask',
|
||||
'javelin-util',
|
||||
'phuix-icon-view',
|
||||
'phabricator-busy',
|
||||
),
|
||||
'e379b58e' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
|
|
@ -134,21 +134,13 @@ final class PhabricatorFileLinkView extends AphrontTagView {
|
|||
$dl_icon = id(new PHUIIconView())
|
||||
->setIcon('fa-download');
|
||||
|
||||
$download_form = phabricator_form(
|
||||
$this->getViewer(),
|
||||
array(
|
||||
'action' => $this->getFileDownloadURI(),
|
||||
'method' => 'POST',
|
||||
'class' => 'embed-download-form',
|
||||
'sigil' => 'embed-download-form download',
|
||||
),
|
||||
phutil_tag(
|
||||
'button',
|
||||
$download_link = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'phabricator-remarkup-embed-layout-download',
|
||||
'type' => 'submit',
|
||||
'href' => $this->getFileDownloadURI(),
|
||||
),
|
||||
pht('Download')));
|
||||
pht('Download'));
|
||||
|
||||
$info = phutil_tag(
|
||||
'span',
|
||||
|
@ -177,7 +169,7 @@ final class PhabricatorFileLinkView extends AphrontTagView {
|
|||
return array(
|
||||
$icon,
|
||||
$inner,
|
||||
$download_form,
|
||||
$download_link,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,35 +279,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
|||
}
|
||||
}
|
||||
|
||||
$icon = id(new PHUIIconView())
|
||||
->setIcon('fa-download')
|
||||
->addClass('phui-icon-circle-icon');
|
||||
$lightbox_id = celerity_generate_unique_node_id();
|
||||
$download_form = phabricator_form(
|
||||
$user,
|
||||
array(
|
||||
'action' => '#',
|
||||
'method' => 'POST',
|
||||
'class' => 'lightbox-download-form',
|
||||
'sigil' => 'download lightbox-download-submit',
|
||||
'id' => 'lightbox-download-form',
|
||||
),
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'lightbox-download phui-icon-circle hover-green',
|
||||
'href' => '#',
|
||||
),
|
||||
array(
|
||||
$icon,
|
||||
)));
|
||||
|
||||
Javelin::initBehavior(
|
||||
'lightbox-attachments',
|
||||
array(
|
||||
'lightbox_id' => $lightbox_id,
|
||||
'downloadForm' => $download_form,
|
||||
));
|
||||
Javelin::initBehavior('lightbox-attachments');
|
||||
}
|
||||
|
||||
Javelin::initBehavior('aphront-form-disable-on-submit');
|
||||
|
|
|
@ -9,19 +9,18 @@
|
|||
* phabricator-busy
|
||||
*/
|
||||
|
||||
JX.behavior('lightbox-attachments', function (config) {
|
||||
JX.behavior('lightbox-attachments', function() {
|
||||
|
||||
var lightbox = null;
|
||||
|
||||
var prev = null;
|
||||
var next = null;
|
||||
var shown = false;
|
||||
var downloadForm = JX.$H(config.downloadForm).getFragment().firstChild;
|
||||
var lightbox_id = config.lightbox_id;
|
||||
|
||||
function _toggleComment(e) {
|
||||
e.kill();
|
||||
shown = !shown;
|
||||
JX.DOM.alterClass(JX.$(lightbox_id), 'comment-panel-open', shown);
|
||||
JX.DOM.alterClass(lightbox, 'comment-panel-open', shown);
|
||||
}
|
||||
|
||||
function markCommentsLoading(loading) {
|
||||
|
@ -48,6 +47,12 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
return;
|
||||
}
|
||||
|
||||
// If you click the "Download" link inside an embedded file element,
|
||||
// don't lightbox the file.
|
||||
if (e.getNode('tag:a')) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.kill();
|
||||
|
||||
var mainFrame = JX.$('main-page-frame');
|
||||
|
@ -82,8 +87,7 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
var img_uri = '';
|
||||
var img = '';
|
||||
var extra_status = '';
|
||||
// for now, this conditional is always true
|
||||
// revisit if / when we decide to add non-images to lightbox view
|
||||
|
||||
if (target_data.viewable) {
|
||||
img_uri = target_data.uri;
|
||||
var alt_name = '';
|
||||
|
@ -114,7 +118,7 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
{
|
||||
className : 'lightbox-icon-frame',
|
||||
sigil : 'lightbox-download-submit',
|
||||
href : '#',
|
||||
href : target_data.dUri,
|
||||
},
|
||||
[ imgIcon, nameElement ]
|
||||
);
|
||||
|
@ -138,12 +142,12 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
);
|
||||
|
||||
var commentClass = (shown) ? 'comment-panel-open' : '';
|
||||
|
||||
lightbox =
|
||||
JX.$N('div',
|
||||
{
|
||||
className : 'lightbox-attachment ' + commentClass,
|
||||
sigil : 'lightbox-attachment',
|
||||
id : lightbox_id
|
||||
sigil : 'lightbox-attachment'
|
||||
},
|
||||
[imgFrame, commentFrame]
|
||||
);
|
||||
|
@ -161,12 +165,17 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
]
|
||||
);
|
||||
|
||||
var downloadSpan =
|
||||
JX.$N('span',
|
||||
var download_icon = new JX.PHUIXIconView()
|
||||
.setIcon('fa-download phui-icon-circle-icon')
|
||||
.getNode();
|
||||
|
||||
var download_button = JX.$N(
|
||||
'a',
|
||||
{
|
||||
className : 'lightbox-download'
|
||||
}
|
||||
);
|
||||
className: 'lightbox-download phui-icon-circle hover-sky',
|
||||
href: target_data.dUri
|
||||
},
|
||||
download_icon);
|
||||
|
||||
var commentIcon = new JX.PHUIXIconView()
|
||||
.setIcon('fa-comments phui-icon-circle-icon')
|
||||
|
@ -180,6 +189,7 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
},
|
||||
commentIcon
|
||||
);
|
||||
|
||||
var closeIcon = new JX.PHUIXIconView()
|
||||
.setIcon('fa-times phui-icon-circle-icon')
|
||||
.getNode();
|
||||
|
@ -190,12 +200,13 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
href : '#'
|
||||
},
|
||||
closeIcon);
|
||||
|
||||
var statusHTML =
|
||||
JX.$N('div',
|
||||
{
|
||||
className : 'lightbox-status'
|
||||
},
|
||||
[statusSpan, closeButton, commentButton, downloadSpan]
|
||||
[statusSpan, closeButton, commentButton, download_button]
|
||||
);
|
||||
JX.DOM.appendContent(lightbox, statusHTML);
|
||||
JX.DOM.listen(closeButton, 'click', null, closeLightBox);
|
||||
|
@ -246,9 +257,6 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
JX.DOM.alterClass(document.body, 'lightbox-attached', true);
|
||||
JX.Mask.show('jx-dark-mask');
|
||||
|
||||
downloadForm.action = target_data.dUri;
|
||||
downloadSpan.appendChild(downloadForm);
|
||||
|
||||
document.body.appendChild(lightbox);
|
||||
|
||||
if (img_uri) {
|
||||
|
@ -365,23 +373,12 @@ JX.behavior('lightbox-attachments', function (config) {
|
|||
'lightbox-comment-form',
|
||||
_sendMessage);
|
||||
|
||||
var _startDownload = function(e) {
|
||||
e.kill();
|
||||
var form = JX.$('lightbox-download-form');
|
||||
form.submit();
|
||||
};
|
||||
|
||||
var _startPageDownload = function(e) {
|
||||
e.kill();
|
||||
var form = e.getNode('tag:form');
|
||||
form.submit();
|
||||
};
|
||||
|
||||
JX.Stratcom.listen(
|
||||
'click',
|
||||
'lightbox-download-submit',
|
||||
_startDownload);
|
||||
|
||||
JX.Stratcom.listen(
|
||||
'click',
|
||||
'embed-download-form',
|
||||
|
|
Loading…
Reference in a new issue