more better right click menus
This commit is contained in:
parent
ea0b98e7ce
commit
ebe6c5aae3
4 changed files with 97 additions and 29 deletions
|
@ -101,8 +101,14 @@ class ContextButton<x, y> implements menuPart<x, y> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Seperator<x, y> implements menuPart<x, y> {
|
class Seperator<x, y> implements menuPart<x, y> {
|
||||||
makeContextHTML(_obj1: x, _obj2: y, menu: HTMLDivElement): void {
|
private visable?: (obj1: x, obj2: y) => boolean;
|
||||||
menu.append(document.createElement("hr"));
|
constructor(visable?: (obj1: x, obj2: y) => boolean) {
|
||||||
|
this.visable = visable;
|
||||||
|
}
|
||||||
|
makeContextHTML(obj1: x, obj2: y, menu: HTMLDivElement): void {
|
||||||
|
if (!this.visable || this.visable(obj1, obj2)) {
|
||||||
|
menu.append(document.createElement("hr"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Contextmenu<x, y> {
|
class Contextmenu<x, y> {
|
||||||
|
@ -139,8 +145,8 @@ class Contextmenu<x, y> {
|
||||||
) {
|
) {
|
||||||
this.buttons.push(new ContextButton(text, onClick, addProps));
|
this.buttons.push(new ContextButton(text, onClick, addProps));
|
||||||
}
|
}
|
||||||
addSeperator() {
|
addSeperator(visable?: (obj1: x, obj2: y) => boolean) {
|
||||||
this.buttons.push(new Seperator());
|
this.buttons.push(new Seperator(visable));
|
||||||
}
|
}
|
||||||
private makemenu(x: number, y: number, addinfo: x, other: y) {
|
private makemenu(x: number, y: number, addinfo: x, other: y) {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
|
|
|
@ -342,13 +342,6 @@ class Group extends Channel {
|
||||||
user: User;
|
user: User;
|
||||||
static contextmenu = new Contextmenu<Group, undefined>("channel menu");
|
static contextmenu = new Contextmenu<Group, undefined>("channel menu");
|
||||||
static setupcontextmenu() {
|
static setupcontextmenu() {
|
||||||
this.contextmenu.addButton(
|
|
||||||
() => I18n.getTranslation("DMs.copyId"),
|
|
||||||
function (this: Group) {
|
|
||||||
navigator.clipboard.writeText(this.id);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("DMs.markRead"),
|
() => I18n.getTranslation("DMs.markRead"),
|
||||||
function (this: Group) {
|
function (this: Group) {
|
||||||
|
@ -356,19 +349,32 @@ class Group extends Channel {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator();
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("DMs.close"),
|
() => I18n.getTranslation("DMs.close"),
|
||||||
function (this: Group) {
|
function (this: Group) {
|
||||||
this.deleteChannel();
|
this.deleteChannel();
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
color: "red",
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator();
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.copyId"),
|
() => I18n.getTranslation("user.copyId"),
|
||||||
function () {
|
function () {
|
||||||
navigator.clipboard.writeText(this.user.id);
|
navigator.clipboard.writeText(this.user.id);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
this.contextmenu.addButton(
|
||||||
|
() => I18n.getTranslation("DMs.copyId"),
|
||||||
|
function (this: Group) {
|
||||||
|
navigator.clipboard.writeText(this.id);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
constructor(json: dirrectjson, owner: Direct) {
|
constructor(json: dirrectjson, owner: Direct) {
|
||||||
super(-1, owner, json.id);
|
super(-1, owner, json.id);
|
||||||
|
|
|
@ -835,6 +835,7 @@ span.instanceStatus {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
.liststyle .statusDiv {
|
.liststyle .statusDiv {
|
||||||
right: -1px;
|
right: -1px;
|
||||||
|
@ -2280,6 +2281,35 @@ fieldset input[type="radio"] {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.2in;
|
padding: 0.2in;
|
||||||
|
overflow: scroll;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
background: #00000030;
|
background: #00000030;
|
||||||
margin-bottom: 0.1in;
|
margin-bottom: 0.1in;
|
||||||
|
|
|
@ -164,18 +164,22 @@ class User extends SnowFlake {
|
||||||
this.relationshipType = type;
|
this.relationshipType = type;
|
||||||
}
|
}
|
||||||
static setUpContextMenu(): void {
|
static setUpContextMenu(): void {
|
||||||
this.contextmenu.addButton(
|
|
||||||
() => I18n.getTranslation("user.copyId"),
|
|
||||||
function (this: User) {
|
|
||||||
navigator.clipboard.writeText(this.id);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.message"),
|
() => I18n.getTranslation("user.message"),
|
||||||
function (this: User) {
|
function (this: User) {
|
||||||
this.opendm();
|
this.opendm();
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: {
|
||||||
|
css: "svg-frmessage",
|
||||||
|
},
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator((user) => {
|
||||||
|
return user.id !== user.localuser.user.id;
|
||||||
|
});
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.block"),
|
() => I18n.getTranslation("user.block"),
|
||||||
function (this: User) {
|
function (this: User) {
|
||||||
|
@ -211,6 +215,9 @@ class User extends SnowFlake {
|
||||||
this.id !== this.localuser.user.id
|
this.id !== this.localuser.user.id
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
icon: {
|
||||||
|
css: "svg-addfriend",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
|
@ -224,6 +231,23 @@ class User extends SnowFlake {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator();
|
||||||
|
|
||||||
|
this.contextmenu.addButton(
|
||||||
|
() => I18n.getTranslation("user.editServerProfile"),
|
||||||
|
function (this: User, member: Member | undefined) {
|
||||||
|
if (!member) return;
|
||||||
|
member.showEditProfile();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
visable: function (member) {
|
||||||
|
return member?.id === this.localuser.user.id;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
//TODO kick icon
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.kick"),
|
() => I18n.getTranslation("user.kick"),
|
||||||
function (this: User, member: Member | undefined) {
|
function (this: User, member: Member | undefined) {
|
||||||
|
@ -241,21 +265,11 @@ class User extends SnowFlake {
|
||||||
}
|
}
|
||||||
return us.hasPermission("KICK_MEMBERS") && this.id !== this.localuser.user.id;
|
return us.hasPermission("KICK_MEMBERS") && this.id !== this.localuser.user.id;
|
||||||
},
|
},
|
||||||
|
color: "red",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
//TODO ban icon
|
||||||
() => I18n.getTranslation("user.editServerProfile"),
|
|
||||||
function (this: User, member: Member | undefined) {
|
|
||||||
if (!member) return;
|
|
||||||
member.showEditProfile();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
visable: function (member) {
|
|
||||||
return member?.id === this.localuser.user.id;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.ban"),
|
() => I18n.getTranslation("user.ban"),
|
||||||
function (this: User, member: Member | undefined) {
|
function (this: User, member: Member | undefined) {
|
||||||
|
@ -273,8 +287,12 @@ class User extends SnowFlake {
|
||||||
}
|
}
|
||||||
return us.hasPermission("BAN_MEMBERS") && this.id !== this.localuser.user.id;
|
return us.hasPermission("BAN_MEMBERS") && this.id !== this.localuser.user.id;
|
||||||
},
|
},
|
||||||
|
color: "red",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator();
|
||||||
|
|
||||||
this.contextmenu.addButton(
|
this.contextmenu.addButton(
|
||||||
() => I18n.getTranslation("user.addRole"),
|
() => I18n.getTranslation("user.addRole"),
|
||||||
async function (this: User, member: Member | undefined, e) {
|
async function (this: User, member: Member | undefined, e) {
|
||||||
|
@ -329,6 +347,14 @@ class User extends SnowFlake {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.contextmenu.addSeperator();
|
||||||
|
this.contextmenu.addButton(
|
||||||
|
() => I18n.getTranslation("user.copyId"),
|
||||||
|
function (this: User) {
|
||||||
|
navigator.clipboard.writeText(this.id);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static checkuser(user: User | userjson, owner: Localuser): User {
|
static checkuser(user: User | userjson, owner: Localuser): User {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue