mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Restyle regex script toggles
This commit is contained in:
@ -77,17 +77,20 @@ async function loadRegexScripts() {
|
|||||||
scriptHtml.attr('id', uuidv4());
|
scriptHtml.attr('id', uuidv4());
|
||||||
scriptHtml.find('.regex_script_name').text(script.scriptName);
|
scriptHtml.find('.regex_script_name').text(script.scriptName);
|
||||||
scriptHtml.find('.disable_regex').prop("checked", script.disabled ?? false)
|
scriptHtml.find('.disable_regex').prop("checked", script.disabled ?? false)
|
||||||
.each(function() {
|
.on('input', function () {
|
||||||
$(this).closest('.checkbox').find('span').toggle(this.checked);
|
script.disabled = !!$(this).prop("checked");
|
||||||
})
|
saveSettingsDebounced();
|
||||||
.on('click', function() {
|
|
||||||
script.disabled = !script.disabled;
|
|
||||||
$(this).closest('.checkbox').find('span').toggle(this.checked);
|
|
||||||
});
|
});
|
||||||
scriptHtml.find('.edit_existing_regex').on('click', async function() {
|
scriptHtml.find('.regex-toggle-on').on('click', function () {
|
||||||
|
scriptHtml.find('.disable_regex').prop("checked", true).trigger('input');
|
||||||
|
});
|
||||||
|
scriptHtml.find('.regex-toggle-off').on('click', function () {
|
||||||
|
scriptHtml.find('.disable_regex').prop("checked", false).trigger('input');
|
||||||
|
});
|
||||||
|
scriptHtml.find('.edit_existing_regex').on('click', async function () {
|
||||||
await onRegexEditorOpenClick(scriptHtml.attr("id"));
|
await onRegexEditorOpenClick(scriptHtml.attr("id"));
|
||||||
});
|
});
|
||||||
scriptHtml.find('.delete_regex').on('click', async function() {
|
scriptHtml.find('.delete_regex').on('click', async function () {
|
||||||
await deleteRegexScript({ existingId: scriptHtml.attr("id") });
|
await deleteRegexScript({ existingId: scriptHtml.attr("id") });
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -165,7 +168,7 @@ async function onRegexEditorOpenClick(existingId) {
|
|||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="replace_position"]`)
|
.find(`input[name="replace_position"]`)
|
||||||
.filter(":checked")
|
.filter(":checked")
|
||||||
.map(function() { return parseInt($(this).val()) })
|
.map(function () { return parseInt($(this).val()) })
|
||||||
.get()
|
.get()
|
||||||
.filter((e) => e !== NaN) || [],
|
.filter((e) => e !== NaN) || [],
|
||||||
disabled:
|
disabled:
|
||||||
@ -247,7 +250,7 @@ jQuery(async () => {
|
|||||||
|
|
||||||
const settingsHtml = await $.get("scripts/extensions/regex/dropdown.html");
|
const settingsHtml = await $.get("scripts/extensions/regex/dropdown.html");
|
||||||
$("#extensions_settings2").append(settingsHtml);
|
$("#extensions_settings2").append(settingsHtml);
|
||||||
$("#open_regex_editor").on("click", function() {
|
$("#open_regex_editor").on("click", function () {
|
||||||
onRegexEditorOpenClick(false);
|
onRegexEditorOpenClick(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
<span class="drag-handle menu-handle">☰</span>
|
<span class="drag-handle menu-handle">☰</span>
|
||||||
<div class="regex_script_name flexGrow overflow-hidden"></div>
|
<div class="regex_script_name flexGrow overflow-hidden"></div>
|
||||||
<div class="flex-container flexnowrap">
|
<div class="flex-container flexnowrap">
|
||||||
<label class="checkbox flex-container">
|
<label class="checkbox flex-container" for="regex_disable">
|
||||||
<span data-i18n="Disabled">Disabled</span>
|
<input type="checkbox" name="regex_disable" class="disable_regex" />
|
||||||
<input id="disabled" type="checkbox" name="disabled" class="disable_regex" />
|
<span class="regex-toggle-on fa-solid fa-toggle-on" title="Disable script"></span>
|
||||||
|
<span class="regex-toggle-off fa-solid fa-toggle-off" title="Enable script"></span>
|
||||||
</label>
|
</label>
|
||||||
<div class="edit_existing_regex menu_button">
|
<div class="edit_existing_regex menu_button">
|
||||||
<i class="fa-solid fa-pencil"></i>
|
<i class="fa-solid fa-pencil"></i>
|
||||||
|
@ -22,3 +22,33 @@
|
|||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
margin-bottom: 1px;
|
margin-bottom: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.disable_regex {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.regex-toggle-off {
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.5;
|
||||||
|
filter: grayscale(0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.regex-toggle-on {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable_regex:checked ~ .regex-toggle-off {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable_regex:checked ~ .regex-toggle-on {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable_regex:not(:checked) ~ .regex-toggle-off {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable_regex:not(:checked) ~ .regex-toggle-on {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user