Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Dec 27, 2023
1 parent c5e9f77 commit 433c921
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
25 changes: 11 additions & 14 deletions ext/js/pages/settings/profile-conditions-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,6 @@ class ProfileConditionUI {
let inputValue = value;
let inputStep = null;
let showMouseButton = false;
/** @type {import('event-listener-collection').AddEventListenerArgs[]} */
const events1 = [];
/** @type {import('event-listener-collection').OnArgs[]} */
const events2 = [];
/** @type {import('profile-conditions-ui').InputData} */
const inputData = {validate, normalize};
const node = this._valueInput;
Expand All @@ -873,18 +869,13 @@ class ProfileConditionUI {
case 'integer':
inputType = 'number';
inputStep = '1';
events1.push([node, 'change', this._onValueInputChange.bind(this, inputData), false]);
break;
case 'modifierKeys':
case 'modifierInputs':
inputValue = null;
showMouseButton = (type === 'modifierInputs');
this._kbmInputField = this._parent.parent.createKeyboardMouseInputField(node, this._mouseButton);
this._kbmInputField.prepare(null, this._splitModifiers(value), showMouseButton, false);
events2.push([this._kbmInputField, 'change', this._onModifierInputChange.bind(this, inputData)]);
break;
default: // 'string'
events1.push([node, 'change', this._onValueInputChange.bind(this, inputData), false]);
break;
}

Expand All @@ -900,11 +891,17 @@ class ProfileConditionUI {
node.removeAttribute('step');
}
this._mouseButtonContainer.hidden = !showMouseButton;
for (const args of events1) {
this._inputEventListeners.addEventListener(...args);
}
for (const args of events2) {
this._inputEventListeners.on(...args);

switch (type) {
case 'modifierKeys':
case 'modifierInputs':
if (this._kbmInputField !== null) {
this._inputEventListeners.on(this._kbmInputField, 'change', this._onModifierInputChange.bind(this, inputData));
}
break;
default: // 'integer', 'string'
this._inputEventListeners.addEventListener(node, 'change', this._onValueInputChange.bind(this, inputData), false);
break;
}

return this._validateValue(value, validate);
Expand Down
6 changes: 0 additions & 6 deletions types/ext/event-listener-collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,3 @@ export type AddEventListenerArgs = [
listener: EventListener | EventListenerObject | EventListenerFunction,
options?: AddEventListenerOptions | boolean,
];

export type OnArgs = [
target: Core.EventDispatcherOffGeneric,
eventName: string,
callback: (details: Core.SafeAny) => void,
];

0 comments on commit 433c921

Please sign in to comment.