source: trip-planner-front/node_modules/primeng/fesm2015/primeng-image.mjs@ 6fe77af

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

adding photos

  • Property mode set to 100644
File size: 14.4 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChildren, NgModule } from '@angular/core';
3import * as i2 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import * as i1 from 'primeng/api';
6import { PrimeTemplate, SharedModule } from 'primeng/api';
7import { trigger, transition, style, animate } from '@angular/animations';
8import { DomHandler } from 'primeng/dom';
9import { ZIndexUtils } from 'primeng/utils';
10
11class Image {
12 constructor(config, cd) {
13 this.config = config;
14 this.cd = cd;
15 this.preview = false;
16 this.showTransitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)';
17 this.hideTransitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)';
18 this.onShow = new EventEmitter();
19 this.onHide = new EventEmitter();
20 this.maskVisible = false;
21 this.previewVisible = false;
22 this.rotate = 0;
23 this.scale = 1;
24 this.previewClick = false;
25 }
26 ngAfterContentInit() {
27 this.templates.forEach((item) => {
28 switch (item.getType()) {
29 case 'indicator':
30 this.indicatorTemplate = item.template;
31 break;
32 default:
33 this.indicatorTemplate = item.template;
34 break;
35 }
36 });
37 }
38 onImageClick() {
39 if (this.preview) {
40 this.maskVisible = true;
41 this.previewVisible = true;
42 }
43 }
44 onMaskClick() {
45 if (!this.previewClick) {
46 this.previewVisible = false;
47 this.rotate = 0;
48 this.scale = 1;
49 }
50 this.previewClick = false;
51 }
52 onPreviewImageClick() {
53 this.previewClick = true;
54 }
55 rotateRight() {
56 this.rotate += 90;
57 this.previewClick = true;
58 }
59 rotateLeft() {
60 this.rotate -= 90;
61 this.previewClick = true;
62 }
63 zoomIn() {
64 this.scale = this.scale + 0.1;
65 this.previewClick = true;
66 }
67 zoomOut() {
68 this.scale = this.scale - 0.1;
69 this.previewClick = true;
70 }
71 zoomDisabled() {
72 return this.scale <= 0.5 || this.scale >= 1.5;
73 }
74 onAnimationStart(event) {
75 switch (event.toState) {
76 case 'visible':
77 this.container = event.element;
78 this.wrapper = this.container.parentElement;
79 this.appendContainer();
80 this.moveOnTop();
81 break;
82 case 'void':
83 DomHandler.addClass(this.wrapper, 'p-component-overlay-leave');
84 break;
85 }
86 }
87 onAnimationEnd(event) {
88 switch (event.toState) {
89 case 'void':
90 ZIndexUtils.clear(this.container);
91 this.maskVisible = false;
92 this.container = null;
93 this.wrapper = null;
94 this.cd.markForCheck();
95 this.onHide.emit({});
96 break;
97 case 'visible':
98 this.onShow.emit({});
99 break;
100 }
101 }
102 moveOnTop() {
103 ZIndexUtils.set('modal', this.container, this.config.zIndex.modal);
104 this.wrapper.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1);
105 }
106 appendContainer() {
107 if (this.appendTo) {
108 if (this.appendTo === 'body')
109 document.body.appendChild(this.wrapper);
110 else
111 DomHandler.appendChild(this.wrapper, this.appendTo);
112 }
113 }
114 imagePreviewStyle() {
115 return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' };
116 }
117 containerClass() {
118 return {
119 'p-image p-component': true,
120 'p-image-preview-container': this.preview
121 };
122 }
123}
124Image.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Image, deps: [{ token: i1.PrimeNGConfig }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
125Image.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Image, selector: "p-image", inputs: { imageClass: "imageClass", imageStyle: "imageStyle", styleClass: "styleClass", style: "style", src: "src", alt: "alt", width: "width", height: "height", appendTo: "appendTo", preview: "preview", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions" }, outputs: { onShow: "onShow", onHide: "onHide" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "mask", first: true, predicate: ["mask"], descendants: true }], ngImport: i0, template: `
126 <span [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style">
127 <img [attr.src]="src" [attr.alt]="alt" [attr.width]="width" [attr.height]="height" [ngStyle]="imageStyle" [class]="imageClass" />
128 <div class="p-image-preview-indicator" *ngIf="preview" (click)="onImageClick()">
129 <ng-container *ngIf="indicatorTemplate;else defaultTemplate">
130 <ng-container *ngTemplateOutlet="indicatorTemplate"></ng-container>
131 </ng-container>
132 <ng-template #defaultTemplate>
133 <i class="p-image-preview-icon pi pi-eye"></i>
134 </ng-template>
135 </div>
136 <div #mask class="p-image-mask p-component-overlay p-component-overlay-enter" *ngIf="maskVisible" (click)="onMaskClick()">
137 <div class="p-image-toolbar">
138 <button class="p-image-action p-link" (click)="rotateRight()" type="button">
139 <i class="pi pi-refresh"></i>
140 </button>
141 <button class="p-image-action p-link" (click)="rotateLeft()" type="button">
142 <i class="pi pi-undo"></i>
143 </button>
144 <button class="p-image-action p-link" (click)="zoomOut()" type="button" [disabled]="zoomDisabled()">
145 <i class="pi pi-search-minus"></i>
146 </button>
147 <button class="p-image-action p-link" (click)="zoomIn()" type="button" [disabled]="zoomDisabled()">
148 <i class="pi pi-search-plus"></i>
149 </button>
150 <button class="p-image-action p-link" type="button">
151 <i class="pi pi-times"></i>
152 </button>
153 </div>
154 <div *ngIf="previewVisible" [@animation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}"
155 (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)">
156 <img [attr.src]="src" class="p-image-preview" [ngStyle]="imagePreviewStyle()" (click)="onPreviewImageClick()"/>
157 </div>
158 </div>
159 </span>
160 `, isInline: true, styles: [".p-image-mask{display:flex;align-items:center;justify-content:center}.p-image-preview-container{position:relative;display:inline-block}.p-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .3s}.p-image-preview-icon{font-size:1.5rem}.p-image-preview-container:hover>.p-image-preview-indicator{opacity:1;cursor:pointer}.p-image-preview-container>img{cursor:pointer}.p-image-toolbar{position:absolute;top:0;right:0;display:flex}.p-image-action.p-link{display:flex;justify-content:center;align-items:center}.p-image-preview{transition:transform .15s;max-width:100vw;max-height:100vh}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], animations: [
161 trigger('animation', [
162 transition('void => visible', [
163 style({ transform: 'scale(0.7)', opacity: 0 }),
164 animate('{{showTransitionParams}}')
165 ]),
166 transition('visible => void', [
167 animate('{{hideTransitionParams}}', style({ transform: 'scale(0.7)', opacity: 0 }))
168 ])
169 ])
170 ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
171i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Image, decorators: [{
172 type: Component,
173 args: [{ selector: 'p-image', template: `
174 <span [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style">
175 <img [attr.src]="src" [attr.alt]="alt" [attr.width]="width" [attr.height]="height" [ngStyle]="imageStyle" [class]="imageClass" />
176 <div class="p-image-preview-indicator" *ngIf="preview" (click)="onImageClick()">
177 <ng-container *ngIf="indicatorTemplate;else defaultTemplate">
178 <ng-container *ngTemplateOutlet="indicatorTemplate"></ng-container>
179 </ng-container>
180 <ng-template #defaultTemplate>
181 <i class="p-image-preview-icon pi pi-eye"></i>
182 </ng-template>
183 </div>
184 <div #mask class="p-image-mask p-component-overlay p-component-overlay-enter" *ngIf="maskVisible" (click)="onMaskClick()">
185 <div class="p-image-toolbar">
186 <button class="p-image-action p-link" (click)="rotateRight()" type="button">
187 <i class="pi pi-refresh"></i>
188 </button>
189 <button class="p-image-action p-link" (click)="rotateLeft()" type="button">
190 <i class="pi pi-undo"></i>
191 </button>
192 <button class="p-image-action p-link" (click)="zoomOut()" type="button" [disabled]="zoomDisabled()">
193 <i class="pi pi-search-minus"></i>
194 </button>
195 <button class="p-image-action p-link" (click)="zoomIn()" type="button" [disabled]="zoomDisabled()">
196 <i class="pi pi-search-plus"></i>
197 </button>
198 <button class="p-image-action p-link" type="button">
199 <i class="pi pi-times"></i>
200 </button>
201 </div>
202 <div *ngIf="previewVisible" [@animation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}"
203 (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)">
204 <img [attr.src]="src" class="p-image-preview" [ngStyle]="imagePreviewStyle()" (click)="onPreviewImageClick()"/>
205 </div>
206 </div>
207 </span>
208 `, animations: [
209 trigger('animation', [
210 transition('void => visible', [
211 style({ transform: 'scale(0.7)', opacity: 0 }),
212 animate('{{showTransitionParams}}')
213 ]),
214 transition('visible => void', [
215 animate('{{hideTransitionParams}}', style({ transform: 'scale(0.7)', opacity: 0 }))
216 ])
217 ])
218 ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
219 'class': 'p-element'
220 }, styles: [".p-image-mask{display:flex;align-items:center;justify-content:center}.p-image-preview-container{position:relative;display:inline-block}.p-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .3s}.p-image-preview-icon{font-size:1.5rem}.p-image-preview-container:hover>.p-image-preview-indicator{opacity:1;cursor:pointer}.p-image-preview-container>img{cursor:pointer}.p-image-toolbar{position:absolute;top:0;right:0;display:flex}.p-image-action.p-link{display:flex;justify-content:center;align-items:center}.p-image-preview{transition:transform .15s;max-width:100vw;max-height:100vh}\n"] }]
221 }], ctorParameters: function () { return [{ type: i1.PrimeNGConfig }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { imageClass: [{
222 type: Input
223 }], imageStyle: [{
224 type: Input
225 }], styleClass: [{
226 type: Input
227 }], style: [{
228 type: Input
229 }], src: [{
230 type: Input
231 }], alt: [{
232 type: Input
233 }], width: [{
234 type: Input
235 }], height: [{
236 type: Input
237 }], appendTo: [{
238 type: Input
239 }], preview: [{
240 type: Input
241 }], showTransitionOptions: [{
242 type: Input
243 }], hideTransitionOptions: [{
244 type: Input
245 }], onShow: [{
246 type: Output
247 }], onHide: [{
248 type: Output
249 }], mask: [{
250 type: ViewChild,
251 args: ['mask']
252 }], templates: [{
253 type: ContentChildren,
254 args: [PrimeTemplate]
255 }] } });
256class ImageModule {
257}
258ImageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
259ImageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, declarations: [Image], imports: [CommonModule], exports: [Image, SharedModule] });
260ImageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, imports: [[CommonModule], SharedModule] });
261i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ImageModule, decorators: [{
262 type: NgModule,
263 args: [{
264 imports: [CommonModule],
265 exports: [Image, SharedModule],
266 declarations: [Image]
267 }]
268 }] });
269
270/**
271 * Generated bundle index. Do not edit.
272 */
273
274export { Image, ImageModule };
Note: See TracBrowser for help on using the repository browser.