WIP
This commit is contained in:
parent
edbb8086bc
commit
5db0d5d59a
@ -20,12 +20,14 @@
|
|||||||
function optionsToForm(opts) {
|
function optionsToForm(opts) {
|
||||||
$('#scanLength').val(opts.scanLength);
|
$('#scanLength').val(opts.scanLength);
|
||||||
$('#loadOnStartup').prop('checked', opts.loadOnStartup);
|
$('#loadOnStartup').prop('checked', opts.loadOnStartup);
|
||||||
|
$('#highlightText').prop('checked', opts.highlightText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formToOptions() {
|
function formToOptions() {
|
||||||
return sanitizeOptions({
|
return sanitizeOptions({
|
||||||
scanLength: $('#scanLength').val(),
|
scanLength: $('#scanLength').val(),
|
||||||
loadOnStartup: $('#loadOnStartup').prop('checked')
|
loadOnStartup: $('#loadOnStartup').prop('checked'),
|
||||||
|
highlightText: $('#highlightText').prop('checked')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
function sanitizeOptions(options) {
|
function sanitizeOptions(options) {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
scanLength: 20,
|
scanLength: 20,
|
||||||
loadOnStartup: false
|
loadOnStartup: false,
|
||||||
|
highlightText: true
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in defaults) {
|
for (const key in defaults) {
|
||||||
|
@ -21,9 +21,15 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label><input type="checkbox" id="loadOnStartup"> Load on startup</label>
|
||||||
<input type="checkbox" id="loadOnStartup"> Load on startup
|
</div>
|
||||||
</label>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label><input type="checkbox" id="highlightText" checked> Highlight text</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -113,9 +113,11 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showPopup(range) {
|
showPopup(range) {
|
||||||
const selection = window.getSelection();
|
if (this.options.highlightText) {
|
||||||
selection.removeAllRanges();
|
const selection = window.getSelection();
|
||||||
selection.addRange(range);
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
}
|
||||||
|
|
||||||
const pos = getPopupPositionForRange(this.popup, range, this.popupOffset);
|
const pos = getPopupPositionForRange(this.popup, range, this.popupOffset);
|
||||||
|
|
||||||
@ -130,8 +132,10 @@ class Client {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const selection = window.getSelection();
|
if (this.options.highlightText) {
|
||||||
selection.removeAllRanges();
|
const selection = window.getSelection();
|
||||||
|
selection.removeAllRanges();
|
||||||
|
}
|
||||||
|
|
||||||
this.popupText = '';
|
this.popupText = '';
|
||||||
this.popup.style.visibility = 'hidden';
|
this.popup.style.visibility = 'hidden';
|
||||||
|
Loading…
Reference in New Issue
Block a user