Cleaned up the code

pull/2/head
Erebus 2020-12-01 05:42:12 +01:00
parent 54ac488e73
commit 6f6a1e7e2d
6 changed files with 25 additions and 72 deletions

View File

@ -243,23 +243,8 @@ export class ActorSheetKH extends ActorSheet {
// Delete Inventory Item
html.find(".item-delete").click((ev) => {
const li = $(ev.currentTarget).parents(".item");
this.actor.deleteOwnedItem(li.data("itemId"));
li.slideUp(200, () => this.render(false));
});
html.find(".item-attack-delete").click((ev) => {
const li = $(ev.currentTarget).parents(".item-attack");
this.actor.deleteOwnedItem(li.data("itemId"));
li.slideUp(200, () => this.render(false));
});
html.find(".item-weapon-delete").click((ev) => {
const li = $(ev.currentTarget).parents(".item-weapon");
let parent = $(ev.currentTarget).data("parent")
const li = $(ev.currentTarget).parents(parent);
this.actor.deleteOwnedItem(li.data("itemId"));
@ -268,43 +253,8 @@ export class ActorSheetKH extends ActorSheet {
// Edit Inventory Item
html.find(".item-edit").click(async (ev) => {
let li = $(ev.currentTarget).parents(".item");
let itemId = li.data("itemId");
let item = this.actor.getOwnedItem(itemId);
if (!item) {
item = game.items.get(itemId);
if (!item) {
console.log("IMPORT ERROR")
}
}
if (item?.sheet) {
item.sheet.render(true);
}
});
html.find(".item-attack-edit").click(async (ev) => {
let li = $(ev.currentTarget).parents(".item-attack");
let itemId = li.data("itemId");
let item = this.actor.getOwnedItem(itemId);
if (!item) {
item = game.items.get(itemId);
if (!item) {
console.log("IMPORT ERROR")
}
}
if (item?.sheet) {
item.sheet.render(true);
}
});
html.find(".item-weapon-edit").click(async (ev) => {
let li = $(ev.currentTarget).parents(".item-weapon");
let parent = $(ev.currentTarget).data("parent")
let li = $(ev.currentTarget).parents(parent);
let itemId = li.data("itemId");
let item = this.actor.getOwnedItem(itemId);
@ -457,6 +407,7 @@ export class ActorSheetKH extends ActorSheet {
/* Toggle item equipped */
html.find(".items .item a.toggle-equipped").click(this._toggleEquippedItem.bind(this));
html.find(".items .item-weapon a.toggle-equipped").click(this._toggleEquippedItem.bind(this));
/* Handle increase of items in inventory */
html.find(".item-quantity .quantity.increase").click(this._increaseQuantity.bind((this)));
@ -643,7 +594,7 @@ export class ActorSheetKH extends ActorSheet {
const item = this.actor.getOwnedItem(li.data("itemId"));
const actor = this.actor;
if (item) {
if(item) {
if(item.type === "armor") {
let initValue = -1

View File

@ -111,10 +111,12 @@
text-align: center;
}
.items .items-list .item .toggle-equipped {
.items .items-list .item .toggle-equipped,
.items .items-list .item-weapon .toggle-equipped {
color: #888;
}
.items .items-list .item .toggle-equipped.active {
.items .items-list .item .toggle-equipped.active,
.items .items-list .item-weapon .toggle-equipped.active{
color: #191813;
}

View File

@ -65,8 +65,8 @@
</div>
</div>
<div class="item-controls">
<a class="item-control item-attack-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-attack-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item-attack" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item-attack" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -40,8 +40,8 @@
</div>
</div>
<div class="item-controls">
<a class="item-control item-weapon-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-weapon-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item-weapon" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item-weapon" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
@ -79,8 +79,8 @@
</div>
{{/if}}
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
@ -105,8 +105,8 @@
<div class="quantity decrease"><i class="far fa-minus-square"></i></div>
</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -57,8 +57,8 @@
</div>
</div>
<div class="item-controls">
<a class="item-control item-attack-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-attack-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item-attack" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item-attack" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -9,8 +9,8 @@
<li class="item flexrow" data-item-id="{{talent._id}}">
<div class="item-name">{{talent.name}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
@ -30,8 +30,8 @@
<div class="cost roll-spell-cost rollable">{{spell.data.cost.value}}</div>
<div class="difficulty">{{rollDifficulty spell.data.difficulty.value}}</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" data-parent=".item" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}