Rename file modal select and focus filename
This commit is contained in:
@@ -1203,6 +1203,16 @@ export function renameFile(oldName, folder) {
|
|||||||
window.fileFolder = folder || window.currentFolder || "root";
|
window.fileFolder = folder || window.currentFolder || "root";
|
||||||
document.getElementById("newFileName").value = oldName;
|
document.getElementById("newFileName").value = oldName;
|
||||||
document.getElementById("renameFileModal").style.display = "block";
|
document.getElementById("renameFileModal").style.display = "block";
|
||||||
|
setTimeout(() => {
|
||||||
|
const input = document.getElementById("newFileName");
|
||||||
|
input.focus();
|
||||||
|
const lastDot = oldName.lastIndexOf('.');
|
||||||
|
if (lastDot > 0) {
|
||||||
|
input.setSelectionRange(0, lastDot);
|
||||||
|
} else {
|
||||||
|
input.select();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|||||||
@@ -4,20 +4,13 @@ import { toggleVisibility, showToast } from './domUtils.js';
|
|||||||
import { loadFileList } from './fileManager.js';
|
import { loadFileList } from './fileManager.js';
|
||||||
import { loadFolderTree } from './folderManager.js';
|
import { loadFolderTree } from './folderManager.js';
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a custom confirmation modal with the given message.
|
|
||||||
* Calls onConfirm() if the user confirms.
|
|
||||||
*/
|
|
||||||
function showConfirm(message, onConfirm) {
|
function showConfirm(message, onConfirm) {
|
||||||
// Assume your custom confirm modal exists with id "customConfirmModal"
|
|
||||||
// and has elements "confirmMessage", "confirmYesBtn", and "confirmNoBtn".
|
|
||||||
const modal = document.getElementById("customConfirmModal");
|
const modal = document.getElementById("customConfirmModal");
|
||||||
const messageElem = document.getElementById("confirmMessage");
|
const messageElem = document.getElementById("confirmMessage");
|
||||||
const yesBtn = document.getElementById("confirmYesBtn");
|
const yesBtn = document.getElementById("confirmYesBtn");
|
||||||
const noBtn = document.getElementById("confirmNoBtn");
|
const noBtn = document.getElementById("confirmNoBtn");
|
||||||
|
|
||||||
if (!modal || !messageElem || !yesBtn || !noBtn) {
|
if (!modal || !messageElem || !yesBtn || !noBtn) {
|
||||||
// Fallback to browser confirm if custom modal is not found.
|
|
||||||
if (confirm(message)) {
|
if (confirm(message)) {
|
||||||
onConfirm();
|
onConfirm();
|
||||||
}
|
}
|
||||||
@@ -42,10 +35,6 @@ function showConfirm(message, onConfirm) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up event listeners for trash restore and delete operations.
|
|
||||||
* This function should be called from main.js after authentication.
|
|
||||||
*/
|
|
||||||
export function setupTrashRestoreDelete() {
|
export function setupTrashRestoreDelete() {
|
||||||
|
|
||||||
// --- Attach listener to the restore button (created in auth.js) to open the modal.
|
// --- Attach listener to the restore button (created in auth.js) to open the modal.
|
||||||
|
|||||||
Reference in New Issue
Block a user