mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	more refactoring
This commit is contained in:
		| @@ -38,7 +38,7 @@ | |||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div id="noteDetailWrapper" style="width: 750px; float: left; margin-left: 30px;"> |       <div id="noteDetailWrapper"> | ||||||
|         <div style="float: left; margin: 0 5px 5px 5px;" class="hide-toggle"> |         <div style="float: left; margin: 0 5px 5px 5px;" class="hide-toggle"> | ||||||
|           <button class="btn btn-sm" |           <button class="btn btn-sm" | ||||||
|                   onclick="encryptNoteAndSendToServer();" |                   onclick="encryptNoteAndSendToServer();" | ||||||
| @@ -153,19 +153,23 @@ | |||||||
|  |  | ||||||
|     <script src="stat/js/init.js"></script> |     <script src="stat/js/init.js"></script> | ||||||
|  |  | ||||||
|  |     <!-- Tree scripts --> | ||||||
|     <script src="stat/js/tree.js"></script> |     <script src="stat/js/tree.js"></script> | ||||||
|     <script src="stat/js/treeutils.js"></script> |     <script src="stat/js/tree_mutations.js"></script> | ||||||
|     <script src="stat/js/draganddrop.js"></script> |     <script src="stat/js/tree_utils.js"></script> | ||||||
|     <script src="stat/js/contextmenu.js"></script> |     <script src="stat/js/drag_and_drop.js"></script> | ||||||
|  |     <script src="stat/js/context_menu.js"></script> | ||||||
|  |  | ||||||
|  |     <!-- Note detail --> | ||||||
|     <script src="stat/js/note.js"></script> |     <script src="stat/js/note.js"></script> | ||||||
|     <script src="stat/js/notecase2html.js"></script> |     <script src="stat/js/notecase2html.js"></script> | ||||||
|     <script src="stat/js/html2notecase.js"></script> |     <script src="stat/js/html2notecase.js"></script> | ||||||
|     <script src="stat/js/encryption.js"></script> |     <script src="stat/js/encryption.js"></script> | ||||||
|  |  | ||||||
|     <script src="stat/js/recentnotes.js"></script> |     <!-- dialogs --> | ||||||
|     <script src="stat/js/addlink.js"></script> |     <script src="stat/js/recent_notes.js"></script> | ||||||
|     <script src="stat/js/jumptonote.js"></script> |     <script src="stat/js/add_link.js"></script> | ||||||
|  |     <script src="stat/js/jump_to_note.js"></script> | ||||||
|  |  | ||||||
|     <script src="stat/js/utils.js"></script> |     <script src="stat/js/utils.js"></script> | ||||||
|   </body> |   </body> | ||||||
|   | |||||||
| @@ -1,89 +1,3 @@ | |||||||
| function moveBeforeNode(node, beforeNode) { |  | ||||||
|     $.ajax({ |  | ||||||
|         url: baseUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key, |  | ||||||
|         type: 'PUT', |  | ||||||
|         contentType: "application/json", |  | ||||||
|         success: function () { |  | ||||||
|             node.moveTo(beforeNode, 'before'); |  | ||||||
|         } |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function moveAfterNode(node, afterNode) { |  | ||||||
|     $.ajax({ |  | ||||||
|         url: baseUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key, |  | ||||||
|         type: 'PUT', |  | ||||||
|         contentType: "application/json", |  | ||||||
|         success: function () { |  | ||||||
|             node.moveTo(afterNode, 'after'); |  | ||||||
|         } |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function moveToNode(node, toNode) { |  | ||||||
|     $.ajax({ |  | ||||||
|         url: baseUrl + 'notes/' + node.key + '/moveTo/' + toNode.key, |  | ||||||
|         type: 'PUT', |  | ||||||
|         contentType: "application/json", |  | ||||||
|         success: function () { |  | ||||||
|             node.moveTo(toNode); |  | ||||||
|  |  | ||||||
|             toNode.setExpanded(true); |  | ||||||
|  |  | ||||||
|             toNode.folder = true; |  | ||||||
|             toNode.renderTitle(); |  | ||||||
|         } |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function deleteNode(node) { |  | ||||||
|     if (confirm('Are you sure you want to delete note "' + node.title + '"?')) { |  | ||||||
|         $.ajax({ |  | ||||||
|             url: baseUrl + 'notes/' + node.key, |  | ||||||
|             type: 'DELETE', |  | ||||||
|             success: function () { |  | ||||||
|                 if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { |  | ||||||
|                     node.getParent().folder = false; |  | ||||||
|                     node.getParent().renderTitle(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 globalAllNoteIds = globalAllNoteIds.filter(e => e !== node.key); |  | ||||||
|  |  | ||||||
|                 // remove from recent notes |  | ||||||
|                 globalRecentNotes = globalRecentNotes.filter(note => note !== node.key); |  | ||||||
|  |  | ||||||
|                 let next = node.getNextSibling(); |  | ||||||
|                 if (!next) { |  | ||||||
|                     next = node.getParent(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 node.remove(); |  | ||||||
|  |  | ||||||
|                 // activate next element after this one is deleted so we don't lose focus |  | ||||||
|                 next.setActive(); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function moveNodeUp(node) { |  | ||||||
|     if (node.getParent() !== null) { |  | ||||||
|         $.ajax({ |  | ||||||
|             url: baseUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key, |  | ||||||
|             type: 'PUT', |  | ||||||
|             contentType: "application/json", |  | ||||||
|             success: function () { |  | ||||||
|                 if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { |  | ||||||
|                     node.getParent().folder = false; |  | ||||||
|                     node.getParent().renderTitle(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 node.moveTo(node.getParent(), 'after'); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const keybindings = { | const keybindings = { | ||||||
|     "insert": function(node) { |     "insert": function(node) { | ||||||
|         const parentKey = getParentKey(node); |         const parentKey = getParentKey(node); | ||||||
|   | |||||||
							
								
								
									
										85
									
								
								static/js/tree_mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								static/js/tree_mutations.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | |||||||
|  | function moveBeforeNode(node, beforeNode) { | ||||||
|  |     $.ajax({ | ||||||
|  |         url: baseUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key, | ||||||
|  |         type: 'PUT', | ||||||
|  |         contentType: "application/json", | ||||||
|  |         success: function () { | ||||||
|  |             node.moveTo(beforeNode, 'before'); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function moveAfterNode(node, afterNode) { | ||||||
|  |     $.ajax({ | ||||||
|  |         url: baseUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key, | ||||||
|  |         type: 'PUT', | ||||||
|  |         contentType: "application/json", | ||||||
|  |         success: function () { | ||||||
|  |             node.moveTo(afterNode, 'after'); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function moveToNode(node, toNode) { | ||||||
|  |     $.ajax({ | ||||||
|  |         url: baseUrl + 'notes/' + node.key + '/moveTo/' + toNode.key, | ||||||
|  |         type: 'PUT', | ||||||
|  |         contentType: "application/json", | ||||||
|  |         success: function () { | ||||||
|  |             node.moveTo(toNode); | ||||||
|  |  | ||||||
|  |             toNode.setExpanded(true); | ||||||
|  |  | ||||||
|  |             toNode.folder = true; | ||||||
|  |             toNode.renderTitle(); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function deleteNode(node) { | ||||||
|  |     if (confirm('Are you sure you want to delete note "' + node.title + '"?')) { | ||||||
|  |         $.ajax({ | ||||||
|  |             url: baseUrl + 'notes/' + node.key, | ||||||
|  |             type: 'DELETE', | ||||||
|  |             success: function () { | ||||||
|  |                 if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { | ||||||
|  |                     node.getParent().folder = false; | ||||||
|  |                     node.getParent().renderTitle(); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 globalAllNoteIds = globalAllNoteIds.filter(e => e !== node.key); | ||||||
|  |  | ||||||
|  |                 // remove from recent notes | ||||||
|  |                 globalRecentNotes = globalRecentNotes.filter(note => note !== node.key); | ||||||
|  |  | ||||||
|  |                 let next = node.getNextSibling(); | ||||||
|  |                 if (!next) { | ||||||
|  |                     next = node.getParent(); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 node.remove(); | ||||||
|  |  | ||||||
|  |                 // activate next element after this one is deleted so we don't lose focus | ||||||
|  |                 next.setActive(); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function moveNodeUp(node) { | ||||||
|  |     if (node.getParent() !== null) { | ||||||
|  |         $.ajax({ | ||||||
|  |             url: baseUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key, | ||||||
|  |             type: 'PUT', | ||||||
|  |             contentType: "application/json", | ||||||
|  |             success: function () { | ||||||
|  |                 if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { | ||||||
|  |                     node.getParent().folder = false; | ||||||
|  |                     node.getParent().renderTitle(); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 node.moveTo(node.getParent(), 'after'); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -8,6 +8,12 @@ | |||||||
|     background-color: #eee; |     background-color: #eee; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #noteDetailWrapper { | ||||||
|  |     width: 750px; | ||||||
|  |     float: left; | ||||||
|  |     margin-left: 30px; | ||||||
|  | } | ||||||
|  |  | ||||||
| #top-message { | #top-message { | ||||||
|     display: none; /* initial state is hidden */ |     display: none; /* initial state is hidden */ | ||||||
|     background-color: #e0e0e0; |     background-color: #e0e0e0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user