mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
refactoring of legacy js events
This commit is contained in:
@@ -19,7 +19,7 @@ export async function showDialog() {
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
$autoComplete.val('').focus();
|
||||
$autoComplete.val('').trigger('focus');
|
||||
$linkTitle.val('');
|
||||
|
||||
async function setDefaultLinkTitle(noteId) {
|
||||
@@ -51,7 +51,7 @@ export async function showDialog() {
|
||||
noteAutocompleteService.showRecentNotes($autoComplete);
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
const notePath = $autoComplete.getSelectedPath();
|
||||
|
||||
if (notePath) {
|
||||
|
||||
@@ -99,7 +99,7 @@ function AttributesModel() {
|
||||
await showAttributes(attributes);
|
||||
|
||||
// attribute might not be rendered immediatelly so could not focus
|
||||
setTimeout(() => $(".attribute-type-select:last").focus(), 1000);
|
||||
setTimeout(() => $(".attribute-type-select:last").trigger('focus'), 1000);
|
||||
};
|
||||
|
||||
this.deleteAttribute = function(data, event) {
|
||||
@@ -129,7 +129,7 @@ function AttributesModel() {
|
||||
// we need to defocus from input (in case of enter-triggered save) because value is updated
|
||||
// on blur event (because of conflict with jQuery UI Autocomplete). Without this, input would
|
||||
// stay in focus, blur wouldn't be triggered and change wouldn't be updated in the viewmodel.
|
||||
$saveAttributesButton.focus();
|
||||
$saveAttributesButton.trigger('focus');
|
||||
|
||||
if (!isValid()) {
|
||||
alert("Please fix all validation errors and try saving again.");
|
||||
|
||||
@@ -41,10 +41,10 @@ async function savePrefix() {
|
||||
toastService.showMessage("Branch prefix has been saved.");
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
savePrefix();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$dialog.on('shown.bs.modal', () => $treePrefixInput.focus());
|
||||
$dialog.on('shown.bs.modal', () => $treePrefixInput.trigger('focus'));
|
||||
@@ -26,13 +26,13 @@ export async function showDialog(noteId) {
|
||||
|
||||
$dialog.modal();
|
||||
|
||||
$noteAutoComplete.val('').focus();
|
||||
$noteAutoComplete.val('').trigger('focus');
|
||||
|
||||
noteAutocompleteService.initNoteAutocomplete($noteAutoComplete);
|
||||
noteAutocompleteService.showRecentNotes($noteAutoComplete);
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
const notePath = $noteAutoComplete.getSelectedPath();
|
||||
|
||||
if (notePath) {
|
||||
|
||||
@@ -64,7 +64,7 @@ $dialog.on("hidden.bs.modal", () => {
|
||||
}
|
||||
|
||||
if ($originallyFocused) {
|
||||
$originallyFocused.focus();
|
||||
$originallyFocused.trigger('focus');
|
||||
$originallyFocused = null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ export async function showDialog(node, defaultType) {
|
||||
$noteTitle.html(noteTitle);
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
$dialog.modal('hide');
|
||||
|
||||
const exportType = $dialog.find("input[name='export-type']:checked").val();
|
||||
|
||||
@@ -35,7 +35,7 @@ export async function showDialog(node) {
|
||||
$dialog.modal();
|
||||
}
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
// disabling so that import is not triggered again.
|
||||
$importButton.attr("disabled", "disabled");
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ $dialog.on("hidden.bs.modal", () => {
|
||||
}
|
||||
|
||||
if ($originallyFocused) {
|
||||
$originallyFocused.focus();
|
||||
$originallyFocused.trigger('focus');
|
||||
$originallyFocused = null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -51,6 +51,6 @@ async function sendForm() {
|
||||
|
||||
$importButton.on('click', sendForm);
|
||||
|
||||
$dialog.on('shown.bs.modal', () => $importTextarea.focus());
|
||||
$dialog.on('shown.bs.modal', () => $importTextarea.trigger('focus'));
|
||||
|
||||
utils.bindElShortcut($dialog, 'ctrl+return', sendForm);
|
||||
@@ -31,7 +31,7 @@ export default class ChangePasswordOptions {
|
||||
this.$newPassword1 = $("#new-password1");
|
||||
this.$newPassword2 = $("#new-password2");
|
||||
|
||||
this.$form.submit(() => this.save());
|
||||
this.$form.on('submit', () => this.save());
|
||||
}
|
||||
|
||||
optionsLoaded(options) {}
|
||||
|
||||
@@ -47,7 +47,7 @@ export default class SyncOptions {
|
||||
this.$syncProxy = $("#sync-proxy");
|
||||
this.$testSyncButton = $("#test-sync-button");
|
||||
|
||||
this.$form.submit(() => this.save());
|
||||
this.$form.on('submit', () => this.save());
|
||||
|
||||
this.$testSyncButton.on('click', async () => {
|
||||
const result = await server.post('sync/test');
|
||||
|
||||
@@ -44,7 +44,7 @@ $dialog.on('shown.bs.modal', () => {
|
||||
shownCb({ $dialog, $question, $answer, $form });
|
||||
}
|
||||
|
||||
$answer.focus().select();
|
||||
$answer.trigger('focus').select();
|
||||
});
|
||||
|
||||
$dialog.on("hidden.bs.modal", () => {
|
||||
@@ -53,7 +53,7 @@ $dialog.on("hidden.bs.modal", () => {
|
||||
}
|
||||
});
|
||||
|
||||
$form.submit(() => {
|
||||
$form.on('submit', () => {
|
||||
resolve($answer.val());
|
||||
|
||||
$dialog.modal('hide');
|
||||
|
||||
@@ -7,7 +7,7 @@ const $passwordInput = $dialog.find(".protected-session-password");
|
||||
export function show() {
|
||||
$dialog.modal();
|
||||
|
||||
$passwordInput.focus();
|
||||
$passwordInput.trigger('focus');
|
||||
}
|
||||
|
||||
export function close() {
|
||||
@@ -18,7 +18,7 @@ export function close() {
|
||||
catch (e) {}
|
||||
}
|
||||
|
||||
$passwordForm.submit(() => {
|
||||
$passwordForm.on('submit', () => {
|
||||
const password = $passwordInput.val();
|
||||
$passwordInput.val("");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user