Added the logic of wrapper + responsiveness controllers.

This commit is contained in:
2022-07-19 18:43:16 +03:00
parent a7e51803cf
commit 9173efe9c9
24 changed files with 535 additions and 76 deletions
+32 -7
View File
@@ -1,13 +1,38 @@
(function () {
const dataOptionsSelect = document.getElementById('data-options');
if (!dataOptionsSelect) {
return;
const previewFrame = document.getElementById('preview_frame');
initDataOptions();
initResponsiveMode();
/**
* Functions
*/
function initDataOptions() {
const dataOptionsSelect = document.getElementById('data-options');
if (!dataOptionsSelect) {
return;
}
dataOptionsSelect.addEventListener('change', function () {
previewFrame.src = window.previewFrameUrl + '?data=' + this.value;
});
}
dataOptionsSelect.addEventListener('change', function () {
console.log(this.value)
window.location = '?data=' + this.value;
})
function initResponsiveMode() {
document.querySelectorAll('input[name="responsive_mode"]').forEach((input) => {
input.addEventListener('change', (event) => {
const mode = event.target.value;
previewFrame.classList.remove('breakpoint--desktop');
previewFrame.classList.remove('breakpoint--tablet');
previewFrame.classList.remove('breakpoint--mobile');
previewFrame.classList.add('breakpoint--' + mode);
});
});
}
})();