/*
 * 特别声明：本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》等法律、法规、行政
 * 规章以及有关国际条约的保护，赞同科技享有知识产权、保留一切权利并视其为技术秘密。未经本公司书
 * 面许可，任何人不得擅自（包括但不限于：以非法的方式复制、传播、展示、镜像、上载、下载）使用，
 * 不得向第三方泄露、透露、披露。否则，本公司将依法追究侵权者的法律责任。特此声明！
 *
 * Special Declaration: These technical material reserved as the technical secrets by AGREE 
 * TECHNOLOGY have been protected by the "Copyright Law" "ordinances on Protection of Computer 
 * Software" and other relevant administrative regulations and international treaties. Without 
 * the written permission of the Company, no person may use (including but not limited to the 
 * illegal copy, distribute, display, image, upload, and download) and disclose the above 
 * technical documents to any third party. Otherwise, any infringer shall afford the legal 
 * liability to the company.
 */
import {Widget} from "widget/Widget";
import {Composite} from "widget/Composite";
import {ADORE} from "ADORE";
import {EventHub} from "event/EventHub";
import {MessageType} from "event/MessageType";
import {Event} from "event/Event";

export class DrawerMenu extends Widget {
    private static Template = `<ul class='dropdown-content adore_drawerMenu adore-hidden-scrollbar'></ul>`;
    private contentOne: any;
    private contentTwo: any;
    private contentThree: any;
    private contentFour: any;

    constructor(parentId: string, id: string, style: number) {
        super(parentId, id, style);
        this.$thisNode = $(DrawerMenu.Template).attr("id", this.id);
        this.contentOne = new Array();
        this.contentTwo = new Array();
        this.contentThree = new Array();
        this.contentFour = new Array();
    }

    /*args: { degree:string, text: string [], parentId: string}*/
    public setContents(args: { attribute: string }) {
        let data = JSON.parse(args.attribute);
        for (let key in data) {
            var cutKey: any;
            var location: any;
            var m: number;
            var n: number;
            var k: number;
            var h: number;
            var belongTo = key.length - key.replace(/,/g, "").length;
            switch (belongTo) {
                       case 0:
                            this.contentOne[parseInt(key)] = data[key];
                            this.contentTwo[parseInt(key)] = new Array();
                            this.contentThree[parseInt(key)] = new Array();
                            this.contentFour[parseInt(key)] = new Array();
                            break;

                        case 1:
                            cutKey = key.substr(1, key.length - 2);
                            location = cutKey.split(",");
                            m = Number(location[0]);
                            n = Number(location[1]);
                            this.contentTwo[m][n] = data[key];
                            this.contentThree[m][n] = new Array();
                            this.contentFour[m][n] = new Array();
                            break;

                        case 2:
                            cutKey = key.substr(1, key.length - 2);
                            location = cutKey.split(",");
                            var m = Number(location[0]);
                            var n = Number(location[1]);
                            var k = Number(location[2]);
                            this.contentThree[m][n][k] = data[key];
                            this.contentFour[m][n][k] = new Array();
                            break;
                            
                        case 3:
                            cutKey = key.substr(1,key.length -2);
                            location = cutKey.split(",");
                            var m = Number(location[0]);
                            var n = Number(location[1]);
                            var k = Number(location[2]);
                            var h = Number(location[3]);
                            this.contentFour[m][n][k][h] = data[key];
                            break;
                            
                        default:
                            console.log("data error");
                            break;
             }
        }
    }

    /*setIconPath(args:{iconPath:string})*/
    public setIconPaths(args: { iconPaths: string }) {
        let pathData = JSON.parse(args.iconPaths);
        //给一级目录设立icon  
        for (let key in pathData) {
            //修改路径的，避免路径错误
            let path = pathData[key];
            if(path.indexOf("file:") === 0) path=path.replace(/\\/g, "\\\\");
            this.$thisNode.find("li:eq(" + parseInt(key) + ") a i.svg_icon").css({
                "background-image": "url(" + path + ")",
                "width": "1em",
                "height": "1em"
            });
        }
    }

    public initDropdown() {
        let Index1 = 0, Index2 = 0,Index3 = 0,Index4 = 0;
        let flagTwo = false,flagThree =false, flagFour = false;
        let content = "";
        let own = this;
        let block_height:number =48;//抽屉li的高度
        let wrapperTwoNode = $("");
        let wrapperThreeNode = $("");
        let wrapperFourNode =$("");
        let drawerMenu_deg_twoNode = $("");
        let drawerMenu_deg_threeNode = $("");
        let drawerMenu_deg_fourNode = $("");
        //判断是否创建二三四级抽屉
        for (var i = 0; i < this.contentTwo.length; i++) {
            if (this.contentTwo[i].length > 0) {
                flagTwo = true;
                break;
            }
        }
        
        for (var i = 0; i < this.contentThree.length; i++) {
            for (var j = 0; j < this.contentThree[i].length; j++) {
                if (this.contentThree[i][j].length > 0) {
                    flagThree = true;
                    break;
                }
            }
            if (flagThree) {
                break;
            }
        }
                        
        for (var i = 0; i < this.contentFour.length; i++) {
            for (var j = 0; j < this.contentFour[i].length; j++) {
                for(var m=0; m<this.contentFour[i][j].length;m++){
                    if (this.contentFour[i][j].length > 0) {
                        flagFour = true;
                        break;
                    }
                }
                if(flagFour){
                    break;
                }
            }
            if (flagFour) {
                break;
            }
        }
        
        /*当重复初始化加载菜单数据时，清除节点下的所有元素,只保留最新的一次设置*/
        if(this.$thisNode.find("li").length >0){
            this.$thisNode.empty();
            $("#" + this.id + "wrapperTwo").remove();
            $("#" + this.id + "wrapperThree").remove();
            $("#" + this.id + "wrapperFour").remove();
        }
        //第一级抽屉菜单初始化
        for (let i = 0, z = this.contentOne.length; i < z; i++) {
            if (this.contentTwo[i].length > 0) {
                    this.$thisNode.append($("<li><a href='###'><i class='svg_icon'></i>" + this.contentOne[i] + "<i class='fold'></i></a></li>"));
            }
            else {
                this.$thisNode.append($("<li><a href='###'><i class='svg_icon'></i>" + this.contentOne[i] + "</a></li>"));
            }
        }   
        
        if (flagTwo) {
            wrapperTwoNode = $("<div><iframe class='myclass'></iframe><div><i class='triangle'></i><ul class='drawerMenu_deg_two dropdown-content show_drawerMenu'></ul></div></div>").attr("id", this.id + "wrapperTwo");
            wrapperTwoNode.appendTo("body");
            drawerMenu_deg_twoNode = wrapperTwoNode.find(".dropdown-content");
        }
        if (flagThree) {
            wrapperThreeNode = $("<div><iframe class='myclass'></iframe><div><i class='triangle'></i><ul class='drawerMenu_deg_three dropdown-content show_drawerMenu'></ul></div></div>").attr("id", this.id + "wrapperThree");
            wrapperThreeNode.appendTo("body");
            drawerMenu_deg_threeNode = wrapperThreeNode.find(".dropdown-content");
        }
        if(flagFour){
            wrapperFourNode = $("<div><iframe class='myclass'></iframe><div><i class='triangle'></i><ul class='drawerMenu_deg_four dropdown-content show_drawerMenu'></ul></div></div>").attr("id", this.id + "wrapperFour");
            wrapperFourNode.appendTo("body");
            drawerMenu_deg_fourNode = wrapperFourNode.find(".dropdown-content");
        }
        //第一级抽屉菜单的绑定事件      
        this.$thisNode.on("mouseenter", "li", {
            contentTwo: this.contentTwo,
            contentThree: this.contentThree
        }, function (event) {
            drawerMenu_deg_twoNode.empty();
            wrapperTwoNode.find(".myclass").hide();
            wrapperTwoNode.find(".triangle").hide();
            drawerMenu_deg_threeNode.empty();
            wrapperThreeNode.find(".myclass").hide();
            wrapperThreeNode.find(".triangle").hide();

            Index1 = own.$thisNode.find("li").index($(this));

            own.$thisNode.find("li a i.fold").css({
                "background-image": "url(images/drawer_menu/icon_normal_arrow.png)"
            });
            own.$thisNode.find("li:eq(" + Index1 + ") a i.fold").css({
                "background-image": "url(images/drawer_menu/icon_pressed_arrow.png)"
            });

            for (var i = 0, z = event.data.contentTwo[Index1].length; i < z; i++) {
                if (event.data.contentThree[Index1][i].length > 0) {
                    drawerMenu_deg_twoNode.append($("<li><a href='###'>" + event.data.contentTwo[Index1][i] + "<i class='fold'></i></a></li>"));
                }
                else {
                    drawerMenu_deg_twoNode.append($("<li><a href='###'>" + event.data.contentTwo[Index1][i] + "</a></li>"));
                }
            }
            //定位抽屉二级的位置
            if (drawerMenu_deg_twoNode.find("li").length > 0) {
                var two_height = drawerMenu_deg_twoNode.height();
                var primate_height = $(this).offset().top;
                var screen_height = $(window).height();
                var aa = screen_height-primate_height-block_height;
                
                if(two_height + primate_height >=screen_height){
                    drawerMenu_deg_twoNode.css({
                        "bottom":aa,
                        "display": "block",
                        "left": $(this).parent().outerWidth() + $(this).parent().offset().left+12,
                        "top":"auto"
                    });
                    drawerMenu_deg_twoNode.css({
                        "max-height": near(screen_height-aa)
                    });
                    wrapperTwoNode.find(".myclass").css({
                        "width": drawerMenu_deg_twoNode.width(),
                        "height": drawerMenu_deg_twoNode.height(),
                        "left": drawerMenu_deg_twoNode.css("left"),
                        "bottom" : drawerMenu_deg_twoNode.css("bottom"),
                        "display": "block",
                        "top" : "auto"
                    });
                     wrapperTwoNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_twoNode.css("left"))-8,
                        "bottom":parseInt(drawerMenu_deg_twoNode.css("bottom"))+24,
                        "display":"block",
                        "top" : "auto"
                     });
                }
                else{
                    drawerMenu_deg_twoNode.css({
                        "top": primate_height,
                        "display": "block",
                        "left": $(this).parent().outerWidth() + $(this).parent().offset().left+12,
                        "bottom":"auto"                 
                    });
                    drawerMenu_deg_twoNode.css({
                        "max-height": near($(window).height()-$(this).offset().top)
                    });
                    wrapperTwoNode.find(".myclass").css({
                        "width": drawerMenu_deg_twoNode.width(),
                        "height": drawerMenu_deg_twoNode.height(),
                        "left": drawerMenu_deg_twoNode.css("left"),
                        "top" : drawerMenu_deg_twoNode.css("top"),
                        "display": "block",
                        "bottom":"auto"
                    });
                    wrapperTwoNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_twoNode.css("left"))-8,
                        "top":parseInt(drawerMenu_deg_twoNode.css("top"))+24,
                        "display":"block",
                        "bottom":"auto"
                     });
                }
            }
        });
        
        this.$thisNode.on("mouseleave", "li", function (event) {
            var x = event.clientX;
            var y = event.clientY;
            if (drawerMenu_deg_twoNode.offset()) {
                var borderX = drawerMenu_deg_twoNode.offset().left + drawerMenu_deg_twoNode.width();
                var borderY = drawerMenu_deg_twoNode.offset().top + drawerMenu_deg_twoNode.height();
                if ((x >= drawerMenu_deg_twoNode.offset().left-18) && (x <= borderX) && (y >= drawerMenu_deg_twoNode.offset().top+10) && (y <= borderY)) {
                    drawerMenu_deg_twoNode.show();
                    wrapperTwoNode.find(".myclass").show();
                }
                else {
                    $("#" + own.id + " li ").removeClass("block_fontcolor");
                    cleanBlock();
                }
            }
        });
        
        this.$thisNode.on("click", "li", function (event) {
                    var apple = $("#" + own.id + " li").index($(this));
                    content = "" + apple;
                    //传递一级节点信息
                    EventHub.dispatchEvent(MessageType.WIDGET, {
                        id: own.id,
                        degree: "1",
                        location: content,
                        evtType: Event.CLICK
                    });
        });

        //第二级抽屉菜单的绑定事件
        drawerMenu_deg_twoNode.on("mouseenter", "li", {
            contentThree : this.contentThree,
            contentFour : this.contentFour
        }, function (event) {
            drawerMenu_deg_threeNode.empty();
            wrapperThreeNode.find(".myclass").hide();
            wrapperThreeNode.find(".triangle").hide();
            drawerMenu_deg_fourNode.empty();
            wrapperFourNode.find(".myclass").hide();
            wrapperFourNode.find(".triangle").hide();

            Index2 = drawerMenu_deg_twoNode.find("li").index($(this));

            drawerMenu_deg_twoNode.find(".fold").css({
                "background-image": "url(images/drawer_menu/icon_normal_arrow.png)"
            });
            drawerMenu_deg_twoNode.find("li:eq(" + Index2 + ") a i.fold").css({
                "background-image": "url(images/drawer_menu/icon_pressed_arrow.png)"
            });
            $(this).addClass("block_fontcolor").siblings().removeClass("block_fontcolor");
            for (var i = 0, z = event.data.contentThree[Index1][Index2].length; i < z; i++) {
                //根据是否有下一层来选择加载不一样的模板
                if (event.data.contentFour[Index1][Index2][i].length > 0) {
                    drawerMenu_deg_threeNode.append($("<li><a href='###'>" + event.data.contentThree[Index1][Index2][i] + "<i class='fold'></i></a></li>"));
                }
                else {
                     drawerMenu_deg_threeNode.append($("<li><a href='###'>" + event.data.contentThree[Index1][Index2][i] + "</a></li>"));
                }
            }
            //定位抽屉三级的位置
            if (drawerMenu_deg_threeNode.find("li").length > 0) {
                var three_height = drawerMenu_deg_threeNode.height();
                var primate_height = $(this).offset().top;
                var screen_height = $(window).height();
                var aa = screen_height-primate_height-block_height;
                if(primate_height>aa){
                    //从下面开始排起
                    drawerMenu_deg_threeNode.css({
                        "top": "auto",
                        "left": drawerMenu_deg_twoNode.offset().left + drawerMenu_deg_twoNode.width()+12,
                        "display": "block",
                        "bottom" : aa
                    });
                    drawerMenu_deg_threeNode.css({
                        "max-height": near(screen_height-aa)
                    });
                    wrapperThreeNode.find(".myclass").css({
                        "width": drawerMenu_deg_threeNode.width(),
                        "height": drawerMenu_deg_threeNode.height(),
                        "top": drawerMenu_deg_threeNode.css("top"),
                        "left": drawerMenu_deg_threeNode.css("left"),
                        "display": "block",
                        "bottom": drawerMenu_deg_threeNode.css("bottom")
                    });
                    wrapperThreeNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_threeNode.css("left"))-8,
                        "bottom":parseInt(drawerMenu_deg_threeNode.css("bottom"))+24,
                        "display":"block",
                        "top" : "auto"
                     });
                }
                else{
                    drawerMenu_deg_threeNode.css({
                        "top": $(this).offset().top,
                        "left": drawerMenu_deg_twoNode.offset().left + drawerMenu_deg_twoNode.width()+12,
                        "display": "block",
                        "bottom" : "auto"
                    });
                    drawerMenu_deg_threeNode.css({
                        "max-height": near($(window).height() - $(this).offset().top)
                    });
                    wrapperThreeNode.find(".myclass").css({
                        "width": drawerMenu_deg_threeNode.width(),
                        "height": drawerMenu_deg_threeNode.height(),
                        "top": drawerMenu_deg_threeNode.css("top"),
                        "left": drawerMenu_deg_threeNode.css("left"),
                        "display": "block",
                        "bottom": drawerMenu_deg_threeNode.css("bottom")
                    });
                    wrapperThreeNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_threeNode.css("left"))-8,
                        "top":parseInt(drawerMenu_deg_threeNode.css("top"))+24,
                        "display":"block",
                        "bottom":"auto"
                     });
                }
            }
        });
        
        drawerMenu_deg_twoNode.on("mouseleave", function (event) {
            var x = event.clientX;
            var y = event.clientY;

            //鼠标焦点移出
            if (drawerMenu_deg_threeNode.offset()) {
                var borderX = drawerMenu_deg_threeNode.offset().left + drawerMenu_deg_threeNode.width();
                var borderY = drawerMenu_deg_threeNode.offset().top + drawerMenu_deg_threeNode.height();
                if ((x >= drawerMenu_deg_threeNode.offset().left-18) && (x <= borderX) && (y >= drawerMenu_deg_threeNode.offset().top+10) && (y <= borderY)) {
                    drawerMenu_deg_threeNode.show();
                    wrapperThreeNode.find(".myclass").show();
                }
                else {
                    $("#" + own.id + " li").removeClass("block_fontcolor");
                    cleanBlock();
                }
            }
        });
        
        drawerMenu_deg_twoNode.on("click", "li", function () {
            var apple = drawerMenu_deg_twoNode.find("li").index($(this));
            content = '[' + Index1 + ',' + apple + ']';
            //传递二级节点信息
            EventHub.dispatchEvent(MessageType.WIDGET, {
                id: own.id,
                degree: "2",
                location: content,
                evtType: Event.CLICK
            });
            //该节点没有孩子节点
            if (drawerMenu_deg_threeNode.find("li").length == 0) {
                cleanBlock();
            }
        });
        
        //第三级抽屉菜单的绑定事件
        drawerMenu_deg_threeNode.on("mouseenter","li",{ 
            contentFour: this.contentFour
        },function(event){
            drawerMenu_deg_fourNode.empty();
            wrapperFourNode.find(".myclass").hide();
            wrapperFourNode.find(".triangle").hide();
            
            Index3 = drawerMenu_deg_threeNode.find("li").index($(this));

            drawerMenu_deg_threeNode.find(".fold").css({
                "background-image": "url(images/drawer_menu/icon_normal_arrow.png)"
            });
            drawerMenu_deg_threeNode.find("li:eq(" + Index3 + ") a i.fold").css({
                "background-image": "url(images/drawer_menu/icon_pressed_arrow.png)"
            });
            $(this).addClass("block_fontcolor").siblings().removeClass("block_fontcolor");
            for (var i = 0, z = event.data.contentFour[Index1][Index2][Index3].length; i < z; i++) {
                drawerMenu_deg_fourNode.append($("<li><a href='###'>" + event.data.contentFour[Index1][Index2][Index3][i] + "</a></li>"));
            }
            //定位四级抽屉位置
            if (drawerMenu_deg_fourNode.find("li").length > 0) {
                var four_height = drawerMenu_deg_fourNode.height();
                var primate_height = $(this).offset().top;
                var screen_height = $(window).height();
                var aa = screen_height-primate_height-block_height;
                if(primate_height>aa){
                    //从下面开始排起
                    drawerMenu_deg_fourNode.css({
                        "top": "auto",
                        "left": drawerMenu_deg_threeNode.offset().left + drawerMenu_deg_threeNode.width()+12,
                        "display": "block",
                        "bottom" : aa
                    });
                    drawerMenu_deg_fourNode.css({
                        "max-height": near(screen_height-aa)
                    });
                    wrapperFourNode.find(".myclass").css({
                        "width": drawerMenu_deg_fourNode.width(),
                        "height": drawerMenu_deg_fourNode.height(),
                        "top": drawerMenu_deg_fourNode.css("top"),
                        "left": drawerMenu_deg_fourNode.css("left"),
                        "display": "block",
                        "bottom": drawerMenu_deg_fourNode.css("bottom")
                    });
                    wrapperFourNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_fourNode.css("left"))-8,
                        "bottom":parseInt(drawerMenu_deg_fourNode.css("bottom"))+24,
                        "display":"block",
                        "top" : "auto"
                     });
                }
                else{
                    drawerMenu_deg_fourNode.css({
                        "top": $(this).offset().top,
                        "left": drawerMenu_deg_threeNode.offset().left + drawerMenu_deg_threeNode.width()+12,
                        "display": "block",
                        "bottom" : "auto"
                    });
                    drawerMenu_deg_fourNode.css({
                        "max-height": near($(window).height() - $(this).offset().top)
                    });
                    wrapperFourNode.find(".myclass").css({
                        "width": drawerMenu_deg_fourNode.width(),
                        "height": drawerMenu_deg_fourNode.height(),
                        "top": drawerMenu_deg_fourNode.css("top"),
                        "left": drawerMenu_deg_fourNode.css("left"),
                        "display": "block",
                        "bottom": drawerMenu_deg_fourNode.css("bottom")
                    });
                    wrapperFourNode.find(".triangle").css({
                        "left":parseInt(drawerMenu_deg_fourNode.css("left"))-8,
                        "bottom":"auto",
                        "display":"block",
                        "top" : parseInt(drawerMenu_deg_fourNode.css("top"))+24
                     });
                }
            }
        });
        
        drawerMenu_deg_threeNode.on("mouseleave", function (event) {
            var x = event.clientX;
            var y = event.clientY;

            //鼠标焦点移出
            if(drawerMenu_deg_fourNode.offset()){
                var borderX = drawerMenu_deg_fourNode.offset().left + drawerMenu_deg_fourNode.width();
                var borderY = drawerMenu_deg_fourNode.offset().top + drawerMenu_deg_fourNode.height();
                if((x >= drawerMenu_deg_fourNode.offset().left-18) && (x <= borderX) && (y >= drawerMenu_deg_fourNode.offset().top+10) && (y <= borderY)) {
                        drawerMenu_deg_fourNode.show();
                        wrapperFourNode.find(".myclass").show();
                }
                else{
                        $("#" + own.id + " li").removeClass("block_fontcolor");
                        cleanBlock();
                }
            }
        });
        
        drawerMenu_deg_threeNode.on("click", "li", function (event) {
            Index3 = drawerMenu_deg_threeNode.find("li").index($(this));
            content = '[' + Index1 + ',' + Index2 + ',' + Index3 + ']';
            //传递三级节点信息
            EventHub.dispatchEvent(MessageType.WIDGET, {
                id: own.id,
                degree: "3",
                location: content,
                evtType: Event.CLICK
            });
            //该节点没有孩子节点
            if (drawerMenu_deg_fourNode.find("li").length == 0) {
                cleanBlock();
            }
        });

        //第四级抽屉菜单的绑定事件
        drawerMenu_deg_fourNode.on("mouseleave","li",function(event){
            var x = event.clientX;
            var y = event.clientY;
            var borderX = drawerMenu_deg_threeNode.offset().left+drawerMenu_deg_threeNode.width();
            var borderY = drawerMenu_deg_threeNode.offset().top+drawerMenu_deg_threeNode.height();
            var borderXX = drawerMenu_deg_fourNode.offset().left + drawerMenu_deg_fourNode.width();
            var borderYY = drawerMenu_deg_fourNode.offset().top + drawerMenu_deg_fourNode.height();
            
            if((y <= drawerMenu_deg_fourNode.offset().top) ||(x >= borderXX)||(y >= borderYY)){
                cleanBlock();
            }
            if((x <borderX)&&(y >borderY)){
                cleanBlock();
            }
        });

        drawerMenu_deg_fourNode.on("click","li",function(event){
            Index4 = drawerMenu_deg_fourNode.find("li").index($(this));
            content = '[' + Index1 + ',' + Index2 + ',' + Index3 + ','+Index4+']';
            //传递第四级节点信息
            EventHub.dispatchEvent(MessageType.WIDGET, {
                id: own.id,
                degree: "4",
                location: content,
                evtType: Event.CLICK
            });
            cleanBlock();
        });

        //动态加载清道夫
        function cleanBlock () {
                drawerMenu_deg_fourNode.empty();
                drawerMenu_deg_fourNode.hide();     
                drawerMenu_deg_threeNode.empty();
                drawerMenu_deg_threeNode.hide();
                drawerMenu_deg_twoNode.empty();
                drawerMenu_deg_twoNode.hide();
                wrapperTwoNode.find(".myclass").hide();
                wrapperThreeNode.find(".myclass").hide();
                wrapperFourNode.find(".myclass").hide();
                wrapperTwoNode.find(".triangle").hide();
                wrapperThreeNode.find(".triangle").hide();
                wrapperFourNode.find(".triangle").hide();
                own.$thisNode.find("li:eq(" + Index1 + ") a i.fold").css({
                    "background-image": "url(images/drawer_menu/icon_normal_arrow.png)"
                });
                drawerMenu_deg_twoNode.css("max-height","none");
                drawerMenu_deg_threeNode.css("max-height","none");
                drawerMenu_deg_fourNode.css("max-height","none");
                $("#" + own.id + " li").removeClass("block_fontcolor");
                drawerMenu_deg_twoNode.find("li").removeClass("block_fontcolor");
                drawerMenu_deg_threeNode.find("li").removeClass("block_fontcolor");
                drawerMenu_deg_fourNode.find("li").removeClass("block_fontcolor");           
        }
        //取一个li的整数倍
        function near(numb :number){
            var left :number,right :number,num :number;
            var block_height :number = 48;
            left = numb % block_height;
            num = numb-left;
            //最小也要有至少一列
            if(num< block_height){
                num = block_height;
            }
            return num;
        }
    }

    public dispose() {
        super.dispose();
        $("#" + this.id + "wrapperTwo").remove();
        $("#" + this.id + "wrapperThree").remove();
    }
}