|
|
@@ -85,8 +85,8 @@
|
|
|
<div class="box-container">
|
|
|
<div class="demo-visual">
|
|
|
<div class="row">
|
|
|
- <button class="btn primary" onclick="openDom()">Open DOM popup</button>
|
|
|
- <button class="btn success" onclick="openWizard()">Open step wizard</button>
|
|
|
+ <button id="openDom" class="btn primary">Open DOM popup</button>
|
|
|
+ <button id="openWizard" class="btn success">Open step wizard</button>
|
|
|
</div>
|
|
|
<div class="hint">
|
|
|
Tip: step wizard disables backdrop/ESC close to avoid accidental dismiss.
|
|
|
@@ -103,69 +103,105 @@
|
|
|
</div>
|
|
|
|
|
|
<pre id="js-code" class="code-view active">// 1) Single popup: show a hidden DOM block inside Layer
|
|
|
-xjs.layer({
|
|
|
- title: 'DOM content',
|
|
|
- dom: '#demo_dom_block',
|
|
|
- showCancelButton: true,
|
|
|
- confirmButtonText: 'OK',
|
|
|
- cancelButtonText: 'Close'
|
|
|
+$('#openDom').click(function () {
|
|
|
+ $.layer({
|
|
|
+ title: 'DOM content',
|
|
|
+ dom: '#demo_dom_block',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ cancelButtonText: 'Close'
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
// 2) Step flow (wizard) - no icon during steps; final summary is allowed
|
|
|
-xjs.Layer.$({
|
|
|
- closeOnClickOutside: false,
|
|
|
- closeOnEsc: false,
|
|
|
- popupAnimation: false,
|
|
|
- confirmButtonColor: '#3085d6',
|
|
|
- cancelButtonColor: '#444'
|
|
|
-})
|
|
|
-.step({
|
|
|
- title: 'Step 1: Basic info',
|
|
|
- dom: '#wizard_step_1',
|
|
|
- showCancelButton: true,
|
|
|
- cancelButtonText: 'Cancel',
|
|
|
- preConfirm(popup) {
|
|
|
- const name = popup.querySelector('input[name="name"]').value.trim();
|
|
|
- const err = popup.querySelector('[data-error]');
|
|
|
- if (!name) { err.textContent = 'Please enter your name.'; return false; }
|
|
|
- err.textContent = '';
|
|
|
- return { name };
|
|
|
- }
|
|
|
-})
|
|
|
-.step({
|
|
|
- title: 'Step 2: Preferences',
|
|
|
- dom: '#wizard_step_2',
|
|
|
- preConfirm(popup) {
|
|
|
- const plan = popup.querySelector('select[name="plan"]').value;
|
|
|
- return { plan };
|
|
|
- }
|
|
|
-})
|
|
|
-.step({
|
|
|
- title: 'Summary',
|
|
|
- icon: 'success',
|
|
|
- isSummary: true,
|
|
|
- html: '<div class="hint">Click OK to finish.</div>'
|
|
|
-})
|
|
|
-.fire()
|
|
|
-.then((res) => {
|
|
|
- if (res.isConfirmed) {
|
|
|
- xjs.layer({
|
|
|
- title: 'Done',
|
|
|
- icon: 'success',
|
|
|
- popupAnimation: false,
|
|
|
- replace: true,
|
|
|
- html: '<pre>' + JSON.stringify(res.value, null, 2) + '</pre>'
|
|
|
- });
|
|
|
- }
|
|
|
+$('#openWizard').click(function () {
|
|
|
+ $.layer({
|
|
|
+ closeOnClickOutside: false,
|
|
|
+ closeOnEsc: false,
|
|
|
+ popupAnimation: false,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#444'
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Step 1: Basic info',
|
|
|
+ dom: '#wizard_step_1',
|
|
|
+ showCancelButton: true,
|
|
|
+ cancelButtonText: 'Cancel',
|
|
|
+ preConfirm(popup) {
|
|
|
+ const name = popup.querySelector('input[name="name"]').value.trim();
|
|
|
+ const err = popup.querySelector('[data-error]');
|
|
|
+ if (!name) { err.textContent = 'Please enter your name.'; return false; }
|
|
|
+ err.textContent = '';
|
|
|
+ return { name };
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Step 2: Preferences',
|
|
|
+ dom: '#wizard_step_2',
|
|
|
+ preConfirm(popup) {
|
|
|
+ const plan = popup.querySelector('select[name="plan"]').value;
|
|
|
+ return { plan };
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Summary',
|
|
|
+ icon: 'success',
|
|
|
+ isSummary: true,
|
|
|
+ html: '<div class="hint">Click OK to finish.</div>'
|
|
|
+ })
|
|
|
+ .run()
|
|
|
+ .then((res) => {
|
|
|
+ if (res.isConfirmed) {
|
|
|
+ $.layer({
|
|
|
+ title: 'Done',
|
|
|
+ icon: 'success',
|
|
|
+ popupAnimation: false,
|
|
|
+ replace: true,
|
|
|
+ html: '<pre>' + JSON.stringify(res.value, null, 2) + '</pre>'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
});</pre>
|
|
|
|
|
|
<pre id="html-code" class="html-view"><button class="btn primary" onclick="openDom()">Open DOM popup</button>
|
|
|
<button class="btn success" onclick="openWizard()">Open step wizard</button>
|
|
|
|
|
|
<!-- Hidden DOM blocks (default display:none) -->
|
|
|
-<div id="demo_dom_block" class="hidden-dom">...</div>
|
|
|
-<div id="wizard_step_1" class="hidden-dom">...</div>
|
|
|
-<div id="wizard_step_2" class="hidden-dom">...</div></pre>
|
|
|
+<div id="demo_dom_block" class="hidden-dom">
|
|
|
+ <div class="form">
|
|
|
+ <div class="field">
|
|
|
+ <label>Quick note</label>
|
|
|
+ <input placeholder="This input lives in a hidden DOM block" value="Hello from DOM!">
|
|
|
+ </div>
|
|
|
+ <div class="hint" style="margin-top: -4px;">
|
|
|
+ This DOM node is moved into the popup and restored on close.
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<div id="wizard_step_1" class="hidden-dom">
|
|
|
+ <div class="form">
|
|
|
+ <div class="field">
|
|
|
+ <label>Name</label>
|
|
|
+ <input name="name" placeholder="Your name">
|
|
|
+ </div>
|
|
|
+ <div class="error" data-error></div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<div id="wizard_step_2" class="hidden-dom">
|
|
|
+ <div class="form">
|
|
|
+ <div class="field">
|
|
|
+ <label>Plan</label>
|
|
|
+ <select name="plan">
|
|
|
+ <option value="free">Free</option>
|
|
|
+ <option value="pro">Pro</option>
|
|
|
+ <option value="team">Team</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="hint">Confirm will finish the wizard.</div>
|
|
|
+ </div>
|
|
|
+</div></pre>
|
|
|
|
|
|
<pre id="css-code" class="css-view">/* This page hides DOM blocks by default:
|
|
|
.hidden-dom { display: none; }
|
|
|
@@ -264,65 +300,68 @@ then restore it back (and restore display/hidden state) on close. */</pre>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function openDom() {
|
|
|
- xjs.layer({
|
|
|
- title: 'DOM content',
|
|
|
- dom: '#demo_dom_block',
|
|
|
- popupAnimation: true,
|
|
|
- showCancelButton: true,
|
|
|
- confirmButtonText: 'OK',
|
|
|
- cancelButtonText: 'Close'
|
|
|
+ function bindDemoHandlers() {
|
|
|
+ if (typeof $ !== 'function') return;
|
|
|
+ $('#openDom').click(function () {
|
|
|
+ $.layer({
|
|
|
+ title: 'DOM content',
|
|
|
+ dom: '#demo_dom_block',
|
|
|
+ popupAnimation: true,
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ cancelButtonText: 'Close'
|
|
|
+ });
|
|
|
});
|
|
|
- }
|
|
|
|
|
|
- function openWizard() {
|
|
|
- xjs.Layer.$({
|
|
|
- closeOnClickOutside: false,
|
|
|
- closeOnEsc: false,
|
|
|
- popupAnimation: false,
|
|
|
- confirmButtonColor: '#3085d6',
|
|
|
- cancelButtonColor: '#444'
|
|
|
- })
|
|
|
- .step({
|
|
|
- title: 'Step 1: Basic info',
|
|
|
- dom: '#wizard_step_1',
|
|
|
- showCancelButton: true,
|
|
|
- cancelButtonText: 'Cancel',
|
|
|
- preConfirm(popup) {
|
|
|
- const name = popup.querySelector('input[name="name"]').value.trim();
|
|
|
- const err = popup.querySelector('[data-error]');
|
|
|
- if (!name) { err.textContent = 'Please enter your name.'; return false; }
|
|
|
- err.textContent = '';
|
|
|
- return { name };
|
|
|
- }
|
|
|
- })
|
|
|
- .step({
|
|
|
- title: 'Step 2: Preferences',
|
|
|
- dom: '#wizard_step_2',
|
|
|
- preConfirm(popup) {
|
|
|
- const plan = popup.querySelector('select[name="plan"]').value;
|
|
|
- return { plan };
|
|
|
- }
|
|
|
- })
|
|
|
- .step({
|
|
|
- title: 'Summary',
|
|
|
- icon: 'success',
|
|
|
- isSummary: true,
|
|
|
- html: '<div class="hint">Click OK to finish.</div>'
|
|
|
- })
|
|
|
- .fire()
|
|
|
- .then((res) => {
|
|
|
- if (res.isConfirmed) {
|
|
|
- xjs.layer({
|
|
|
- title: 'Done',
|
|
|
- icon: 'success',
|
|
|
- popupAnimation: false,
|
|
|
- replace: true,
|
|
|
- html: '<pre>' + JSON.stringify(res.value, null, 2) + '</pre>'
|
|
|
- });
|
|
|
- } else {
|
|
|
- xjs.layer({ title: 'Dismissed', icon: 'info', popupAnimation: false, replace: true, text: 'Flow cancelled' });
|
|
|
- }
|
|
|
+ $('#openWizard').click(function () {
|
|
|
+ $.layer({
|
|
|
+ closeOnClickOutside: false,
|
|
|
+ closeOnEsc: false,
|
|
|
+ popupAnimation: false,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#444'
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Step 1: Basic info',
|
|
|
+ dom: '#wizard_step_1',
|
|
|
+ showCancelButton: true,
|
|
|
+ cancelButtonText: 'Cancel',
|
|
|
+ preConfirm(popup) {
|
|
|
+ const name = popup.querySelector('input[name="name"]').value.trim();
|
|
|
+ const err = popup.querySelector('[data-error]');
|
|
|
+ if (!name) { err.textContent = 'Please enter your name.'; return false; }
|
|
|
+ err.textContent = '';
|
|
|
+ return { name };
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Step 2: Preferences',
|
|
|
+ dom: '#wizard_step_2',
|
|
|
+ preConfirm(popup) {
|
|
|
+ const plan = popup.querySelector('select[name="plan"]').value;
|
|
|
+ return { plan };
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .step({
|
|
|
+ title: 'Summary',
|
|
|
+ icon: 'success',
|
|
|
+ isSummary: true,
|
|
|
+ html: '<div class="hint">Click OK to finish.</div>'
|
|
|
+ })
|
|
|
+ .run()
|
|
|
+ .then((res) => {
|
|
|
+ if (res.isConfirmed) {
|
|
|
+ $.layer({
|
|
|
+ title: 'Done',
|
|
|
+ icon: 'success',
|
|
|
+ popupAnimation: false,
|
|
|
+ replace: true,
|
|
|
+ html: '<pre>' + JSON.stringify(res.value, null, 2) + '</pre>'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $.layer({ title: 'Dismissed', icon: 'info', popupAnimation: false, replace: true, text: 'Flow cancelled' });
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -355,8 +394,12 @@ then restore it back (and restore display/hidden state) on close. */</pre>
|
|
|
// (without cache-busting) and may overwrite the fresh one after our load finishes.
|
|
|
// - Load sources directly with cache-bust to guarantee we use the current workspace code.
|
|
|
await loadScript(base + 'animal.js?_=' + DEV_CACHE_BUST);
|
|
|
- try { if (window.animal && !window.xjs) window.xjs = window.animal; } catch {}
|
|
|
+ try {
|
|
|
+ if (window.animal && !window.xjs) window.xjs = window.animal;
|
|
|
+ if (window.xjs && !window.$) window.$ = window.xjs;
|
|
|
+ } catch {}
|
|
|
await loadScript(base + 'layer.js?_=' + DEV_CACHE_BUST);
|
|
|
+ bindDemoHandlers();
|
|
|
})().catch((e) => {
|
|
|
try { console.error(e); } catch {}
|
|
|
});
|