Update the popup preview to always be visible on the settings v2 page (#1151)

This commit is contained in:
toasted-nutbread 2020-12-20 22:16:38 -05:00 committed by GitHub
parent abfe066d7e
commit abc017545c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 34 deletions

View File

@ -561,11 +561,7 @@ h3 {
.preview-frame-container { .preview-frame-container {
position: relative; position: relative;
align-self: stretch; align-self: stretch;
flex: 0 1 auto; flex: 1 1 auto;
visibility: hidden;
}
.preview-frame-container.preview-frame-container-visible {
flex-grow: 1;
visibility: visible; visibility: visible;
} }
.preview-frame { .preview-frame {

View File

@ -821,7 +821,6 @@
"type": "object", "type": "object",
"required": [ "required": [
"database", "database",
"showPopupPreview",
"useSettingsV2" "useSettingsV2"
], ],
"properties": { "properties": {
@ -837,10 +836,6 @@
} }
} }
}, },
"showPopupPreview": {
"type": "boolean",
"default": false
},
"useSettingsV2": { "useSettingsV2": {
"type": "boolean", "type": "boolean",
"default": false "default": false

View File

@ -665,6 +665,8 @@ class OptionsUtil {
// Added general.popupCurrentIndicatorMode. // Added general.popupCurrentIndicatorMode.
// Added general.popupActionBarVisibility. // Added general.popupActionBarVisibility.
// Added general.popupActionBarLocation. // Added general.popupActionBarLocation.
// Removed global option showPopupPreview.
delete options.global.showPopupPreview;
for (const profile of options.profiles) { for (const profile of options.profiles) {
profile.options.general.maximumClipboardSearchLength = 1000; profile.options.general.maximumClipboardSearchLength = 1000;
profile.options.general.popupCurrentIndicatorMode = 'bar-left'; profile.options.general.popupCurrentIndicatorMode = 'bar-left';

View File

@ -29,7 +29,6 @@ class PopupPreviewController {
this._customCss = null; this._customCss = null;
this._customOuterCss = null; this._customOuterCss = null;
this._previewFrameContainer = null; this._previewFrameContainer = null;
this._showPopupPreviewCheckbox = null;
} }
async prepare() { async prepare() {
@ -41,19 +40,13 @@ class PopupPreviewController {
this._customCss = document.querySelector('#custom-popup-css'); this._customCss = document.querySelector('#custom-popup-css');
this._customOuterCss = document.querySelector('#custom-popup-outer-css'); this._customOuterCss = document.querySelector('#custom-popup-outer-css');
this._previewFrameContainer = document.querySelector('.preview-frame-container'); this._previewFrameContainer = document.querySelector('.preview-frame-container');
this._showPopupPreviewCheckbox = document.querySelector('#show-preview-checkbox');
this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false); this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false);
this._customCss.addEventListener('settingChanged', 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('input', this._onCustomOuterCssChange.bind(this), false);
this._customOuterCss.addEventListener('settingChanged', this._onCustomOuterCssChange.bind(this), false); this._customOuterCss.addEventListener('settingChanged', this._onCustomOuterCssChange.bind(this), false);
this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false); this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false);
this._showPopupPreviewCheckbox.addEventListener('change', this._onShowPreviewCheckboxChange.bind(this), false);
this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this)); this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this));
const {global: {showPopupPreview}} = await this._settingsController.getOptionsFull();
this._showPopupPreviewCheckbox.checked = showPopupPreview;
this._updatePopupPreviewVisibility();
} }
} }
@ -65,10 +58,6 @@ class PopupPreviewController {
this._previewVisible = true; this._previewVisible = true;
} }
_onShowPreviewCheckboxChange() {
this._updatePopupPreviewVisibility();
}
_showAppearancePreview() { _showAppearancePreview() {
const container = document.querySelector('#settings-popup-preview-container'); const container = document.querySelector('#settings-popup-preview-container');
const buttonContainer = document.querySelector('#settings-popup-preview-button-container'); const buttonContainer = document.querySelector('#settings-popup-preview-button-container');
@ -137,10 +126,4 @@ class PopupPreviewController {
if (this._frame === null || this._frame.contentWindow === null) { return; } if (this._frame === null || this._frame.contentWindow === null) { return; }
this._frame.contentWindow.postMessage({action, params}, this._targetOrigin); this._frame.contentWindow.postMessage({action, params}, this._targetOrigin);
} }
_updatePopupPreviewVisibility() {
const value = this._showPopupPreviewCheckbox.checked;
this._previewFrameContainer.classList.toggle('preview-frame-container-visible', value);
this._settingsController.setGlobalSetting('global.showPopupPreview', value);
}
} }

View File

@ -1458,12 +1458,6 @@
</div> </div>
<div class="content-right"> <div class="content-right">
<div class="preview-sidebar"><div class="preview-sidebar-inner"> <div class="preview-sidebar"><div class="preview-sidebar-inner">
<div class="preview-sidebar-setting">
<label class="show-preview-switch"><span class="show-preview-switch-inner">
<label class="toggle"><input type="checkbox" id="show-preview-checkbox"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
<span class="show-preview-switch-label">Show popup preview</span>
</span></label>
</div>
<div class="preview-frame-container"> <div class="preview-frame-container">
<iframe src="/bg/popup-preview.html" class="preview-frame" id="popup-preview-frame"></iframe> <iframe src="/bg/popup-preview.html" class="preview-frame" id="popup-preview-frame"></iframe>
</div> </div>

View File

@ -507,7 +507,6 @@ function createOptionsUpdatedTestData1() {
database: { database: {
prefixWildcardsSupported: false prefixWildcardsSupported: false
}, },
showPopupPreview: false,
useSettingsV2: false useSettingsV2: false
} }
}; };