3,389
个编辑
MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
Salt lovely(留言 | 贡献) 小 (// Edit via Wikiplus) |
Salt lovely(留言 | 贡献) 小 (// Edit via Wikiplus) |
||
| 第54行: | 第54行: | ||
*/ | */ | ||
function confirmUI(text = '', callback) { | function confirmUI(text = '', callback) { | ||
// 安全锁,防止用户多次点击 | |||
let safe = true | |||
// 容器 | // 容器 | ||
let container = document.createElement('div') | let container = document.createElement('div') | ||
| 第64行: | 第66行: | ||
yesBtn.textContent = '确定' | yesBtn.textContent = '确定' | ||
yesBtn.addEventListener('click', () => { | yesBtn.addEventListener('click', () => { | ||
callback(true) | if (safe) { | ||
safe = false | |||
callback(true) | |||
selfRemove() // 移除确认框 | |||
} | |||
}) | }) | ||
container.appendChild(yesBtn) | container.appendChild(yesBtn) | ||
| 第74行: | 第79行: | ||
noBtn.textContent = '取消' | noBtn.textContent = '取消' | ||
noBtn.addEventListener('click', () => { | noBtn.addEventListener('click', () => { | ||
callback(false) | if (safe) { | ||
safe = false | |||
callback(false) | |||
selfRemove() | |||
} | |||
}) | }) | ||
container.style.opacity = '0' | |||
container.appendChild(noBtn) | container.appendChild(noBtn) | ||
// 显示UI | // 显示UI | ||
| 第83行: | 第92行: | ||
container.style.marginLeft = (container.offsetWidth * -0.5) + 'px' | container.style.marginLeft = (container.offsetWidth * -0.5) + 'px' | ||
container.style.marginTop = (container.offsetHeight * -0.5) + 'px' | container.style.marginTop = (container.offsetHeight * -0.5) + 'px' | ||
container.style.opacity = '1' | |||
/**移除自己 */ | |||
function selfRemove() { | |||
container.style.top = '-100%' | |||
container.style.opacity = '1' | |||
setTimeout(container.remove, 500) | |||
} | |||
} | } | ||
// CSS | // CSS | ||
| 第98行: | 第114行: | ||
background: #FDF6E6; | background: #FDF6E6; | ||
user-select: none; | user-select: none; | ||
transition: .4s ease-in; | |||
} | } | ||
.confirmUIcontainer > center{ | .confirmUIcontainer > center{ | ||