fix contextmenu in el7 and default link target

This commit is contained in:
joshuaboud 2021-06-02 13:37:52 -03:00
parent e387f77688
commit 56f3c94b06
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E
3 changed files with 17 additions and 8 deletions

View File

@ -471,6 +471,7 @@ input:checked + .slider:before {
} }
.nav-context-menu { .nav-context-menu {
display: none;
position: absolute; position: absolute;
background-color: var(--container); background-color: var(--container);
border: 1px solid var(--border); border: 1px solid var(--border);

View File

@ -178,6 +178,6 @@
</div> </div>
</div> </div>
</body> </body>
<div class="nav-context-menu flex-col" id="nav-context-menu" hidden> <div class="nav-context-menu flex-col" id="nav-context-menu">
</div> </div>
</html> </html>

View File

@ -721,7 +721,7 @@ class NavContextMenu {
this.dom_element = document.getElementById(id); this.dom_element = document.getElementById(id);
this.nav_window_ref = nav_window_ref; this.nav_window_ref = nav_window_ref;
this.menu_options = {}; this.menu_options = {};
window.addEventListener("click", (event) => { document.documentElement.addEventListener("click", (event) => {
if (event.target !== this.dom_element) if (event.target !== this.dom_element)
this.hide(); this.hide();
}); });
@ -738,7 +738,7 @@ class NavContextMenu {
this.dom_element.appendChild(elem); this.dom_element.appendChild(elem);
this.menu_options[func] = elem; this.menu_options[func] = elem;
} }
this.menu_options["paste"].hidden = true; this.menu_options["paste"].style.display = "none";
} }
new_dir() { new_dir() {
@ -750,7 +750,10 @@ class NavContextMenu {
} }
new_link() { new_link() {
this.nav_window_ref.ln(); var default_target = "";
if (this.target !== this.nav_window_ref.pwd())
default_target = this.target.filename();
this.nav_window_ref.ln(default_target);
} }
cut() { cut() {
@ -814,14 +817,19 @@ class NavContextMenu {
this.menu_options["cut"].hidden = false; this.menu_options["cut"].hidden = false;
this.menu_options["delete"].hidden = false; this.menu_options["delete"].hidden = false;
} }
if (this.nav_window_ref.selected_entries.size > 1) {
this.menu_options["rename"].hidden = true;
} else {
this.menu_options["rename"].hidden = false;
}
this.target = target; this.target = target;
this.dom_element.hidden = false; this.dom_element.style.display = "inline";
this.dom_element.style.left = event.clientX + "px"; this.dom_element.style.left = event.clientX + "px";
this.dom_element.style.top = event.clientY + "px"; this.dom_element.style.top = event.clientY + "px";
} }
hide() { hide() {
this.dom_element.hidden = true; this.dom_element.style.display = "none";
} }
hide_paste() { hide_paste() {
@ -1193,8 +1201,8 @@ class NavWindow {
this.refresh(); this.refresh();
} }
async ln() { async ln(default_target = "") {
var link_target = window.prompt("Link Target: "); var link_target = window.prompt("Link Target: ", default_target);
if (link_target === null) if (link_target === null)
return; return;
var link_name = window.prompt("Link Name: "); var link_name = window.prompt("Link Name: ");