diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index ed3dd704c..34b4b1db2 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -2,7 +2,7 @@ import {callPopup, event_types, eventSource, is_send_press, main_api, substitute import { is_group_generating } from "./group-chats.js"; import {TokenHandler} from "./openai.js"; import {power_user} from "./power-user.js"; -import { debounce, waitUntilCondition } from "./utils.js"; +import { debounce, getSortableDelay, waitUntilCondition } from "./utils.js"; function debouncePromise(func, delay) { let timeoutId; @@ -1511,6 +1511,7 @@ PromptManagerModule.prototype.getFormattedDate = function() { */ PromptManagerModule.prototype.makeDraggable = function () { $(`#${this.configuration.prefix}prompt_manager_list`).sortable({ + delay: getSortableDelay(), items: `.${this.configuration.prefix}prompt_manager_prompt_draggable`, update: ( event, ui ) => { const promptOrder = this.getPromptOrderForCharacter(this.activeCharacter); diff --git a/public/scripts/extensions/regex/index.js b/public/scripts/extensions/regex/index.js index 103f294a1..8e57c5590 100644 --- a/public/scripts/extensions/regex/index.js +++ b/public/scripts/extensions/regex/index.js @@ -1,6 +1,6 @@ -import { callPopup, eventSource, event_types, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced } from "../../../script.js"; +import { callPopup, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced } from "../../../script.js"; import { extension_settings } from "../../extensions.js"; -import { uuidv4, waitUntilCondition } from "../../utils.js"; +import { getSortableDelay, uuidv4 } from "../../utils.js"; import { regex_placement } from "./engine.js"; async function saveRegexScript(regexScript, existingScriptIndex) { @@ -236,6 +236,7 @@ jQuery(async () => { }); $('#saved_regex_scripts').sortable({ + delay: getSortableDelay(), stop: function () { let newScripts = []; $('#saved_regex_scripts').children().each(function () { diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 302e45d5d..d1f8895ac 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -7,6 +7,7 @@ import { import { power_user, } from "./power-user.js"; +import { getSortableDelay } from "./utils.js"; export { kai_settings, @@ -243,7 +244,7 @@ function sortItemsByOrder(orderArray) { } } -$(document).ready(function () { +jQuery(function () { sliders.forEach(slider => { $(document).on("input", slider.sliderId, function () { const value = $(this).val(); @@ -267,6 +268,7 @@ $(document).ready(function () { }); $('#kobold_order').sortable({ + delay: getSortableDelay(), stop: function () { const order = []; $('#kobold_order').children().each(function () { diff --git a/public/scripts/nai-settings.js b/public/scripts/nai-settings.js index 3f60df1fb..883f11ea1 100644 --- a/public/scripts/nai-settings.js +++ b/public/scripts/nai-settings.js @@ -10,8 +10,9 @@ import { import { getCfg } from "./extensions/cfg/util.js"; import { MAX_CONTEXT_DEFAULT, tokenizers } from "./power-user.js"; import { + getSortableDelay, getStringHash, - uuidv4 + uuidv4, } from "./utils.js"; export { @@ -638,7 +639,7 @@ $("#nai_preamble_restore").on('click', function () { saveSettingsDebounced(); }); -$(document).ready(function () { +jQuery(function () { sliders.forEach(slider => { $(document).on("input", slider.sliderId, function () { const value = $(this).val(); @@ -677,6 +678,7 @@ $(document).ready(function () { }); $('#novel_order').sortable({ + delay: getSortableDelay(), stop: saveSamplingOrder, }); diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 94ee9bf30..8673427aa 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -8,6 +8,11 @@ export function isDigitsOnly(str) { return /^\d+$/.test(str); } +// Increase delay on touch screens +export function getSortableDelay() { + return navigator.maxTouchPoints > 0 ? 750 : 100; +} + export function shuffle(array) { let currentIndex = array.length, randomIndex; diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index f37b74f0f..88e569236 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -1,5 +1,5 @@ import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types } from "../script.js"; -import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, delay, getCharaFilename, deepClone } from "./utils.js"; +import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, deepClone, getSortableDelay } from "./utils.js"; import { getContext } from "./extensions.js"; import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js"; import { registerSlashCommand } from "./slash-commands.js"; @@ -302,6 +302,7 @@ function displayWorldEntries(name, data) { } $("#world_popup_entries_list").sortable({ + delay: getSortableDelay(), handle: ".drag-handle", stop: async function (event, ui) { $('#world_popup_entries_list .world_entry').each(function (index) {