New Note Modal Button Reverse Function

This commit is contained in:
Ozan Tellioglu 2023-06-07 21:57:40 +02:00
parent 752121be89
commit cb578f9c55
2 changed files with 19 additions and 2 deletions

View file

@ -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();

View file

@ -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', {