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 // Delete Inventory Item
html.find(".item-delete").click((ev) => { html.find(".item-delete").click((ev) => {
const li = $(ev.currentTarget).parents(".item"); let parent = $(ev.currentTarget).data("parent")
const li = $(ev.currentTarget).parents(parent);
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");
this.actor.deleteOwnedItem(li.data("itemId")); this.actor.deleteOwnedItem(li.data("itemId"));
@ -268,43 +253,8 @@ export class ActorSheetKH extends ActorSheet {
// Edit Inventory Item // Edit Inventory Item
html.find(".item-edit").click(async (ev) => { html.find(".item-edit").click(async (ev) => {
let li = $(ev.currentTarget).parents(".item"); let parent = $(ev.currentTarget).data("parent")
let itemId = li.data("itemId"); let li = $(ev.currentTarget).parents(parent);
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 itemId = li.data("itemId"); let itemId = li.data("itemId");
let item = this.actor.getOwnedItem(itemId); let item = this.actor.getOwnedItem(itemId);
@ -457,6 +407,7 @@ export class ActorSheetKH extends ActorSheet {
/* Toggle item equipped */ /* Toggle item equipped */
html.find(".items .item a.toggle-equipped").click(this._toggleEquippedItem.bind(this)); 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 */ /* Handle increase of items in inventory */
html.find(".item-quantity .quantity.increase").click(this._increaseQuantity.bind((this))); html.find(".item-quantity .quantity.increase").click(this._increaseQuantity.bind((this)));

View File

@ -111,10 +111,12 @@
text-align: center; text-align: center;
} }
.items .items-list .item .toggle-equipped { .items .items-list .item .toggle-equipped,
.items .items-list .item-weapon .toggle-equipped {
color: #888; 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; color: #191813;
} }

View File

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

View File

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

View File

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

View File

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