Skip to content

Commit 4cf42a6

Browse files
authored
Refactor shortcuts modal to use <dialog> (hestiacp#3023)
1 parent a84d8ce commit 4cf42a6

File tree

16 files changed

+100
-207
lines changed

16 files changed

+100
-207
lines changed

web/css/src/themes/dark.css

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,73 +1207,12 @@ form#vstobjects.suspended {
12071207
background: rgb(30 30 30 / 95%);
12081208
border: 1px solid rgb(255 255 255 / 25%);
12091209
box-shadow: 0 0 20px rgb(0 0 0 / 50%);
1210-
border-bottom: none !important;
12111210
}
12121211

12131212
.shortcuts-header {
12141213
border-bottom: 1px solid #353535;
12151214
}
12161215

1217-
.description {
1218-
1219-
}
1220-
1221-
.description ul{
1222-
1223-
}
1224-
1225-
.description li{
1226-
1227-
}
1228-
1229-
.description a {
1230-
1231-
}
1232-
1233-
.description a.purchase {
1234-
1235-
}
1236-
1237-
.description a.purchase:hover {
1238-
color: #d4d4d4;
1239-
}
1240-
1241-
.description a.purchase:active {
1242-
color: #d4d4d4;
1243-
}
1244-
1245-
.description a.cancel {
1246-
1247-
}
1248-
1249-
.description a.cancel:hover {
1250-
1251-
}
1252-
1253-
.description a.cancel:active {
1254-
1255-
}
1256-
1257-
.description.cancel-success {
1258-
1259-
}
1260-
1261-
.description .licence {
1262-
1263-
}
1264-
1265-
.description .licence input {
1266-
1267-
}
1268-
1269-
.description span {
1270-
1271-
}
1272-
1273-
.description .twoco {
1274-
1275-
}
1276-
12771216
.ui-dialog {
12781217
background-color: rgb(45 45 45 / 95%);
12791218
border: 1px solid rgb(80 80 80 / 97%);

web/css/src/themes/default.css

Lines changed: 49 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Define Exo font family
33
Primary font used throughout the user interface
44
========================================================================== */
5+
56
/* exo-300 - latin-ext_latin */
67
@font-face {
78
font-family: 'Exo';
@@ -182,6 +183,15 @@ pre {
182183
margin: 0;
183184
}
184185

186+
dialog {
187+
position: fixed;
188+
padding: 0;
189+
}
190+
191+
dialog::backdrop {
192+
background-color: rgb(0 0 0 / 60%);
193+
}
194+
185195
ol,
186196
ul {
187197
list-style: none;
@@ -2361,7 +2371,11 @@ body.mobile .l-icon-shortcuts {
23612371
font-weight: normal;
23622372
}
23632373

2364-
.ftp-path-prefix { padding-top: 12px; font-size: 0.8rem; color: #555; }
2374+
.ftp-path-prefix {
2375+
padding-top: 12px;
2376+
font-size: 0.8rem;
2377+
color: #555;
2378+
}
23652379

23662380
.dialog {
23672381
display: none;
@@ -2641,10 +2655,9 @@ a.button.cancel {
26412655

26422656
.body-login,
26432657
.body-reset {
2644-
height: auto;
26452658
display: flex;
2659+
align-items: center;
26462660
justify-content: center;
2647-
padding-top: 10%;
26482661
background: rgb(102 158 231);
26492662
background: radial-gradient(circle, rgb(102 158 231 / 100%) 0%, rgb(43 86 177 / 100%) 100%);
26502663
}
@@ -2657,17 +2670,31 @@ a.button.cancel {
26572670
}
26582671

26592672
.login {
2660-
display: flex;
2661-
align-items: flex-end;
26622673
font-size: 0.85rem;
26632674
padding: 80px 50px;
2675+
min-width: 320px;
2676+
margin-bottom: 20%;
26642677
background-color: rgb(255 255 255 / 70%);
26652678
border-radius: 6px;
26662679
box-shadow:
26672680
0 8px 25px rgb(0 0 0 / 30%),
26682681
inset 0 0 2px rgb(255 255 255 / 100%);
26692682
}
26702683

2684+
@media screen and (min-width: 768px) {
2685+
2686+
.login {
2687+
display: flex;
2688+
align-items: flex-end;
2689+
width: 100%;
2690+
max-width: 500px;
2691+
}
2692+
2693+
.login form {
2694+
flex-grow: 1;
2695+
}
2696+
}
2697+
26712698
.login-title {
26722699
color: #4b4b4b;
26732700
font-size: 1.05rem;
@@ -3193,29 +3220,19 @@ form#vstobjects.suspended {
31933220

31943221
.shortcuts {
31953222
background: rgb(50 50 50 / 93%);
3196-
display: inline-block;
3197-
position: fixed;
3198-
left: 50%;
3199-
bottom: 0;
32003223
color: #eee;
3201-
width: 800px;
32023224
border: 1px solid rgb(255 255 255 / 70%);
3203-
border-bottom: 0;
32043225
font-size: 0.8rem;
3205-
z-index: 120;
3206-
transform: translate(-50%, 0);
3207-
border-top-left-radius: 6px;
3208-
border-top-right-radius: 6px;
3226+
border-radius: 6px;
32093227
box-shadow: 0 4px 30px rgb(0 0 0 / 50%);
3210-
line-height: 0.9rem;
32113228
}
32123229

32133230
.shortcuts-header {
32143231
display: flex;
32153232
align-items: center;
32163233
justify-content: space-between;
32173234
border-bottom: 1px solid #606060;
3218-
padding: 10px 10px 10px 15px;
3235+
padding: 10px 10px 10px 20px;
32193236
}
32203237

32213238
.shortcuts-title {
@@ -3228,7 +3245,7 @@ form#vstobjects.suspended {
32283245

32293246
.shortcuts-close {
32303247
cursor: pointer;
3231-
padding: 5px;
3248+
padding: 5px 10px;
32323249
}
32333250

32343251
.shortcuts-close:hover {
@@ -3239,103 +3256,35 @@ form#vstobjects.suspended {
32393256
color: #a60000;
32403257
}
32413258

3242-
.shortcuts-inner {
3243-
display: flex;
3244-
width: 100%;
3259+
.shortcuts-inner {}
3260+
3261+
@media screen and (min-width: 768px) {
3262+
3263+
.shortcuts-inner {
3264+
display: flex;
3265+
}
32453266
}
32463267

3247-
.shortcuts ul {
3268+
.shortcuts-list {
32483269
flex-grow: 1;
3249-
padding: 40px 20px;
3270+
padding: 40px;
32503271
}
32513272

3252-
.shortcuts ul li {
3273+
.shortcuts li {
32533274
padding: 5px 20px;
32543275
}
32553276

3256-
.shortcuts ul li span {
3277+
.shortcuts .key {
32573278
color: #ff3478;
32583279
display: inline-block;
32593280
font-weight: 600;
3260-
padding: 0 20px 0 0;
3261-
text-align: right;
3281+
padding-right: 20px;
32623282
}
32633283

3264-
.shortcuts ul li span.bigger {
3284+
.shortcuts .key.bigger {
32653285
font-size: 18px;
32663286
}
32673287

3268-
.description {
3269-
font-weight: normal;
3270-
line-height: 25px;
3271-
padding-bottom: 45px;
3272-
margin-left: 50px;
3273-
}
3274-
3275-
.description ul {
3276-
margin-top: 15px;
3277-
padding-left: 0;
3278-
}
3279-
3280-
.description li {
3281-
margin: 10px 0;
3282-
}
3283-
3284-
.description a {
3285-
line-height: 30px;
3286-
text-decoration: underline;
3287-
color: #326b9b;
3288-
}
3289-
3290-
.description a.purchase {
3291-
color: #fff;
3292-
background-color: #3b9de8;
3293-
border: none;
3294-
border-radius: 3px;
3295-
font-size: 0.8rem;
3296-
font-weight: 600;
3297-
padding: 7px 15px;
3298-
text-transform: capitalize;
3299-
text-decoration: none;
3300-
}
3301-
3302-
.description a.cancel {
3303-
background-color: #999;
3304-
border: none;
3305-
border-radius: 3px;
3306-
color: #fff;
3307-
font-size: 0.8rem;
3308-
font-weight: 600;
3309-
padding: 7px 15px;
3310-
text-transform: capitalize;
3311-
text-decoration: none;
3312-
}
3313-
3314-
.description a.cancel:hover {
3315-
background-color: #326b9b;
3316-
}
3317-
3318-
.description a.cancel:active {
3319-
background-color: #5f9491;
3320-
}
3321-
3322-
.description.cancel-success {
3323-
color: #8fac0a;
3324-
font-weight: 600;
3325-
}
3326-
3327-
.description span {
3328-
font-style: italic;
3329-
line-height: 45px;
3330-
padding-top: 20px;
3331-
}
3332-
3333-
.description .twoco {
3334-
font-style: italic;
3335-
line-height: 15px;
3336-
font-size: 0.8rem;
3337-
}
3338-
33393288
.ui-dialog {
33403289
font-family: Exo, Arial, Helvetica, sans-serif;
33413290
font-weight: 500;
@@ -3369,8 +3318,7 @@ form#vstobjects.suspended {
33693318
}
33703319

33713320
.ui-widget-overlay {
3372-
opacity: 0.8;
3373-
background: rgb(10 10 10 / 90%);
3321+
background-color: rgb(0 0 0 / 60%);
33743322
}
33753323

33763324
.helper-container {
@@ -3762,10 +3710,6 @@ li[aria-expanded="true"] a {
37623710
padding-top: 18px !important;
37633711
}
37643712

3765-
.u-pt30 {
3766-
padding-top: 30px !important;
3767-
}
3768-
37693713
.u-pl30 {
37703714
padding-left: 30px !important;
37713715
}

web/css/src/themes/vestia.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ strong {
478478
}
479479

480480
.shortcuts-title,
481-
.shortcuts ul li span {
481+
.shortcuts .key {
482482
color: #b5da0b;
483483
}
484484

web/css/themes/dark.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/css/themes/default.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/css/themes/vestia.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/init.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ $(document).ready(function(){
337337
);
338338

339339
shortcut.add("h", function(){
340-
$('.shortcuts').toggleClass('u-hidden');
340+
var shortcutsDialog = document.querySelector('.shortcuts');
341+
if (shortcutsDialog.open) {
342+
shortcutsDialog.close();
343+
} else {
344+
shortcutsDialog.showModal();
345+
}
341346
}, {
342347
'type': 'keydown',
343348
'propagate': false,
@@ -347,7 +352,10 @@ $(document).ready(function(){
347352
);
348353

349354
shortcut.add("Esc", function(){
350-
$('.shortcuts').addClass('u-hidden');
355+
var shortcutsDialog = document.querySelector('.shortcuts');
356+
if (shortcutsDialog.open) {
357+
shortcutsDialog.close();
358+
}
351359
$('input, checkbox, textarea, select').blur();
352360
}, {
353361
'type': 'keydown',
@@ -536,14 +544,21 @@ $(document).ready(function(){
536544
}
537545
);
538546

539-
540-
541-
$('.shortcuts-close').click(function(){
542-
$('.shortcuts').addClass('u-hidden');
547+
document.querySelector('.shortcuts-close').addEventListener('click', function(){
548+
var shortcutsDialog = document.querySelector('.shortcuts');
549+
if (shortcutsDialog.open) {
550+
shortcutsDialog.close();
551+
}
543552
});
544553

545-
$('.to-shortcuts').click(function(){
546-
$('.shortcuts').toggleClass('u-hidden');
554+
document.querySelector('.to-shortcuts').addEventListener('click', function() {
555+
event.preventDefault();
556+
var shortcutsDialog = document.querySelector('.shortcuts');
557+
if (shortcutsDialog.open) {
558+
shortcutsDialog.close();
559+
} else {
560+
shortcutsDialog.showModal();
561+
}
547562
});
548563

549564
$(document).click(function(evt){

0 commit comments

Comments
 (0)