UNPKG

ferngully-aurelia-tools

Version:

Ferngully Tools for Aurelia

140 lines 6.31 kB
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, bindingMode, TemplatingEngine } from "aurelia-framework"; import { AureliaHelperService } from "../../../services/aurelia-helper-service"; import { I18N } from 'aurelia-i18n'; var Popover = (function () { function Popover(element, templatingEngine, aureliaHelperService, i18n) { this.templatingEngine = templatingEngine; this.aureliaHelperService = aureliaHelperService; this.i18n = i18n; this.element = element; } Popover.prototype.bind = function (bindingContext) { var _this = this; this.bindingContext = bindingContext; this.title = this.i18n.tr(this.title); this.content = this.i18n.tr(this.content); if (this.enable) { this.configurePopover(); } if (this.template) { $(this.element).on("shown.bs.popover.myTooltip", function () { return _this.enhance(); }); } if (this.trigger === "hover-modal") { var $element_1 = $(this.element); var fnHandleMouseOver_1 = function () { return $element_1.one('mouseover.myTooltip', function () { $element_1.focus(); }); }; fnHandleMouseOver_1(); $element_1.on("hide.bs.popover.myTooltip", function () { return fnHandleMouseOver_1(); }); } }; Popover.prototype.unbind = function () { if (this.template) { $(this.element).off('shown.bs.popover.myTooltip'); } }; Popover.prototype.titleChanged = function (newValue, oldValue) { this.title = newValue; }; Popover.prototype.contentChanged = function (newValue) { this.content = newValue; }; Popover.prototype.templateChanged = function (newValue, oldValue) { this.template = newValue; }; Popover.prototype.enableChanged = function (newValue, oldValue) { this.enable = newValue; if (newValue) { this.configurePopover(); } else { $(this.element).popover("destroy"); } }; Popover.prototype.configurePopover = function () { var _this = this; $(this.element) .popover({ title: function () { return _this.title; }, placement: this.placement, trigger: this.trigger === "hover-modal" ? "focus" : this.trigger, container: this.container, html: this.html, animation: this.animation, viewport: this.viewport, delay: this.template ? 100 : 0, content: function () { return _this.template ? _this.template.content : _this.content; } }); }; Popover.prototype.enhance = function () { this.aureliaHelperService.enhance(this.template.selectionPath, this.template.bindingContext || this.bindingContext); }; __decorate([ bindable({ defaultValue: 0, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Object) ], Popover.prototype, "delay", void 0); __decorate([ bindable({ defaultValue: "top", defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Object) ], Popover.prototype, "placement", void 0); __decorate([ bindable({ defaultValue: null, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", String) ], Popover.prototype, "title", void 0); __decorate([ bindable({ defaultValue: null, defaultBindingMode: bindingMode.oneWay, primaryProperty: true }), __metadata("design:type", String) ], Popover.prototype, "content", void 0); __decorate([ bindable({ defaultValue: null, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Object) ], Popover.prototype, "template", void 0); __decorate([ bindable({ defaultValue: "body", defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Object) ], Popover.prototype, "container", void 0); __decorate([ bindable({ defaultValue: "hover", defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", String) ], Popover.prototype, "trigger", void 0); __decorate([ bindable({ defaultValue: true, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Boolean) ], Popover.prototype, "enable", void 0); __decorate([ bindable({ defaultValue: true, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Boolean) ], Popover.prototype, "animation", void 0); __decorate([ bindable({ defaultValue: false, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Boolean) ], Popover.prototype, "html", void 0); __decorate([ bindable({ defaultValue: { selector: 'body', padding: 0 }, defaultBindingMode: bindingMode.oneWay }), __metadata("design:type", Object) ], Popover.prototype, "viewport", void 0); Popover = __decorate([ customAttribute('popover'), inject(Element, TemplatingEngine, AureliaHelperService, I18N), __metadata("design:paramtypes", [HTMLElement, TemplatingEngine, AureliaHelperService, I18N]) ], Popover); return Popover; }()); export { Popover }; //# sourceMappingURL=popover.js.map