diff --git a/src/public/javascripts/dialogs/add_link.js b/src/public/javascripts/dialogs/add_link.js
index 2985a8ef1..ea91e33a8 100644
--- a/src/public/javascripts/dialogs/add_link.js
+++ b/src/public/javascripts/dialogs/add_link.js
@@ -1,18 +1,18 @@
"use strict";
const addLink = (function() {
- const dialogEl = $("#add-link-dialog");
- const formEl = $("#add-link-form");
- const autoCompleteEl = $("#note-autocomplete");
- const linkTitleEl = $("#link-title");
- const clonePrefixEl = $("#clone-prefix");
- const linkTitleFormGroup = $("#add-link-title-form-group");
- const prefixFormGroup = $("#add-link-prefix-form-group");
- const linkTypeEls = $("input[name='add-link-type']");
- const linkTypeHtmlEl = linkTypeEls.filter('input[value="html"]');
+ const $dialog = $("#add-link-dialog");
+ const $form = $("#add-link-form");
+ const $autoComplete = $("#note-autocomplete");
+ const $linkTitle = $("#link-title");
+ const $clonePrefix = $("#clone-prefix");
+ const $linkTitleFormGroup = $("#add-link-title-form-group");
+ const $prefixFormGroup = $("#add-link-prefix-form-group");
+ const $linkTypes = $("input[name='add-link-type']");
+ const $linkTypeHtml = $linkTypes.filter('input[value="html"]');
function setLinkType(linkType) {
- linkTypeEls.each(function () {
+ $linkTypes.each(function () {
$(this).prop('checked', $(this).val() === linkType);
});
@@ -20,39 +20,39 @@ const addLink = (function() {
}
function showDialog() {
- glob.activeDialog = dialogEl;
+ glob.activeDialog = $dialog;
if (noteEditor.getCurrentNoteType() === 'text') {
- linkTypeHtmlEl.prop('disabled', false);
+ $linkTypeHtml.prop('disabled', false);
setLinkType('html');
}
else {
- linkTypeHtmlEl.prop('disabled', true);
+ $linkTypeHtml.prop('disabled', true);
setLinkType('selected-to-current');
}
- dialogEl.dialog({
+ $dialog.dialog({
modal: true,
width: 700
});
- autoCompleteEl.val('').focus();
- clonePrefixEl.val('');
- linkTitleEl.val('');
+ $autoComplete.val('').focus();
+ $clonePrefix.val('');
+ $linkTitle.val('');
function setDefaultLinkTitle(noteId) {
const noteTitle = noteTree.getNoteTitle(noteId);
- linkTitleEl.val(noteTitle);
+ $linkTitle.val(noteTitle);
}
- autoCompleteEl.autocomplete({
+ $autoComplete.autocomplete({
source: noteTree.getAutocompleteItems(),
minLength: 0,
change: () => {
- const val = autoCompleteEl.val();
+ const val = $autoComplete.val();
const notePath = link.getNodePathFromLabel(val);
if (!notePath) {
return;
@@ -75,8 +75,8 @@ const addLink = (function() {
});
}
- formEl.submit(() => {
- const value = autoCompleteEl.val();
+ $form.submit(() => {
+ const value = $autoComplete.val();
const notePath = link.getNodePathFromLabel(value);
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
@@ -85,25 +85,25 @@ const addLink = (function() {
const linkType = $("input[name='add-link-type']:checked").val();
if (linkType === 'html') {
- const linkTitle = linkTitleEl.val();
+ const linkTitle = $linkTitle.val();
- dialogEl.dialog("close");
+ $dialog.dialog("close");
link.addLinkToEditor(linkTitle, '#' + notePath);
}
else if (linkType === 'selected-to-current') {
- const prefix = clonePrefixEl.val();
+ const prefix = $clonePrefix.val();
cloning.cloneNoteTo(noteId, noteEditor.getCurrentNoteId(), prefix);
- dialogEl.dialog("close");
+ $dialog.dialog("close");
}
else if (linkType === 'current-to-selected') {
- const prefix = clonePrefixEl.val();
+ const prefix = $clonePrefix.val();
cloning.cloneNoteTo(noteEditor.getCurrentNoteId(), noteId, prefix);
- dialogEl.dialog("close");
+ $dialog.dialog("close");
}
}
@@ -111,19 +111,19 @@ const addLink = (function() {
});
function linkTypeChanged() {
- const value = linkTypeEls.filter(":checked").val();
+ const value = $linkTypes.filter(":checked").val();
if (value === 'html') {
- linkTitleFormGroup.show();
- prefixFormGroup.hide();
+ $linkTitleFormGroup.show();
+ $prefixFormGroup.hide();
}
else {
- linkTitleFormGroup.hide();
- prefixFormGroup.show();
+ $linkTitleFormGroup.hide();
+ $prefixFormGroup.show();
}
}
- linkTypeEls.change(linkTypeChanged);
+ $linkTypes.change(linkTypeChanged);
$(document).bind('keydown', 'ctrl+l', e => {
showDialog();
diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js
index 837e96e8d..bd3afa366 100644
--- a/src/public/javascripts/dialogs/attributes.js
+++ b/src/public/javascripts/dialogs/attributes.js
@@ -33,6 +33,8 @@ const attributesDialog = (function() {
update: function() {
let position = 0;
+ // we need to update positions by searching in the DOM, because order of the
+ // attributes in the viewmodel (self.attributes()) stays the same
$attributesBody.find('input[name="position"]').each(function() {
const attr = self.getTargetAttribute(this);
diff --git a/src/public/javascripts/dialogs/edit_tree_prefix.js b/src/public/javascripts/dialogs/edit_tree_prefix.js
index e84e3d2b1..1729c1051 100644
--- a/src/public/javascripts/dialogs/edit_tree_prefix.js
+++ b/src/public/javascripts/dialogs/edit_tree_prefix.js
@@ -1,17 +1,17 @@
"use strict";
const editTreePrefix = (function() {
- const dialogEl = $("#edit-tree-prefix-dialog");
- const formEl = $("#edit-tree-prefix-form");
- const treePrefixInputEl = $("#tree-prefix-input");
- const noteTitleEl = $('#tree-prefix-note-title');
+ const $dialog = $("#edit-tree-prefix-dialog");
+ const $form = $("#edit-tree-prefix-form");
+ const $treePrefixInput = $("#tree-prefix-input");
+ const $noteTitle = $('#tree-prefix-note-title');
let noteTreeId;
async function showDialog() {
- glob.activeDialog = dialogEl;
+ glob.activeDialog = $dialog;
- await dialogEl.dialog({
+ await $dialog.dialog({
modal: true,
width: 500
});
@@ -20,21 +20,21 @@ const editTreePrefix = (function() {
noteTreeId = currentNode.data.noteTreeId;
- treePrefixInputEl.val(currentNode.data.prefix).focus();
+ $treePrefixInput.val(currentNode.data.prefix).focus();
const noteTitle = noteTree.getNoteTitle(currentNode.data.noteId);
- noteTitleEl.html(noteTitle);
+ $noteTitle.html(noteTitle);
}
- formEl.submit(() => {
- const prefix = treePrefixInputEl.val();
+ $form.submit(() => {
+ const prefix = $treePrefixInput.val();
server.put('tree/' + noteTreeId + '/set-prefix', {
prefix: prefix
}).then(() => noteTree.setPrefix(noteTreeId, prefix));
- dialogEl.dialog("close");
+ $dialog.dialog("close");
return false;
});
diff --git a/src/public/javascripts/dialogs/event_log.js b/src/public/javascripts/dialogs/event_log.js
index 2d65a30c9..1d223e68f 100644
--- a/src/public/javascripts/dialogs/event_log.js
+++ b/src/public/javascripts/dialogs/event_log.js
@@ -1,13 +1,13 @@
"use strict";
const eventLog = (function() {
- const dialogEl = $("#event-log-dialog");
- const listEl = $("#event-log-list");
+ const $dialog = $("#event-log-dialog");
+ const $list = $("#event-log-list");
async function showDialog() {
- glob.activeDialog = dialogEl;
+ glob.activeDialog = $dialog;
- dialogEl.dialog({
+ $dialog.dialog({
modal: true,
width: 800,
height: 700
@@ -15,7 +15,7 @@ const eventLog = (function() {
const result = await server.get('event-log');
- listEl.html('');
+ $list.html('');
for (const event of result) {
const dateTime = formatDateTime(parseDate(event.dateAdded));
@@ -28,7 +28,7 @@ const eventLog = (function() {
const eventEl = $('
').html(dateTime + " - " + event.comment);
- listEl.append(eventEl);
+ $list.append(eventEl);
}
}
diff --git a/src/public/javascripts/dialogs/jump_to_note.js b/src/public/javascripts/dialogs/jump_to_note.js
index 9066ad616..f7c151254 100644
--- a/src/public/javascripts/dialogs/jump_to_note.js
+++ b/src/public/javascripts/dialogs/jump_to_note.js
@@ -1,28 +1,28 @@
"use strict";
const jumpToNote = (function() {
- const dialogEl = $("#jump-to-note-dialog");
- const autoCompleteEl = $("#jump-to-note-autocomplete");
- const formEl = $("#jump-to-note-form");
+ const $dialog = $("#jump-to-note-dialog");
+ const $autoComplete = $("#jump-to-note-autocomplete");
+ const $form = $("#jump-to-note-form");
async function showDialog() {
- glob.activeDialog = dialogEl;
+ glob.activeDialog = $dialog;
- autoCompleteEl.val('');
+ $autoComplete.val('');
- dialogEl.dialog({
+ $dialog.dialog({
modal: true,
width: 800
});
- await autoCompleteEl.autocomplete({
+ await $autoComplete.autocomplete({
source: await stopWatch("building autocomplete", noteTree.getAutocompleteItems),
minLength: 0
});
}
function getSelectedNotePath() {
- const val = autoCompleteEl.val();
+ const val = $autoComplete.val();
return link.getNodePathFromLabel(val);
}
@@ -32,7 +32,7 @@ const jumpToNote = (function() {
if (notePath) {
noteTree.activateNode(notePath);
- dialogEl.dialog('close');
+ $dialog.dialog('close');
}
}
@@ -42,8 +42,8 @@ const jumpToNote = (function() {
e.preventDefault();
});
- formEl.submit(() => {
- const action = dialogEl.find("button:focus").val();
+ $form.submit(() => {
+ const action = $dialog.find("button:focus").val();
goToNote();
diff --git a/src/public/javascripts/dialogs/note_history.js b/src/public/javascripts/dialogs/note_history.js
index f92a66a13..48f54610d 100644
--- a/src/public/javascripts/dialogs/note_history.js
+++ b/src/public/javascripts/dialogs/note_history.js
@@ -1,10 +1,10 @@
"use strict";
const noteHistory = (function() {
- const dialogEl = $("#note-history-dialog");
- const listEl = $("#note-history-list");
- const contentEl = $("#note-history-content");
- const titleEl = $("#note-history-title");
+ const $dialog = $("#note-history-dialog");
+ const $list = $("#note-history-list");
+ const $content = $("#note-history-content");
+ const $title = $("#note-history-title");
let historyItems = [];
@@ -13,23 +13,23 @@ const noteHistory = (function() {
}
async function showNoteHistoryDialog(noteId, noteRevisionId) {
- glob.activeDialog = dialogEl;
+ glob.activeDialog = $dialog;
- dialogEl.dialog({
+ $dialog.dialog({
modal: true,
width: 800,
height: 700
});
- listEl.empty();
- contentEl.empty();
+ $list.empty();
+ $content.empty();
historyItems = await server.get('notes-history/' + noteId);
for (const item of historyItems) {
const dateModified = parseDate(item.dateModifiedFrom);
- listEl.append($('