/home/mjc1/public_html/faq/left_navi.php


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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<style>
li.tree-empty, li.tree-closed, li.tree-opened { position:relative;}
li.tree-empty > .toggler { cursor:default; }
li.tree-empty > .toggler:before { content:url(./images/common/tree_file.png);}
li.tree-closed > .toggler:before { content:url(./images/common/tree_closed.png);}
li.tree-opened > .toggler:before { content:url(./images/common/tree_opened.png);}
.treemenu .toggler { cursor:pointer;}
.treemenu .toggler:before { position:absolute;top:6px;width:16px;}

.tree { padding:0 0 0 20px;}
.tree li,
.tree li > a,
.tree li > span { width:200px;padding:5px 0;letter-spacing:-1.5px;background:#fff;}
.tree li a { padding-left:23px;}
.tree li a:hover,
.tree .active, 
.tree .active a { color:#ff6400;}
.tree .cate2 { text-indent:2px;}
.tree .cate3 { text-indent:4px;}
.tree .cate1 > a { color:#555;font-size:16px;font-weight:600;}
.tree .cate2 a { color:#555;font-size:15px;}
.tree .cate3 a { color:#777;font-size:13px;}
</style>



<ul class="tree">
<?php
    $sql 
"select * from cs3_manual_cate1 where 1=1 order by code";
    
$res mysql_query($sql);
    while(
$info=mysql_fetch_array($res)){
        
$cate1_array[] = $info;
    }
    foreach(
$cate1_array as $key=>$info){
        
$cate2_array null;
        
$sql "select * from cs3_manual_cate2 where 1=1 and substring(code,1,2) = '{$info['code']}' order by code";
        
$res2 mysql_query($sql);
        while(
$info2=mysql_fetch_array($res2)){
            
$cate2_array[] = $info2;
        }
?>
        <li class="cate1">
            <span class="<?php if(count($cate2_array)>0){?>toggler<?php }?>"></span>
            <a <?php if(count($cate2_array)==0){?>href="?SearchMsw1=<?php echo $info['code']?>"<?php } else {?>class="open_class"<?php }?>><?php echo $info['name']?></a>
<?
        
if(count($cate2_array)>0){
            echo 
"<ul>";
            foreach(
$cate2_array as $key=>$info2){
                
$cate3_array null;
                
$sql "select * from cs3_manual_cate3 where 1=1 and substring(code,1,4) = '{$info2['code']}' order by code";
                
$res3 mysql_query($sql);
                while(
$info3=mysql_fetch_array($res3)){
                    
$cate3_array[] = $info3;
                }
?>
            <li class="cate2">
                <span class="<?php if(count($cate3_array)>0){?>toggler<?php }?>"></span>
                <a <?php if(count($cate3_array)==0){?>href="?SearchMsw2=<?php echo $info2['code']?>"<?php } else {?>class="open_class"<?php }?>><?php echo $info2['name'];?></a>
<?php
            
            
if(count($cate3_array)>0){
                echo 
"<ul>";
                foreach(
$cate3_array as $key=>$info3){
?>
                    <li class="cate3"><a href="?SearchMsw3=<?php echo $info3['code']?>"><?php echo $info3['name'];?></a>
<?php
                
}
                echo 
"</ul>";
            }
?>
            </li>
<?php
            
}
            echo 
"</ul>";
        }
?>
        </li>
<?php
    
}
?>
</ul>

<script>
$(function(){
        $(".tree").treemenu({delay:500}); //.openActive()
    });
</script>
<script type="text/javascript">
(function($){
    $.fn.treemenu = function(options) {
        options = options || {};
        options.delay = options.delay || 0;
        options.openActive = options.openActive || false;
        options.closeOther = options.closeOther || false;
        options.activeSelector = options.activeSelector || ".active";

        this.addClass("treemenu");

        if (!options.nonroot) {
            this.addClass("treemenu-root");
        }

        options.nonroot = true;

        this.find("> li").each(function() {
            e = $(this);
            var subtree = e.find('> ul');
            var button = e.find('.toggler').eq(0);

            if(button.length == 0) {
                // create toggler
                var button = $('<span>');
                button.addClass('toggler');
                e.prepend(button);
            }

            if(subtree.length > 0) {
                subtree.hide();

                e.addClass('tree-closed');

                e.find(button).click(function() {
                    var li = $(this).parent('li');

                    if (options.closeOther && li.hasClass('tree-closed')) {
                        var siblings = li.parent('ul').find("li:not(.tree-empty)");
                        siblings.removeClass("tree-opened");
                        siblings.addClass("tree-closed");
                        siblings.removeClass(options.activeSelector);
                        siblings.find('> ul').slideUp(options.delay);
                    }

                    li.find('> ul').slideToggle(options.delay);
                    li.toggleClass('tree-opened');
                    li.toggleClass('tree-closed');
                    li.toggleClass(options.activeSelector);
                });

                $(this).find('> ul').treemenu(options);
            } else {
                $(this).addClass('tree-empty');
            }
        });

        if (options.openActive) {
            var cls = this.attr("class");

            this.find(options.activeSelector).each(function(){
                var el = $(this).parent();

                while (el.attr("class") !== cls) {
                    el.find('> ul').show();
                    if(el.prop("tagName") === 'UL') {
                        el.show();
                    } else if (el.prop("tagName") === 'LI') {
                        el.removeClass('tree-closed');
                        el.addClass("tree-opened");
                        el.show();
                    }

                    el = el.parent();
                }
            });
        }

        return this;
    }

    $(".open_class").click(function(){
        $li_obj = $(this).closest("li");
        $li_obj.find("span").eq(0).click();
    });
})(jQuery);

</script>