mirror of https://github.com/rancher/ui.git
34 lines
598 B
JavaScript
34 lines
598 B
JavaScript
import { later, cancel } from '@ember/runloop';
|
|
import Service, { inject as service } from '@ember/service';
|
|
|
|
const DELAY = 250;
|
|
|
|
export default Service.extend({
|
|
mouseLeaveTimer: null,
|
|
requireClick: false,
|
|
tooltipOpts: null,
|
|
openedViaContextClick: false,
|
|
app: service(),
|
|
|
|
startTimer() {
|
|
this.set('mouseLeaveTimer', later(() => {
|
|
this.hide();
|
|
}, DELAY));
|
|
},
|
|
|
|
cancelTimer() {
|
|
cancel(this.get('mouseLeaveTimer'));
|
|
},
|
|
|
|
hide() {
|
|
this.set('tooltipOpts', null);
|
|
},
|
|
|
|
leave() {
|
|
if ( !this.get('requireClick') )
|
|
{
|
|
this.startTimer();
|
|
}
|
|
},
|
|
});
|