| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Layer Static API - Animal.js</title>
- <link rel="stylesheet" href="../demo.css">
- <link rel="stylesheet" href="../../xjs.css">
- <style>
- .row {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- align-items: center;
- }
- .btn {
- appearance: none;
- border: 1px solid rgba(255,255,255,0.12);
- background: rgba(255,255,255,0.04);
- color: #fff;
- border-radius: 999px;
- padding: 10px 14px;
- font-weight: 650;
- cursor: pointer;
- transition: border-color 0.15s ease, background 0.15s ease;
- }
- .btn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
- .btn.primary { border-color: rgba(48,133,214,0.55); background: rgba(48,133,214,0.18); }
- .btn.primary:hover { border-color: rgba(48,133,214,0.8); background: rgba(48,133,214,0.24); }
- .demo-visual { padding: 22px 24px; }
- .hint { font-size: 12px; color: #8c8c8c; line-height: 1.5; margin-top: 10px; }
- .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="page-top">
- <div class="crumb">UI › LAYER</div>
- <div class="since">STATIC API</div>
- </div>
- <h1>Static API / Builder API</h1>
- <p class="description">
- Layer supports <code class="inline">Layer.fire()</code> and <code class="inline">Layer.$(...).fire()</code> (builder style), and returns a Promise result.
- </p>
- <div class="box-container">
- <div class="demo-visual">
- <div class="row">
- <button class="btn primary" onclick="openFire()">Layer.fire()</button>
- <button class="btn" onclick="openBuilder()">Builder fire()</button>
- </div>
- <div class="hint">
- Promise result is printed to <span class="mono">console</span>.
- </div>
- </div>
- <div class="box-header">
- <div class="box-title">Examples</div>
- <div class="tabs">
- <div class="tab active" onclick="switchTab('js')">JavaScript</div>
- <div class="tab" onclick="switchTab('html')">HTML</div>
- <div class="tab" onclick="switchTab('css')">CSS</div>
- </div>
- </div>
- <pre id="js-code" class="code-view active">// 1) Static fire
- Layer.fire({ title: 'Hello', text: 'Layer.fire(...)', icon: 'info' });
- // 2) Builder style
- Layer.$()
- .config({ title: 'Confirm?', icon: 'warning', showCancelButton: true })
- .fire()
- .then((res) => console.log(res));</pre>
- <pre id="html-code" class="html-view"><button class="btn primary">Layer.fire()</button>
- <button class="btn">Layer.$().config().fire()</button></pre>
- <pre id="css-code" class="css-view">/* Local styles for buttons only */</pre>
- <div class="feature-desc">
- <strong>功能说明:</strong>验证 Layer 自身的静态入口(不依赖 Selection.layer 绑定),以及 builder 模式的链式配置。
- </div>
- </div>
- <div class="doc-nav" aria-label="Previous and next navigation">
- <a href="#" id="prevLink" onclick="goPrev(); return false;">
- <span><span class="nav-label">Previous</span><br><span class="nav-title" id="prevTitle">—</span></span>
- <span aria-hidden="true">←</span>
- </a>
- <div class="nav-center" id="navCenter">Layer</div>
- <a href="#" id="nextLink" onclick="goNext(); return false;">
- <span><span class="nav-label">Next</span><br><span class="nav-title" id="nextTitle">—</span></span>
- <span aria-hidden="true">→</span>
- </a>
- </div>
- </div>
- <script src="../highlight_css.js"></script>
- <!-- Dev/test: load source files directly with cache-bust (avoid stale iframe cache) -->
- <script>
- (function () {
- var b = Date.now();
- document.write('<script src="../../animal.js?_=' + b + '"><\/script>');
- document.write('<script src="../../layer.js?_=' + b + '"><\/script>');
- document.write('<script>try{if(window.animal&&!window.xjs)window.xjs=window.animal;}catch(e){}<\/script>');
- })();
- </script>
- <script>
- const CURRENT = 'layer/test_static_fire.html';
- function switchTab(tab) {
- document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
- document.querySelectorAll('.code-view, .html-view, .css-view').forEach(v => v.classList.remove('active'));
- if (tab === 'js') {
- document.querySelector('.tabs .tab:nth-child(1)')?.classList.add('active');
- document.getElementById('js-code')?.classList.add('active');
- } else if (tab === 'html') {
- document.querySelector('.tabs .tab:nth-child(2)')?.classList.add('active');
- document.getElementById('html-code')?.classList.add('active');
- } else {
- document.querySelector('.tabs .tab:nth-child(3)')?.classList.add('active');
- document.getElementById('css-code')?.classList.add('active');
- }
- }
- function openFire() {
- Layer.fire({ title: 'Hello', text: 'Layer.fire(...)', icon: 'info', popupAnimation: true })
- .then((res) => console.log('[Layer.fire] result:', res));
- }
- function openBuilder() {
- Layer.$()
- .config({
- title: 'Confirm?',
- text: 'Builder style API',
- icon: 'warning',
- popupAnimation: true,
- showCancelButton: true
- })
- .fire()
- .then((res) => {
- console.log('[Layer.builder] result:', res);
- if (res.isConfirmed) xjs.layer({ title: 'Confirmed', icon: 'success', popupAnimation: true });
- });
- }
- function goPrev() { window.parent?.docNavigatePrev?.(CURRENT); }
- function goNext() { window.parent?.docNavigateNext?.(CURRENT); }
- function syncNavLabels() {
- const api = window.parent?.docGetPrevNext;
- if (typeof api !== 'function') return;
- const { prev, next, current } = api(CURRENT) || {};
- const prevLink = document.getElementById('prevLink');
- const nextLink = document.getElementById('nextLink');
- if (prev) document.getElementById('prevTitle').textContent = prev.title || prev.url;
- else { prevLink.style.visibility = 'hidden'; }
- if (next) document.getElementById('nextTitle').textContent = next.title || next.url;
- else { nextLink.style.visibility = 'hidden'; }
- document.getElementById('navCenter').textContent = (current && current.group) ? current.group : 'Layer';
- }
- try { window.parent?.setMiddleActive?.(CURRENT); } catch {}
- syncNavLabels();
- </script>
- </body>
- </html>
|