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 ' }); let addSpace = contentEl.createEl('div', { cls: 'oz-calendar-modal-addspacediv ' });
// Create - Cancel Buttons // 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', { const cancelButton = contentEl.createEl('button', {
text: 'Cancel', text: 'Cancel',
cls: 'oz-calendar-modal-float-right', cls: this.plugin.settings.newNoteCancelButtonReverse ? '' : 'oz-calendar-modal-float-right',
}); });
cancelButton.addEventListener('click', () => { cancelButton.addEventListener('click', () => {
thisModal.close(); thisModal.close();

View file

@ -21,6 +21,7 @@ export interface OZCalendarPluginSettings {
openFileBehaviour: OpenFileBehaviourType; openFileBehaviour: OpenFileBehaviourType;
sortingOption: SortingOption; sortingOption: SortingOption;
newNoteDate: NewNoteDateType; newNoteDate: NewNoteDateType;
newNoteCancelButtonReverse: boolean;
} }
export const DEFAULT_SETTINGS: OZCalendarPluginSettings = { export const DEFAULT_SETTINGS: OZCalendarPluginSettings = {
@ -36,6 +37,7 @@ export const DEFAULT_SETTINGS: OZCalendarPluginSettings = {
openFileBehaviour: 'current-tab', openFileBehaviour: 'current-tab',
sortingOption: 'name', sortingOption: 'name',
newNoteDate: 'current-date', newNoteDate: 'current-date',
newNoteCancelButtonReverse: false,
}; };
export class OZCalendarPluginSettingsTab extends PluginSettingTab { 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('h2', { text: 'Style Settings' });
containerEl.createEl('p', { containerEl.createEl('p', {