diff --git a/module/applications/ux/contextMenu.mjs b/module/applications/ux/contextMenu.mjs index 9a308667..6e70da0c 100644 --- a/module/applications/ux/contextMenu.mjs +++ b/module/applications/ux/contextMenu.mjs @@ -52,6 +52,46 @@ * @extends {foundry.applications.ux.ContextMenu} */ export default class DHContextMenu extends foundry.applications.ux.ContextMenu { + /** + * @param {HTMLElement|jQuery} container - The HTML element that contains the context menu targets. + * @param {string} selector - A CSS selector which activates the context menu. + * @param {ContextMenuEntry[]} menuItems - An Array of entries to display in the menu + * @param {ContextMenuOptions} [options] - Additional options to configure the context menu. + */ + constructor(container, selector, menuItems, options) { + super(container, selector, menuItems, options); + + /** @deprecated since v13 until v15 */ + this.#jQuery = options.jQuery; + } + + /** + * Whether to pass jQuery objects or HTMLElement instances to callback. + * @type {boolean} + */ + #jQuery; + + /**@inheritdoc */ + activateListeners(menu) { + menu.addEventListener('click', this.#onClickItem.bind(this)); + } + + /** + * Handle click events on context menu items. + * @param {PointerEvent} event The click event + */ + #onClickItem(event) { + event.preventDefault(); + event.stopPropagation(); + const element = event.target.closest('.context-item'); + if (!element) return; + const item = this.menuItems.find(i => i.element === element); + item?.onClick(event, this.#jQuery ? $(this.target) : this.target); + this.close(); + } + + /* -------------------------------------------- */ + /** * Trigger a context menu event in response to a normal click on a additional options button. * @param {PointerEvent} event diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 75fc3981..eea0d6c4 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -354,11 +354,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel } get hasDamage() { - return !foundry.utils.isEmpty(this.damage?.parts) && this.type !== 'healing'; + return !foundry.utils.isEmpty(this.damage.parts) && this.type !== 'healing'; } get hasHealing() { - return !foundry.utils.isEmpty(this.damage?.parts) && this.type === 'healing'; + return !foundry.utils.isEmpty(this.damage.parts) && this.type === 'healing'; } get hasSave() { diff --git a/module/data/fields/actionField.mjs b/module/data/fields/actionField.mjs index 20e4d6f0..624985fc 100644 --- a/module/data/fields/actionField.mjs +++ b/module/data/fields/actionField.mjs @@ -87,10 +87,10 @@ export class ActionField extends foundry.data.fields.ObjectField { /* -------------------------------------------- */ /** @override */ - _cleanType(value, options, _state) { + _cleanType(value, options) { if (!(typeof value === 'object')) value = {}; const cls = this.getModel(value); - if (cls) return cls.cleanData(value, options, _state); + if (cls) return cls.cleanData(value, options); return value; } diff --git a/module/data/fields/actorField.mjs b/module/data/fields/actorField.mjs index 69ba6bf1..1399fb32 100644 --- a/module/data/fields/actorField.mjs +++ b/module/data/fields/actorField.mjs @@ -52,8 +52,8 @@ class ResourcesField extends fields.TypedObjectField { return key in CONFIG.DH.RESOURCE[this.actorType].all; } - _cleanType(value, options, _state) { - value = super._cleanType(value, options, _state); + _cleanType(value, options) { + value = super._cleanType(value, options); // If not partial, ensure all data exists if (!options.partial) { diff --git a/styles/less/global/sheet.less b/styles/less/global/sheet.less index 6f77a481..1e7bad0a 100755 --- a/styles/less/global/sheet.less +++ b/styles/less/global/sheet.less @@ -14,7 +14,11 @@ body.game:is(.performance-low, .noblur) { .themed.theme-dark .application.daggerheart.sheet.dh-style, .themed.theme-dark.application.daggerheart.sheet.dh-style, &.theme-dark .application.daggerheart { - background: @dark-blue; + &.adversary, + &.character, + &.item { + background: @dark-blue; + } } }