This commit is contained in:
Mirco Wittrien 2019-10-24 21:30:55 +02:00
parent d0dc465981
commit 2b91239706
3 changed files with 73 additions and 66 deletions

View File

@ -5711,13 +5711,17 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}
return BDFDB.ReactUtils.createElement(LibraryComponents.Clickable, {
className: this.props.className,
onContextMenu: e => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target) && typeof this.props.onContextMenu == "function") this.props.onContextMenu(this, e);
},
onClick: e => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if (typeof this.props.onClick == "function") this.props.onClick(this, e);
if (typeof this.handleClick == "function") this.handleClick();
if ((this.props.openOnClick || this.props.openOnClick === undefined) && typeof this.handleClick == "function") this.handleClick();
}
else BDFDB.ListenerUtils.stopEvent(e);
},
onContextMenu: e => {
if (!this.domElementRef.current || this.domElementRef.current.contains(e.target)) {
if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(this, e);
if (this.props.openOnContextMenu && typeof this.handleClick == "function") this.handleClick();
}
else BDFDB.ListenerUtils.stopEvent(e);
},

File diff suppressed because one or more lines are too long

View File

@ -259,8 +259,38 @@ class GoogleTranslateOption {
}
else if (methodnames.includes("render")) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {props:[["className", BDFDB.disCN.textareapickerbuttons]]});
if (!this.stopping && index > -1 && children[index].props && children[index].props.children) {
children[index].props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.PopoutContainer, {
if (!this.stopping && index > -1 && children[index].props && children[index].props.children) children[index].props.children.unshift(this.createTranslateButton());
}
}
processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) {
let optionPopoutButton = BDFDB.DOMUtils.create(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
optionPopoutButton.addEventListener("click", () => {BDFDB.createMessageOptionPopout(optionPopoutButton);});
buttonwrap.appendChild(optionPopoutButton);
}
}
}
processMessageContent (instance, wrapper, returnvalue) {
if (instance.props && instance.props.message && instance.props.channel) {
let messagediv = BDFDB.DOMUtils.getParent(".GTO-translated-message", wrapper);
if (messagediv && !wrapper.querySelector(".GTO-translation")) BDFDB.DOMUtils.removeClass(messagediv, "GTO-translated-message");
}
}
processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.setLanguages();
BDFDB.ModuleUtils.forceAllUpdates(this, "ChannelTextArea");
}
}
createTranslateButton () {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.PopoutContainer, {
className: BDFDB.disCN.textareapickerbuttoncontainer,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ChannelTextAreaButton, {
className: ["translate-button", this.translating ? "translating-active" : null, BDFDB.disCN.textareapickerbutton].filter(n => n).join(" "),
@ -278,15 +308,16 @@ class GoogleTranslateOption {
BDFDB.ReactUtils.forceUpdate(channelTextareaButtonIns);
}
},
onContextMenu: _ => {
onContextMenu: instance => {
this.translating = !this.translating;
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"ChannelTextAreaButton"});
if (channelTextareaButtonIns) {
channelTextareaButtonIns.props.className = ["translate-button", this.translating ? "translating-active" : null, BDFDB.disCN.textareapickerbutton].filter(n => n).join(" ");
BDFDB.ReactUtils.forceUpdate(channelTextareaButtonIns);
instance.close();
}
},
renderPopout: (instance, close) => {
renderPopout: instance => {
let channelTextareaButtonIns = BDFDB.ReactUtils.findOwner(instance, {name:"ChannelTextAreaButton"});
if (channelTextareaButtonIns) {
channelTextareaButtonIns.props.isActive = true;
@ -318,35 +349,7 @@ class GoogleTranslateOption {
}));
return popoutelements;
}
}));
}
}
}
processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) {
let optionPopoutButton = BDFDB.DOMUtils.create(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
optionPopoutButton.addEventListener("click", () => {BDFDB.createMessageOptionPopout(optionPopoutButton);});
buttonwrap.appendChild(optionPopoutButton);
}
}
}
processMessageContent (instance, wrapper, returnvalue) {
if (instance.props && instance.props.message && instance.props.channel) {
let messagediv = BDFDB.DOMUtils.getParent(".GTO-translated-message", wrapper);
if (messagediv && !wrapper.querySelector(".GTO-translation")) BDFDB.DOMUtils.removeClass(messagediv, "GTO-translated-message");
}
}
processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.setLanguages();
BDFDB.ModuleUtils.forceAllUpdates(this, "ChannelTextArea");
}
});
}
createSelects (inPopout) {