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