1 | import { Component, ChangeDetectionStrategy, NgZone, ElementRef, ChangeDetectorRef, Renderer2, Input, Output, ViewChildren, EventEmitter, Directive, NgModule } from '@angular/core';
|
2 | import { CommonModule } from '@angular/common';
|
3 | import { __spread } from 'tslib';
|
4 | import { Observable, Subject } from 'rxjs';
|
5 | import { debounceTime } from 'rxjs/operators';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function getPointFromEvent(event) {
|
16 |
|
17 | if ((( (event))).changedTouches !== undefined && (( (event))).changedTouches.length > 0) {
|
18 | return {
|
19 | x: (( (event))).changedTouches[0].clientX,
|
20 | y: (( (event))).changedTouches[0].clientY,
|
21 | };
|
22 | }
|
23 |
|
24 | else if ((( (event))).clientX !== undefined && (( (event))).clientY !== undefined) {
|
25 | return {
|
26 | x: (( (event))).clientX,
|
27 | y: (( (event))).clientY,
|
28 | };
|
29 | }
|
30 | return null;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | function getElementPixelSize(elRef, direction) {
|
38 |
|
39 | var rect = (( (elRef.nativeElement))).getBoundingClientRect();
|
40 | return (direction === 'horizontal') ? rect.width : rect.height;
|
41 | }
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | function getInputBoolean(v) {
|
47 | return (typeof (v) === 'boolean') ? v : (v === 'false' ? false : true);
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | function getInputPositiveNumber(v, defaultValue) {
|
56 | if (v === null || v === undefined)
|
57 | return defaultValue;
|
58 | v = Number(v);
|
59 | return !isNaN(v) && v >= 0 ? v : defaultValue;
|
60 | }
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function isUserSizesValid(unit, sizes) {
|
67 |
|
68 | if (unit === 'percent') {
|
69 |
|
70 | var total = sizes.reduce(( |
71 |
|
72 |
|
73 |
|
74 |
|
75 | function (total, s) { return s !== null ? total + s : total; }), 0);
|
76 | return sizes.every(( |
77 |
|
78 |
|
79 |
|
80 | function (s) { return s !== null; })) && total > 99.9 && total < 100.1;
|
81 | }
|
82 |
|
83 | if (unit === 'pixel') {
|
84 | return sizes.filter(( |
85 |
|
86 |
|
87 |
|
88 | function (s) { return s === null; })).length === 1;
|
89 | }
|
90 | }
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | function getAreaMinSize(a) {
|
96 | if (a.size === null) {
|
97 | return null;
|
98 | }
|
99 | if (a.component.lockSize === true) {
|
100 | return a.size;
|
101 | }
|
102 | if (a.component.minSize === null) {
|
103 | return null;
|
104 | }
|
105 | if (a.component.minSize > a.size) {
|
106 | return a.size;
|
107 | }
|
108 | return a.component.minSize;
|
109 | }
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | function getAreaMaxSize(a) {
|
115 | if (a.size === null) {
|
116 | return null;
|
117 | }
|
118 | if (a.component.lockSize === true) {
|
119 | return a.size;
|
120 | }
|
121 | if (a.component.maxSize === null) {
|
122 | return null;
|
123 | }
|
124 | if (a.component.maxSize < a.size) {
|
125 | return a.size;
|
126 | }
|
127 | return a.component.maxSize;
|
128 | }
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | function getGutterSideAbsorptionCapacity(unit, sideAreas, pixels, allAreasSizePixel) {
|
137 | return sideAreas.reduce(( |
138 |
|
139 |
|
140 |
|
141 |
|
142 | function (acc, area) {
|
143 |
|
144 | var res = getAreaAbsorptionCapacity(unit, area, acc.remain, allAreasSizePixel);
|
145 | acc.list.push(res);
|
146 | acc.remain = res.pixelRemain;
|
147 | return acc;
|
148 | }), { remain: pixels, list: [] });
|
149 | }
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | function getAreaAbsorptionCapacity(unit, areaSnapshot, pixels, allAreasSizePixel) {
|
158 |
|
159 | if (pixels === 0) {
|
160 | return {
|
161 | areaSnapshot: areaSnapshot,
|
162 | pixelAbsorb: 0,
|
163 | percentAfterAbsorption: areaSnapshot.sizePercentAtStart,
|
164 | pixelRemain: 0,
|
165 | };
|
166 | }
|
167 |
|
168 | if (areaSnapshot.sizePixelAtStart === 0 && pixels < 0) {
|
169 | return {
|
170 | areaSnapshot: areaSnapshot,
|
171 | pixelAbsorb: 0,
|
172 | percentAfterAbsorption: 0,
|
173 | pixelRemain: pixels,
|
174 | };
|
175 | }
|
176 | if (unit === 'percent') {
|
177 | return getAreaAbsorptionCapacityPercent(areaSnapshot, pixels, allAreasSizePixel);
|
178 | }
|
179 | if (unit === 'pixel') {
|
180 | return getAreaAbsorptionCapacityPixel(areaSnapshot, pixels);
|
181 | }
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | function getAreaAbsorptionCapacityPercent(areaSnapshot, pixels, allAreasSizePixel) {
|
190 |
|
191 | var tempPixelSize = areaSnapshot.sizePixelAtStart + pixels;
|
192 |
|
193 | var tempPercentSize = tempPixelSize / allAreasSizePixel * 100;
|
194 |
|
195 | if (pixels > 0) {
|
196 |
|
197 | if (areaSnapshot.area.maxSize !== null && tempPercentSize > areaSnapshot.area.maxSize) {
|
198 |
|
199 |
|
200 | var maxSizePixel = areaSnapshot.area.maxSize / 100 * allAreasSizePixel;
|
201 | return {
|
202 | areaSnapshot: areaSnapshot,
|
203 | pixelAbsorb: maxSizePixel,
|
204 | percentAfterAbsorption: areaSnapshot.area.maxSize,
|
205 | pixelRemain: areaSnapshot.sizePixelAtStart + pixels - maxSizePixel
|
206 | };
|
207 | }
|
208 | return {
|
209 | areaSnapshot: areaSnapshot,
|
210 | pixelAbsorb: pixels,
|
211 | percentAfterAbsorption: tempPercentSize > 100 ? 100 : tempPercentSize,
|
212 | pixelRemain: 0
|
213 | };
|
214 | }
|
215 |
|
216 | else if (pixels < 0) {
|
217 |
|
218 | if (areaSnapshot.area.minSize !== null && tempPercentSize < areaSnapshot.area.minSize) {
|
219 |
|
220 |
|
221 | var minSizePixel = areaSnapshot.area.minSize / 100 * allAreasSizePixel;
|
222 | return {
|
223 | areaSnapshot: areaSnapshot,
|
224 | pixelAbsorb: minSizePixel,
|
225 | percentAfterAbsorption: areaSnapshot.area.minSize,
|
226 | pixelRemain: areaSnapshot.sizePixelAtStart + pixels - minSizePixel
|
227 | };
|
228 | }
|
229 |
|
230 | else if (tempPercentSize < 0) {
|
231 |
|
232 | return {
|
233 | areaSnapshot: areaSnapshot,
|
234 | pixelAbsorb: -areaSnapshot.sizePixelAtStart,
|
235 | percentAfterAbsorption: 0,
|
236 | pixelRemain: pixels + areaSnapshot.sizePixelAtStart
|
237 | };
|
238 | }
|
239 | return {
|
240 | areaSnapshot: areaSnapshot,
|
241 | pixelAbsorb: pixels,
|
242 | percentAfterAbsorption: tempPercentSize,
|
243 | pixelRemain: 0
|
244 | };
|
245 | }
|
246 | }
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | function getAreaAbsorptionCapacityPixel(areaSnapshot, pixels, containerSizePixel) {
|
254 |
|
255 | var tempPixelSize = areaSnapshot.sizePixelAtStart + pixels;
|
256 |
|
257 | if (pixels > 0) {
|
258 |
|
259 | if (areaSnapshot.area.maxSize !== null && tempPixelSize > areaSnapshot.area.maxSize) {
|
260 | return {
|
261 | areaSnapshot: areaSnapshot,
|
262 | pixelAbsorb: areaSnapshot.area.maxSize - areaSnapshot.sizePixelAtStart,
|
263 | percentAfterAbsorption: -1,
|
264 | pixelRemain: tempPixelSize - areaSnapshot.area.maxSize
|
265 | };
|
266 | }
|
267 | return {
|
268 | areaSnapshot: areaSnapshot,
|
269 | pixelAbsorb: pixels,
|
270 | percentAfterAbsorption: -1,
|
271 | pixelRemain: 0
|
272 | };
|
273 | }
|
274 |
|
275 | else if (pixels < 0) {
|
276 |
|
277 | if (areaSnapshot.area.minSize !== null && tempPixelSize < areaSnapshot.area.minSize) {
|
278 | return {
|
279 | areaSnapshot: areaSnapshot,
|
280 | pixelAbsorb: areaSnapshot.area.minSize + pixels - tempPixelSize,
|
281 | percentAfterAbsorption: -1,
|
282 | pixelRemain: tempPixelSize - areaSnapshot.area.minSize
|
283 | };
|
284 | }
|
285 |
|
286 | else if (tempPixelSize < 0) {
|
287 | return {
|
288 | areaSnapshot: areaSnapshot,
|
289 | pixelAbsorb: -areaSnapshot.sizePixelAtStart,
|
290 | percentAfterAbsorption: -1,
|
291 | pixelRemain: pixels + areaSnapshot.sizePixelAtStart
|
292 | };
|
293 | }
|
294 | return {
|
295 | areaSnapshot: areaSnapshot,
|
296 | pixelAbsorb: pixels,
|
297 | percentAfterAbsorption: -1,
|
298 | pixelRemain: 0
|
299 | };
|
300 | }
|
301 | }
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 | function updateAreaSize(unit, item) {
|
308 | if (unit === 'percent') {
|
309 | item.areaSnapshot.area.size = item.percentAfterAbsorption;
|
310 | }
|
311 | else if (unit === 'pixel') {
|
312 |
|
313 | if (item.areaSnapshot.area.size !== null) {
|
314 | item.areaSnapshot.area.size = item.areaSnapshot.sizePixelAtStart + item.pixelAbsorb;
|
315 | }
|
316 | }
|
317 | }
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | var SplitComponent = (function () {
|
353 | function SplitComponent(ngZone, elRef, cdRef, renderer) {
|
354 | this.ngZone = ngZone;
|
355 | this.elRef = elRef;
|
356 | this.cdRef = cdRef;
|
357 | this.renderer = renderer;
|
358 | this._direction = 'horizontal';
|
359 |
|
360 | this._unit = 'percent';
|
361 |
|
362 | this._gutterSize = 11;
|
363 |
|
364 | this._gutterStep = 1;
|
365 |
|
366 | this._restrictMove = false;
|
367 |
|
368 | this._useTransition = false;
|
369 |
|
370 | this._disabled = false;
|
371 |
|
372 | this._dir = 'ltr';
|
373 |
|
374 | this._gutterDblClickDuration = 0;
|
375 |
|
376 | this.dragStart = new EventEmitter(false);
|
377 | this.dragEnd = new EventEmitter(false);
|
378 | this.gutterClick = new EventEmitter(false);
|
379 | this.gutterDblClick = new EventEmitter(false);
|
380 | this.dragProgressSubject = new Subject();
|
381 | this.dragProgress$ = this.dragProgressSubject.asObservable();
|
382 |
|
383 | this.isDragging = false;
|
384 | this.dragListeners = [];
|
385 | this.snapshot = null;
|
386 | this.startPoint = null;
|
387 | this.endPoint = null;
|
388 | this.displayedAreas = [];
|
389 | this.hidedAreas = [];
|
390 | this._clickTimeout = null;
|
391 |
|
392 | this.direction = this._direction;
|
393 | }
|
394 | Object.defineProperty(SplitComponent.prototype, "direction", {
|
395 | get: /**
|
396 | * @return {?}
|
397 | */
|
398 | function () {
|
399 | return this._direction;
|
400 | },
|
401 | set: /**
|
402 | * @param {?} v
|
403 | * @return {?}
|
404 | */
|
405 | function (v) {
|
406 | this._direction = (v === 'vertical') ? 'vertical' : 'horizontal';
|
407 | this.renderer.addClass(this.elRef.nativeElement, "as-" + this._direction);
|
408 | this.renderer.removeClass(this.elRef.nativeElement, "as-" + ((this._direction === 'vertical') ? 'horizontal' : 'vertical'));
|
409 | this.build(false, false);
|
410 | },
|
411 | enumerable: true,
|
412 | configurable: true
|
413 | });
|
414 | Object.defineProperty(SplitComponent.prototype, "unit", {
|
415 | get: /**
|
416 | * @return {?}
|
417 | */
|
418 | function () {
|
419 | return this._unit;
|
420 | },
|
421 | set: /**
|
422 | * @param {?} v
|
423 | * @return {?}
|
424 | */
|
425 | function (v) {
|
426 | this._unit = (v === 'pixel') ? 'pixel' : 'percent';
|
427 | this.renderer.addClass(this.elRef.nativeElement, "as-" + this._unit);
|
428 | this.renderer.removeClass(this.elRef.nativeElement, "as-" + ((this._unit === 'pixel') ? 'percent' : 'pixel'));
|
429 | this.build(false, true);
|
430 | },
|
431 | enumerable: true,
|
432 | configurable: true
|
433 | });
|
434 | Object.defineProperty(SplitComponent.prototype, "gutterSize", {
|
435 | get: /**
|
436 | * @return {?}
|
437 | */
|
438 | function () {
|
439 | return this._gutterSize;
|
440 | },
|
441 | set: /**
|
442 | * @param {?} v
|
443 | * @return {?}
|
444 | */
|
445 | function (v) {
|
446 | this._gutterSize = getInputPositiveNumber(v, 11);
|
447 | this.build(false, false);
|
448 | },
|
449 | enumerable: true,
|
450 | configurable: true
|
451 | });
|
452 | Object.defineProperty(SplitComponent.prototype, "gutterStep", {
|
453 | get: /**
|
454 | * @return {?}
|
455 | */
|
456 | function () {
|
457 | return this._gutterStep;
|
458 | },
|
459 | set: /**
|
460 | * @param {?} v
|
461 | * @return {?}
|
462 | */
|
463 | function (v) {
|
464 | this._gutterStep = getInputPositiveNumber(v, 1);
|
465 | },
|
466 | enumerable: true,
|
467 | configurable: true
|
468 | });
|
469 | Object.defineProperty(SplitComponent.prototype, "restrictMove", {
|
470 | get: /**
|
471 | * @return {?}
|
472 | */
|
473 | function () {
|
474 | return this._restrictMove;
|
475 | },
|
476 | set: /**
|
477 | * @param {?} v
|
478 | * @return {?}
|
479 | */
|
480 | function (v) {
|
481 | this._restrictMove = getInputBoolean(v);
|
482 | },
|
483 | enumerable: true,
|
484 | configurable: true
|
485 | });
|
486 | Object.defineProperty(SplitComponent.prototype, "useTransition", {
|
487 | get: /**
|
488 | * @return {?}
|
489 | */
|
490 | function () {
|
491 | return this._useTransition;
|
492 | },
|
493 | set: /**
|
494 | * @param {?} v
|
495 | * @return {?}
|
496 | */
|
497 | function (v) {
|
498 | this._useTransition = getInputBoolean(v);
|
499 | if (this._useTransition)
|
500 | this.renderer.addClass(this.elRef.nativeElement, 'as-transition');
|
501 | else
|
502 | this.renderer.removeClass(this.elRef.nativeElement, 'as-transition');
|
503 | },
|
504 | enumerable: true,
|
505 | configurable: true
|
506 | });
|
507 | Object.defineProperty(SplitComponent.prototype, "disabled", {
|
508 | get: /**
|
509 | * @return {?}
|
510 | */
|
511 | function () {
|
512 | return this._disabled;
|
513 | },
|
514 | set: /**
|
515 | * @param {?} v
|
516 | * @return {?}
|
517 | */
|
518 | function (v) {
|
519 | this._disabled = getInputBoolean(v);
|
520 | if (this._disabled)
|
521 | this.renderer.addClass(this.elRef.nativeElement, 'as-disabled');
|
522 | else
|
523 | this.renderer.removeClass(this.elRef.nativeElement, 'as-disabled');
|
524 | },
|
525 | enumerable: true,
|
526 | configurable: true
|
527 | });
|
528 | Object.defineProperty(SplitComponent.prototype, "dir", {
|
529 | get: /**
|
530 | * @return {?}
|
531 | */
|
532 | function () {
|
533 | return this._dir;
|
534 | },
|
535 | set: /**
|
536 | * @param {?} v
|
537 | * @return {?}
|
538 | */
|
539 | function (v) {
|
540 | this._dir = (v === 'rtl') ? 'rtl' : 'ltr';
|
541 | this.renderer.setAttribute(this.elRef.nativeElement, 'dir', this._dir);
|
542 | },
|
543 | enumerable: true,
|
544 | configurable: true
|
545 | });
|
546 | Object.defineProperty(SplitComponent.prototype, "gutterDblClickDuration", {
|
547 | get: /**
|
548 | * @return {?}
|
549 | */
|
550 | function () {
|
551 | return this._gutterDblClickDuration;
|
552 | },
|
553 | set: /**
|
554 | * @param {?} v
|
555 | * @return {?}
|
556 | */
|
557 | function (v) {
|
558 | this._gutterDblClickDuration = getInputPositiveNumber(v, 0);
|
559 | },
|
560 | enumerable: true,
|
561 | configurable: true
|
562 | });
|
563 | Object.defineProperty(SplitComponent.prototype, "transitionEnd", {
|
564 | get: /**
|
565 | * @return {?}
|
566 | */
|
567 | function () {
|
568 | var _this = this;
|
569 | return new Observable(( |
570 |
|
571 |
|
572 |
|
573 | function (subscriber) { return _this.transitionEndSubscriber = subscriber; })).pipe(debounceTime(20));
|
574 | },
|
575 | enumerable: true,
|
576 | configurable: true
|
577 | });
|
578 | |
579 |
|
580 |
|
581 | SplitComponent.prototype.ngAfterViewInit = |
582 |
|
583 |
|
584 | function () {
|
585 | var _this = this;
|
586 | this.ngZone.runOutsideAngular(( |
587 |
|
588 |
|
589 | function () {
|
590 |
|
591 | setTimeout(( |
592 |
|
593 |
|
594 | function () { return _this.renderer.addClass(_this.elRef.nativeElement, 'as-init'); }));
|
595 | }));
|
596 | };
|
597 | |
598 |
|
599 |
|
600 |
|
601 | SplitComponent.prototype.getNbGutters = |
602 |
|
603 |
|
604 |
|
605 | function () {
|
606 | return (this.displayedAreas.length === 0) ? 0 : this.displayedAreas.length - 1;
|
607 | };
|
608 | |
609 |
|
610 |
|
611 |
|
612 | SplitComponent.prototype.addArea = |
613 |
|
614 |
|
615 |
|
616 | function (component) {
|
617 |
|
618 | var newArea = {
|
619 | component: component,
|
620 | order: 0,
|
621 | size: 0,
|
622 | minSize: null,
|
623 | maxSize: null,
|
624 | };
|
625 | if (component.visible === true) {
|
626 | this.displayedAreas.push(newArea);
|
627 | this.build(true, true);
|
628 | }
|
629 | else {
|
630 | this.hidedAreas.push(newArea);
|
631 | }
|
632 | };
|
633 | |
634 |
|
635 |
|
636 |
|
637 | SplitComponent.prototype.removeArea = |
638 |
|
639 |
|
640 |
|
641 | function (component) {
|
642 | if (this.displayedAreas.some(( |
643 |
|
644 |
|
645 |
|
646 | function (a) { return a.component === component; }))) {
|
647 |
|
648 | var area = this.displayedAreas.find(( |
649 |
|
650 |
|
651 |
|
652 | function (a) { return a.component === component; }));
|
653 | this.displayedAreas.splice(this.displayedAreas.indexOf(area), 1);
|
654 | this.build(true, true);
|
655 | }
|
656 | else if (this.hidedAreas.some(( |
657 |
|
658 |
|
659 |
|
660 | function (a) { return a.component === component; }))) {
|
661 |
|
662 | var area = this.hidedAreas.find(( |
663 |
|
664 |
|
665 |
|
666 | function (a) { return a.component === component; }));
|
667 | this.hidedAreas.splice(this.hidedAreas.indexOf(area), 1);
|
668 | }
|
669 | };
|
670 | |
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 | SplitComponent.prototype.updateArea = |
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 | function (component, resetOrders, resetSizes) {
|
683 | if (component.visible === true) {
|
684 | this.build(resetOrders, resetSizes);
|
685 | }
|
686 | };
|
687 | |
688 |
|
689 |
|
690 |
|
691 | SplitComponent.prototype.showArea = |
692 |
|
693 |
|
694 |
|
695 | function (component) {
|
696 | var _a;
|
697 |
|
698 | var area = this.hidedAreas.find(( |
699 |
|
700 |
|
701 |
|
702 | function (a) { return a.component === component; }));
|
703 | if (area === undefined) {
|
704 | return;
|
705 | }
|
706 |
|
707 | var areas = this.hidedAreas.splice(this.hidedAreas.indexOf(area), 1);
|
708 | (_a = this.displayedAreas).push.apply(_a, __spread(areas));
|
709 | this.build(true, true);
|
710 | };
|
711 | |
712 |
|
713 |
|
714 |
|
715 | SplitComponent.prototype.hideArea = |
716 |
|
717 |
|
718 |
|
719 | function (comp) {
|
720 | var _a;
|
721 |
|
722 | var area = this.displayedAreas.find(( |
723 |
|
724 |
|
725 |
|
726 | function (a) { return a.component === comp; }));
|
727 | if (area === undefined) {
|
728 | return;
|
729 | }
|
730 |
|
731 | var areas = this.displayedAreas.splice(this.displayedAreas.indexOf(area), 1);
|
732 | areas.forEach(( |
733 |
|
734 |
|
735 |
|
736 | function (area) {
|
737 | area.order = 0;
|
738 | area.size = 0;
|
739 | }));
|
740 | (_a = this.hidedAreas).push.apply(_a, __spread(areas));
|
741 | this.build(true, true);
|
742 | };
|
743 | |
744 |
|
745 |
|
746 | SplitComponent.prototype.getVisibleAreaSizes = |
747 |
|
748 |
|
749 | function () {
|
750 | return this.displayedAreas.map(( |
751 |
|
752 |
|
753 |
|
754 | function (a) { return a.size === null ? '*' : a.size; }));
|
755 | };
|
756 | |
757 |
|
758 |
|
759 |
|
760 | SplitComponent.prototype.setVisibleAreaSizes = |
761 |
|
762 |
|
763 |
|
764 | function (sizes) {
|
765 | if (sizes.length !== this.displayedAreas.length) {
|
766 | return false;
|
767 | }
|
768 |
|
769 | var formatedSizes = sizes.map(( |
770 |
|
771 |
|
772 |
|
773 | function (s) { return getInputPositiveNumber(s, null); }));
|
774 |
|
775 | var isValid = isUserSizesValid(this.unit, formatedSizes);
|
776 | if (isValid === false) {
|
777 | return false;
|
778 | }
|
779 |
|
780 | this.displayedAreas.forEach(( |
781 |
|
782 |
|
783 |
|
784 |
|
785 | function (area, i) { return area.component._size = formatedSizes[i]; }));
|
786 | this.build(false, true);
|
787 | return true;
|
788 | };
|
789 | |
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 | SplitComponent.prototype.build = |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | function (resetOrders, resetSizes) {
|
802 | this.stopDragging();
|
803 |
|
804 | if (resetOrders === true) {
|
805 |
|
806 | if (this.displayedAreas.every(( |
807 |
|
808 |
|
809 |
|
810 | function (a) { return a.component.order !== null; }))) {
|
811 | this.displayedAreas.sort(( |
812 |
|
813 |
|
814 |
|
815 |
|
816 | function (a, b) { return (( (a.component.order))) - (( (b.component.order))); }));
|
817 | }
|
818 |
|
819 | this.displayedAreas.forEach(( |
820 |
|
821 |
|
822 |
|
823 |
|
824 | function (area, i) {
|
825 | area.order = i * 2;
|
826 | area.component.setStyleOrder(area.order);
|
827 | }));
|
828 | }
|
829 |
|
830 | if (resetSizes === true) {
|
831 |
|
832 | var useUserSizes_1 = isUserSizesValid(this.unit, this.displayedAreas.map(( |
833 |
|
834 |
|
835 |
|
836 | function (a) { return a.component.size; })));
|
837 | switch (this.unit) {
|
838 | case 'percent': {
|
839 |
|
840 | var defaultSize_1 = 100 / this.displayedAreas.length;
|
841 | this.displayedAreas.forEach(( |
842 |
|
843 |
|
844 |
|
845 | function (area) {
|
846 | area.size = useUserSizes_1 ? ( (area.component.size)) : defaultSize_1;
|
847 | area.minSize = getAreaMinSize(area);
|
848 | area.maxSize = getAreaMaxSize(area);
|
849 | }));
|
850 | break;
|
851 | }
|
852 | case 'pixel': {
|
853 | if (useUserSizes_1) {
|
854 | this.displayedAreas.forEach(( |
855 |
|
856 |
|
857 |
|
858 | function (area) {
|
859 | area.size = area.component.size;
|
860 | area.minSize = getAreaMinSize(area);
|
861 | area.maxSize = getAreaMaxSize(area);
|
862 | }));
|
863 | }
|
864 | else {
|
865 |
|
866 | var wildcardSizeAreas = this.displayedAreas.filter(( |
867 |
|
868 |
|
869 |
|
870 | function (a) { return a.component.size === null; }));
|
871 |
|
872 | if (wildcardSizeAreas.length === 0 && this.displayedAreas.length > 0) {
|
873 | this.displayedAreas.forEach(( |
874 |
|
875 |
|
876 |
|
877 |
|
878 | function (area, i) {
|
879 | area.size = (i === 0) ? null : area.component.size;
|
880 | area.minSize = (i === 0) ? null : getAreaMinSize(area);
|
881 | area.maxSize = (i === 0) ? null : getAreaMaxSize(area);
|
882 | }));
|
883 | }
|
884 |
|
885 | else if (wildcardSizeAreas.length > 1) {
|
886 |
|
887 | var alreadyGotOne_1 = false;
|
888 | this.displayedAreas.forEach(( |
889 |
|
890 |
|
891 |
|
892 | function (area) {
|
893 | if (area.component.size === null) {
|
894 | if (alreadyGotOne_1 === false) {
|
895 | area.size = null;
|
896 | area.minSize = null;
|
897 | area.maxSize = null;
|
898 | alreadyGotOne_1 = true;
|
899 | }
|
900 | else {
|
901 | area.size = 100;
|
902 | area.minSize = null;
|
903 | area.maxSize = null;
|
904 | }
|
905 | }
|
906 | else {
|
907 | area.size = area.component.size;
|
908 | area.minSize = getAreaMinSize(area);
|
909 | area.maxSize = getAreaMaxSize(area);
|
910 | }
|
911 | }));
|
912 | }
|
913 | }
|
914 | break;
|
915 | }
|
916 | }
|
917 | }
|
918 | this.refreshStyleSizes();
|
919 | this.cdRef.markForCheck();
|
920 | };
|
921 | |
922 |
|
923 |
|
924 |
|
925 | SplitComponent.prototype.refreshStyleSizes = |
926 |
|
927 |
|
928 |
|
929 | function () {
|
930 | var _this = this;
|
931 |
|
932 |
|
933 | if (this.unit === 'percent') {
|
934 |
|
935 | if (this.displayedAreas.length === 1) {
|
936 | this.displayedAreas[0].component.setStyleFlex(0, 0, "100%", false, false);
|
937 | }
|
938 |
|
939 | else {
|
940 |
|
941 | var sumGutterSize_1 = this.getNbGutters() * this.gutterSize;
|
942 | this.displayedAreas.forEach(( |
943 |
|
944 |
|
945 |
|
946 | function (area) {
|
947 | area.component.setStyleFlex(0, 0, "calc( " + area.size + "% - " + ( (area.size)) / 100 * sumGutterSize_1 + "px )", (area.minSize !== null && area.minSize === area.size) ? true : false, (area.maxSize !== null && area.maxSize === area.size) ? true : false);
|
948 | }));
|
949 | }
|
950 | }
|
951 |
|
952 |
|
953 | else if (this.unit === 'pixel') {
|
954 | this.displayedAreas.forEach(( |
955 |
|
956 |
|
957 |
|
958 | function (area) {
|
959 |
|
960 | if (area.size === null) {
|
961 | if (_this.displayedAreas.length === 1) {
|
962 | area.component.setStyleFlex(1, 1, "100%", false, false);
|
963 | }
|
964 | else {
|
965 | area.component.setStyleFlex(1, 1, "auto", false, false);
|
966 | }
|
967 | }
|
968 |
|
969 | else {
|
970 |
|
971 | if (_this.displayedAreas.length === 1) {
|
972 | area.component.setStyleFlex(0, 0, "100%", false, false);
|
973 | }
|
974 |
|
975 | else {
|
976 | area.component.setStyleFlex(0, 0, area.size + "px", (area.minSize !== null && area.minSize === area.size) ? true : false, (area.maxSize !== null && area.maxSize === area.size) ? true : false);
|
977 | }
|
978 | }
|
979 | }));
|
980 | }
|
981 | };
|
982 | |
983 |
|
984 |
|
985 |
|
986 |
|
987 | SplitComponent.prototype.clickGutter = |
988 |
|
989 |
|
990 |
|
991 |
|
992 | function (event, gutterNum) {
|
993 | var _this = this;
|
994 |
|
995 | var tempPoint = getPointFromEvent(event);
|
996 |
|
997 | if (this.startPoint && this.startPoint.x === tempPoint.x && this.startPoint.y === tempPoint.y) {
|
998 |
|
999 | if (this._clickTimeout !== null) {
|
1000 | window.clearTimeout(this._clickTimeout);
|
1001 | this._clickTimeout = null;
|
1002 | this.notify('dblclick', gutterNum);
|
1003 | this.stopDragging();
|
1004 | }
|
1005 |
|
1006 | else {
|
1007 | this._clickTimeout = window.setTimeout(( |
1008 |
|
1009 |
|
1010 | function () {
|
1011 | _this._clickTimeout = null;
|
1012 | _this.notify('click', gutterNum);
|
1013 | _this.stopDragging();
|
1014 | }), this.gutterDblClickDuration);
|
1015 | }
|
1016 | }
|
1017 | };
|
1018 | |
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 | SplitComponent.prototype.startDragging = |
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 | function (event, gutterOrder, gutterNum) {
|
1031 | var _this = this;
|
1032 | event.preventDefault();
|
1033 | event.stopPropagation();
|
1034 | this.startPoint = getPointFromEvent(event);
|
1035 | if (this.startPoint === null || this.disabled === true) {
|
1036 | return;
|
1037 | }
|
1038 | this.snapshot = {
|
1039 | gutterNum: gutterNum,
|
1040 | lastSteppedOffset: 0,
|
1041 | allAreasSizePixel: getElementPixelSize(this.elRef, this.direction) - this.getNbGutters() * this.gutterSize,
|
1042 | allInvolvedAreasSizePercent: 100,
|
1043 | areasBeforeGutter: [],
|
1044 | areasAfterGutter: [],
|
1045 | };
|
1046 | this.displayedAreas.forEach(( |
1047 |
|
1048 |
|
1049 |
|
1050 | function (area) {
|
1051 |
|
1052 | var areaSnapshot = {
|
1053 | area: area,
|
1054 | sizePixelAtStart: getElementPixelSize(area.component.elRef, _this.direction),
|
1055 | sizePercentAtStart: (_this.unit === 'percent') ? area.size : -1
|
1056 | };
|
1057 | if (area.order < gutterOrder) {
|
1058 | if (_this.restrictMove === true) {
|
1059 | _this.snapshot.areasBeforeGutter = [areaSnapshot];
|
1060 | }
|
1061 | else {
|
1062 | _this.snapshot.areasBeforeGutter.unshift(areaSnapshot);
|
1063 | }
|
1064 | }
|
1065 | else if (area.order > gutterOrder) {
|
1066 | if (_this.restrictMove === true) {
|
1067 | if (_this.snapshot.areasAfterGutter.length === 0)
|
1068 | _this.snapshot.areasAfterGutter = [areaSnapshot];
|
1069 | }
|
1070 | else {
|
1071 | _this.snapshot.areasAfterGutter.push(areaSnapshot);
|
1072 | }
|
1073 | }
|
1074 | }));
|
1075 | this.snapshot.allInvolvedAreasSizePercent = __spread(this.snapshot.areasBeforeGutter, this.snapshot.areasAfterGutter).reduce(( |
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 | function (t, a) { return t + a.sizePercentAtStart; }), 0);
|
1081 | if (this.snapshot.areasBeforeGutter.length === 0 || this.snapshot.areasAfterGutter.length === 0) {
|
1082 | return;
|
1083 | }
|
1084 | this.dragListeners.push(this.renderer.listen('document', 'mouseup', this.stopDragging.bind(this)));
|
1085 | this.dragListeners.push(this.renderer.listen('document', 'touchend', this.stopDragging.bind(this)));
|
1086 | this.dragListeners.push(this.renderer.listen('document', 'touchcancel', this.stopDragging.bind(this)));
|
1087 | this.ngZone.runOutsideAngular(( |
1088 |
|
1089 |
|
1090 | function () {
|
1091 | _this.dragListeners.push(_this.renderer.listen('document', 'mousemove', _this.dragEvent.bind(_this)));
|
1092 | _this.dragListeners.push(_this.renderer.listen('document', 'touchmove', _this.dragEvent.bind(_this)));
|
1093 | }));
|
1094 | this.displayedAreas.forEach(( |
1095 |
|
1096 |
|
1097 |
|
1098 | function (area) { return area.component.lockEvents(); }));
|
1099 | this.isDragging = true;
|
1100 | this.renderer.addClass(this.elRef.nativeElement, 'as-dragging');
|
1101 | this.renderer.addClass(this.gutterEls.toArray()[this.snapshot.gutterNum - 1].nativeElement, 'as-dragged');
|
1102 | this.notify('start', this.snapshot.gutterNum);
|
1103 | };
|
1104 | |
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 | SplitComponent.prototype.dragEvent = |
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 | function (event) {
|
1115 | var _this = this;
|
1116 | event.preventDefault();
|
1117 | event.stopPropagation();
|
1118 | if (this._clickTimeout !== null) {
|
1119 | window.clearTimeout(this._clickTimeout);
|
1120 | this._clickTimeout = null;
|
1121 | }
|
1122 | if (this.isDragging === false) {
|
1123 | return;
|
1124 | }
|
1125 | this.endPoint = getPointFromEvent(event);
|
1126 | if (this.endPoint === null) {
|
1127 | return;
|
1128 | }
|
1129 |
|
1130 |
|
1131 | var offset = (this.direction === 'horizontal') ? (this.startPoint.x - this.endPoint.x) : (this.startPoint.y - this.endPoint.y);
|
1132 | if (this.dir === 'rtl') {
|
1133 | offset = -offset;
|
1134 | }
|
1135 |
|
1136 | var steppedOffset = Math.round(offset / this.gutterStep) * this.gutterStep;
|
1137 | if (steppedOffset === this.snapshot.lastSteppedOffset) {
|
1138 | return;
|
1139 | }
|
1140 | this.snapshot.lastSteppedOffset = steppedOffset;
|
1141 |
|
1142 |
|
1143 | var areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -steppedOffset, this.snapshot.allAreasSizePixel);
|
1144 |
|
1145 | var areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset, this.snapshot.allAreasSizePixel);
|
1146 |
|
1147 | if (areasBefore.remain !== 0 && areasAfter.remain !== 0) {
|
1148 | if (Math.abs(areasBefore.remain) === Math.abs(areasAfter.remain)) ;
|
1149 | else if (Math.abs(areasBefore.remain) > Math.abs(areasAfter.remain)) {
|
1150 | areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset + areasBefore.remain, this.snapshot.allAreasSizePixel);
|
1151 | }
|
1152 | else {
|
1153 | areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -(steppedOffset - areasAfter.remain), this.snapshot.allAreasSizePixel);
|
1154 | }
|
1155 | }
|
1156 |
|
1157 | else if (areasBefore.remain !== 0) {
|
1158 | areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset + areasBefore.remain, this.snapshot.allAreasSizePixel);
|
1159 | }
|
1160 |
|
1161 | else if (areasAfter.remain !== 0) {
|
1162 | areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -(steppedOffset - areasAfter.remain), this.snapshot.allAreasSizePixel);
|
1163 | }
|
1164 | if (this.unit === 'percent') {
|
1165 |
|
1166 |
|
1167 |
|
1168 | var all = __spread(areasBefore.list, areasAfter.list);
|
1169 |
|
1170 | var areaToReset_1 = all.find(( |
1171 |
|
1172 |
|
1173 |
|
1174 | function (a) { return a.percentAfterAbsorption !== 0 && a.percentAfterAbsorption !== a.areaSnapshot.area.minSize && a.percentAfterAbsorption !== a.areaSnapshot.area.maxSize; }));
|
1175 | if (areaToReset_1) {
|
1176 | areaToReset_1.percentAfterAbsorption = this.snapshot.allInvolvedAreasSizePercent - all.filter(( |
1177 |
|
1178 |
|
1179 |
|
1180 | function (a) { return a !== areaToReset_1; })).reduce(( |
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 | function (total, a) { return total + a.percentAfterAbsorption; }), 0);
|
1186 | }
|
1187 | }
|
1188 |
|
1189 | areasBefore.list.forEach(( |
1190 |
|
1191 |
|
1192 |
|
1193 | function (item) { return updateAreaSize(_this.unit, item); }));
|
1194 | areasAfter.list.forEach(( |
1195 |
|
1196 |
|
1197 |
|
1198 | function (item) { return updateAreaSize(_this.unit, item); }));
|
1199 | this.refreshStyleSizes();
|
1200 | this.notify('progress', this.snapshot.gutterNum);
|
1201 | };
|
1202 | |
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 | SplitComponent.prototype.stopDragging = |
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 | function (event) {
|
1213 | var _this = this;
|
1214 | if (event) {
|
1215 | event.preventDefault();
|
1216 | event.stopPropagation();
|
1217 | }
|
1218 | if (this.isDragging === false) {
|
1219 | return;
|
1220 | }
|
1221 | this.displayedAreas.forEach(( |
1222 |
|
1223 |
|
1224 |
|
1225 | function (area) { return area.component.unlockEvents(); }));
|
1226 | while (this.dragListeners.length > 0) {
|
1227 |
|
1228 | var fct = this.dragListeners.pop();
|
1229 | if (fct)
|
1230 | fct();
|
1231 | }
|
1232 |
|
1233 |
|
1234 | this.isDragging = false;
|
1235 |
|
1236 | if (this.endPoint && (this.startPoint.x !== this.endPoint.x || this.startPoint.y !== this.endPoint.y)) {
|
1237 | this.notify('end', this.snapshot.gutterNum);
|
1238 | }
|
1239 | this.renderer.removeClass(this.elRef.nativeElement, 'as-dragging');
|
1240 | this.renderer.removeClass(this.gutterEls.toArray()[this.snapshot.gutterNum - 1].nativeElement, 'as-dragged');
|
1241 | this.snapshot = null;
|
1242 |
|
1243 | this.ngZone.runOutsideAngular(( |
1244 |
|
1245 |
|
1246 | function () {
|
1247 | setTimeout(( |
1248 |
|
1249 |
|
1250 | function () {
|
1251 | _this.startPoint = null;
|
1252 | _this.endPoint = null;
|
1253 | }));
|
1254 | }));
|
1255 | };
|
1256 | |
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 | SplitComponent.prototype.notify = |
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 | function (type, gutterNum) {
|
1267 | var _this = this;
|
1268 |
|
1269 | var sizes = this.getVisibleAreaSizes();
|
1270 | if (type === 'start') {
|
1271 | this.dragStart.emit({ gutterNum: gutterNum, sizes: sizes });
|
1272 | }
|
1273 | else if (type === 'end') {
|
1274 | this.dragEnd.emit({ gutterNum: gutterNum, sizes: sizes });
|
1275 | }
|
1276 | else if (type === 'click') {
|
1277 | this.gutterClick.emit({ gutterNum: gutterNum, sizes: sizes });
|
1278 | }
|
1279 | else if (type === 'dblclick') {
|
1280 | this.gutterDblClick.emit({ gutterNum: gutterNum, sizes: sizes });
|
1281 | }
|
1282 | else if (type === 'transitionEnd') {
|
1283 | if (this.transitionEndSubscriber) {
|
1284 | this.ngZone.run(( |
1285 |
|
1286 |
|
1287 | function () { return _this.transitionEndSubscriber.next(sizes); }));
|
1288 | }
|
1289 | }
|
1290 | else if (type === 'progress') {
|
1291 |
|
1292 | this.dragProgressSubject.next({ gutterNum: gutterNum, sizes: sizes });
|
1293 | }
|
1294 | };
|
1295 | |
1296 |
|
1297 |
|
1298 | SplitComponent.prototype.ngOnDestroy = |
1299 |
|
1300 |
|
1301 | function () {
|
1302 | this.stopDragging();
|
1303 | };
|
1304 | SplitComponent.decorators = [
|
1305 | { type: Component, args: [{
|
1306 | selector: 'as-split',
|
1307 | exportAs: 'asSplit',
|
1308 | changeDetection: ChangeDetectionStrategy.OnPush,
|
1309 | template: "\n <ng-content></ng-content>\n <ng-template ngFor [ngForOf]=\"displayedAreas\" let-index=\"index\" let-last=\"last\">\n <div *ngIf=\"last === false\" \n #gutterEls\n class=\"as-split-gutter\"\n [style.flex-basis.px]=\"gutterSize\"\n [style.order]=\"index*2+1\"\n (mousedown)=\"startDragging($event, index*2+1, index+1)\"\n (touchstart)=\"startDragging($event, index*2+1, index+1)\"\n (mouseup)=\"clickGutter($event, index+1)\"\n (touchend)=\"clickGutter($event, index+1)\">\n <div class=\"as-split-gutter-icon\"></div>\n </div>\n </ng-template>",
|
1310 | styles: [":host{display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:stretch;overflow:hidden;width:100%;height:100%}:host>.as-split-gutter{flex-grow:0;flex-shrink:0;background-color:#eee;display:flex;align-items:center;justify-content:center}:host>.as-split-gutter>.as-split-gutter-icon{width:100%;height:100%;background-position:center center;background-repeat:no-repeat}:host ::ng-deep>.as-split-area{flex-grow:0;flex-shrink:0;overflow-x:hidden;overflow-y:auto}:host ::ng-deep>.as-split-area.as-hidden{flex:0 1 0!important;overflow-x:hidden;overflow-y:hidden}:host.as-horizontal{flex-direction:row}:host.as-horizontal>.as-split-gutter{flex-direction:row;cursor:col-resize;height:100%}:host.as-horizontal>.as-split-gutter>.as-split-gutter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==)}:host.as-horizontal ::ng-deep>.as-split-area{height:100%}:host.as-vertical{flex-direction:column}:host.as-vertical>.as-split-gutter{flex-direction:column;cursor:row-resize;width:100%}:host.as-vertical>.as-split-gutter .as-split-gutter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFCAMAAABl/6zIAAAABlBMVEUAAADMzMzIT8AyAAAAAXRSTlMAQObYZgAAABRJREFUeAFjYGRkwIMJSeMHlBkOABP7AEGzSuPKAAAAAElFTkSuQmCC)}:host.as-vertical ::ng-deep>.as-split-area{width:100%}:host.as-vertical ::ng-deep>.as-split-area.as-hidden{max-width:0}:host.as-disabled>.as-split-gutter{cursor:default}:host.as-disabled>.as-split-gutter .as-split-gutter-icon{background-image:url(\"\")}:host.as-transition.as-init:not(.as-dragging) ::ng-deep>.as-split-area,:host.as-transition.as-init:not(.as-dragging)>.as-split-gutter{transition:flex-basis .3s}"]
|
1311 | }] }
|
1312 | ];
|
1313 |
|
1314 | SplitComponent.ctorParameters = function () { return [
|
1315 | { type: NgZone },
|
1316 | { type: ElementRef },
|
1317 | { type: ChangeDetectorRef },
|
1318 | { type: Renderer2 }
|
1319 | ]; };
|
1320 | SplitComponent.propDecorators = {
|
1321 | direction: [{ type: Input }],
|
1322 | unit: [{ type: Input }],
|
1323 | gutterSize: [{ type: Input }],
|
1324 | gutterStep: [{ type: Input }],
|
1325 | restrictMove: [{ type: Input }],
|
1326 | useTransition: [{ type: Input }],
|
1327 | disabled: [{ type: Input }],
|
1328 | dir: [{ type: Input }],
|
1329 | gutterDblClickDuration: [{ type: Input }],
|
1330 | dragStart: [{ type: Output }],
|
1331 | dragEnd: [{ type: Output }],
|
1332 | gutterClick: [{ type: Output }],
|
1333 | gutterDblClick: [{ type: Output }],
|
1334 | transitionEnd: [{ type: Output }],
|
1335 | gutterEls: [{ type: ViewChildren, args: ['gutterEls',] }]
|
1336 | };
|
1337 | return SplitComponent;
|
1338 | }());
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 | var SplitAreaDirective = (function () {
|
1345 | function SplitAreaDirective(ngZone, elRef, renderer, split) {
|
1346 | this.ngZone = ngZone;
|
1347 | this.elRef = elRef;
|
1348 | this.renderer = renderer;
|
1349 | this.split = split;
|
1350 | this._order = null;
|
1351 |
|
1352 | this._size = null;
|
1353 |
|
1354 | this._minSize = null;
|
1355 |
|
1356 | this._maxSize = null;
|
1357 |
|
1358 | this._lockSize = false;
|
1359 |
|
1360 | this._visible = true;
|
1361 | this.lockListeners = [];
|
1362 | this.renderer.addClass(this.elRef.nativeElement, 'as-split-area');
|
1363 | }
|
1364 | Object.defineProperty(SplitAreaDirective.prototype, "order", {
|
1365 | get: /**
|
1366 | * @return {?}
|
1367 | */
|
1368 | function () {
|
1369 | return this._order;
|
1370 | },
|
1371 | set: /**
|
1372 | * @param {?} v
|
1373 | * @return {?}
|
1374 | */
|
1375 | function (v) {
|
1376 | this._order = getInputPositiveNumber(v, null);
|
1377 | this.split.updateArea(this, true, false);
|
1378 | },
|
1379 | enumerable: true,
|
1380 | configurable: true
|
1381 | });
|
1382 | Object.defineProperty(SplitAreaDirective.prototype, "size", {
|
1383 | get: /**
|
1384 | * @return {?}
|
1385 | */
|
1386 | function () {
|
1387 | return this._size;
|
1388 | },
|
1389 | set: /**
|
1390 | * @param {?} v
|
1391 | * @return {?}
|
1392 | */
|
1393 | function (v) {
|
1394 | this._size = getInputPositiveNumber(v, null);
|
1395 | this.split.updateArea(this, false, true);
|
1396 | },
|
1397 | enumerable: true,
|
1398 | configurable: true
|
1399 | });
|
1400 | Object.defineProperty(SplitAreaDirective.prototype, "minSize", {
|
1401 | get: /**
|
1402 | * @return {?}
|
1403 | */
|
1404 | function () {
|
1405 | return this._minSize;
|
1406 | },
|
1407 | set: /**
|
1408 | * @param {?} v
|
1409 | * @return {?}
|
1410 | */
|
1411 | function (v) {
|
1412 | this._minSize = getInputPositiveNumber(v, null);
|
1413 | this.split.updateArea(this, false, true);
|
1414 | },
|
1415 | enumerable: true,
|
1416 | configurable: true
|
1417 | });
|
1418 | Object.defineProperty(SplitAreaDirective.prototype, "maxSize", {
|
1419 | get: /**
|
1420 | * @return {?}
|
1421 | */
|
1422 | function () {
|
1423 | return this._maxSize;
|
1424 | },
|
1425 | set: /**
|
1426 | * @param {?} v
|
1427 | * @return {?}
|
1428 | */
|
1429 | function (v) {
|
1430 | this._maxSize = getInputPositiveNumber(v, null);
|
1431 | this.split.updateArea(this, false, true);
|
1432 | },
|
1433 | enumerable: true,
|
1434 | configurable: true
|
1435 | });
|
1436 | Object.defineProperty(SplitAreaDirective.prototype, "lockSize", {
|
1437 | get: /**
|
1438 | * @return {?}
|
1439 | */
|
1440 | function () {
|
1441 | return this._lockSize;
|
1442 | },
|
1443 | set: /**
|
1444 | * @param {?} v
|
1445 | * @return {?}
|
1446 | */
|
1447 | function (v) {
|
1448 | this._lockSize = getInputBoolean(v);
|
1449 | this.split.updateArea(this, false, true);
|
1450 | },
|
1451 | enumerable: true,
|
1452 | configurable: true
|
1453 | });
|
1454 | Object.defineProperty(SplitAreaDirective.prototype, "visible", {
|
1455 | get: /**
|
1456 | * @return {?}
|
1457 | */
|
1458 | function () {
|
1459 | return this._visible;
|
1460 | },
|
1461 | set: /**
|
1462 | * @param {?} v
|
1463 | * @return {?}
|
1464 | */
|
1465 | function (v) {
|
1466 | this._visible = getInputBoolean(v);
|
1467 | if (this._visible) {
|
1468 | this.split.showArea(this);
|
1469 | this.renderer.removeClass(this.elRef.nativeElement, 'as-hidden');
|
1470 | }
|
1471 | else {
|
1472 | this.split.hideArea(this);
|
1473 | this.renderer.addClass(this.elRef.nativeElement, 'as-hidden');
|
1474 | }
|
1475 | },
|
1476 | enumerable: true,
|
1477 | configurable: true
|
1478 | });
|
1479 | |
1480 |
|
1481 |
|
1482 | SplitAreaDirective.prototype.ngOnInit = |
1483 |
|
1484 |
|
1485 | function () {
|
1486 | var _this = this;
|
1487 | this.split.addArea(this);
|
1488 | this.ngZone.runOutsideAngular(( |
1489 |
|
1490 |
|
1491 | function () {
|
1492 | _this.transitionListener = _this.renderer.listen(_this.elRef.nativeElement, 'transitionend', ( |
1493 |
|
1494 |
|
1495 |
|
1496 | function (event) {
|
1497 |
|
1498 | if (event.propertyName === 'flex-basis') {
|
1499 | _this.split.notify('transitionEnd', -1);
|
1500 | }
|
1501 | }));
|
1502 | }));
|
1503 | };
|
1504 | |
1505 |
|
1506 |
|
1507 |
|
1508 | SplitAreaDirective.prototype.setStyleOrder = |
1509 |
|
1510 |
|
1511 |
|
1512 | function (value) {
|
1513 | this.renderer.setStyle(this.elRef.nativeElement, 'order', value);
|
1514 | };
|
1515 | |
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 | SplitAreaDirective.prototype.setStyleFlex = |
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 | function (grow, shrink, basis, isMin, isMax) {
|
1532 |
|
1533 | this.renderer.setStyle(this.elRef.nativeElement, 'flex-grow', grow);
|
1534 | this.renderer.setStyle(this.elRef.nativeElement, 'flex-shrink', shrink);
|
1535 | this.renderer.setStyle(this.elRef.nativeElement, 'flex-basis', basis);
|
1536 | if (isMin === true)
|
1537 | this.renderer.addClass(this.elRef.nativeElement, 'as-min');
|
1538 | else
|
1539 | this.renderer.removeClass(this.elRef.nativeElement, 'as-min');
|
1540 | if (isMax === true)
|
1541 | this.renderer.addClass(this.elRef.nativeElement, 'as-max');
|
1542 | else
|
1543 | this.renderer.removeClass(this.elRef.nativeElement, 'as-max');
|
1544 | };
|
1545 | |
1546 |
|
1547 |
|
1548 | SplitAreaDirective.prototype.lockEvents = |
1549 |
|
1550 |
|
1551 | function () {
|
1552 | var _this = this;
|
1553 | this.ngZone.runOutsideAngular(( |
1554 |
|
1555 |
|
1556 | function () {
|
1557 | _this.lockListeners.push(_this.renderer.listen(_this.elRef.nativeElement, 'selectstart', ( |
1558 |
|
1559 |
|
1560 |
|
1561 | function (e) { return false; })));
|
1562 | _this.lockListeners.push(_this.renderer.listen(_this.elRef.nativeElement, 'dragstart', ( |
1563 |
|
1564 |
|
1565 |
|
1566 | function (e) { return false; })));
|
1567 | }));
|
1568 | };
|
1569 | |
1570 |
|
1571 |
|
1572 | SplitAreaDirective.prototype.unlockEvents = |
1573 |
|
1574 |
|
1575 | function () {
|
1576 | while (this.lockListeners.length > 0) {
|
1577 |
|
1578 | var fct = this.lockListeners.pop();
|
1579 | if (fct)
|
1580 | fct();
|
1581 | }
|
1582 | };
|
1583 | |
1584 |
|
1585 |
|
1586 | SplitAreaDirective.prototype.ngOnDestroy = |
1587 |
|
1588 |
|
1589 | function () {
|
1590 | this.unlockEvents();
|
1591 | if (this.transitionListener) {
|
1592 | this.transitionListener();
|
1593 | }
|
1594 | this.split.removeArea(this);
|
1595 | };
|
1596 | SplitAreaDirective.decorators = [
|
1597 | { type: Directive, args: [{
|
1598 | selector: 'as-split-area, [as-split-area]',
|
1599 | exportAs: 'asSplitArea'
|
1600 | },] }
|
1601 | ];
|
1602 |
|
1603 | SplitAreaDirective.ctorParameters = function () { return [
|
1604 | { type: NgZone },
|
1605 | { type: ElementRef },
|
1606 | { type: Renderer2 },
|
1607 | { type: SplitComponent }
|
1608 | ]; };
|
1609 | SplitAreaDirective.propDecorators = {
|
1610 | order: [{ type: Input }],
|
1611 | size: [{ type: Input }],
|
1612 | minSize: [{ type: Input }],
|
1613 | maxSize: [{ type: Input }],
|
1614 | lockSize: [{ type: Input }],
|
1615 | visible: [{ type: Input }]
|
1616 | };
|
1617 | return SplitAreaDirective;
|
1618 | }());
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 | var AngularSplitModule = (function () {
|
1625 | function AngularSplitModule() {
|
1626 | }
|
1627 | |
1628 |
|
1629 |
|
1630 | AngularSplitModule.forRoot = |
1631 |
|
1632 |
|
1633 | function () {
|
1634 | return {
|
1635 | ngModule: AngularSplitModule,
|
1636 | providers: []
|
1637 | };
|
1638 | };
|
1639 | |
1640 |
|
1641 |
|
1642 | AngularSplitModule.forChild = |
1643 |
|
1644 |
|
1645 | function () {
|
1646 | return {
|
1647 | ngModule: AngularSplitModule,
|
1648 | providers: []
|
1649 | };
|
1650 | };
|
1651 | AngularSplitModule.decorators = [
|
1652 | { type: NgModule, args: [{
|
1653 | imports: [
|
1654 | CommonModule
|
1655 | ],
|
1656 | declarations: [
|
1657 | SplitComponent,
|
1658 | SplitAreaDirective,
|
1659 | ],
|
1660 | exports: [
|
1661 | SplitComponent,
|
1662 | SplitAreaDirective,
|
1663 | ]
|
1664 | },] }
|
1665 | ];
|
1666 | return AngularSplitModule;
|
1667 | }());
|
1668 |
|
1669 | export { AngularSplitModule, SplitAreaDirective, SplitComponent };
|
1670 |
|