source: trip-planner-front/node_modules/primeng/fesm2020/primeng-styleclass.mjs@ 1ad8e64

Last change on this file since 1ad8e64 was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 7.9 KB
RevLine 
[59329aa]1import { CommonModule } from '@angular/common';
2import * as i0 from '@angular/core';
3import { Directive, Input, NgModule } from '@angular/core';
4import { DomHandler } from 'primeng/dom';
5
6class StyleClass {
7 constructor(el, renderer) {
8 this.el = el;
9 this.renderer = renderer;
10 }
11 ngAfterViewInit() {
12 this.eventListener = this.renderer.listen(this.el.nativeElement, 'click', () => {
13 this.target = this.resolveTarget();
14 if (this.toggleClass) {
15 if (DomHandler.hasClass(this.target, this.toggleClass))
16 DomHandler.removeClass(this.target, this.toggleClass);
17 else
18 DomHandler.addClass(this.target, this.toggleClass);
19 }
20 else {
21 if (this.target.offsetParent === null)
22 this.enter();
23 else
24 this.leave();
25 }
26 });
27 }
28 enter() {
29 if (this.enterActiveClass) {
30 if (!this.animating) {
31 this.animating = true;
32 if (this.enterActiveClass === 'slidedown') {
33 this.target.style.height = '0px';
34 DomHandler.removeClass(this.target, 'hidden');
35 this.target.style.maxHeight = this.target.scrollHeight + 'px';
36 DomHandler.addClass(this.target, 'hidden');
37 this.target.style.height = '';
38 }
39 DomHandler.addClass(this.target, this.enterActiveClass);
40 if (this.enterClass) {
41 DomHandler.removeClass(this.target, this.enterClass);
42 }
43 this.enterListener = this.renderer.listen(this.target, 'animationend', () => {
44 DomHandler.removeClass(this.target, this.enterActiveClass);
45 if (this.enterToClass) {
46 DomHandler.addClass(this.target, this.enterToClass);
47 }
48 this.enterListener();
49 if (this.enterActiveClass === 'slidedown') {
50 this.target.style.maxHeight = '';
51 }
52 this.animating = false;
53 });
54 }
55 }
56 else {
57 if (this.enterClass) {
58 DomHandler.removeClass(this.target, this.enterClass);
59 }
60 if (this.enterToClass) {
61 DomHandler.addClass(this.target, this.enterToClass);
62 }
63 }
64 if (this.hideOnOutsideClick) {
65 this.bindDocumentListener();
66 }
67 }
68 leave() {
69 if (this.leaveActiveClass) {
70 if (!this.animating) {
71 this.animating = true;
72 DomHandler.addClass(this.target, this.leaveActiveClass);
73 if (this.leaveClass) {
74 DomHandler.removeClass(this.target, this.leaveClass);
75 }
76 this.leaveListener = this.renderer.listen(this.target, 'animationend', () => {
77 DomHandler.removeClass(this.target, this.leaveActiveClass);
78 if (this.leaveToClass) {
79 DomHandler.addClass(this.target, this.leaveToClass);
80 }
81 this.leaveListener();
82 this.animating = false;
83 });
84 }
85 }
86 else {
87 if (this.leaveClass) {
88 DomHandler.removeClass(this.target, this.leaveClass);
89 }
90 if (this.leaveToClass) {
91 DomHandler.addClass(this.target, this.leaveToClass);
92 }
93 }
94 if (this.hideOnOutsideClick) {
95 this.unbindDocumentListener();
96 }
97 }
98 resolveTarget() {
99 if (this.target) {
100 return this.target;
101 }
102 switch (this.selector) {
103 case '@next':
104 return this.el.nativeElement.nextElementSibling;
105 case '@prev':
106 return this.el.nativeElement.previousElementSibling;
107 case '@parent':
108 return this.el.nativeElement.parentElement;
109 case '@grandparent':
110 return this.el.nativeElement.parentElement.parentElement;
111 default:
112 return document.querySelector(this.selector);
113 }
114 }
115 bindDocumentListener() {
116 if (!this.documentListener) {
117 this.documentListener = this.renderer.listen(this.el.nativeElement.ownerDocument, 'click', event => {
118 if (getComputedStyle(this.target).getPropertyValue('position') === 'static') {
119 this.unbindDocumentListener();
120 }
121 else if (!this.el.nativeElement.isSameNode(event.target) && !this.el.nativeElement.contains(event.target) && !this.target.contains(event.target)) {
122 this.leave();
123 }
124 });
125 }
126 }
127 unbindDocumentListener() {
128 if (this.documentListener) {
129 this.documentListener();
130 this.documentListener = null;
131 }
132 }
133 ngOnDestroy() {
134 this.target = null;
135 if (this.eventListener) {
136 this.eventListener();
137 }
138 this.unbindDocumentListener();
139 }
140}
141StyleClass.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClass, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
142StyleClass.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0", type: StyleClass, selector: "[pStyleClass]", inputs: { selector: ["pStyleClass", "selector"], enterClass: "enterClass", enterActiveClass: "enterActiveClass", enterToClass: "enterToClass", leaveClass: "leaveClass", leaveActiveClass: "leaveActiveClass", leaveToClass: "leaveToClass", hideOnOutsideClick: "hideOnOutsideClick", toggleClass: "toggleClass" }, host: { classAttribute: "p-element" }, ngImport: i0 });
143i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClass, decorators: [{
144 type: Directive,
145 args: [{
146 selector: '[pStyleClass]',
147 host: {
148 'class': 'p-element'
149 }
150 }]
151 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { selector: [{
152 type: Input,
153 args: ['pStyleClass']
154 }], enterClass: [{
155 type: Input
156 }], enterActiveClass: [{
157 type: Input
158 }], enterToClass: [{
159 type: Input
160 }], leaveClass: [{
161 type: Input
162 }], leaveActiveClass: [{
163 type: Input
164 }], leaveToClass: [{
165 type: Input
166 }], hideOnOutsideClick: [{
167 type: Input
168 }], toggleClass: [{
169 type: Input
170 }] } });
171class StyleClassModule {
172}
173StyleClassModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClassModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
174StyleClassModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClassModule, declarations: [StyleClass], imports: [CommonModule], exports: [StyleClass] });
175StyleClassModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClassModule, imports: [[CommonModule]] });
176i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: StyleClassModule, decorators: [{
177 type: NgModule,
178 args: [{
179 imports: [CommonModule],
180 exports: [StyleClass],
181 declarations: [StyleClass]
182 }]
183 }] });
184
185/**
186 * Generated bundle index. Do not edit.
187 */
188
189export { StyleClass, StyleClassModule };
Note: See TracBrowser for help on using the repository browser.