Skip to content

Commit

Permalink
Clean up Popover after decaffeinate
Browse files Browse the repository at this point in the history
References #460
  • Loading branch information
Gert-dev committed Jun 4, 2019
1 parent b7dad31 commit d2bbce8
Showing 1 changed file with 65 additions and 73 deletions.
138 changes: 65 additions & 73 deletions lib/Widgets/Popover.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,78 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let Popover;
'use strict';

const {Disposable} = require('atom');

module.exports =

//#*
// Widget that can be used to display information about a certain context.
//#
(Popover = (function() {
Popover = class Popover extends Disposable {
static initClass() {
this.prototype.element = null;
}
/**
* Widget that can be used to display information about a certain context.
*/
class Popover extends Disposable
{
/**
* Constructor.
*/
constructor() {
super(() => {
this.destructor();
});

this.element = document.createElement('div');
this.element.className = 'tooltip bottom fade php-ide-serenata-popover';
this.element.innerHTML = '<div class="tooltip-arrow"></div><div class="tooltip-inner"></div>';

/**
* Constructor.
*/
constructor() {
super(() => { this.destructor(); });
document.body.appendChild(this.element);
}

this.element = document.createElement('div');
this.element.className = 'tooltip bottom fade php-ide-serenata-popover';
this.element.innerHTML = '<div class="tooltip-arrow"></div><div class="tooltip-inner"></div>';
/**
* Destructor.
*/
destructor() {
this.hide();

document.body.appendChild(this.element);
}
document.body.removeChild(this.element);
}

/**
* Destructor.
*/
destructor() {
this.hide();
return document.body.removeChild(this.element);
}
/**
* Retrieves the HTML element containing the popover.
*
* @return {HTMLElement}
*/
getElement() {
return this.element;
}

/**
* Retrieves the HTML element containing the popover.
*
* @return {HTMLElement}
*/
getElement() {
return this.element;
}
/**
* sets the text to display.
*
* @param {String} text
*/
setText(text) {
const item = this.element.querySelector('.tooltip-inner');

/**
* sets the text to display.
*
* @param {String} text
*/
setText(text) {
const item = this.element.querySelector('.tooltip-inner');
return item.innerHTML =
`<div class="php-ide-serenata-popover-wrapper">${text.replace(/\n\n/g, '<br/><br/>')}</div>`;
}
item.innerHTML =
`<div class="php-ide-serenata-popover-wrapper">${text.replace(/\n\n/g, '<br/><br/>')}</div>`;
}

/**
* Shows a popover at the specified location with the specified text and fade in time.
*
* @param {Number} x The X coordinate to show the popover at (left).
* @param {Number} y The Y coordinate to show the popover at (top).
*/
show(x, y) {
this.element.style.left = x + 'px';
this.element.style.top = y + 'px';
/**
* Shows a popover at the specified location with the specified text and fade in time.
*
* @param {Number} x The X coordinate to show the popover at (left).
* @param {Number} y The Y coordinate to show the popover at (top).
*/
show(x, y) {
this.element.style.left = x + 'px';
this.element.style.top = y + 'px';

this.element.classList.add('in');
return this.element.style.display = 'block';
}
this.element.classList.add('in');
this.element.style.display = 'block';
}

/**
* Hides the tooltip, if it is displayed.
*/
hide() {
this.element.classList.remove('in');
return this.element.style.display = 'none';
}
};
Popover.initClass();
return Popover;
})());
/**
* Hides the tooltip, if it is displayed.
*/
hide() {
this.element.classList.remove('in');
this.element.style.display = 'none';
}
};

0 comments on commit d2bbce8

Please sign in to comment.