Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/queuepro/node_modules/@tarekraafat/autocomplete.js/src/controllers/ drwxrwxr-x | |
| Viewing file: Select action/file-type: import start from "../services/start";
import { debounce as debouncer } from "../helpers/io";
import { click, navigate, close } from "./listController";
/**
* Manage all given events
*
* @param {Object} events - List of events
* @param {Function} callback - Callback function
*/
const eventsManager = (events, callback) => {
for (const element in events) {
for (const event in events[element]) {
callback(element, event);
}
}
};
/**
* Attach all events listeners
*
* @param {Object} ctx - autoComplete.js context
*/
const addEvents = (ctx) => {
const { events } = ctx;
const run = debouncer(() => start(ctx), ctx.debounce);
// Public events listeners list
const publicEvents = (ctx.events = {
input: {
...(events && events.input),
},
...(ctx.resultsList && { list: events ? { ...events.list } : {} }),
});
// Private events listeners list
const privateEvents = {
input: {
input() {
run();
},
keydown(event) {
navigate(event, ctx);
},
blur() {
close(ctx);
},
},
list: {
mousedown(event) {
event.preventDefault();
},
click(event) {
click(event, ctx);
},
},
};
// Populate all private events into public events list
eventsManager(privateEvents, (element, event) => {
// Do NOT populate any events except "input" If "resultsList" disabled
if (!ctx.resultsList && event !== "input") return;
// Do NOT overwrite public events
if (publicEvents[element][event]) return;
// Populate public events
publicEvents[element][event] = privateEvents[element][event];
});
// Attach all public events
eventsManager(publicEvents, (element, event) => {
ctx[element].addEventListener(event, publicEvents[element][event]);
});
};
/**
* Remove all attached public events listeners
*
* @param {Object} ctx - autoComplete.js context
*/
const removeEvents = (ctx) => {
eventsManager(ctx.events, (element, event) => {
ctx[element].removeEventListener(event, ctx.events[element][event]);
});
};
export { addEvents, removeEvents };
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.024 ]-- |