all files / core/services/ vg-utils.ts

100% Statements 21/21
75% Branches 6/8
100% Functions 5/5
100% Lines 20/20
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 43 44 45 46 47 48 49 50 51                   46×   46×                 15×                          
import {Injectable} from '@angular/core';
 
 
export class VgUtils {
    /**
     * Inspired by Paul Irish
     * https://gist.github.com/paulirish/211209
     * @returns {number}
     */
    static getZIndex():number {
        let zIndex = 1;
        let elementZIndex:number;
 
        let tags = document.getElementsByTagName('*');
 
        for (let i = 0, l = tags.length; i < l; i++) {
            elementZIndex = parseInt(window.getComputedStyle(tags[i])["z-index"], 10);
 
            if (elementZIndex > zIndex) {
                zIndex = elementZIndex + 1;
            }
        }
 
        return zIndex;
    }
 
    // Very simple mobile detection, not 100% reliable
    static isMobileDevice() {
        return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf("IEMobile") !== -1);
    };
 
    static isiOSDevice() {
        return (navigator.userAgent.match(/ip(hone|ad|od)/i) && !navigator.userAgent.match(/(iemobile)[\/\s]?([\w\.]*)/i));
    };
 
    static isCordova() {
        return document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1;
    };
static decorators: DecoratorInvocation[] = [
{ type: Injectable },
];
/** @nocollapse */
static ctorParameters: ({type: any, decorators?: DecoratorInvocation[]}|null)[] = [
];
}
 
interface DecoratorInvocation {
  type: Function;
  args?: any[];
}