Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Commit 79613b5

Browse files
MichaelpalacceMichaelpalacce
Michaelpalacce
authored and
Michaelpalacce
committed
[master] V8.3.0
1 parent 836c0b0 commit 79613b5

11 files changed

+371
-110
lines changed

UPDATELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
8.3.0
2+
- Added Modal logic
3+
- Added modals instead of prompts and alerts
4+
- Moved the Upload Folder button to the sidebar
5+
- The mobile design now works correctly
6+
- Updated the design a bit
7+
18
8.2.5
29
- Small design fix
310

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "server-emulator",
3-
"version": "8.2.5",
3+
"version": "8.3.0",
44
"description": "Server emulator used to easily emulate the FS in a browser and allow streaming,downloading,deletion, etc.",
55
"main": "index.js",
66
"scripts": {

public/css/folder-upload.css

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
1-
21
.inputfile {
3-
width: 0.1px;
4-
height: 0.1px;
2+
width: 0px;
3+
height: 0px;
54
opacity: 0;
65
overflow: hidden;
7-
position: absolute;
86
z-index: -1;
97
}
10-
.inputfile + label {
11-
border-radius: 10px;
12-
font-size: 1.25em;
13-
font-weight: 700;
14-
color: white;
15-
padding: 10px;
16-
background-color: slategrey;
17-
display: inline-block;
18-
}
19-
20-
.inputfile:focus + label,
21-
.inputfile + label:hover {
22-
background-color: #c55454;
23-
}
248

259
.inputfile + label {
10+
color: rgba(255,255,255,.5);;
2611
cursor: pointer; /* "hand" cursor */
2712
}
2813

2914
.inputfile:focus + label {
3015
outline: 1px dotted #000;
3116
outline: -webkit-focus-ring-color auto 5px;
32-
}
17+
}

public/css/modal.css

+33-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.modal {
22
display: none;
33
position: fixed;
4-
z-index: 1;
4+
z-index: 99999;
55
padding-top: 100px;
66
left: 0;
77
top: 0;
@@ -12,24 +12,50 @@
1212
background-color: rgba(0,0,0,0.4);
1313
}
1414

15+
16+
@media (min-width: 768px) {
17+
.modal-content {
18+
background-color: #fefefe;
19+
margin: auto;
20+
padding: 20px;
21+
border: 1px solid #888;
22+
width: 35% !important;
23+
}
24+
}
25+
1526
.modal-content {
16-
background-color: #fefefe;
17-
margin: auto;
18-
padding: 20px;
19-
border: 1px solid #888;
20-
width: 80%;
27+
width: 100%;
28+
padding-bottom: 25px;
2129
}
2230

2331
.close {
2432
color: #aaaaaa;
2533
font-size: 28px;
2634
font-weight: bold;
2735
text-align: right;
36+
text-shadow: none!important;
2837
}
2938

3039
.close:hover,
3140
.close:focus {
32-
color: #000;
41+
color: #c55454;
3342
text-decoration: none;
3443
cursor: pointer;
44+
}
45+
46+
.btn-outline-main-red{
47+
color: #c55454;
48+
border-color: #c55454;
49+
background: transparent;
50+
}
51+
52+
.btn-outline-main-red:hover{
53+
color: white;
54+
border-color: #c55454;
55+
background: #c55454;
56+
}
57+
58+
.choice-button
59+
{
60+
margin: 10px;
3561
}

public/css/sidebar.css

+24-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,27 @@ body {
6262
.navbar.fixed-left .navbar-nav .nav-item .dropdown-menu {
6363
left: 100%;
6464
}
65-
}
65+
}
66+
67+
.navbar{
68+
background: #343a40!important;
69+
border-bottom: 1px solid gray;
70+
}
71+
72+
.nav-line
73+
{
74+
margin-top: 50px;
75+
margin-bottom: 10px;
76+
border-bottom: 1px solid #c55454;
77+
}
78+
79+
.navbar-action{
80+
font-size: 1.25em;
81+
font-weight: bold;
82+
display: inline-block;
83+
text-align: center;
84+
}
85+
86+
.dropdown-item:hover{
87+
background: transparent!important;
88+
}

public/js/contextMenu.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,26 @@ class ContextMenu
129129
event.preventDefault();
130130
event.stopPropagation();
131131
event.stopImmediatePropagation();
132+
this.element.hide();
132133

