mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better protected/unprotected note indicator, fixes #110
This commit is contained in:
parent
31b76b23ce
commit
083cccea28
BIN
src/public/images/icons/shield-off.png
Normal file
BIN
src/public/images/icons/shield-off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 462 B |
BIN
src/public/images/icons/shield.png
Normal file
BIN
src/public/images/icons/shield.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 388 B |
@ -22,6 +22,7 @@ const $noteDetailComponents = $(".note-detail-component");
|
||||
const $protectButton = $("#protect-button");
|
||||
const $unprotectButton = $("#unprotect-button");
|
||||
const $noteDetailWrapper = $("#note-detail-wrapper");
|
||||
const $noteDetailComponentWrapper = $("#note-detail-component-wrapper");
|
||||
const $noteIdDisplay = $("#note-id-display");
|
||||
const $labelList = $("#label-list");
|
||||
const $labelListInner = $("#label-list-inner");
|
||||
@ -116,9 +117,9 @@ async function saveNoteIfChanged() {
|
||||
function setNoteBackgroundIfProtected(note) {
|
||||
const isProtected = !!note.isProtected;
|
||||
|
||||
$noteDetailWrapper.toggleClass("protected", isProtected);
|
||||
$protectButton.toggle(!isProtected);
|
||||
$unprotectButton.toggle(isProtected);
|
||||
$noteDetailComponentWrapper.toggleClass("protected", isProtected);
|
||||
$protectButton.toggleClass("active", isProtected);
|
||||
$unprotectButton.toggleClass("active", !isProtected);
|
||||
}
|
||||
|
||||
let isNewNoteCreated = false;
|
||||
@ -150,6 +151,8 @@ async function loadNoteDetail(noteId) {
|
||||
|
||||
$noteIdDisplay.html(noteId);
|
||||
|
||||
setNoteBackgroundIfProtected(currentNote);
|
||||
|
||||
await handleProtectedSession();
|
||||
|
||||
$noteDetailWrapper.show();
|
||||
@ -170,7 +173,6 @@ async function loadNoteDetail(noteId) {
|
||||
noteChangeDisabled = false;
|
||||
}
|
||||
|
||||
setNoteBackgroundIfProtected(currentNote);
|
||||
treeService.setBranchBackgroundBasedOnProtectedStatus(noteId);
|
||||
|
||||
// after loading new note make sure editor is scrolled to the top
|
||||
|
@ -105,6 +105,10 @@ async function enterProtectedSessionOnServer(password) {
|
||||
}
|
||||
|
||||
async function protectNoteAndSendToServer() {
|
||||
if (noteDetailService.getCurrentNote().isProtected) {
|
||||
return;
|
||||
}
|
||||
|
||||
await ensureProtectedSession(true, true);
|
||||
|
||||
const note = noteDetailService.getCurrentNote();
|
||||
@ -118,6 +122,10 @@ async function protectNoteAndSendToServer() {
|
||||
}
|
||||
|
||||
async function unprotectNoteAndSendToServer() {
|
||||
if (!noteDetailService.getCurrentNote().isProtected) {
|
||||
return;
|
||||
}
|
||||
|
||||
await ensureProtectedSession(true, true);
|
||||
|
||||
const note = noteDetailService.getCurrentNote();
|
||||
|
@ -51,7 +51,7 @@
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#note-detail-wrapper.protected, #note-detail-wrapper.protected .CodeMirror {
|
||||
#note-detail-component-wrapper.protected, #note-detail-component-wrapper.protected .CodeMirror {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
@ -138,10 +138,6 @@ span.fancytree-active:not(.fancytree-focused) .fancytree-title {
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
#protect-button, #unprotect-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ui-widget-content a:not(.ui-tabs-anchor) {
|
||||
color: #337ab7 !important;
|
||||
}
|
||||
@ -361,10 +357,11 @@ div.ui-tooltip {
|
||||
|
||||
.btn {
|
||||
border-color: #ddd;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.btn.active {
|
||||
background-color: #ddd;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
#note-path-list .current a {
|
||||
|
@ -105,15 +105,18 @@
|
||||
|
||||
<span id="note-id-display" title="Note ID"></span>
|
||||
|
||||
<a title="Protect the note so that password will be required to view the note"
|
||||
class="icon-action"
|
||||
id="protect-button"
|
||||
style="display: none; background: url('images/icons/lock.png')"></a>
|
||||
<div>
|
||||
<span style="font-size: smaller">Protected:</span>
|
||||
|
||||
<a title="Unprotect note so that password will not be required to access this note in the future"
|
||||
class="icon-action"
|
||||
id="unprotect-button"
|
||||
style="display: none; background: url('images/icons/unlock.png')"></a>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<button type="button" class="btn" id="protect-button" title="Protected note can be viewed and edited only after entering password">
|
||||
<img src="images/icons/shield.png"/>
|
||||
</button>
|
||||
<button type="button" class="btn" id="unprotect-button" title="Not protected note can be viewed without entering password">
|
||||
<img src="images/icons/shield-off.png"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user