aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/popup-preview-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-30 22:21:56 -0400
committerGitHub <noreply@github.com>2020-10-30 22:21:56 -0400
commit54768ca6e40ccfe545f083b33c4fdbe5a0bc53d2 (patch)
treeb92ee3f753b7928fef8b8b41bb8fdba42eef05c5 /ext/bg/js/settings/popup-preview-controller.js
parentf5d6573bec6ee0133e260d1a7825d91ba5d6c9e7 (diff)
Update PopupPreviewController to support settings v2 (#972)
Diffstat (limited to 'ext/bg/js/settings/popup-preview-controller.js')
-rw-r--r--ext/bg/js/settings/popup-preview-controller.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/ext/bg/js/settings/popup-preview-controller.js b/ext/bg/js/settings/popup-preview-controller.js
index 796b23ea..80a64156 100644
--- a/ext/bg/js/settings/popup-preview-controller.js
+++ b/ext/bg/js/settings/popup-preview-controller.js
@@ -26,10 +26,26 @@ class PopupPreviewController {
this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');
this._frame = null;
this._previewTextInput = null;
+ this._customCss = null;
+ this._customOuterCss = null;
}
prepare() {
- document.querySelector('#settings-popup-preview-button').addEventListener('click', this._onShowPopupPreviewButtonClick.bind(this), false);
+ const button = document.querySelector('#settings-popup-preview-button');
+ if (button !== null) {
+ button.addEventListener('click', this._onShowPopupPreviewButtonClick.bind(this), false);
+ } else {
+ this._frame = document.querySelector('#popup-preview-frame');
+ this._customCss = document.querySelector('#custom-popup-css');
+ this._customOuterCss = document.querySelector('#custom-popup-outer-css');
+
+ this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false);
+ this._customCss.addEventListener('settingChanged', this._onCustomCssChange.bind(this), false);
+ this._customOuterCss.addEventListener('input', this._onCustomOuterCssChange.bind(this), false);
+ this._customOuterCss.addEventListener('settingChanged', this._onCustomOuterCssChange.bind(this), false);
+ this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false);
+ this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this));
+ }
}
// Private
@@ -51,6 +67,8 @@ class PopupPreviewController {
this._previewTextInput = text;
this._frame = frame;
+ this._customCss = customCss;
+ this._customOuterCss = customOuterCss;
wanakana.bind(text);
@@ -75,16 +93,22 @@ class PopupPreviewController {
this._setText(this._previewTextInput.value);
}
+ _onFrameLoad2() {
+ this._onOptionsContextChange();
+ this._onCustomCssChange();
+ this._onCustomOuterCssChange();
+ }
+
_onTextChange(e) {
this._setText(e.currentTarget.value);
}
- _onCustomCssChange(e) {
- this._invoke('setCustomCss', {css: e.currentTarget.value});
+ _onCustomCssChange() {
+ this._invoke('setCustomCss', {css: this._customCss.value});
}
- _onCustomOuterCssChange(e) {
- this._invoke('setCustomOuterCss', {css: e.currentTarget.value});
+ _onCustomOuterCssChange() {
+ this._invoke('setCustomOuterCss', {css: this._customOuterCss.value});
}
_onOptionsContextChange() {