133-
const newName = prompt( 'What is the new name of the file' );
134-
135-
$.ajax({
136-
url : '/file/rename',
137-
method :'POST',
138-
data : {
139-
newPath: this.view.currentDir + encodeURIComponent( '/' + newName ),
140-
oldPath: this.getElementPath( target )
141-
},
142-
success : ( data )=>
143-
{
144-
target.remove();
145-
this.view.fetchDataForFileAndAddItem( encodeURIComponent( JSON.parse( data ).newPath ) );
146-
this.flushActionElementData();
147-
},
148-
error : this.view.showError.bind( this.view )
134+
const oldName = target.closest( '.item' ).attr( 'data-item-name' );
135+
modal.askUserInput( 'What is the new name of the file', oldName ).then( ( newName )=>{
136+
$.ajax({
137+
url : '/file/rename',
138+
method :'POST',
139+
data : {
140+
newPath: this.view.currentDir + encodeURIComponent( '/' + newName ),
141+
oldPath: this.getElementPath( target )
142+
},
143+
success : ( data )=>
144+
{
145+
target.remove();
146+
this.view.fetchDataForFileAndAddItem( encodeURIComponent( JSON.parse( data ).newPath ) );
147+
this.flushActionElementData();
148+
},
149+
error : this.view.showError.bind( this.view )
150+
});
149151
});
150-
151-
this.element.hide();
152152
} ).show();
153153
break;
154154

@@ -163,6 +163,7 @@ class ContextMenu
163163
event.preventDefault();
164164
event.stopPropagation();
165165
event.stopImmediatePropagation();
166+
this.element.hide();
166167

167168
const method = 'POST';
168169
let url = '';
@@ -178,7 +179,7 @@ class ContextMenu
178179

179180
case ACTION_NONE:
180181
default:
181-
alert( 'There is nothing to paste!' );
182+
modal.show( 'There is nothing to paste!' );
182183
return;
183184
}
184185

@@ -200,8 +201,6 @@ class ContextMenu
200201
},
201202
error : this.view.showError.bind( this.view )
202203
});
203-
204-
this.element.hide();
205204
} ).show();
206205
return;
207206
}

public/js/main.js

+45-37
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,32 @@ class View
105105
return;
106106
}
107107

108+
const deleteItemAjax = ()=>{
109+
$.ajax({
110+
url : `/${type}?item=${itemToDelete}`,
111+
method : 'DELETE',
112+
success : function()
113+
{
114+
element.remove();
115+
}
116+
});
117+
};
118+
108119
if ( type === View.TYPE_FOLDER )
109120
{
110-
const confirmDelete = confirm( `Are you sure you want to delete this item?` );
121+
modal.askConfirmation( `Are you sure you want to delete this item?` ).then(( confirmDelete )=>{
122+
if ( ! confirmDelete )
123+
{
124+
return;
125+
}
111126

112-
if ( ! confirmDelete )
113-
{
114-
return;
115-
}
127+
deleteItemAjax();
128+
});
129+
130+
return;
116131
}
117132

118-
$.ajax({
119-
url : `/${type}?item=${itemToDelete}`,
120-
method : 'DELETE',
121-
success : function()
122-
{
123-
element.remove();
124-
}
125-
});
133+
deleteItemAjax();
126134
}
127135

128136
/**
@@ -361,31 +369,31 @@ class View
361369
addFolderElement.off( 'click' );
362370

363371
addFolderElement.on( 'click', ()=>{
364-
const userFolder = prompt( 'Please enter the name of the folder.', 'New Folder' );
365-
366-
if ( userFolder == null || userFolder === '' )
367-
{
368-
return;
369-
}
370-
371-
const folderName = userFolder;
372-
const encodedFolderName = encodeURIComponent( '/' + userFolder );
373-
const encodedUri = decodeURIComponent( this.currentDir ) === '/' ? encodedFolderName : this.currentDir + encodedFolderName;
374-
375-
$.ajax({
376-
url : '/folder',
377-
data : {
378-
folder: encodedUri
379-
},
380-
method : 'POST',
381-
success : ()=>
372+
modal.askUserInput( 'Please enter the name of the folder.', 'New Folder' ).then(( userFolder )=>{
373+
if ( userFolder == null || userFolder === '' )
382374
{
383-
this.addItem( folderName, encodedUri, 0, true, false, 'directory', null );
384-
this.addAddFolderButton();
385-
},
386-
error : this.showError.bind( this )
375+
return;
376+
}
377+
378+
const folderName = userFolder;
379+
const encodedFolderName = encodeURIComponent( '/' + userFolder );
380+
const encodedUri = decodeURIComponent( this.currentDir ) === '/' ? encodedFolderName : this.currentDir + encodedFolderName;
381+
382+
$.ajax({
383+
url : '/folder',
384+
data : {
385+
folder: encodedUri
386+
},
387+
method : 'POST',
388+
success : ()=>
389+
{
390+
this.addItem( folderName, encodedUri, 0, true, false, 'directory', null );
391+
this.addAddFolderButton();
392+
},
393+
error : this.showError.bind( this )
394+
});
387395
});
388-
} );
396+
});
389397
}
390398

391399
/**
@@ -397,7 +405,7 @@ class View
397405
*/
398406
showError( jqXHR )
399407
{
400-
alert( jqXHR.responseText );
408+
modal.show( jqXHR.responseText );
401409
}
402410
}
403411

0 commit comments

Comments
 (0)