Add settings to control popup content scale

This commit is contained in:
toasted-nutbread 2019-12-23 17:39:00 -05:00
parent e740965d4f
commit 351598a182
4 changed files with 25 additions and 1 deletions

View File

@ -279,6 +279,8 @@ function profileOptionsCreateDefaults() {
popupVerticalOffset2: 0,
popupHorizontalTextPosition: 'below',
popupVerticalTextPosition: 'before',
popupScalingFactor: 1,
popupScaleRelativeToPageZoom: false,
showGuide: true,
compactTags: false,
compactGlossaries: false,

View File

@ -44,6 +44,8 @@ async function formRead(options) {
options.general.popupVerticalOffset = parseInt($('#popup-vertical-offset').val(), 10);
options.general.popupHorizontalOffset2 = parseInt($('#popup-horizontal-offset2').val(), 0);
options.general.popupVerticalOffset2 = parseInt($('#popup-vertical-offset2').val(), 10);
options.general.popupScalingFactor = parseInt($('#popup-scaling-factor').val(), 10);
options.general.popupScaleRelativeToPageZoom = $('#popup-scale-relative-to-page-zoom').val() === 'true';
options.general.popupTheme = $('#popup-theme').val();
options.general.popupOuterTheme = $('#popup-outer-theme').val();
options.general.customPopupCss = $('#custom-popup-css').val();
@ -109,6 +111,8 @@ async function formWrite(options) {
$('#popup-vertical-offset').val(options.general.popupVerticalOffset);
$('#popup-horizontal-offset2').val(options.general.popupHorizontalOffset2);
$('#popup-vertical-offset2').val(options.general.popupVerticalOffset2);
$('#popup-scaling-factor').val(options.general.popupScalingFactor);
$('#popup-scale-relative-to-page-zoom').val(options.general.popupScaleRelativeToPageZoom ? 'true' : 'false');
$('#popup-theme').val(options.general.popupTheme);
$('#popup-outer-theme').val(options.general.popupOuterTheme);
$('#custom-popup-css').val(options.general.customPopupCss);

View File

@ -237,6 +237,22 @@
</div>
</div>
<div class="form-group options-advanced">
<div class="row">
<div class="col-xs-6">
<label for="popup-scaling-factor">Popup size multiplier</label>
<input type="number" min="0" id="popup-scaling-factor" class="form-control">
</div>
<div class="col-xs-6">
<label for="popup-scale-relative-to-page-zoom">Popup size mode</label>
<select class="form-control" id="popup-scale-relative-to-page-zoom">
<option value="false">Absolute</option>
<option value="true">Relative to zoom level</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-xs-6">

View File

@ -196,7 +196,9 @@ class Frontend extends TextScanner {
}
_updateContentScale() {
const contentScale = 1.0 / this._pageZoomFactor; // TODO : Use options
const {popupScalingFactor, popupScaleRelativeToPageZoom} = this.options.general;
let contentScale = popupScalingFactor;
if (popupScaleRelativeToPageZoom) { contentScale /= this._pageZoomFactor; }
if (contentScale === this._contentScale) { return; }
this._contentScale = contentScale;