cartodb-4.42/lib/assets/javascripts/cartodb/old_common/tipsy_tooltip.js

59 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
/**
* 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);
}
});