This commit is contained in:
parent
dacdc533da
commit
3ab1c0c119
21 changed files with 2244 additions and 0 deletions
31
theme/default/js/demo-preview.js
Normal file
31
theme/default/js/demo-preview.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const demo = document.querySelectorAll('.idoc-demo-warpper .idoc-demo-previw');
|
||||
|
||||
function getButton(elm, type = 'BUTTON') {
|
||||
let btn;
|
||||
do {
|
||||
elm = elm.nextElementSibling;
|
||||
if (elm.tagName === type) {
|
||||
btn = elm;
|
||||
elm = undefined;
|
||||
break;
|
||||
}
|
||||
} while (elm);
|
||||
return btn;
|
||||
}
|
||||
if (demo && demo.length > 0) {
|
||||
demo.forEach((item) => {
|
||||
if (item.previousElementSibling && item.previousElementSibling.tagName === 'INPUT') {
|
||||
const button = getButton(item);
|
||||
if (button) {
|
||||
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
|
||||
if (item.tagName === 'DIV') {
|
||||
item.innerHTML = item.previousElementSibling.defaultValue;
|
||||
}
|
||||
button.onclick = () => {
|
||||
item.classList.toggle('ishiden');
|
||||
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue