ferngully-aurelia-tools
Version:
Ferngully Tools for Aurelia
86 lines • 3.42 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { customAttribute, inject, bindable } from "aurelia-framework";
import { I18N } from 'aurelia-i18n';
var Tooltip = (function () {
function Tooltip(element, i18n) {
this.element = element;
this.i18n = i18n;
}
Tooltip.prototype.bind = function () {
this.title = this.i18n.tr(this.title);
if (this.enable) {
this.configureTooltip();
}
};
Tooltip.prototype.titleChanged = function (newValue, oldValue) {
this.title = newValue;
};
Tooltip.prototype.enableChanged = function (newValue, oldValue) {
if (newValue) {
this.configureTooltip();
}
else {
$(this.element)
.tooltip("destroy");
}
};
Tooltip.prototype.configureTooltip = function () {
var _this = this;
$(this.element)
.tooltip({
title: function () { return _this.title; },
placement: this.placement,
trigger: this.trigger,
container: this.container,
animation: this.animation,
html: this.html
});
if (!this.clickHandler) {
this.clickHandler = $(this.element).on("click", function () { $(_this.element).tooltip("hide"); });
}
};
__decorate([
bindable({ primaryProperty: true }),
__metadata("design:type", String)
], Tooltip.prototype, "title", void 0);
__decorate([
bindable({ defaultValue: "top" }),
__metadata("design:type", String)
], Tooltip.prototype, "placement", void 0);
__decorate([
bindable({ defaultValue: "body" }),
__metadata("design:type", Object)
], Tooltip.prototype, "container", void 0);
__decorate([
bindable({ defaultValue: "hover" }),
__metadata("design:type", String)
], Tooltip.prototype, "trigger", void 0);
__decorate([
bindable({ defaultValue: false }),
__metadata("design:type", Boolean)
], Tooltip.prototype, "html", void 0);
__decorate([
bindable({ defaultValue: true }),
__metadata("design:type", Boolean)
], Tooltip.prototype, "enable", void 0);
__decorate([
bindable({ defaultValue: true }),
__metadata("design:type", Boolean)
], Tooltip.prototype, "animation", void 0);
Tooltip = __decorate([
customAttribute('tooltip'),
inject(Element, I18N),
__metadata("design:paramtypes", [HTMLElement, I18N])
], Tooltip);
return Tooltip;
}());
export { Tooltip };
//# sourceMappingURL=tooltip.js.map