Skip to content

Commit 592a1ad

Browse files
committed
Refactors the publicshareauth template to have the Enter key working in the
email input field and add a 'Back' button. This commit is part of #31005 Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
1 parent 63d478b commit 592a1ad

File tree

3 files changed

+69
-19
lines changed

3 files changed

+69
-19
lines changed

core/css/publicshareauth.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ form fieldset > p {
1818
min-width: 0; /* FF hack for to override default value */
1919
}
2020

21-
input[type='submit'],
22-
input[type='submit'].icon-confirm {
21+
#password-input-form input[type='submit'],
22+
#email-input-form input[type='submit'],
23+
#email-input-form input[type='submit'].icon-confirm,
24+
#password-input-form input[type='submit'].icon-confirm {
2325
position: absolute;
2426
top: 0px;
2527
right: -5px;

core/js/publicshareauth.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
function showEmailAddressPrompt() {
1+
function showEmailAddressPromptForm() {
22
// Shows email prompt
3-
var emailInput = document.getElementById('email-input');
4-
var emailPrompt = document.getElementById('email-prompt');
3+
var emailInput = document.getElementById('email-input-form');
54
emailInput.style.display="block";
6-
emailPrompt.style.display="block";
75

8-
// Hides password prompt
6+
// Shows back button
7+
var backButton = document.getElementById('request-password-back-button');
8+
backButton.style.display="block";
9+
10+
// Hides password prompt and 'request password' button
911
var passwordRequestButton = document.getElementById('request-password-button-not-talk');
10-
var passwordInput = document.getElementById('password-input');
12+
var passwordInput = document.getElementById('password-input-form');
1113
passwordRequestButton.style.display="none";
1214
passwordInput.style.display="none";
1315

@@ -23,17 +25,28 @@ function showEmailAddressPrompt() {
2325
}
2426

2527
document.addEventListener('DOMContentLoaded', function() {
28+
// Enables password submit button only when user has typed something in the password field
2629
var passwordInput = document.getElementById('password');
2730
var passwordButton = document.getElementById('password-submit');
2831
var eventListener = function() {
2932
passwordButton.disabled = passwordInput.value.length === 0;
3033
};
31-
3234
passwordInput.addEventListener('click', eventListener);
3335
passwordInput.addEventListener('keyup', eventListener);
3436
passwordInput.addEventListener('change', eventListener);
3537

38+
// Enables email request button only when user has typed something in the email field
39+
var emailInput = document.getElementById('email');
40+
var emailButton = document.getElementById('password-request');
41+
eventListener = function() {
42+
emailButton.disabled = emailInput.value.length === 0;
43+
};
44+
emailInput.addEventListener('click', eventListener);
45+
emailInput.addEventListener('keyup', eventListener);
46+
emailInput.addEventListener('change', eventListener);
47+
48+
// Adds functionality to the request password button
3649
var passwordRequestButton = document.getElementById('request-password-button-not-talk');
37-
passwordRequestButton.addEventListener('click', showEmailAddressPrompt);
50+
passwordRequestButton.addEventListener('click', showEmailAddressPromptForm);
3851

3952
});

core/templates/publicshareauth.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
style('core', 'publicshareauth');
66
script('core', 'publicshareauth');
77
?>
8-
<form method="post">
8+
9+
<!-- password prompt form. It should be hidden when we show the email prompt form -->
10+
<?php if (!isset($_['identityOk'])): ?>
11+
<form method="post" id="password-input-form">
12+
<?php else: ?>
13+
<form method="post" id="password-input-form" style="display:none;">
14+
<?php endif; ?>
915
<fieldset class="warning">
1016
<?php if (!isset($_['wrongpw'])): ?>
1117
<div class="warning-info"><?php p($l->t('This share is password-protected')); ?></div>
1218
<?php endif; ?>
1319
<?php if (isset($_['wrongpw'])): ?>
1420
<div class="warning"><?php p($l->t('The password is wrong. Try again.')); ?></div>
1521
<?php endif; ?>
16-
<div class="warning-info" id="email-prompt" style="display:none;"><?php p($l->t('Please type in your email address to request a temporary password')); ?></div>
17-
<p id="password-input">
22+
<p>
1823
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
1924
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
2025
<input type="password" name="password" id="password"
@@ -26,23 +31,53 @@
2631
<input type="submit" id="password-submit"
2732
class="svg icon-confirm input-button-inline" value="" disabled="disabled" />
2833
</p>
29-
<p id="email-input" style="display:none;">
34+
</fieldset>
35+
</form>
36+
37+
<!-- email prompt form. It should initially be hidden -->
38+
<?php if (isset($_['identityOk'])): ?>
39+
<form method="post" id="email-input-form">
40+
<?php else: ?>
41+
<form method="post" id="email-input-form" style="display:none;">
42+
<?php endif; ?>
43+
<fieldset class="warning">
44+
<div class="warning-info" id="email-prompt"><?php p($l->t('Please type in your email address to request a temporary password')); ?></div>
45+
<p>
3046
<input type="email" id="email" name="identityToken" placeholder="<?php p($l->t('Email address')); ?>" />
31-
<input type="submit" id="password-request" name="passwordRequest" class="svg icon-confirm input-button-inline" value="" />
47+
<input type="submit" id="password-request" name="passwordRequest" class="svg icon-confirm input-button-inline" value="" disabled="disabled"/>
48+
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
49+
<input type="hidden" name="sharingToken" value="<?php p($_['share']->getToken()) ?>" id="sharingToken">
50+
<input type="hidden" name="sharingType" value="<?php p($_['share']->getShareType()) ?>" id="sharingType">
3251
</p>
3352
<?php if (isset($_['identityOk'])): ?>
3453
<?php if ($_['identityOk']): ?>
3554
<div class="warning-info" id="identification-success"><?php p($l->t('Password sent!')); ?></div>
36-
<?php endif; ?>
37-
<?php if (!$_['identityOk']): ?>
38-
<div class="warning-info" id="identification-failure"><?php p($l->t('You are not authorized to request a password for this share')); ?></div>
55+
<?php else: ?>
56+
<div class="warning" id="identification-failure"><?php p($l->t('You are not authorized to request a password for this share')); ?></div>
3957
<?php endif; ?>
4058
<?php endif; ?>
4159
</fieldset>
4260
</form>
43-
<?php if ($_['share']->getShareType()===$_['share']::TYPE_EMAIL && !$_['share']->getSendPasswordByTalk()): ?>
61+
62+
<!-- request password button -->
63+
<?php if (!isset($_['identityOk']) && $_['share']->getShareType()===$_['share']::TYPE_EMAIL && !$_['share']->getSendPasswordByTalk()): ?>
4464
<input type="button"
4565
id="request-password-button-not-talk"
4666
value="<?php p($l->t('Request password')); ?>"
4767
class="primary" />
4868
<?php endif; ?>
69+
70+
<!-- back to showShare button -->
71+
<form method="get">
72+
<fieldset>
73+
<input type="submit"
74+
id="request-password-back-button"
75+
value="<?php p($l->t('Back')); ?>"
76+
class="primary"
77+
<?php if (isset($_['identityOk'])): ?>
78+
style="display:block;" />
79+
<?php else: ?>
80+
style="display:none;" />
81+
<?php endif; ?>
82+
</fieldset>
83+
</form>

0 commit comments

Comments
 (0)