Skip to content

Commit 420f695

Browse files
authored
Merge pull request #6 from makermelissa/main
Bug fixes and updates for mobile
2 parents 18e34a7 + e8f9763 commit 420f695

File tree

15 files changed

+492
-241
lines changed

15 files changed

+492
-241
lines changed

assets/css/style.css

Lines changed: 138 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/style.css.map

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

assets/js/file_dialog.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class FileDialog {
142142
async _openFolder(path) {
143143
const fileList = this._currentModal.querySelector("#file-list");
144144
const okButton = this._currentModal.querySelector("button.ok-button");
145+
const fileName = this._currentModal.querySelector("#filename");
145146
this._removeAllChildNodes(fileList);
146147
if (path !== undefined) {
147148
this._currentPath = path;
@@ -167,6 +168,7 @@ class FileDialog {
167168
} catch(e) {
168169
console.log(e);
169170
}
171+
fileName.value = "";
170172
okButton.disabled = true;
171173
}
172174

@@ -218,26 +220,31 @@ class FileDialog {
218220

219221
async _openItem(item) {
220222
const fileNameField = this._currentModal.querySelector("#filename");
223+
const fileList = this._currentModal.querySelector("#file-list");
221224
let filetype, filename;
225+
let selectedItem = null;
226+
227+
// Loop through items and see if any have data-selected
228+
for (let listItem of fileList.childNodes) {
229+
if ((/true/i).test(listItem.getAttribute("data-selected"))) {
230+
selectedItem = listItem;
231+
}
232+
}
222233

223234
if (item !== undefined) {
224235
filetype = item.getAttribute("data-type");
225236
filename = item.querySelector("span").innerHTML;
226237
} else if (this._validFilename(fileNameField.value)) {
227-
filename = fileNameField.value;
228-
filetype = "text";
229-
} else {
230-
// Loop through items and see if any have data-selected
231-
const fileList = this._currentModal.querySelector("#file-list");
232-
for (let listItem of fileList.childNodes) {
233-
if ((/true/i).test(listItem.getAttribute("data-selected"))) {
234-
item = listItem;
235-
}
236-
}
237-
if (item !== undefined) {
238-
filetype = item.getAttribute("data-type");
239-
filename = item.querySelector("span").innerHTML;
238+
if (selectedItem !== null && fileNameField.value != selectedItem.querySelector("span").innerHTML) {
239+
filetype = selectedItem.getAttribute("data-type");
240+
filename = selectedItem.querySelector("span").innerHTML;
241+
} else {
242+
filename = fileNameField.value;
243+
filetype = "text";
240244
}
245+
} else if (selectedItem !== null) {
246+
filetype = selectedItem.getAttribute("data-type");
247+
filename = selectedItem.querySelector("span").innerHTML;
241248
}
242249

243250
if (filename !== undefined && filetype !== undefined) {

assets/js/header_mobile.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
document.getElementById('mobile-menu-button').addEventListener('click', handleMobileToggle);
3+
document.querySelectorAll('#mobile-menu-contents li a').forEach((element) => {
4+
element.addEventListener('click', handleMobileToggle);
5+
});
6+
});
7+
8+
function handleMobileToggle(event) {
9+
event.preventDefault();
10+
11+
var menuContainer = document.getElementById('mobile-menu-contents');
12+
13+
menuContainer.classList.toggle('hidden');
14+
15+
var menuIcon = document.querySelector('#mobile-menu-button > i');
16+
if (menuContainer.classList.contains('hidden')) {
17+
menuIcon.classList.replace('fa-times', 'fa-bars');
18+
} else {
19+
menuIcon.classList.replace('fa-bars', 'fa-times');
20+
}
21+
}

0 commit comments

Comments
 (0)