mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-30 12:13:52 +08:00 
			
		
		
		
	removed sidebar widget settings
This commit is contained in:
		
							parent
							
								
									81ec85083a
								
							
						
					
					
						commit
						c4f7bb37db
					
				
							
								
								
									
										3
									
								
								libraries/sortable.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								libraries/sortable.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -16,7 +16,6 @@ export async function showDialog() { | |||||||
|         import('./options/code_notes.js'), |         import('./options/code_notes.js'), | ||||||
|         import('./options/change_password.js'), |         import('./options/change_password.js'), | ||||||
|         import('./options/other.js'), |         import('./options/other.js'), | ||||||
|         import('./options/sidebar.js'), |  | ||||||
|         import('./options/sync.js'), |         import('./options/sync.js'), | ||||||
|         import('./options/keyboard_shortcuts.js'), |         import('./options/keyboard_shortcuts.js'), | ||||||
|     ])) |     ])) | ||||||
|  | |||||||
| @ -1,117 +0,0 @@ | |||||||
| import libraryLoader from "../../services/library_loader.js"; |  | ||||||
| import server from "../../services/server.js"; |  | ||||||
| import optionsService from "../../services/options.js"; |  | ||||||
| 
 |  | ||||||
| const TPL = ` |  | ||||||
| <h4>Widgets</h4> |  | ||||||
| 
 |  | ||||||
| <div id="widgets-configuration" class="row"> |  | ||||||
|     <h5 class="col-6">Enabled widgets</h5> |  | ||||||
| 
 |  | ||||||
|     <h5 class="col-6">Disabled widgets</h5> |  | ||||||
| 
 |  | ||||||
|     <div id="widgets-enabled" class="list-group col"></div> |  | ||||||
| 
 |  | ||||||
|     <div id="widgets-disabled" class="list-group col"></div> |  | ||||||
| </div>`; |  | ||||||
| 
 |  | ||||||
