lib
This commit is contained in:
parent
ed21481ea4
commit
f57ff9108b
|
@ -2309,7 +2309,12 @@ var BDFDB = {
|
|||
|
||||
BDFDB.ColorUtils = {};
|
||||
BDFDB.ColorUtils.convert = function (color, conv, type) {
|
||||
if (color == null) return null;
|
||||
if (BDFDB.ObjectUtils.is(color)) {
|
||||
var newcolor = {};
|
||||
for (let pos in color) newcolor[pos] = BDFDB.ColorUtils.convert(color[pos], conv, type);
|
||||
return newcolor;
|
||||
}
|
||||
else {
|
||||
conv = conv === undefined || !conv ? conv = "RGBCOMP" : conv.toUpperCase();
|
||||
type = type === undefined || !type || !["RGB", "RGBA", "RGBCOMP", "HSL", "HSLA", "HSLCOMP", "HEX", "HEXA", "INT"].includes(type.toUpperCase()) ? BDFDB.ColorUtils.getType(color) : type.toUpperCase();
|
||||
if (conv == "RGBCOMP") {
|
||||
|
@ -2399,6 +2404,8 @@ var BDFDB = {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
function processC(c) {if (c == null) {return 255;} else {c = parseInt(c.toString().replace(/[^0-9\-]/g, ""));return isNaN(c) || c > 255 ? 255 : c < 0 ? 0 : c;}};
|
||||
function processRGB(comp) {return comp.map(c => {return processC(c);});};
|
||||
function processA(a) {if (a == null) {return 1;} else {a = a.toString();a = (a.indexOf("%") > -1 ? 0.01 : 1) * parseFloat(a.replace(/[^0-9\.\-]/g, ""));return isNaN(a) || a > 1 ? 1 : a < 0 ? 0 : a;}};
|
||||
|
@ -2409,11 +2416,10 @@ var BDFDB = {
|
|||
BDFDB.ColorUtils.setAlpha = function (color, a, conv) {
|
||||
if (BDFDB.ObjectUtils.is(color)) {
|
||||
var newcolor = {};
|
||||
for (let pos in color) newcolor[pos] = setAlpha(color[pos], a, conv);
|
||||
for (let pos in color) newcolor[pos] = BDFDB.ColorUtils.setAlpha(color[pos], a, conv);
|
||||
return newcolor;
|
||||
}
|
||||
return setAlpha(color, a, conv);
|
||||
function setAlpha (color) {
|
||||
else {
|
||||
var comp = BDFDB.ColorUtils.convert(color, "RGBCOMP");
|
||||
if (comp) {
|
||||
a = a.toString();
|
||||
|
@ -2424,8 +2430,8 @@ var BDFDB = {
|
|||
conv = conv == "RGB" || conv == "HSL" || conv == "HEX" ? conv + "A" : conv;
|
||||
return BDFDB.ColorUtils.convert(comp, conv);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
BDFDB.ColorUtils.getAlpha = function (color) {
|
||||
var comp = BDFDB.ColorUtils.convert(color, "RGBCOMP");
|
||||
|
@ -2444,13 +2450,10 @@ var BDFDB = {
|
|||
if (color != null && typeof value == "number" && !isNaN(value)) {
|
||||
if (BDFDB.ObjectUtils.is(color)) {
|
||||
var newcolor = {};
|
||||
for (let pos in color) newcolor[pos] = change(color[pos], value, conv);
|
||||
for (let pos in color) newcolor[pos] = BDFDB.ColorUtils.change(color[pos], value, conv);
|
||||
return newcolor;
|
||||
}
|
||||
else return change(color, value, conv);
|
||||
}
|
||||
return null;
|
||||
function change (color) {
|
||||
else {
|
||||
var comp = BDFDB.ColorUtils.convert(color, "RGBCOMP");
|
||||
if (comp) {
|
||||
if (parseInt(value) !== value) {
|
||||
|
@ -2461,17 +2464,22 @@ var BDFDB = {
|
|||
}
|
||||
else return BDFDB.ColorUtils.convert([Math.round(comp[0] + value), Math.round(comp[1] + value), Math.round(comp[2] + value)], conv || BDFDB.ColorUtils.getType(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
};
|
||||
BDFDB.ColorUtils.invert = function (color, conv) {
|
||||
if (color != null) {
|
||||
if (BDFDB.ObjectUtils.is(color)) {
|
||||
var newcolor = {};
|
||||
for (let pos in color) newcolor[pos] = BDFDB.ColorUtils.invert(color[pos], conv);
|
||||
return newcolor;
|
||||
}
|
||||
else {
|
||||
var comp = BDFDB.ColorUtils.convert(color, "RGBCOMP");
|
||||
if (comp) return BDFDB.ColorUtils.convert([255 - comp[0], 255 - comp[1], 255 - comp[2]], conv || BDFDB.ColorUtils.getType(color));
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
BDFDB.ColorUtils.compare = function (color1, color2) {
|
||||
if (color1 && color2) {
|
||||
color1 = BDFDB.ColorUtils.convert(color1, "RGBA");
|
||||
|
@ -2512,7 +2520,10 @@ var BDFDB = {
|
|||
BDFDB.ColorUtils.createGradient = function (colorobj, direction = "to right") {
|
||||
var sortedgradient = {};
|
||||
var gradientstring = "linear-gradient(" + direction;
|
||||
for (let pos of Object.keys(colorobj).sort()) gradientstring += `, ${colorobj[pos]} ${pos*100}%`
|
||||
for (let pos of Object.keys(colorobj).sort()) {
|
||||
let color = BDFDB.ColorUtils.convert(colorobj[pos], "RGBA");
|
||||
gradientstring += color ? `, ${color} ${pos*100}%` : ''
|
||||
}
|
||||
return gradientstring += ")";
|
||||
};
|
||||
BDFDB.ColorUtils.getSwatchColor = function (container, number) {
|
||||
|
@ -2520,10 +2531,10 @@ var BDFDB = {
|
|||
var swatches = container.querySelector(`${BDFDB.dotCN.colorpickerswatches}[number="${number}"], ${BDFDB.dotCN.colorpickerswatch}[number="${number}"]`);
|
||||
if (!swatches) return null;
|
||||
var ins = BDFDB.ReactUtils.getInstance(swatches);
|
||||
if (ins) return BDFDB.ReactUtils.findValue(ins, "selectedColor", {up:true, blacklist:{"props":true}});
|
||||
if (ins) return BDFDB.ColorUtils.convert(BDFDB.ReactUtils.findValue(ins, "selectedColor", {up:true, blacklist:{"props":true}}));
|
||||
else { // REMOVE ONCE REWRITTEN
|
||||
var swatch = swatches.querySelector(`${BDFDB.dotCN.colorpickerswatch + BDFDB.dotCN.colorpickerswatchselected}`);
|
||||
return swatch ? swatch.gradient || BDFDB.ColorUtils.convert(swatch.style.getPropertyValue("background-color"), "RGBCOMP") : null;
|
||||
return swatch ? BDFDB.ColorUtils.convert(swatch.gradient || swatch.style.getPropertyValue("background-color"), "RGBCOMP") : null;
|
||||
}
|
||||
};
|
||||
BDFDB.ColorUtils.openPicker = function (container, target, color, options = {gradient: true, alpha: true, callback: _ => {}}) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -245,28 +245,23 @@ class EditUsers {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_username_text,
|
||||
className: BDFDB.disCN.marginbottom20 + " input-username",
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
value: data.name,
|
||||
placeholder: member.nick || info.username,
|
||||
autoFocus: true
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_usertag_text,
|
||||
className: BDFDB.disCN.marginbottom20 + " input-usertag",
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
value: data.tag
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_useravatar_text,
|
||||
className: BDFDB.disCN.marginbottom8 + " input-useravatar",
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null,
|
||||
inputId: "USERAVATAR",
|
||||
value: data.url,
|
||||
|
@ -279,7 +274,6 @@ class EditUsers {
|
|||
this.checkUrl(value, instance);
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Switch",
|
||||
|
@ -303,22 +297,18 @@ class EditUsers {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_colorpicker1_text,
|
||||
className: BDFDB.disCN.marginbottom20,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
color: data.color1,
|
||||
number: 1
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_colorpicker2_text,
|
||||
className: BDFDB.disCN.marginbottom20,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
color: data.color2,
|
||||
number: 2
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}),
|
||||
|
@ -328,24 +318,20 @@ class EditUsers {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_colorpicker3_text,
|
||||
className: BDFDB.disCN.marginbottom20,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
color: data.color3,
|
||||
number: 3,
|
||||
disabled: data.ignoreTagColor
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||
title: this.labels.modal_colorpicker4_text,
|
||||
className: BDFDB.disCN.marginbottom20,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
|
||||
color: data.color4,
|
||||
number: 4,
|
||||
disabled: data.ignoreTagColor
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Switch",
|
||||
|
@ -760,7 +746,7 @@ class EditUsers {
|
|||
this.changeBotTags(data, username, member);
|
||||
if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) {
|
||||
let isBRCenabled = BDFDB.BDUtils.isPluginEnabled("BetterRoleColors");
|
||||
let usenick = !BDFDB.DOMUtils.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.DOMUtils.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname, BDFDB.disCN.accountinfodetails, false) && member.nick;
|
||||
let usenick = !BDFDB.DOMUtils.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.DOMUtils.containsClass(username.parentElement, BDFDB.disCN.listname, BDFDB.disCN.accountinfodetails, false) && member.nick;
|
||||
let usemembercolor = !BDFDB.DOMUtils.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname) && (BDFDB.DOMUtils.containsClass(username, BDFDB.disCN.memberusername, BDFDB.disCN.messageusername, false) || isBRCenabled);
|
||||
|
||||
if (BDFDB.ObjectUtils.is(data.color1)) {
|
||||
|
|
Loading…
Reference in New Issue