username@email.com
2025-04-27 15eb82df2d6ec539e9d4245bfe08d531e8eb6379
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
//滑动菜单
; RoadUI.Accordion = function ()
{
    var instance = this;
    this.init = function ($divs, showIndex)
    {
        $divs.each(function ()
        {
            var $accordionTitles = $(".accordiontitle", $(this));
            var borderHeight = $(this).css("border").indexOf("none") >= 0 ? -1 : 0;//div是否有边框,没有边框内容高度要-1
            var contentHeight = $(this).height() - ($accordionTitles.size() * 27) + ($accordionTitles.size() - 1) + 2 + borderHeight;
            var defaultShowIndex = showIndex || 0;
            $accordionTitles.each(function (i)
            {
                if (i == 0)
                {
                    $(this).css({ "border-top": "none" });
                }
                else
                {
                    $(this).css({ "border-bottom": "none" });
                }
                $(this).next().css({ "height": contentHeight.toString() + "px", "display": i == defaultShowIndex ? "block" : "none" });
                $(this).bind("click", function ()
                {
                    var border = "";
                    $(".accordion div .accordiontitle").each(function ()
                    {
                        $(this).next().hide();
                        $(this).css({ "border-bottom": "none" });
                        if (border.length == 0 && $(this).css("border").indexOf("none") == 0)
                        {
                            border = $(this).css("border");
                        }
                    });
                    $(this).next().show(300);
                    $(this).css({ "border-bottom": border });
                });
            });
        });
    };
 
    this.resize = function ($div)
    {
        var $accordionTitles = $("div .accordiontitle", $div);
        var borderHeight = $div.css("border").indexOf("none") >= 0 ? -1 : 0;//div是否有边框,没有边框内容高度要-1
        var contentHeight = $div.height() - ($accordionTitles.size() * 27) + ($accordionTitles.size() - 1) + 2 + borderHeight;
        $(".accordioncontent", $div).height(contentHeight);
    }
}