let arrTopNode = [];    
export default {
    getDialogZIndex() {
        window.dialogZIndex = window.dialogZIndex || 1001;
        return ++window.dialogZIndex;
    },
    getModalZIndex() {
        window.modalZIndex = window.modalZIndex || 1101;
        return ++window.modalZIndex;
    },
    getToolTipIndex() {
        window.toolTipZIndex = window.toolTipZIndex || 3001;
        return ++window.toolTipZIndex;
    },
    getLoadingIndex(){
        window.loadingZIndex = window.loadingZIndex || 2000;
        return ++window.loadingZIndex;
    },
    getTopIndex(){
        window.topZIndex = window.topZIndex || 999999
        return ++window.topZIndex;
    },
    
    getGlobalZIndex() {
        window.globalZIndex = window.globalZIndex || 10001;   
        this.updateTopNode();
        return ++window.globalZIndex;
    },
    
    updateTopNode() {
        let topIndex = window.dialogZIndex + 11;
        arrTopNode.forEach((node) => {
            node.style.zIndex = topIndex;
        });
    },
    
    addTopNode(newNode) {
        if(arrTopNode.indexOf(newNode) === -1){
            arrTopNode.push(newNode);
        }
        this.updateTopNode();
    },
    
    removeTopNode(newNode){
        arrTopNode.forEach((node, index) => {
            if(newNode === node){
                arrTopNode.splice(index, 1);
                return false;
            }
        });
        this.updateTopNode();
    }
}