Skip to content

Commit

Permalink
monster tooltip encounter builder
Browse files Browse the repository at this point in the history
Scans the patch for monster tooltips and adds the ability to build an encounter right next to the link
  • Loading branch information
mouse0270 committed Jan 28, 2018
1 parent 07b9bb7 commit df0c684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions scripts/toolbox.monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
};

this.monsterEncounters = function() {
$('body span:not(.tb-processed) > a.monster-tooltip').each(function(index, item) {
var $item = $(item).closest('span'),
$('body a.monster-tooltip').each(function(index, item) {
var $item = $(item),
$btn = $('<button class="tb-btn"><i class="tb-icon tb-swords-and-shield"></i></button>');

$btn.on('click', function(evt) {
evt.preventDefault();
var $monsterStats = $('<div></div>'),
monsterURL = $(this).closest('.tb-processed').find('a').attr('href');
monsterURL = $(this).closest('a.tb-processed').attr('href');

$monsterStats.load('{0} .mon-stat-block'.format(monsterURL), function() {
var monster = {
Expand All @@ -56,7 +56,7 @@
Toolbox.Encounters.modal(evt, monster);
});
});
$item.addClass('tb-processed').append($btn);
$item.addClass('tb-processed tb-monster-tooltip').append($btn);
});
};

Expand Down
15 changes: 12 additions & 3 deletions styles/xcontent.css
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,11 @@ body.modal-shown {
width: 38px;
}

span.tb-processed {
.tb-monster-tooltip.tb-processed {
position: relative;
padding-right: 30px;
}
span.tb-processed .tb-btn {
.tb-monster-tooltip.tb-processed .tb-btn {
position: absolute;
right: 0px;
min-height: 20px;
Expand All @@ -671,10 +671,19 @@ span.tb-processed .tb-btn {
padding: 5px;
top: -7px;
}
span.tb-processed .tb-btn > .tb-icon {
.tb-monster-tooltip.tb-processed .tb-btn > .tb-icon {
width: 20px;
height: 20px;
}
.plural-monster-tooltip {
font-size: 0px;
}
.plural-monster-tooltip > a.tb-monster-tooltip {
font-size: 14px;
}
.plural-monster-tooltip > a.tb-monster-tooltip.tb-processed:after {
content: 's';
}

/* TOOLTIP
=================================*/
Expand Down

0 comments on commit df0c684

Please sign in to comment.