refactoring of legacy js events

This commit is contained in:
zadam
2019-11-09 17:39:48 +01:00
parent 179d530ea9
commit 31bcc037f1
39 changed files with 110 additions and 110 deletions

View File

@@ -76,5 +76,5 @@ function doResolve(ret) {
$dialog.modal("hide");
}
$cancelButton.click(() => doResolve(false));
$okButton.click(() => doResolve(true));
$cancelButton.on('click', () => doResolve(false));
$okButton.on('click', () => doResolve(true));

View File

@@ -24,13 +24,13 @@ export async function showDialog(node, defaultType) {
$exportButton.removeAttr("disabled");
if (defaultType === 'subtree') {
$subtreeType.prop("checked", true).change();
$subtreeType.prop("checked", true).trigger('change');
// to show/hide OPML versions
$("input[name=export-subtree-format]:checked").change();
$("input[name=export-subtree-format]:checked").trigger('change');
}
else if (defaultType === 'single') {
$singleType.prop("checked", true).change();
$singleType.prop("checked", true).trigger('change');
}
else {
throw new Error("Unrecognized type " + defaultType);
@@ -79,7 +79,7 @@ function exportBranch(branchId, type, format, version) {
utils.download(url);
}
$('input[name=export-type]').change(function () {
$('input[name=export-type]').on('change', function () {
if (this.value === 'subtree') {
if ($("input[name=export-subtree-format]:checked").length === 0) {
$("input[name=export-subtree-format]:first").prop("checked", true);
@@ -98,7 +98,7 @@ $('input[name=export-type]').change(function () {
}
});
$('input[name=export-subtree-format]').change(function () {
$('input[name=export-subtree-format]').on('change', function () {
if (this.value === 'opml') {
$opmlVersions.slideDown();
}

View File

@@ -18,7 +18,7 @@ let parentNoteId = null;
export async function showDialog(node) {
utils.closeActiveDialog();
$fileUploadInput.val('').change(); // to trigger Import button disabling listener below
$fileUploadInput.val('').trigger('change'); // to trigger Import button disabling listener below
$safeImportCheckbox.prop("checked", true);
$shrinkImagesCheckbox.prop("checked", true);
@@ -64,7 +64,7 @@ function boolToString($el) {
return $el.is(":checked") ? "true" : "false";
}
$fileUploadInput.change(() => {
$fileUploadInput.on('change', () => {
if ($fileUploadInput.val()) {
$importButton.removeAttr("disabled");
}

View File

@@ -34,4 +34,4 @@ $dialog.on("hidden.bs.modal", () => {
}
});
$okButton.click(() => $dialog.modal("hide"));
$okButton.on('click', () => $dialog.modal("hide"));

View File

@@ -43,6 +43,6 @@ function showInFullText(e) {
}
$showInFullTextButton.click(showInFullText);
$showInFullTextButton.on('click', showInFullText);
utils.bindElShortcut($dialog, 'ctrl+return', showInFullText);

View File

@@ -49,7 +49,7 @@ async function sendForm() {
$importTextarea.val('');
}
$importButton.click(sendForm);
$importButton.on('click', sendForm);
$dialog.on('shown.bs.modal', () => $importTextarea.focus());

View File

@@ -25,4 +25,4 @@ export function showDialog() {
$mime.text(activeNote.mime);
}
$okButton.click(() => $dialog.modal('hide'));
$okButton.on('click', () => $dialog.modal('hide'));

View File

@@ -37,7 +37,7 @@ async function loadNoteRevisions(noteId, noteRevisionId) {
for (const item of revisionItems) {
$list.append($('<option>', {
value: item.noteRevisionId,
text: item.dateLastEdited.substr(0, 16)
text: item.dateLastEdited.substr(0, 16) + ` (${item.contentLength} bytes)`
}));
}

View File

@@ -37,25 +37,25 @@ export default class AdvancedOptions {
this.$cleanupUnusedImagesButton = $("#cleanup-unused-images-button");
this.$vacuumDatabaseButton = $("#vacuum-database-button");
this.$forceFullSyncButton.click(async () => {
this.$forceFullSyncButton.on('click', async () => {
await server.post('sync/force-full-sync');
toastService.showMessage("Full sync triggered");
});
this.$fillSyncRowsButton.click(async () => {
this.$fillSyncRowsButton.on('click', async () => {
await server.post('sync/fill-sync-rows');
toastService.showMessage("Sync rows filled successfully");
});
this.$anonymizeButton.click(async () => {
this.$anonymizeButton.on('click', async () => {
await server.post('anonymization/anonymize');
toastService.showMessage("Created anonymized database");
});
this.$cleanupSoftDeletedButton.click(async () => {
this.$cleanupSoftDeletedButton.on('click', async () => {
if (confirm("Do you really want to clean up soft-deleted items?")) {
await server.post('cleanup/cleanup-soft-deleted-items');
@@ -63,7 +63,7 @@ export default class AdvancedOptions {
}
});
this.$cleanupUnusedImagesButton.click(async () => {
this.$cleanupUnusedImagesButton.on('click', async () => {
if (confirm("Do you really want to clean up unused images?")) {
await server.post('cleanup/cleanup-unused-images');
@@ -71,7 +71,7 @@ export default class AdvancedOptions {
}
});
this.$vacuumDatabaseButton.click(async () => {
this.$vacuumDatabaseButton.on('click', async () => {
await server.post('cleanup/vacuum-database');
toastService.showMessage("Database has been vacuumed");

View File

@@ -117,7 +117,7 @@ export default class ApperanceOptions {
this.$body = $("body");
this.$container = $("#container");
this.$themeSelect.change(() => {
this.$themeSelect.on('change', () => {
const newTheme = this.$themeSelect.val();
for (const clazz of Array.from(this.$body[0].classList)) { // create copy to safely iterate over while removing classes
@@ -139,40 +139,40 @@ export default class ApperanceOptions {
server.put('options/theme/' + newTheme);
});
this.$zoomFactorSelect.change(() => { zoomService.setZoomFactorAndSave(this.$zoomFactorSelect.val()); });
this.$zoomFactorSelect.on('change', () => { zoomService.setZoomFactorAndSave(this.$zoomFactorSelect.val()); });
this.$oneTabDisplaySelect.change(() => {
this.$oneTabDisplaySelect.on('change', () => {
const hideTabRowForOneTab = this.$oneTabDisplaySelect.val() === 'hide' ? 'true' : 'false';
server.put('options/hideTabRowForOneTab/' + hideTabRowForOneTab)
.then(optionsService.reloadOptions);
});
this.$leftPaneMinWidth.change(async () => {
this.$leftPaneMinWidth.on('change', async () => {
await server.put('options/leftPaneMinWidth/' + this.$leftPaneMinWidth.val());
this.resizeLeftPanel();
});
this.$leftPaneWidthPercent.change(async () => {
this.$leftPaneWidthPercent.on('change', async () => {
await server.put('options/leftPaneWidthPercent/' + this.$leftPaneWidthPercent.val());
this.resizeLeftPanel();
});
this.$mainFontSize.change(async () => {
this.$mainFontSize.on('change', async () => {
await server.put('options/mainFontSize/' + this.$mainFontSize.val());
this.applyFontSizes();
});
this.$treeFontSize.change(async () => {
this.$treeFontSize.on('change', async () => {
await server.put('options/treeFontSize/' + this.$treeFontSize.val());
this.applyFontSizes();
});
this.$detailFontSize.change(async () => {
this.$detailFontSize.on('change', async () => {
await server.put('options/detailFontSize/' + this.$detailFontSize.val());
this.applyFontSizes();

View File

@@ -27,7 +27,7 @@ export default class CodeNotesOptions {
.attr("id", id)
.attr("data-mime-type", mimeType.mime)
.prop("checked", mimeType.enabled))
.change(() => this.save())
.on('change', () => this.save())
.append(" &nbsp; ")
.append($('<label>')
.attr("for", id)

View File

@@ -27,12 +27,12 @@ const TPL = `
<h4>Image compression</h4>
<div class="form-group">
<label for="image-max-width-height">Max width / height of an image in pixels (if image will be resized if it exceeds this setting).</label>
<label for="image-max-width-height">Max width / height of an image in pixels (image will be resized if it exceeds this setting).</label>
<input class="form-control" id="image-max-width-height" type="number">
</div>
<div class="form-group">
<label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality)</label>
<label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
<input class="form-control" id="image-jpeg-quality" min="0" max="100" type="number">
</div>
</div>
@@ -67,14 +67,14 @@ export default class ProtectedSessionOptions {
this.$spellCheckEnabled = $("#spell-check-enabled");
this.$spellCheckLanguageCode = $("#spell-check-language-code");
this.$spellCheckEnabled.change(() => {
this.$spellCheckEnabled.on('change', () => {
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
this.$spellCheckLanguageCode.change(() => {
this.$spellCheckLanguageCode.on('change', () => {
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
@@ -83,7 +83,7 @@ export default class ProtectedSessionOptions {
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
this.$protectedSessionTimeout.change(() => {
this.$protectedSessionTimeout.on('change', () => {
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
@@ -97,7 +97,7 @@ export default class ProtectedSessionOptions {
this.$noteRevisionsTimeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
this.$noteRevisionsTimeInterval.change(() => {
this.$noteRevisionsTimeInterval.on('change', () => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
@@ -107,14 +107,14 @@ export default class ProtectedSessionOptions {
this.$imageMaxWidthHeight = $("#image-max-width-height");
this.$imageJpegQuality = $("#image-jpeg-quality");
this.$imageMaxWidthHeight.change(() => {
this.$imageMaxWidthHeight.on('change', () => {
const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
return false;
});
this.$imageJpegQuality.change(() => {
this.$imageJpegQuality.on('change', () => {
const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() };
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));

View File

@@ -65,19 +65,19 @@ export default class SidebarOptions {
this.$widgetsEnabled = $("#widgets-enabled");
this.$widgetsDisabled = $("#widgets-disabled");
this.$sidebarMinWidth.change(async () => {
this.$sidebarMinWidth.on('change', async () => {
await server.put('options/sidebarMinWidth/' + this.$sidebarMinWidth.val());
this.resizeSidebar();
});
this.$sidebarWidthPercent.change(async () => {
this.$sidebarWidthPercent.on('change', async () => {
await server.put('options/sidebarWidthPercent/' + this.$sidebarWidthPercent.val());
this.resizeSidebar();
});
this.$showSidebarInNewTab.change(async () => {
this.$showSidebarInNewTab.on('change', async () => {
const flag = this.$showSidebarInNewTab.is(":checked") ? 'true' : 'false';
await server.put('options/showSidebarInNewTab/' + flag);
@@ -131,7 +131,7 @@ export default class SidebarOptions {
.attr("title", "If checked, the widget will be by default expanded (opened)")
.append($(`<input type="checkbox"${option.expanded ? ' checked' : ''}>`)
.attr('id', 'widget-exp-' + name)
.change(() => this.save()))
.on('change', () => this.save()))
.append("&nbsp;")
.append($("<label>")
.attr("for", 'widget-exp-' + name)

View File

@@ -49,7 +49,7 @@ export default class SyncOptions {
this.$form.submit(() => this.save());
this.$testSyncButton.click(async () => {
this.$testSyncButton.on('click', async () => {
const result = await server.post('sync/test');
if (result.success) {

View File

@@ -119,10 +119,10 @@ async function showTables() {
$tableLink
.tooltip({html: true, title: $columns.html()})
.click(() => codeEditor.setValue("SELECT * FROM " + table.name + " LIMIT 100"));
.on('click', () => codeEditor.setValue("SELECT * FROM " + table.name + " LIMIT 100"));
}
}
utils.bindElShortcut($query, 'ctrl+return', execute);
$executeButton.click(execute);
$executeButton.on('click', execute);