Skip to content

Commit 798787a

Browse files
committed
use title to show why button is disabled
1 parent 5810c37 commit 798787a

4 files changed

Lines changed: 82 additions & 51 deletions

File tree

webroot/panel/account.php

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@
209209
";
210210
echo $CSRFTokenHiddenFormInput;
211211
if ($SQL->accDeletionRequestExists($USER->uid)) {
212-
echo "<input type='submit' value='Request PI Account' disabled />";
213212
echo "
214-
<label style='margin-left: 10px'>
215-
You cannot request PI Account while you have requested account deletion.
216-
</label>
213+
<input
214+
type='submit'
215+
value='Request PI Account'
216+
title='You cannot request PI Account while you have requested account deletion.'
217+
disabled
218+
/>
217219
";
218220
} else {
219221
if ($SQL->requestExists($USER->uid, UnitySQL::REQUEST_BECOME_PI)) {
@@ -296,38 +298,46 @@
296298
";
297299

298300
if ($hasGroups) {
299-
echo "<p>You cannot request to delete your account while you are in a PI group.</p>";
301+
$request_account_deletion_disabled = "disabled";
302+
$request_account_deletion_title = "You cannot request to delete your account while you are in a PI group.";
300303
} else {
301-
if ($SQL->accDeletionRequestExists($USER->uid)) {
302-
echo "
303-
<p>Your request has been submitted and is currently pending.</p>
304-
<form
305-
action=''
306-
method='POST'
307-
onsubmit='
308-
return confirm(
309-
\"Are you sure you want to cancel your request for account deletion?\"
310-
)
311-
'
312-
>
313-
$CSRFTokenHiddenFormInput
314-
<input type='hidden' name='form_type' value='cancel_account_deletion_request' />
315-
<input type='submit' value='Cancel Account Deletion Request' />
316-
</form>
317-
";
318-
} else {
319-
echo "
320-
<form
321-
action=''
322-
method='POST'
323-
onsubmit='return confirm(\"Are you sure you want to request an account deletion?\")'
324-
>
325-
$CSRFTokenHiddenFormInput
326-
<input type='hidden' name='form_type' value='account_deletion_request' />
327-
<input type='submit' value='Request Account Deletion' />
328-
</form>
329-
";
330-
}
304+
$request_account_deletion_disabled = "";
305+
$request_account_deletion_title = "";
306+
}
307+
if ($SQL->accDeletionRequestExists($USER->uid)) {
308+
echo "
309+
<p>Your request has been submitted and is currently pending.</p>
310+
<form
311+
action=''
312+
method='POST'
313+
onsubmit='
314+
return confirm(
315+
\"Are you sure you want to cancel your request for account deletion?\"
316+
)
317+
'
318+
>
319+
$CSRFTokenHiddenFormInput
320+
<input type='hidden' name='form_type' value='cancel_account_deletion_request' />
321+
<input type='submit' value='Cancel Account Deletion Request' />
322+
</form>
323+
";
324+
} else {
325+
echo "
326+
<form
327+
action=''
328+
method='POST'
329+
onsubmit='return confirm(\"Are you sure you want to request an account deletion?\")'
330+
>
331+
$CSRFTokenHiddenFormInput
332+
<input type='hidden' name='form_type' value='account_deletion_request' />
333+
<input
334+
type='submit'
335+
value='Request Account Deletion'
336+
title='$request_account_deletion_title'
337+
$request_account_deletion_disabled
338+
/>
339+
</form>
340+
";
331341
}
332342

333343
?>
@@ -348,9 +358,9 @@
348358

349359
function enableOrDisableSubmitLoginShell() {
350360
if ($("#loginSelector").val() == ldapLoginShell) {
351-
$("#submitLoginShell").prop("disabled", true);
361+
$("#submitLoginShell").prop("disabled", true).prop("title", "Login shell is unchanged");
352362
} else {
353-
$("#submitLoginShell").prop("disabled", false);
363+
$("#submitLoginShell").prop("disabled", false).prop("title", "");
354364
}
355365
}
356366
$("#loginSelector").change(enableOrDisableSubmitLoginShell);

webroot/panel/groups.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,16 @@
218218

219219
<?php
220220
if ($SQL->accDeletionRequestExists($USER->uid)) {
221-
echo "<button type='button' class='plusBtn btnAddPI' disabled><span>&#43;</span></button>";
222-
echo "<label>You cannot join a PI while you have requested account deletion.</label>";
221+
echo "
222+
<button
223+
type='button'
224+
class='plusBtn btnAddPI'
225+
title='You cannot join a PI while you have requested account deletion.'
226+
disabled
227+
>
228+
<span>&#43;</span>
229+
</button>
230+
";
223231
} else {
224232
echo "<button type='button' class='plusBtn btnAddPI'><span>&#43;</span></button>";
225233
}

webroot/panel/modal/new_pi.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@
4545
Terms of Service
4646
</a>.
4747
</label>
48-
<input type="submit" value="Send Request" disabled>
48+
<input
49+
type="submit"
50+
value="Send Request"
51+
title="Please enter a GID, owner name, or owner email"
52+
disabled
53+
>
4954
</form>
5055

5156
<script>
@@ -62,23 +67,21 @@ function updateSearch() {
6267
const results = JSON.parse(data);
6368
if (results.length === 0) {
6469
wrapper.html("<span>No Results</span>").show();
65-
submit.prop("disabled", true);
70+
submit.prop("disabled", true).prop("title", "no groups found");
6671
} else if (results.includes(query)) {
6772
// search query exactly matches a PI group GID
6873
wrapper.html("").hide();
69-
submit.prop("disabled", false);
74+
submit.prop("disabled", false).prop("title", "");
7075
} else {
7176
const html = results.map(gid => `<span>${gid}</span>`).join('');
7277
wrapper.html(html).show();
73-
submit.prop("disabled", true);
78+
submit.prop("disabled", true).prop("title", "no group found with this GID");
7479
}
7580
},
7681
error: function(result) {
77-
const error_msg_div = $("<div></div>");
78-
error_msg_div.html(result.responseText);
79-
submit.after(error_msg_div);
82+
submit.after($("<div></div>").html(result.responseText));
8083
wrapper.html("").hide();
81-
submit.prop("disabled", true);
84+
submit.prop("disabled", true).prop("title", "something went wrong");
8285
}
8386
});
8487
};

webroot/panel/pi.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,23 @@
206206
";
207207
if (!$user_is_owner) {
208208
echo "
209-
<input type='submit' value='Disable PI Group' class='danger' disabled>
210-
<p>Only the group owner can disable the group.</p>
209+
<input
210+
type='submit'
211+
value='Disable PI Group'
212+
class='danger'
213+
title='Only the group owner can disable the group.'
214+
disabled
215+
>
211216
";
212217
} elseif (count($assocs) > 1) {
213218
echo "
214-
<input type='submit' value='Disable PI Group' class='danger' disabled>
215-
<p>You must first remove all members before you can disable.</p>
219+
<input
220+
type='submit'
221+
value='Disable PI Group'
222+
class='danger'
223+
title='You must first remove all members before you can disable.'
224+
disabled
225+
>
216226
";
217227
} else {
218228
echo "

0 commit comments

Comments
 (0)