spell check support + small options tabs reorganization

This commit is contained in:
zadam
2019-10-06 21:35:26 +02:00
parent 3f2229d9e1
commit c1e8a4b384
26 changed files with 560 additions and 213 deletions

View File

@@ -19,8 +19,7 @@ export async function showDialog() {
import('./options/appearance.js'),
import('./options/code_notes.js'),
import('./options/change_password.js'),
import('./options/note_revisions.js'),
import('./options/protected_session.js'),
import('./options/other.js'),
import('./options/sidebar.js'),
import('./options/sync.js'),
]))

View File

@@ -1,20 +0,0 @@
import server from "../../services/server.js";
import infoService from "../../services/info.js";
export default class NoteRevisionsOptions {
constructor() {
this.$form = $("#note-revision-snapshot-time-interval-form");
this.$timeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
this.$form.submit(() => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$timeInterval.val() };
server.put('options', opts).then(() => infoService.showMessage("Options change have been saved."));
return false;
});
}
optionsLoaded(options) {
this.$timeInterval.val(options['noteRevisionSnapshotTimeInterval']);
}
}

View File

@@ -0,0 +1,54 @@
import optionsService from "../../services/options.js";
import server from "../../services/server.js";
import infoService from "../../services/info.js";
export default class ProtectedSessionOptions {
constructor() {
this.$spellCheckEnabled = $("#spell-check-enabled");
this.$spellCheckLanguageCode = $("#spell-check-language-code");
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
this.$noteRevisionsTimeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
this.$spellCheckEnabled.change(() => {
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" };
server.put('options', opts).then(() => infoService.showMessage("Options change have been saved."));
return false;
});
this.$spellCheckLanguageCode.change(() => {
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() };
server.put('options', opts).then(() => infoService.showMessage("Options change have been saved."));
return false;
});
this.$protectedSessionTimeout.change(() => {
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
optionsService.reloadOptions();
infoService.showMessage("Options change have been saved.");
});
return false;
});
this.$noteRevisionsTimeInterval.change(() => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() };
server.put('options', opts).then(() => infoService.showMessage("Options change have been saved."));
return false;
});
}
optionsLoaded(options) {
this.$spellCheckEnabled.prop("checked", options['spellCheckEnabled'] === 'true');
this.$spellCheckLanguageCode.val(options['spellCheckLanguageCode']);
this.$protectedSessionTimeout.val(options['protectedSessionTimeout']);
this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']);
}
}

View File

@@ -1,28 +0,0 @@
import optionsService from "../../services/options.js";
import server from "../../services/server.js";
import infoService from "../../services/info.js";
export default class ProtectedSessionOptions {
constructor() {
this.$form = $("#protected-session-timeout-form");
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
this.$form.submit(() => this.save());
}
optionsLoaded(options) {
this.$protectedSessionTimeout.val(options['protectedSessionTimeout']);
}
save() {
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
optionsService.reloadOptions();
infoService.showMessage("Options change have been saved.");
});
return false;
}
}