Update live preview custom CSS on input event
This commit is contained in:
parent
883226b045
commit
1da60aae2d
@ -107,6 +107,18 @@ class SettingsPopupPreview {
|
|||||||
this.updateSearch();
|
this.updateSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInfoVisible(visible) {
|
||||||
|
const node = document.querySelector('.placeholder-info');
|
||||||
|
if (node === null) { return; }
|
||||||
|
|
||||||
|
node.classList.toggle('placeholder-info-visible', visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
setCustomCss(css) {
|
||||||
|
if (this.frontend === null) { return; }
|
||||||
|
this.frontend.popup.setCustomCss(css);
|
||||||
|
}
|
||||||
|
|
||||||
async updateSearch() {
|
async updateSearch() {
|
||||||
const exampleText = document.querySelector('#example-text');
|
const exampleText = document.querySelector('#example-text');
|
||||||
if (exampleText === null) { return; }
|
if (exampleText === null) { return; }
|
||||||
@ -128,17 +140,11 @@ class SettingsPopupPreview {
|
|||||||
|
|
||||||
this.setInfoVisible(!this.popupShown);
|
this.setInfoVisible(!this.popupShown);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInfoVisible(visible) {
|
|
||||||
const node = document.querySelector('.placeholder-info');
|
|
||||||
if (node === null) { return; }
|
|
||||||
|
|
||||||
node.classList.toggle('placeholder-info-visible', visible);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsPopupPreview.messageHandlers = {
|
SettingsPopupPreview.messageHandlers = {
|
||||||
setText: (self, {text}) => self.setText(text)
|
setText: (self, {text}) => self.setText(text),
|
||||||
|
setCustomCss: (self, {css}) => self.setCustomCss(css)
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingsPopupPreview.instance = SettingsPopupPreview.create();
|
SettingsPopupPreview.instance = SettingsPopupPreview.create();
|
||||||
|
@ -280,6 +280,7 @@ function showAppearancePreview() {
|
|||||||
const buttonContainer = $('#settings-popup-preview-button-container');
|
const buttonContainer = $('#settings-popup-preview-button-container');
|
||||||
const settings = $('#settings-popup-preview-settings');
|
const settings = $('#settings-popup-preview-settings');
|
||||||
const text = $('#settings-popup-preview-text');
|
const text = $('#settings-popup-preview-text');
|
||||||
|
const customCss = $('#custom-popup-css');
|
||||||
|
|
||||||
const frame = document.createElement('iframe');
|
const frame = document.createElement('iframe');
|
||||||
frame.src = '/bg/settings-popup-preview.html';
|
frame.src = '/bg/settings-popup-preview.html';
|
||||||
@ -292,6 +293,11 @@ function showAppearancePreview() {
|
|||||||
const params = {text: text.val()};
|
const params = {text: text.val()};
|
||||||
frame.contentWindow.postMessage({action, params}, '*');
|
frame.contentWindow.postMessage({action, params}, '*');
|
||||||
});
|
});
|
||||||
|
customCss.on('input', () => {
|
||||||
|
const action = 'setCustomCss';
|
||||||
|
const params = {css: customCss.val()};
|
||||||
|
frame.contentWindow.postMessage({action, params}, '*');
|
||||||
|
});
|
||||||
|
|
||||||
container.append(frame);
|
container.append(frame);
|
||||||
buttonContainer.remove();
|
buttonContainer.remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user