Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
3 years ago
|
/*
|
||
|
* https://github.com/morethanwords/tweb
|
||
|
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
||
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||
|
*/
|
||
|
|
||
|
import { attachClickEvent } from "../../helpers/dom/clickEvent";
|
||
|
import ListenerSetter from "../../helpers/listenerSetter";
|
||
|
import { i18n, LangPackKey } from "../../lib/langPack";
|
||
|
import { ripple } from "../ripple";
|
||
|
|
||
|
export default function makeButton(className: string, listenerSetter: ListenerSetter, options: {
|
||
|
text?: LangPackKey | HTMLElement,
|
||
|
isDanger?: boolean,
|
||
|
noRipple?: boolean,
|
||
|
callback?: () => void,
|
||
|
icon?: string,
|
||
|
isConfirm?: boolean,
|
||
|
}) {
|
||
|
const _className = className + '-button';
|
||
|
const buttonDiv = document.createElement('div');
|
||
|
buttonDiv.classList.add(_className, 'call-button', 'rp-overflow');
|
||
|
|
||
|
if(options.icon) {
|
||
|
buttonDiv.classList.add('tgico-' + options.icon);
|
||
|
}
|
||
|
|
||
|
if(!options.noRipple) {
|
||
|
ripple(buttonDiv);
|
||
|
}
|
||
|
|
||
|
if(options.isDanger) {
|
||
|
buttonDiv.classList.add(_className + '-red');
|
||
|
}
|
||
|
|
||
|
if(options.isConfirm) {
|
||
|
buttonDiv.classList.add(_className + '-green');
|
||
|
}
|
||
|
|
||
|
if(options.callback) {
|
||
|
attachClickEvent(buttonDiv, options.callback, {listenerSetter});
|
||
|
}
|
||
|
|
||
|
let ret = buttonDiv;
|
||
|
if(options.text) {
|
||
|
const div = document.createElement('div');
|
||
|
div.classList.add(_className + '-container', 'call-button-container');
|
||
|
|
||
|
const textEl = typeof(options.text) === 'string' ? i18n(options.text) : options.text;
|
||
|
textEl.classList.add(_className + '-text', 'call-button-text');
|
||
|
|
||
|
div.append(buttonDiv, textEl);
|
||
|
|
||
|
ret = div;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|