fixing up the dialog class with other bug fixes
This commit is contained in:
parent
b57988e734
commit
8e87635209
9 changed files with 55 additions and 66 deletions
|
@ -28,12 +28,12 @@ type dialogjson=[
|
|||
"tabs",[string,dialogjson][]
|
||||
]
|
||||
class Dialog{
|
||||
layout;
|
||||
layout:dialogjson;
|
||||
onclose: Function;
|
||||
onopen: Function;
|
||||
html:HTMLDivElement;
|
||||
background: HTMLDivElement;
|
||||
constructor(layout,onclose=_=>{},onopen=_=>{}){
|
||||
constructor(layout:dialogjson,onclose=_=>{},onopen=_=>{}){
|
||||
this.layout=layout;
|
||||
this.onclose=onclose;
|
||||
this.onopen=onopen;
|
||||
|
@ -60,28 +60,24 @@ class Dialog{
|
|||
}
|
||||
return img;
|
||||
case"hdiv":
|
||||
const hdiv=document.createElement("table");
|
||||
const tr=document.createElement("tr");
|
||||
hdiv.appendChild(tr);
|
||||
const hdiv=document.createElement("div");
|
||||
hdiv.classList.add("flexltr")
|
||||
|
||||
for(const thing of array){
|
||||
if(thing==="hdiv"){
|
||||
continue;
|
||||
}
|
||||
const td=document.createElement("td");
|
||||
td.appendChild(this.tohtml(thing));
|
||||
tr.appendChild(td);
|
||||
hdiv.appendChild(this.tohtml(thing));
|
||||
}
|
||||
return hdiv;
|
||||
case"vdiv":
|
||||
const vdiv=document.createElement("table");
|
||||
const vdiv=document.createElement("div");
|
||||
vdiv.classList.add("flexttb");
|
||||
for(const thing of array){
|
||||
if(thing==="vdiv"){
|
||||
continue;
|
||||
}
|
||||
const tr=document.createElement("tr");
|
||||
tr.appendChild(this.tohtml(thing));
|
||||
vdiv.appendChild(tr);
|
||||
vdiv.appendChild(this.tohtml(thing));
|
||||
}
|
||||
return vdiv;
|
||||
case"checkbox":
|
||||
|
@ -225,36 +221,35 @@ class Dialog{
|
|||
return div;
|
||||
}
|
||||
case"tabs":{
|
||||
const table=document.createElement("table");
|
||||
const tabs=document.createElement("tr");
|
||||
const table=document.createElement("div");
|
||||
table.classList.add("flexttb");
|
||||
const tabs=document.createElement("div");
|
||||
tabs.classList.add("flexltr")
|
||||
tabs.classList.add("tabbed-head");
|
||||
table.appendChild(tabs);
|
||||
const td=document.createElement("td");
|
||||
tabs.appendChild(td);
|
||||
const content=document.createElement("tr");
|
||||
const content=document.createElement("div");
|
||||
content.classList.add("tabbed-content");
|
||||
table.appendChild(content);
|
||||
|
||||
let shown;
|
||||
let shown:HTMLElement|undefined;
|
||||
for(const thing of array[1]){
|
||||
const button=document.createElement("button");
|
||||
button.textContent=thing[0];
|
||||
td.appendChild(button);
|
||||
tabs.appendChild(button);
|
||||
|
||||
|
||||
const tdcontent=document.createElement("td");
|
||||
tdcontent.colSpan=array[1].length;
|
||||
tdcontent.appendChild(this.tohtml(thing[1]));
|
||||
content.appendChild(tdcontent);
|
||||
const html=this.tohtml(thing[1]);
|
||||
content.append(html);
|
||||
if(!shown){
|
||||
shown=tdcontent;
|
||||
shown=html;
|
||||
}else{
|
||||
tdcontent.hidden=true;
|
||||
html.style.display="none";
|
||||
}
|
||||
button.addEventListener("click",_=>{
|
||||
shown.hidden=true;
|
||||
tdcontent.hidden=false;
|
||||
shown=tdcontent;
|
||||
if(shown){
|
||||
shown.style.display="none";
|
||||
}
|
||||
html.style.display="";
|
||||
shown=html;
|
||||
});
|
||||
}
|
||||
return table;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { SnowFlake } from "./snowflake.js";
|
|||
import { Contextmenu } from "./contextmenu.js";
|
||||
|
||||
class Direct extends Guild{
|
||||
channelids:{[key:string]:Group};
|
||||
declare channelids:{[key:string]:Group};
|
||||
getUnixTime(): number {
|
||||
throw new Error("Do not call this for Direct, it does not make sense");
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class InfiniteScroller{
|
|||
}
|
||||
currrunning:boolean=false;
|
||||
async addedBottom(){
|
||||
this.updatestuff();
|
||||
await this.updatestuff();
|
||||
const func=this.snapBottom();
|
||||
await this.watchForChange();
|
||||
func();
|
||||
|
@ -100,7 +100,7 @@ class InfiniteScroller{
|
|||
snapBottom(){
|
||||
const scrollBottom=this.scrollBottom;
|
||||
return()=>{
|
||||
if(this.div&&scrollBottom<10){
|
||||
if(this.div&&scrollBottom<4){
|
||||
this.div.scrollTop=this.div.scrollHeight+20;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1192,7 +1192,7 @@ class Localuser{
|
|||
json.icon ? ["img", this.info.cdn+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
||||
["fileupload", "Application icon:", event=>{
|
||||
const reader=new FileReader();
|
||||
reader.readAsDataURL(event.target.files[0]);
|
||||
reader.readAsDataURL((event.target as HTMLInputElement).files[0]);
|
||||
reader.onload=()=>{
|
||||
fields.icon=reader.result;
|
||||
};
|
||||
|
@ -1280,7 +1280,7 @@ class Localuser{
|
|||
fields.avatar ? ["img", fields.avatar, [128, 128]] : ["text", "No avatar"],
|
||||
["fileupload", "Bot avatar:", event=>{
|
||||
const reader=new FileReader();
|
||||
reader.readAsDataURL(event.target.files[0]);
|
||||
reader.readAsDataURL((event.target as HTMLInputElement).files[0]);
|
||||
reader.onload=()=>{
|
||||
fields.avatar=reader.result;
|
||||
};
|
||||
|
|
|
@ -1054,6 +1054,7 @@ span {
|
|||
}
|
||||
.tabbed-head{
|
||||
background: var(--profile-info-bg);
|
||||
width: 100%;
|
||||
}
|
||||
.tabbed-content td{
|
||||
/* border-color: var(--textarea-bg); */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue