Files
aurora-admin/frameworks/SwitchGroup.html
T

53 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Aurora Admin · SwitchGroup(普通 H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
<link rel="stylesheet" href="SwitchGroup.css" />
<style>body{margin:0;padding:24px;background:#F5F7FA;} .aa-panel{background:#fff;border:1px solid #E8ECF1;border-radius:8px;padding:16px;max-width:360px;}</style>
</head>
<body>
<div class="aa-panel">
<div class="aa-switchgroup" id="app"></div>
</div>
<script>
var DATA = [
{ label: '邮件通知', value: 'mail', desc: '接收系统邮件提醒', on: true },
{ label: '短信通知', value: 'sms', desc: '重要变更发送短信', on: false },
{ label: '站内信', value: 'inbox', desc: '工作台消息中心', on: true }
];
function render() {
var root = document.getElementById('app');
var allOn = DATA.every(function (d) { return d.on; });
var html = '<div class="aa-switchgroup-head"><span class="aa-switchgroup-title">通知设置</span>' +
'<div class="aa-switch ' + (allOn ? 'is-on' : '') + '" data-all="1"></div></div>';
html += DATA.map(function (d) {
return '<div class="aa-switch-row"><div class="aa-switch-text">' +
'<span class="aa-switch-label">' + d.label + '</span>' +
'<span class="aa-switch-desc">' + d.desc + '</span></div>' +
'<div class="aa-switch ' + (d.on ? 'is-on' : '') + '" data-value="' + d.value + '"></div></div>';
}).join('');
root.innerHTML = html;
root.querySelector('[data-all]').addEventListener('click', function () {
var target = !DATA.every(function (d) { return d.on; });
DATA.forEach(function (d) { d.on = target; });
render();
});
root.querySelectorAll('[data-value]').forEach(function (el) {
el.addEventListener('click', function () {
var v = el.dataset.value;
DATA.forEach(function (d) { if (d.value === v) d.on = !d.on; });
render();
});
});
}
render();
</script>
</body>
</html>