| export default class SidebarOptions { |  | ||||||
|     constructor() { |  | ||||||
|         $("#options-sidebar").html(TPL); |  | ||||||
| 
 |  | ||||||
|         this.$widgetsConfiguration = $("#widgets-configuration"); |  | ||||||
|         this.$widgetsEnabled = $("#widgets-enabled"); |  | ||||||
|         this.$widgetsDisabled = $("#widgets-disabled"); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async optionsLoaded(options) { |  | ||||||
|         this.$widgetsEnabled.empty(); |  | ||||||
|         this.$widgetsDisabled.empty(); |  | ||||||
| 
 |  | ||||||
|         const widgets = [ |  | ||||||
|             {name: 'attributes', title: 'Attributes'}, |  | ||||||
|             {name: 'linkMap', title: 'Link map'}, |  | ||||||
|             {name: 'noteInfo', title: 'Note info'}, |  | ||||||
|             {name: 'noteRevisions', title: 'Note revisions'}, |  | ||||||
|             {name: 'whatLinksHere', title: 'What links here'}, |  | ||||||
|             {name: 'similarNotes', title: 'Similar notes'}, |  | ||||||
|             {name: 'editedNotes', title: 'Edited notes (only on day note)'}, |  | ||||||
|             {name: 'calendar', title: 'Calendar (only on day note)'} |  | ||||||
|         ].map(widget => { |  | ||||||
|             widget.option = this.parseJsonSafely(options[widget.name + 'Widget']) || { |  | ||||||
|                 enabled: true, |  | ||||||
|                 expanded: true, |  | ||||||
|                 position: 1000 |  | ||||||
|             }; |  | ||||||
| 
 |  | ||||||
|             return widget; |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         widgets.sort((a, b) => a.option.position - b.option.position); |  | ||||||
| 
 |  | ||||||
|         for (const {name, title, option} of widgets) { |  | ||||||
|             const $widgetTitle = $('<div class="widget-title">') |  | ||||||
|                 .attr('data-widget-name', name) |  | ||||||
|                 .append($("<span>").addClass("handle bx bx-move")) |  | ||||||
|                 .append($("<span>").text(title)); |  | ||||||
| 
 |  | ||||||
|             const $expandedCheckbox = $('<div class="expansion-conf">') |  | ||||||
|                 .attr("title", "If checked, the widget will be by default expanded (opened)") |  | ||||||
|                 .append($(`<input type="checkbox"${option.expanded ? ' checked' : ''}>`) |  | ||||||
|                     .attr('id', 'widget-exp-' + name) |  | ||||||
|                     .on('change', () => this.save())) |  | ||||||
|                 .append(" ") |  | ||||||
|                 .append($("<label>") |  | ||||||
|                     .attr("for", 'widget-exp-' + name) |  | ||||||
|                     .text(" expanded")); |  | ||||||
| 
 |  | ||||||
|             const $el = $('<div>') |  | ||||||
|                 .addClass("list-group-item") |  | ||||||
|                 .append($widgetTitle) |  | ||||||
|                 .append($expandedCheckbox); |  | ||||||
| 
 |  | ||||||
|             (option.enabled ? this.$widgetsEnabled : this.$widgetsDisabled).append($el); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         await libraryLoader.requireLibrary(libraryLoader.SORTABLE); |  | ||||||
| 
 |  | ||||||
|         new Sortable(this.$widgetsEnabled[0], { |  | ||||||
|             group: 'widgets', |  | ||||||
|             handle: '.handle', |  | ||||||
|             animation: 150, |  | ||||||
|             onSort: evt => this.save() |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         new Sortable(this.$widgetsDisabled[0], { |  | ||||||
|             group: 'widgets', |  | ||||||
|             handle: '.handle', |  | ||||||
|             animation: 150, |  | ||||||
|             onSort: evt => this.save() |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async save() { |  | ||||||
|         const opts = {}; |  | ||||||
| 
 |  | ||||||
|         this.$widgetsConfiguration.find('.list-group-item').each((i, el) => { |  | ||||||
|             const widgetName = $(el).find('div[data-widget-name]').attr('data-widget-name'); |  | ||||||
| 
 |  | ||||||
|             opts[widgetName + 'Widget'] = JSON.stringify({ |  | ||||||
|                 enabled: $.contains(this.$widgetsEnabled[0], el), |  | ||||||
|                 expanded: $(el).find("input[type=checkbox]").is(":checked"), |  | ||||||
|                 position: (i + 1) * 100 |  | ||||||
|             }); |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|         await server.put('options', opts); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     parseJsonSafely(str) { |  | ||||||
|         try { |  | ||||||
|             return JSON.parse(str); |  | ||||||
|         } |  | ||||||
|         catch (e) { |  | ||||||
|             return null; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -45,8 +45,6 @@ const LINK_MAP = { | |||||||
| 
 | 
 | ||||||
| const PRINT_THIS = {js: ["libraries/printThis.js"]}; | const PRINT_THIS = {js: ["libraries/printThis.js"]}; | ||||||
| 
 | 
 | ||||||
| const SORTABLE = {js: ["libraries/sortable.min.js"]}; |  | ||||||
| 
 |  | ||||||
| const KNOCKOUT = {js: ["libraries/knockout.min.js"]}; | const KNOCKOUT = {js: ["libraries/knockout.min.js"]}; | ||||||
| 
 | 
 | ||||||
| const CALENDAR_WIDGET = {css: ["stylesheets/calendar.css"]}; | const CALENDAR_WIDGET = {css: ["stylesheets/calendar.css"]}; | ||||||
| @ -98,7 +96,6 @@ export default { | |||||||
|     RELATION_MAP, |     RELATION_MAP, | ||||||
|     LINK_MAP, |     LINK_MAP, | ||||||
|     PRINT_THIS, |     PRINT_THIS, | ||||||
|     SORTABLE, |  | ||||||
|     KNOCKOUT, |     KNOCKOUT, | ||||||
|     CALENDAR_WIDGET |     CALENDAR_WIDGET | ||||||
| } | } | ||||||
| @ -37,9 +37,6 @@ | |||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a class="nav-link active" data-toggle="tab" href="#options-appearance">Appearance</a> |                             <a class="nav-link active" data-toggle="tab" href="#options-appearance">Appearance</a> | ||||||
|                         </li> |                         </li> | ||||||
|                         <li class="nav-item"> |  | ||||||
|                             <a class="nav-link" data-toggle="tab" href="#options-sidebar">Sidebar</a> |  | ||||||
|                         </li> |  | ||||||
|                         <li class="nav-item"> |                         <li class="nav-item"> | ||||||
|                             <a class="nav-link" data-toggle="tab" href="#options-keyboard-shortcuts">Keyboard shortcuts</a> |                             <a class="nav-link" data-toggle="tab" href="#options-keyboard-shortcuts">Keyboard shortcuts</a> | ||||||
|                         </li> |                         </li> | ||||||
| @ -62,7 +59,6 @@ | |||||||
|                     <br/> |                     <br/> | ||||||
|                     <div class="tab-content"> |                     <div class="tab-content"> | ||||||
|                         <div id="options-appearance" class="tab-pane active"></div> |                         <div id="options-appearance" class="tab-pane active"></div> | ||||||
|                         <div id="options-sidebar" class="tab-pane"></div> |  | ||||||
|                         <div id="options-keyboard-shortcuts" class="tab-pane"></div> |                         <div id="options-keyboard-shortcuts" class="tab-pane"></div> | ||||||
|                         <div id="options-code-notes" class="tab-pane"></div> |                         <div id="options-code-notes" class="tab-pane"></div> | ||||||
|                         <div id="options-change-password" class="tab-pane"></div> |                         <div id="options-change-password" class="tab-pane"></div> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam