hjg
2024-01-17 efbf825aa2f845bc6f9b26b0fa10139c8071deef
提交 | 用户 | 时间
58d006 1 /**
A 2  * 
3  */
4 var basic=getpath();
5 jQuery(document).ready(function($) {
6     metromenus()
7 });
8
9 function metromenus(){
10     var path=window.document.location.pathname;
11     jQuery.post(basic+'/admin/bmenucon/ftmenu.htm', {title:'lftmenus'}, function(data, textStatus, xhr) {
12         if(data==null)
13             return;
14         var navlist=$('ul#menuulroot');
15         var startflg=false;
16         var li_parent=null;
17         var ul_child=null;
18         var li_child=null;
19         var li_parent_lft=0;
20         var li_parent_rgt=0;
21         jQuery.each(data, function(index, val) {
22           var lft=val.lft;
23           var rgt=val.rgt;
24           if(lft<li_parent_rgt)
25           {
26               li_child=jQuery('<li> <a href="'+val.url+'">'+val.title+' </a> </li>').appendTo(ul_child); 
27           }else{
28               li_parent=jQuery('<li></li>').appendTo(navlist);
29               if(startflg==false)
30               {
31                   li_parent.addClass('start');
32                   startflg=true;
33               }
34               ul_child=null;
35               var a=jQuery('<a href="javascript:void(0);" class="dropdown-toggle"></a>').appendTo(li_parent);
36               var i=jQuery('<i class="'+val.icon+'"></i>').appendTo(a);
37               var span=jQuery('<span class="menu-text">'+val.title+'</span>').appendTo(a);
38               var b=jQuery('<b class="arrow icon-angle-down"></b>').appendTo(a);
39               li_parent_lft=lft;
40               li_parent_rgt=rgt;
41               if(rgt-lft>1)
42               {
43                   ul_child=jQuery('<ul class="sub-menu"></ul>').appendTo(li_parent);
44               }else{
45                   a.removeClass('dropdown-toggle');
46                   if(val.url!=null&&val.url!='')
47                   {
48                       a.attr('href',val.url);
49                   }
50               }
51           }
52           if(val.url!=null&&val.url.indexOf(path)>=0)
53           {
54               li_parent.addClass('active');
55               li_parent.addClass('open');
56               if(li_child!=null)
57                   li_child.addClass('active');
58           }
59         });
60     },'json');
61 }