hide tips on lock

This commit is contained in:
Antelle 2016-02-28 13:36:56 +03:00
parent 2de1515205
commit 35bd1ab3be
2 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,7 @@ var Backbone = require('backbone'),
_.extend(Backbone.View.prototype, {
hide: function() {
Tip.hideTips(this.$el);
return this.toggle(false);
},
@ -20,6 +21,9 @@ _.extend(Backbone.View.prototype, {
this.$el.toggleClass('hide', !visible);
this._hidden = !visible;
this.trigger(visible ? 'show' : 'hide');
if (!visible) {
Tip.hideTips(this.$el);
}
return this;
},
@ -42,6 +46,7 @@ _.extend(Backbone.View.prototype, {
},
renderTemplate: function(model, replace) {
Tip.hideTips(this.$el);
if (replace && replace.plain) {
this.$el.html(this.template(model));
} else {
@ -81,6 +86,7 @@ _.extend(Backbone.View.prototype, {
try { this.scroll.dispose(); }
catch (e) { }
}
Tip.hideTips(this.$el);
this._parentRemove(arguments);
}
});

View File

@ -21,6 +21,7 @@ Tip.prototype.init = function() {
return;
}
this.el.removeAttr('title');
this.el.attr('data-title', this.title);
this.el.mouseenter(this.mouseenter.bind(this)).mouseleave(this.mouseleave.bind(this));
this.el.click(this.mouseleave.bind(this));
};
@ -140,6 +141,18 @@ Tip.createTips = function(container) {
container.find('[title]').each(function(ix, el) {
var tip = new Tip($(el));
tip.init();
el._tip = tip;
});
};
Tip.hideTips = function(container) {
if (!Tip.enabled) {
return;
}
container.find('[data-title]').each(function(ix, el) {
if (el._tip) {
el._tip.hide();
}
});
};