Alt greetings restyle (#2902) * Slight QoL restyle of alternate greetings * Update to new popup * Add visible labels to buttons
Signed| @@ -6090,7 +6090,10 @@ | |||
| 6090 | <div class="alternate_grettings flexFlowColumn flex-container"> | 6090 | <div class="alternate_grettings flexFlowColumn flex-container"> |
| 6091 | <div class="title_restorable"> | 6091 | <div class="title_restorable"> |
| 6092 | <h3><span data-i18n="Alternate Greetings" class="mdhotkey_location">Alternate Greetings</span></h3> | 6092 | <h3><span data-i18n="Alternate Greetings" class="mdhotkey_location">Alternate Greetings</span></h3> |
| 6093 | <div title="Add" class="menu_button fa-solid fa-plus add_alternate_greeting" data-i18n="[title]Add"></div> | 6093 | <div class="menu_button menu_button_icon add_alternate_greeting"> |
| 6094 | <i class="fa-solid fa-plus"></i> | ||
| 6095 | <span data-i18n="Add">Add</span> | ||
| 6096 | </div> | ||
| 6094 | </div> | 6097 | </div> |
| 6095 | <small class="justifyLeft" data-i18n="Alternate_Greetings_desc"> | 6098 | <small class="justifyLeft" data-i18n="Alternate_Greetings_desc"> |
| 6096 | These will be displayed as swipes on the first message when starting a new chat. | 6099 | These will be displayed as swipes on the first message when starting a new chat. |
| @@ -6106,11 +6109,18 @@ | |||
| 6106 | </div> | 6109 | </div> |
| 6107 | <div id="alternate_greeting_form_template" class="template_element"> | 6110 | <div id="alternate_greeting_form_template" class="template_element"> |
| 6108 | <div class="alternate_greeting"> | 6111 | <div class="alternate_greeting"> |
| 6112 | <details open> | ||
| 6113 | <summary> | ||
| 6109 | <div class="title_restorable"> | 6114 | <div class="title_restorable"> |
| 6110 | <strong><span data-i18n="Alternate Greeting #">Alternate Greeting #</span><span class="greeting_index"></span></strong> | 6115 | <strong><span data-i18n="Alternate Greeting #">Alternate Greeting #</span><span class="greeting_index"></span></strong> |
| 6111 | <div class="menu_button fa-solid fa-trash-alt delete_alternate_greeting"></div> | 6116 | <div class="menu_button menu_button_icon delete_alternate_greeting"> |
| 6117 | <i class="fa-solid fa-trash-alt"></i> | ||
| 6118 | <span data-i18n="Delete">Delete</span> | ||
| 6112 | </div> | 6119 | </div> |
| 6113 | <textarea name="alternate_greetings" data-i18n="[placeholder](This will be the first message from the character that starts every chat)" placeholder="(This will be the first message from the character that starts every chat)" class="text_pole textarea_compact alternate_greeting_text mdHotkeys" value="" autocomplete="off" rows="16"></textarea> | 6120 | </div> |
| 6121 | </summary> | ||
| 6122 | <textarea name="alternate_greetings" data-i18n="[placeholder](This will be the first message from the character that starts every chat)" placeholder="(This will be the first message from the character that starts every chat)" class="text_pole textarea_compact alternate_greeting_text mdHotkeys" value="" autocomplete="off" rows="12"></textarea> | ||
| 6123 | </details> | ||
| 6114 | </div> | 6124 | </div> |
| 6115 | </div> | 6125 | </div> |
| 6116 | 6126 | ||
| @@ -7390,7 +7390,7 @@ function onScenarioOverrideRemoveClick() { | |||
| 7390 | */ | 7390 | */ |
| 7391 | export function callPopup(text, type, inputValue = '', { okButton, rows, wide, wider, large, allowHorizontalScrolling, allowVerticalScrolling, cropAspect } = {}) { | 7391 | export function callPopup(text, type, inputValue = '', { okButton, rows, wide, wider, large, allowHorizontalScrolling, allowVerticalScrolling, cropAspect } = {}) { |
| 7392 | function getOkButtonText() { | 7392 | function getOkButtonText() { |
| 7393 | if (['text', 'alternate_greeting', 'char_not_selected'].includes(popup_type)) { | 7393 | if (['text', 'char_not_selected'].includes(popup_type)) { |
| 7394 | $dialoguePopupCancel.css('display', 'none'); | 7394 | $dialoguePopupCancel.css('display', 'none'); |
| 7395 | return okButton ?? 'Ok'; | 7395 | return okButton ?? 'Ok'; |
| 7396 | } else if (['delete_extension'].includes(popup_type)) { | 7396 | } else if (['delete_extension'].includes(popup_type)) { |
| @@ -7827,24 +7827,42 @@ function openAlternateGreetings() { | |||
| 7827 | 7827 | ||
| 7828 | const template = $('#alternate_greetings_template .alternate_grettings').clone(); | 7828 | const template = $('#alternate_greetings_template .alternate_grettings').clone(); |
| 7829 | const getArray = () => menu_type == 'create' ? create_save.alternate_greetings : characters[chid].data.alternate_greetings; | 7829 | const getArray = () => menu_type == 'create' ? create_save.alternate_greetings : characters[chid].data.alternate_greetings; |
| 7830 | const popup = new Popup(template, POPUP_TYPE.TEXT, '', { | ||
| 7831 | wide: true, | ||
| 7832 | large: true, | ||
| 7833 | allowVerticalScrolling: true, | ||
| 7834 | onClose: async () => { | ||
| 7835 | if (menu_type !== 'create') { | ||
| 7836 | await createOrEditCharacter(); | ||
| 7837 | } | ||
| 7838 | } | ||
| 7839 | }); | ||
| 7830 | 7840 | ||
| 7831 | for (let index = 0; index < getArray().length; index++) { | 7841 | for (let index = 0; index < getArray().length; index++) { |
| 7832 | addAlternateGreeting(template, getArray()[index], index, getArray); | 7842 | addAlternateGreeting(template, getArray()[index], index, getArray, popup); |
| 7833 | } | 7843 | } |
| 7834 | 7844 | ||
| 7835 | template.find('.add_alternate_greeting').on('click', function () { | 7845 | template.find('.add_alternate_greeting').on('click', function () { |
| 7836 | const array = getArray(); | 7846 | const array = getArray(); |
| 7837 | const index = array.length; | 7847 | const index = array.length; |
| 7838 | array.push(''); | 7848 | array.push(''); |
| 7839 | addAlternateGreeting(template, '', index, getArray); | 7849 | addAlternateGreeting(template, '', index, getArray, popup); |
| 7840 | updateAlternateGreetingsHintVisibility(template); | 7850 | updateAlternateGreetingsHintVisibility(template); |
| 7841 | }); | 7851 | }); |
| 7842 | 7852 | ||
| 7843 | updateAlternateGreetingsHintVisibility(template); | 7853 | updateAlternateGreetingsHintVisibility(template); |
| 7844 | callPopup(template, 'alternate_greeting', '', { wide: true, large: true }); | 7854 | popup.show(); |
| 7845 | } | 7855 | } |
| 7846 | 7856 | ||
| 7847 | function addAlternateGreeting(template, greeting, index, getArray) { | 7857 | /** |
| 7858 | * Adds an alternate greeting to the template. | ||
| 7859 | * @param {JQuery<HTMLElement>} template | ||
| 7860 | * @param {string} greeting | ||
| 7861 | * @param {number} index | ||
| 7862 | * @param {() => any[]} getArray | ||
| 7863 | * @param {Popup} popup | ||
| 7864 | */ | ||
| 7865 | function addAlternateGreeting(template, greeting, index, getArray, popup) { | ||
| 7848 | const greetingBlock = $('#alternate_greeting_form_template .alternate_greeting').clone(); | 7866 | const greetingBlock = $('#alternate_greeting_form_template .alternate_greeting').clone(); |
| 7849 | greetingBlock.find('.alternate_greeting_text').on('input', async function () { | 7867 | greetingBlock.find('.alternate_greeting_text').on('input', async function () { |
| 7850 | const value = $(this).val(); | 7868 | const value = $(this).val(); |
| @@ -7852,11 +7870,16 @@ function addAlternateGreeting(template, greeting, index, getArray) { | |||
| 7852 | array[index] = value; | 7870 | array[index] = value; |
| 7853 | }).val(greeting); | 7871 | }).val(greeting); |
| 7854 | greetingBlock.find('.greeting_index').text(index + 1); | 7872 | greetingBlock.find('.greeting_index').text(index + 1); |
| 7855 | greetingBlock.find('.delete_alternate_greeting').on('click', async function () { | 7873 | greetingBlock.find('.delete_alternate_greeting').on('click', async function (event) { |
| 7874 | event.preventDefault(); | ||
| 7875 | event.stopPropagation(); | ||
| 7876 | |||
| 7856 | if (confirm('Are you sure you want to delete this alternate greeting?')) { | 7877 | if (confirm('Are you sure you want to delete this alternate greeting?')) { |
| 7857 | const array = getArray(); | 7878 | const array = getArray(); |
| 7858 | array.splice(index, 1); | 7879 | array.splice(index, 1); |
| 7880 | |||
| 7859 | // We need to reopen the popup to update the index numbers | 7881 | // We need to reopen the popup to update the index numbers |
| 7882 | await popup.complete(POPUP_RESULT.AFFIRMATIVE); | ||
| 7860 | openAlternateGreetings(); | 7883 | openAlternateGreetings(); |
| 7861 | } | 7884 | } |
| 7862 | }); | 7885 | }); |
| @@ -9574,9 +9597,6 @@ jQuery(async function () { | |||
| 9574 | }, 2000); | 9597 | }, 2000); |
| 9575 | } | 9598 | } |
| 9576 | } | 9599 | } |
| 9577 | if (popup_type == 'alternate_greeting' && menu_type !== 'create') { | ||
| 9578 | createOrEditCharacter(); | ||
| 9579 | } | ||
| 9580 | 9600 | ||
| 9581 | if (dialogueResolve) { | 9601 | if (dialogueResolve) { |
| 9582 | if (popup_type == 'input') { | 9602 | if (popup_type == 'input') { |
| @@ -3154,6 +3154,26 @@ grammarly-extension { | |||
| 3154 | align-items: center; | 3154 | align-items: center; |
| 3155 | } | 3155 | } |
| 3156 | 3156 | ||
| 3157 | .alternate_greeting details { | ||
| 3158 | padding: 2px; | ||
| 3159 | } | ||
| 3160 | |||
| 3161 | .alternate_greeting summary { | ||
| 3162 | list-style-position: outside; | ||
| 3163 | margin-left: 1em; | ||
| 3164 | padding-left: 1em; | ||
| 3165 | } | ||
| 3166 | |||
| 3167 | .alternate_greeting textarea { | ||
| 3168 | field-sizing: content; | ||
| 3169 | max-height: 50dvh; | ||
| 3170 | } | ||
| 3171 | |||
| 3172 | .alternate_greeting summary::marker, | ||
| 3173 | .alternate_greeting summary strong { | ||
| 3174 | cursor: pointer; | ||
| 3175 | } | ||
| 3176 | |||
| 3157 | #rm_characters_block .form_create_bottom_buttons_block { | 3177 | #rm_characters_block .form_create_bottom_buttons_block { |
| 3158 | justify-content: space-evenly !important; | 3178 | justify-content: space-evenly !important; |
| 3159 | flex-grow: 0; | 3179 | flex-grow: 0; |