all files / common/core/overlay/ connection-position-pair.ts

94.44% Statements 17/18
50% Branches 1/2
100% Functions 5/5
93.75% Lines 15/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                  124× 124× 124× 355× 355×       355×         355×         355×     124×     77×      
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
 
import { ConnectionPositionPair, OriginConnectionPosition, OverlayConnectionPosition } from '@angular/cdk/overlay';
 
export class DejaConnectionPositionPair extends ConnectionPositionPair {
    public static parse(value: string): ConnectionPositionPair[] {
        const values = value.trim().split(',');
        const positions = [] as ConnectionPositionPair[];
        values.forEach(pos => {
            const poss = pos.trim().split(' ');
            Iif (poss.length !== 4) {
                throw new Error(`Invalid positions property for DejaMenuComponent. String entry must be of type 'positions="start top end bottom"'`);
            }
 
            const originPosition = {
                originX: poss[0],
                originY: poss[1],
            } as OriginConnectionPosition;
 
            const overlayPosition = {
                overlayX: poss[2],
                overlayY: poss[3],
            } as OverlayConnectionPosition;
 
            positions.push(new DejaConnectionPositionPair(originPosition, overlayPosition));
        });
 
        return positions;
    }
 
    public static get default() {
        return DejaConnectionPositionPair.parse('start bottom start top,start top start bottom,end bottom end top,end top end bottom');
    }
}