From 83d3d64be7a9dbc6388ca1df0c262c82e427145d Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Wed, 15 Jul 2015 00:30:22 -0400 Subject: [PATCH] Better battle tooltips Battle tooltips now appear on touch for mobile, and disappear when anything else is tapped. --- js/client-battle.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/client-battle.js b/js/client-battle.js index e25083b7e..121e74c49 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -77,6 +77,7 @@ this.add(data); }, focus: function () { + this.hideTooltip(); if (this.battle.playbackState === 3) this.battle.play(); ConsoleRoom.prototype.focus.call(this); }, @@ -931,7 +932,7 @@ // tooltips tooltipAttrs: function (thing, type, ownHeight, isActive) { - return ' onmouseover="room.showTooltip(\'' + Tools.escapeHTML('' + thing, true) + '\',\'' + type + '\', this, ' + (ownHeight ? 'true' : 'false') + ', ' + (isActive ? 'true' : 'false') + ')" onmouseout="room.hideTooltip()" onmouseup="room.hideTooltip()"'; + return ' onmouseover="room.showTooltip(\'' + Tools.escapeHTML('' + thing, true) + '\',\'' + type + '\', this, ' + (ownHeight ? 'true' : 'false') + ', ' + (isActive ? 'true' : 'false') + ')" ontouchstart="room.showTooltip(\'' + Tools.escapeHTML('' + thing, true) + '\',\'' + type + '\', this, ' + (ownHeight ? 'true' : 'false') + ', ' + (isActive ? 'true' : 'false') + ')" onmouseout="room.hideTooltip()" onmouseup="room.hideTooltip()"'; }, showTooltip: function (thing, type, elem, ownHeight, isActive) { var offset = { @@ -949,7 +950,7 @@ if (x > 335) x = 335; if (y < 140) y = 140; if (x > $(window).width() - 303) x = Math.max($(window).width() - 303, 0); - if (!$('#tooltipwrapper').length) $(document.body).append('
'); + if (!$('#tooltipwrapper').length) $(document.body).append('
'); $('#tooltipwrapper').css({ left: x, top: y