mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Ask for confirmation before removing something
This commit is contained in:
parent
25a5250eb9
commit
5983db1a77
15 changed files with 165 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-11-20 18:31:16.964945842 -0800 PST m=+0.004093224
|
||||
// 2017-11-21 14:38:46.651098874 -0800 PST m=+0.002920446
|
||||
|
||||
package static
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -167,13 +167,6 @@ th {
|
|||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
.table-overflow td {
|
||||
max-width: 0;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
@ -213,7 +206,7 @@ input[type="password"],
|
|||
input[type="text"] {
|
||||
border: 1px solid #ccc;
|
||||
padding: 3px;
|
||||
line-height: 15px;
|
||||
line-height: 20px;
|
||||
width: 250px;
|
||||
font-size: 99%;
|
||||
margin-bottom: 10px;
|
||||
|
@ -652,3 +645,17 @@ a.button {
|
|||
.enclosure-image img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Confirmation */
|
||||
.confirm {
|
||||
font-weight: 500;
|
||||
color: #ed2d04;
|
||||
}
|
||||
|
||||
.confirm a {
|
||||
color: #ed2d04;
|
||||
}
|
||||
|
||||
.loading {
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2017-11-20 18:31:16.972315949 -0800 PST m=+0.011463331
|
||||
// 2017-11-21 14:38:46.652422004 -0800 PST m=+0.004243576
|
||||
|
||||
package static
|
||||
|
||||
|
@ -15,7 +15,9 @@ getKey(event){const mapping={'Esc':'Escape','Up':'ArrowUp','Down':'ArrowDown','L
|
|||
return event.key;}}
|
||||
class FormHandler{static handleSubmitButtons(){let elements=document.querySelectorAll("form");elements.forEach(function(element){element.onsubmit=function(){let button=document.querySelector("button");if(button){button.innerHTML=button.dataset.labelLoading;button.disabled=true;}};});}}
|
||||
class MouseHandler{onClick(selector,callback){let elements=document.querySelectorAll(selector);elements.forEach((element)=>{element.onclick=(event)=>{event.preventDefault();callback(event);};});}}
|
||||
class App{run(){FormHandler.handleSubmitButtons();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>this.goToPage("unread"));keyboardHandler.on("g h",()=>this.goToPage("history"));keyboardHandler.on("g f",()=>this.goToPage("feeds"));keyboardHandler.on("g c",()=>this.goToPage("categories"));keyboardHandler.on("g s",()=>this.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>this.goToPrevious());keyboardHandler.on("ArrowRight",()=>this.goToNext());keyboardHandler.on("j",()=>this.goToPrevious());keyboardHandler.on("p",()=>this.goToPrevious());keyboardHandler.on("k",()=>this.goToNext());keyboardHandler.on("n",()=>this.goToNext());keyboardHandler.on("h",()=>this.goToPage("previous"));keyboardHandler.on("l",()=>this.goToPage("next"));keyboardHandler.on("o",()=>this.openSelectedItem());keyboardHandler.on("v",()=>this.openOriginalLink());keyboardHandler.on("m",()=>this.toggleEntryStatus());keyboardHandler.on("A",()=>this.markPageAsRead());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>this.markPageAsRead());if(document.documentElement.clientWidth<600){mouseHandler.onClick(".logo",()=>this.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>this.clickMenuListItem(event));}}
|
||||
class App{run(){FormHandler.handleSubmitButtons();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>this.goToPage("unread"));keyboardHandler.on("g h",()=>this.goToPage("history"));keyboardHandler.on("g f",()=>this.goToPage("feeds"));keyboardHandler.on("g c",()=>this.goToPage("categories"));keyboardHandler.on("g s",()=>this.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>this.goToPrevious());keyboardHandler.on("ArrowRight",()=>this.goToNext());keyboardHandler.on("j",()=>this.goToPrevious());keyboardHandler.on("p",()=>this.goToPrevious());keyboardHandler.on("k",()=>this.goToNext());keyboardHandler.on("n",()=>this.goToNext());keyboardHandler.on("h",()=>this.goToPage("previous"));keyboardHandler.on("l",()=>this.goToPage("next"));keyboardHandler.on("o",()=>this.openSelectedItem());keyboardHandler.on("v",()=>this.openOriginalLink());keyboardHandler.on("m",()=>this.toggleEntryStatus());keyboardHandler.on("A",()=>this.markPageAsRead());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>this.markPageAsRead());mouseHandler.onClick("a[data-confirm]",(event)=>this.confirm(event));if(document.documentElement.clientWidth<600){mouseHandler.onClick(".logo",()=>this.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>this.clickMenuListItem(event));}}
|
||||
remove(url){let request=new Request(url,{method:"POST",cache:"no-cache",credentials:"include",headers:new Headers({"X-Csrf-Token":this.getCsrfToken()})});fetch(request).then(()=>{window.location.reload();});}
|
||||
confirm(event){let questionElement=document.createElement("span");let linkElement=event.target;let containerElement=linkElement.parentNode;linkElement.style.display="none";let yesElement=document.createElement("a");yesElement.href="#";yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));yesElement.onclick=(event)=>{event.preventDefault();let loadingElement=document.createElement("span");loadingElement.className="loading";loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));questionElement.remove();containerElement.appendChild(loadingElement);this.remove(linkElement.dataset.url);};let noElement=document.createElement("a");noElement.href="#";noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));noElement.onclick=(event)=>{event.preventDefault();linkElement.style.display="inline";questionElement.remove();};questionElement.className="confirm";questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion+" "));questionElement.appendChild(yesElement);questionElement.appendChild(document.createTextNode(", "));questionElement.appendChild(noElement);containerElement.appendChild(questionElement);}
|
||||
clickMenuListItem(event){let element=event.target;console.log(element);if(element.tagName==="A"){window.location.href=element.getAttribute("href");}else{window.location.href=element.querySelector("a").getAttribute("href");}}
|
||||
toggleMainMenu(){let menu=document.querySelector(".header nav ul");if(this.isVisible(menu)){menu.style.display="none";}else{menu.style.display="block";}}
|
||||
updateEntriesStatus(entryIDs,status){let url=document.body.dataset.entriesStatusUrl;let request=new Request(url,{method:"POST",cache:"no-cache",credentials:"include",body:JSON.stringify({entry_ids:entryIDs,status:status}),headers:new Headers({"Content-Type":"application/json","X-Csrf-Token":this.getCsrfToken()})});fetch(request);}
|
||||
|
@ -48,5 +50,5 @@ document.addEventListener("DOMContentLoaded",function(){(new App()).run();});})(
|
|||
}
|
||||
|
||||
var JavascriptChecksums = map[string]string{
|
||||
"app": "e250c2af19dea14fd75681a81080cf183919a7a589b0886a093586ee894c8282",
|
||||
"app": "cc5edd35e9e10e45cd84487bd11bed357f4e759917da1c83137f3c37006edd6f",
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ class App {
|
|||
|
||||
let mouseHandler = new MouseHandler();
|
||||
mouseHandler.onClick("a[data-on-click=markPageAsRead]", () => this.markPageAsRead());
|
||||
mouseHandler.onClick("a[data-confirm]", (event) => this.confirm(event));
|
||||
|
||||
if (document.documentElement.clientWidth < 600) {
|
||||
mouseHandler.onClick(".logo", () => this.toggleMainMenu());
|
||||
|
@ -127,6 +128,61 @@ class App {
|
|||
}
|
||||
}
|
||||
|
||||
remove(url) {
|
||||
let request = new Request(url, {
|
||||
method: "POST",
|
||||
cache: "no-cache",
|
||||
credentials: "include",
|
||||
headers: new Headers({
|
||||
"X-Csrf-Token": this.getCsrfToken()
|
||||
})
|
||||
});
|
||||
|
||||
fetch(request).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
confirm(event) {
|
||||
let questionElement = document.createElement("span");
|
||||
let linkElement = event.target;
|
||||
let containerElement = linkElement.parentNode;
|
||||
linkElement.style.display = "none";
|
||||
|
||||
let yesElement = document.createElement("a");
|
||||
yesElement.href = "#";
|
||||
yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));
|
||||
yesElement.onclick = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let loadingElement = document.createElement("span");
|
||||
loadingElement.className = "loading";
|
||||
loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));
|
||||
|
||||
questionElement.remove();
|
||||
containerElement.appendChild(loadingElement);
|
||||
|
||||
this.remove(linkElement.dataset.url);
|
||||
};
|
||||
|
||||
let noElement = document.createElement("a");
|
||||
noElement.href = "#";
|
||||
noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));
|
||||
noElement.onclick = (event) => {
|
||||
event.preventDefault();
|
||||
linkElement.style.display = "inline";
|
||||
questionElement.remove();
|
||||
};
|
||||
|
||||
questionElement.className = "confirm";
|
||||
questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion + " "));
|
||||
questionElement.appendChild(yesElement);
|
||||
questionElement.appendChild(document.createTextNode(", "));
|
||||
questionElement.appendChild(noElement);
|
||||
|
||||
containerElement.appendChild(questionElement);
|
||||
}
|
||||
|
||||
clickMenuListItem(event) {
|
||||
let element = event.target;console.log(element);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue