From cb578f9c5512be753c8ebb503e6f884a4efcef29 Mon Sep 17 00:00:00 2001 From: Ozan Tellioglu Date: Wed, 7 Jun 2023 21:57:40 +0200 Subject: [PATCH] New Note Modal Button Reverse Function --- src/modal.ts | 7 +++++-- src/settings/settings.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/modal.ts b/src/modal.ts index fde80a4..e68dde1 100644 --- a/src/modal.ts +++ b/src/modal.ts @@ -46,10 +46,13 @@ export class CreateNoteModal extends Modal { let addSpace = contentEl.createEl('div', { cls: 'oz-calendar-modal-addspacediv ' }); // Create - Cancel Buttons - const createButton = contentEl.createEl('button', { text: 'Create Note' }); + const createButton = contentEl.createEl('button', { + text: 'Create Note', + cls: this.plugin.settings.newNoteCancelButtonReverse ? 'oz-calendar-modal-float-right' : '', + }); const cancelButton = contentEl.createEl('button', { text: 'Cancel', - cls: 'oz-calendar-modal-float-right', + cls: this.plugin.settings.newNoteCancelButtonReverse ? '' : 'oz-calendar-modal-float-right', }); cancelButton.addEventListener('click', () => { thisModal.close(); diff --git a/src/settings/settings.ts b/src/settings/settings.ts index f3d2a5a..25937cd 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -21,6 +21,7 @@ export interface OZCalendarPluginSettings { openFileBehaviour: OpenFileBehaviourType; sortingOption: SortingOption; newNoteDate: NewNoteDateType; + newNoteCancelButtonReverse: boolean; } export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { @@ -36,6 +37,7 @@ export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { openFileBehaviour: 'current-tab', sortingOption: 'name', newNoteDate: 'current-date', + newNoteCancelButtonReverse: false, }; export class OZCalendarPluginSettingsTab extends PluginSettingTab { @@ -286,6 +288,18 @@ export class OZCalendarPluginSettingsTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName('Reverse direction of Cancel and New Note Buttons') + .setDesc( + `Enable this setting to change the direction of Cancel and New Note buttons within the New Note Creation Modal` + ) + .addToggle((toggle) => { + toggle.setValue(this.plugin.settings.newNoteCancelButtonReverse).onChange((newValue) => { + this.plugin.settings.newNoteCancelButtonReverse = newValue; + this.plugin.saveSettings(); + }); + }); + containerEl.createEl('h2', { text: 'Style Settings' }); containerEl.createEl('p', {