| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- define("ngx-tooltip/TooltipContent", ["require", "exports", "@angular/core"], function (require, exports, core_1) {
- var TooltipContent = (function () {
- // -------------------------------------------------------------------------
- // Constructor
- // -------------------------------------------------------------------------
- function TooltipContent(element, cdr) {
- this.element = element;
- this.cdr = cdr;
- this.placement = "bottom";
- this.animation = true;
- // -------------------------------------------------------------------------
- // Properties
- // -------------------------------------------------------------------------
- this.top = -100000;
- this.left = -100000;
- this.isIn = false;
- this.isFade = false;
- }
- // -------------------------------------------------------------------------
- // Lifecycle callbacks
- // -------------------------------------------------------------------------
- TooltipContent.prototype.ngAfterViewInit = function () {
- this.show();
- this.cdr.detectChanges();
- };
- // -------------------------------------------------------------------------
- // Public Methods
- // -------------------------------------------------------------------------
- TooltipContent.prototype.show = function () {
- if (!this.hostElement)
- return;
- var p = this.positionElements(this.hostElement, this.element.nativeElement.children[0], this.placement);
- this.top = p.top;
- this.left = p.left;
- this.isIn = true;
- if (this.animation)
- this.isFade = true;
- };
- TooltipContent.prototype.hide = function () {
- this.top = -100000;
- this.left = -100000;
- this.isIn = true;
- if (this.animation)
- this.isFade = false;
- };
- // -------------------------------------------------------------------------
- // Private Methods
- // -------------------------------------------------------------------------
- TooltipContent.prototype.positionElements = function (hostEl, targetEl, positionStr, appendToBody) {
- if (appendToBody === void 0) { appendToBody = false; }
- var positionStrParts = positionStr.split("-");
- var pos0 = positionStrParts[0];
- var pos1 = positionStrParts[1] || "center";
- var hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);
- var targetElWidth = targetEl.offsetWidth;
- var targetElHeight = targetEl.offsetHeight;
- var shiftWidth = {
- center: function () {
- return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
- },
- left: function () {
- return hostElPos.left;
- },
- right: function () {
- return hostElPos.left + hostElPos.width;
- }
- };
- var shiftHeight = {
- center: function () {
- return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
- },
- top: function () {
- return hostElPos.top;
- },
- bottom: function () {
- return hostElPos.top + hostElPos.height;
- }
- };
- var targetElPos;
- switch (pos0) {
- case "right":
- targetElPos = {
- top: shiftHeight[pos1](),
- left: shiftWidth[pos0]()
- };
- break;
- case "left":
- targetElPos = {
- top: shiftHeight[pos1](),
- left: hostElPos.left - targetElWidth
- };
- break;
- case "bottom":
- targetElPos = {
- top: shiftHeight[pos0](),
- left: shiftWidth[pos1]()
- };
- break;
- default:
- targetElPos = {
- top: hostElPos.top - targetElHeight,
- left: shiftWidth[pos1]()
- };
- break;
- }
- return targetElPos;
- };
- TooltipContent.prototype.position = function (nativeEl) {
- var offsetParentBCR = { top: 0, left: 0 };
- var elBCR = this.offset(nativeEl);
- var offsetParentEl = this.parentOffsetEl(nativeEl);
- if (offsetParentEl !== window.document) {
- offsetParentBCR = this.offset(offsetParentEl);
- offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
- offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
- }
- var boundingClientRect = nativeEl.getBoundingClientRect();
- return {
- width: boundingClientRect.width || nativeEl.offsetWidth,
- height: boundingClientRect.height || nativeEl.offsetHeight,
- top: elBCR.top - offsetParentBCR.top,
- left: elBCR.left - offsetParentBCR.left
- };
- };
- TooltipContent.prototype.offset = function (nativeEl) {
- var boundingClientRect = nativeEl.getBoundingClientRect();
- return {
- width: boundingClientRect.width || nativeEl.offsetWidth,
- height: boundingClientRect.height || nativeEl.offsetHeight,
- top: boundingClientRect.top + (window.pageYOffset || window.document.documentElement.scrollTop),
- left: boundingClientRect.left + (window.pageXOffset || window.document.documentElement.scrollLeft)
- };
- };
- TooltipContent.prototype.getStyle = function (nativeEl, cssProp) {
- if (nativeEl.currentStyle)
- return nativeEl.currentStyle[cssProp];
- if (window.getComputedStyle)
- return window.getComputedStyle(nativeEl)[cssProp];
- // finally try and get inline style
- return nativeEl.style[cssProp];
- };
- TooltipContent.prototype.isStaticPositioned = function (nativeEl) {
- return (this.getStyle(nativeEl, "position") || "static") === "static";
- };
- TooltipContent.prototype.parentOffsetEl = function (nativeEl) {
- var offsetParent = nativeEl.offsetParent || window.document;
- while (offsetParent && offsetParent !== window.document && this.isStaticPositioned(offsetParent)) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent || window.document;
- };
- return TooltipContent;
- }());
- __decorate([
- core_1.Input(),
- __metadata("design:type", HTMLElement)
- ], TooltipContent.prototype, "hostElement", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], TooltipContent.prototype, "content", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], TooltipContent.prototype, "placement", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], TooltipContent.prototype, "animation", void 0);
- TooltipContent = __decorate([
- core_1.Component({
- selector: "tooltip-content",
- template: "\n<div class=\"tooltip {{ placement }}\"\n [style.top]=\"top + 'px'\"\n [style.left]=\"left + 'px'\"\n [class.in]=\"isIn\"\n [class.fade]=\"isFade\"\n role=\"tooltip\">\n <div class=\"tooltip-arrow\"></div> \n <div class=\"tooltip-inner\">\n <ng-content></ng-content>\n {{ content }}\n </div> \n</div>\n"
- }),
- __metadata("design:paramtypes", [core_1.ElementRef,
- core_1.ChangeDetectorRef])
- ], TooltipContent);
- exports.TooltipContent = TooltipContent;
- });
- define("ngx-tooltip/Tooltip", ["require", "exports", "@angular/core", "ngx-tooltip/TooltipContent"], function (require, exports, core_2, TooltipContent_1) {
- var Tooltip = (function () {
- // -------------------------------------------------------------------------
- // Constructor
- // -------------------------------------------------------------------------
- function Tooltip(viewContainerRef, resolver) {
- this.viewContainerRef = viewContainerRef;
- this.resolver = resolver;
- this.tooltipAnimation = true;
- this.tooltipPlacement = "bottom";
- }
- // -------------------------------------------------------------------------
- // Public Methods
- // -------------------------------------------------------------------------
- Tooltip.prototype.show = function () {
- if (this.tooltipDisabled || this.visible)
- return;
- this.visible = true;
- if (typeof this.content === "string") {
- var factory = this.resolver.resolveComponentFactory(TooltipContent_1.TooltipContent);
- if (!this.visible)
- return;
- this.tooltip = this.viewContainerRef.createComponent(factory);
- this.tooltip.instance.hostElement = this.viewContainerRef.element.nativeElement;
- this.tooltip.instance.content = this.content;
- this.tooltip.instance.placement = this.tooltipPlacement;
- this.tooltip.instance.animation = this.tooltipAnimation;
- }
- else {
- var tooltip = this.content;
- tooltip.hostElement = this.viewContainerRef.element.nativeElement;
- tooltip.placement = this.tooltipPlacement;
- tooltip.animation = this.tooltipAnimation;
- tooltip.show();
- }
- };
- Tooltip.prototype.hide = function () {
- if (!this.visible)
- return;
- this.visible = false;
- if (this.tooltip)
- this.tooltip.destroy();
- if (this.content instanceof TooltipContent_1.TooltipContent)
- this.content.hide();
- };
- return Tooltip;
- }());
- __decorate([
- core_2.Input("tooltip"),
- __metadata("design:type", Object)
- ], Tooltip.prototype, "content", void 0);
- __decorate([
- core_2.Input(),
- __metadata("design:type", Boolean)
- ], Tooltip.prototype, "tooltipDisabled", void 0);
- __decorate([
- core_2.Input(),
- __metadata("design:type", Boolean)
- ], Tooltip.prototype, "tooltipAnimation", void 0);
- __decorate([
- core_2.Input(),
- __metadata("design:type", String)
- ], Tooltip.prototype, "tooltipPlacement", void 0);
- __decorate([
- core_2.HostListener("focusin"),
- core_2.HostListener("mouseenter"),
- __metadata("design:type", Function),
- __metadata("design:paramtypes", []),
- __metadata("design:returntype", void 0)
- ], Tooltip.prototype, "show", null);
- __decorate([
- core_2.HostListener("focusout"),
- core_2.HostListener("mouseleave"),
- __metadata("design:type", Function),
- __metadata("design:paramtypes", []),
- __metadata("design:returntype", void 0)
- ], Tooltip.prototype, "hide", null);
- Tooltip = __decorate([
- core_2.Directive({
- selector: "[tooltip]"
- }),
- __metadata("design:paramtypes", [core_2.ViewContainerRef,
- core_2.ComponentFactoryResolver])
- ], Tooltip);
- exports.Tooltip = Tooltip;
- });
- define("ngx-tooltip/index", ["require", "exports", "@angular/core", "@angular/common", "ngx-tooltip/Tooltip", "ngx-tooltip/TooltipContent", "ngx-tooltip/Tooltip", "ngx-tooltip/TooltipContent"], function (require, exports, core_3, common_1, Tooltip_1, TooltipContent_2, Tooltip_2, TooltipContent_3) {
- function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- __export(Tooltip_2);
- __export(TooltipContent_3);
- var TooltipModule = (function () {
- function TooltipModule() {
- }
- return TooltipModule;
- }());
- TooltipModule = __decorate([
- core_3.NgModule({
- imports: [
- common_1.CommonModule
- ],
- declarations: [
- Tooltip_1.Tooltip,
- TooltipContent_2.TooltipContent,
- ],
- exports: [
- Tooltip_1.Tooltip,
- TooltipContent_2.TooltipContent,
- ],
- entryComponents: [
- TooltipContent_2.TooltipContent
- ]
- })
- ], TooltipModule);
- exports.TooltipModule = TooltipModule;
- });
- define("ngx-tooltip", ["require", "exports", "ngx-tooltip/index"], function (require, exports, index_1) {
- function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- __export(index_1);
- });
|