cartodb-4.42/lib/assets/javascripts/cartodb/old_common/tipsy_tooltip.js
2024-04-06 05:25:13 +00:00

59 lines
1.1 KiB
JavaScript

/**
* Tipsy tooltip view.
*
* - Needs an element to work.
* - Inits tipsy library.
* - Clean bastard tipsy bindings easily.
*
*/
cdb.common.TipsyTooltip = cdb.core.View.extend({
options: {
gravity: 's',
fade: true
},
initialize: function(opts) {
if (opts.el === undefined) {
cdb.log.info('Element is needed to have tipsy tooltip working');
return false;
}
this._tipsyOpenedManually = opts.trigger === 'manual';
this._initTipsy();
},
showTipsy: function() {
this.$el.tipsy('show');
},
hideTipsy: function() {
this.$el.tipsy('hide');
},
_initTipsy: function() {
this.$el.tipsy(this.options);
this.tipsy = this.$el.data('tipsy');
},
_destroyTipsy: function() {
if (this.tipsy) {
// tipsy does not return this
this.tipsy.hide();
this.$el.unbind('mouseleave mouseenter');
}
if (this._tipsyOpenedManually) {
this.$el.tipsy('hide');
}
},
clean: function() {
this._destroyTipsy();
cdb.core.View.prototype.clean.call(this);
}
});