28 lines
747 B
JavaScript
28 lines
747 B
JavaScript
// 后台只读输入框选择事件代理,用于复制类配置项的一键选中文本。
|
|
|
|
let adminInputSelectionBound = false;
|
|
|
|
/**
|
|
* 绑定后台只读输入框点击选中逻辑。
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
export function bindAdminInputSelection() {
|
|
if (adminInputSelectionBound || typeof document === "undefined") {
|
|
return;
|
|
}
|
|
|
|
adminInputSelectionBound = true;
|
|
|
|
document.addEventListener("click", (event) => {
|
|
if (!(event.target instanceof HTMLInputElement)) {
|
|
return;
|
|
}
|
|
|
|
// 回调地址等只读字段点击后直接选中,便于管理员复制。
|
|
if (event.target.hasAttribute("data-admin-select-on-click")) {
|
|
event.target.select();
|
|
}
|
|
});
|
|
}
|