clean and fix hover code.

This commit is contained in:
Christopher Jeffrey 2015-04-27 23:55:49 -07:00
parent 5468509778
commit a5bfa4397a
1 changed files with 23 additions and 22 deletions

View File

@ -3018,15 +3018,15 @@ Element.prototype.removeHover = function() {
Screen.prototype._initHover = function() { Screen.prototype._initHover = function() {
var self = this; var self = this;
if (this.screen._hoverText) { if (this._hoverText) {
return; return;
} }
this.screen._hoverText = new Box({ this._hoverText = new Box({
screen: this.screen, screen: this,
left: 0, left: 0,
top: 0, top: 0,
tags: this.parseTags, tags: false,
height: 'shrink', height: 'shrink',
width: 'shrink', width: 'shrink',
border: 'line', border: 'line',
@ -3039,32 +3039,33 @@ Screen.prototype._initHover = function() {
} }
}); });
this.screen.on('mousemove', function(data) { this.on('mousemove', function(data) {
if (self.screen._hoverText.detached) return; if (self._hoverText.detached) return;
self.screen._hoverText.rleft = data.x + 1; self._hoverText.rleft = data.x + 1;
self.screen._hoverText.rtop = data.y; self._hoverText.rtop = data.y;
self.screen.render(); self.render();
}); });
this.screen.on('element mouseover', function(el, data) { this.on('element mouseover', function(el, data) {
if (!el._hoverOptions) return; if (!el._hoverOptions) return;
self.screen._hoverText.setContent(el._hoverOptions.text); self._hoverText.setContent(el._hoverOptions.text);
self.screen.append(self.screen._hoverText); self.append(self._hoverText);
self.screen._hoverText.rleft = data.x + 1; self._hoverText.parseTags = el.parseTags;
self.screen._hoverText.rtop = data.y; self._hoverText.rleft = data.x + 1;
self.screen.render(); self._hoverText.rtop = data.y;
self.render();
}); });
this.screen.on('element mouseout', function() { this.on('element mouseout', function() {
if (self.screen._hoverText.detached) return; if (self._hoverText.detached) return;
self.screen._hoverText.detach(); self._hoverText.detach();
self.screen.render(); self.render();
}); });
this.screen.on('element mouseup', function(el, data) { this.on('element mouseup', function(el, data) {
if (!el._hoverOptions) return; if (!el._hoverOptions) return;
self.screen.append(self.screen._hoverText); self.append(self._hoverText);
self.screen.render(); self.render();
}); });
}; };