标签:ast ext show javascrip res class 点击 皮肤 set
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page isELIgnored="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="t" uri="/custom-tags"%> <% String path=request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path; String skinNm=(String)session.getAttribute("Plat_Ui_Skin"); String localeLang = request.getLocale().getLanguage(); String lang = localeLang+"_"+request.getLocale().getCountry(); %> <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="<%=path %>/resources/themes/<%=skinNm %>/common/perfectScrollbar/perfect-scrollbar.css"> <link rel="stylesheet" type="text/css" href="<%=path %>/resources/themes/<%=skinNm %>/common/commen.css"> <link rel="stylesheet" type="text/css" href="<%=path %>/resources/themes/<%=skinNm %>/plat/css/frame.css"> <script src="<%=path %>/resources/js/common/jquery.min.js"></script> <script type="text/javascript" src="<%=path %>/resources/js/common/common.js"></script> <script type="text/javascript" src="<%=path %>/resources/js/common/perfectScrollbar/jquery.mousewheel.js"></script> <script type="text/javascript" src="<%=path %>/resources/js/common/perfectScrollbar/perfect-scrollbar.js"></script> </head> <body> <div id="leftMenu" class="leftMenu"> <ul id="ul1" class="ul-level1" style="margin-top: 0"> </ul> </div> <script type="text/javascript"> var data; function A(d,n){ this.data=d; this.setDom=function(){ n++; var cN="ul-level"+n; var dom="<ul class="+cN+">"; for(var i in this.data){ var path="../../"+this.data[i].permissionCode; var closed=this.data[i].closed; var permissionType = this.data[i].permissionType; if(this.data[i].children.length!=0){ if(this.data[i].permissionType!=3){ if (n==1) { dom+="<li class=‘level1‘ closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:15px 0;‘><img src=../../"+this.data[i].permissionImgUrl+" class=‘level1_img‘><a>"+this.data[i].permissionName+"</a><span id=‘rA‘ class=‘rA‘></span></div>"; }else if(n==2){ dom+="<li class=‘level2‘ closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:10px 8px 10px 0;‘><span class=‘level2_img‘></span><a>"+this.data[i].permissionName+"</a><span>"+"</span><span name=‘leftselect‘></span></div>"; }else{ dom+="<li closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:10px 8px 10px 0;‘><a>"+this.data[i].permissionName+"</a></div>"; } } var dom2=new A(this.data[i].children,n); dom+=dom2.setDom(); }else{ //permissionType=3为按钮,permissionType=4是组件首页在此不显示。 if(this.data[i].permissionType!=3&&this.data[i].permissionType!=4){ if (n==1) { dom+="<li class=‘level1‘ closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:15px 0;‘><img src=../../"+this.data[i].permissionImgUrl+" class=‘level1_img‘><a>"+this.data[i].permissionName+"</a><span id=‘rA‘ class=‘rA‘></span></div>"; }else if(n==2){ dom+="<li class=‘level2‘ closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:10px 8px 10px 0;‘><span class=‘level2_img‘></span><a>"+this.data[i].permissionName+"</a><span>"+"</span><span name=‘leftselect‘></span></div>"; }else{ dom+="<li closed="+closed+"><div path="+path+" permissionType="+permissionType +" style=‘padding:10px 8px 10px 0;‘><a>"+this.data[i].permissionName+"</a></div>"; } } } dom+="</li>"; } dom+="</ul>"; return dom; } } $(function(){ var productName = ‘${param.moduleName}‘; $.ajax({ type:"post", dataType:"json", url:"${pageContext.request.contextPath}/plat/platNav/getMenuId.do", data:{code:productName}, success:function(data){ data=data.children; $("#leftMenu").perfectScrollbar(); init(data); var n=0; var aa=new A(data,n); $("#leftMenu").append(aa.setDom()); showOrHide(); $("ul>li>div").click(function(){ console.log($(this)[0]); if ($(this).parent().attr("class")=="level1"||$(this).parent().attr("class")=="level1 liHG") {//一级菜单 if ($(this).parent().attr("class")=="level1") { $(this).find("#rA").removeClass("rA").addClass("rR"); $(this).parent().addClass("liHG"); }else{ $(this).find("#rA").removeClass("rR").addClass("rA"); $(this).parent().removeClass("liHG"); } }else if($(this).parent().attr("class")=="level2"||$(this).parent().attr("class")=="level2 itemBg") {//二级菜单 $(".hightLight").removeClass("hightLight"); $(".itemBg").removeClass("itemBg");//已添加的背景色去掉 $(this).parent().addClass("itemBg");//为当前的点击的对象添加背景色 $(".leftselect").removeClass("leftselect");//将已加了右边小三角去掉 $($(this).find("span:last")).addClass("leftselect"); }else{//多级菜单 $(".hightLight").removeClass("hightLight"); $(this).addClass("hightLight"); $(".itemBg").removeClass("itemBg");//已添加的背景色去掉 $(this).parents(".level2").addClass("itemBg");//为当前的点击的对象添加背景色 $(".leftselect").removeClass("leftselect");//将已加了右边小三角去掉 $($(this).parents(".level2").find("span:last")).addClass("leftselect"); } var path=$(this).attr("path"); var permissionType=$(this).attr("permissionType"); if (permissionType=="2"||permissionType=="6") { window.parent.frames[‘frameMain‘].location.href = path; } if($(this).next("ul")){ $(this).next("ul").slideToggle(); } }); //换肤改变图片 var sty=window.sessionStorage.getItem("style");//获取当前的皮肤的名称 if(!sty){//获取不到默认为天蓝 window.sessionStorage.setItem("style","blueSky"); }else{ var links=$("head link"); if(links.length==0){ return } for(var i=0;i<links.length;i++){ var href=decodeURI(links.eq(i).attr("href")); var newHref=href.replace(href.split("themes/")[1].split("/")[0],sty); $("head").append(‘<link rel="stylesheet" type="text/css" href="‘+newHref+‘"/>‘); } } //导航各组件图标图片更新 var imgs=$(".ul-level1 img"); for(var i= 0,m=imgs.length;i<m;i++){ var src=imgs.eq(i).attr("src"); var path=src.split("/images")[0].substring(src.split("/images")[0].lastIndexOf("/")); var srcLeft=src.split("themes")[0]+"themes/"; var srcRight=path+src.split(path)[1]; imgs.eq(i).attr("src",srcLeft+window.sessionStorage.getItem("style")+srcRight); } } }) }); //默认初始换显示页面 function init(data) { var notRefMain = ""; if(notRefMain.length==0){ notRefMain = ""; } for(var i=0;i<data.length;i++){ if(data[i].permissionType==4){ window.parent.frames[‘frameMain‘].location.href = "../../" + data[i].permissionCode; return; } } for(var i=0;i<data.length;i++){ if(data[i].permissionType==2){ window.parent.frames[‘frameMain‘].location.href = "../../" + data[i].permissionCode; return; }else{ for(var j=0;j<data[i].children.length;j++){ if(data[i].children[j].permissionType==2){ window.parent.frames[‘frameMain‘].location.href = "../../" + data[i].children[j].permissionCode; return; } if(data[i].children[j].permissionType==6){ window.parent.frames[‘frameMain‘].location.href = "../../" + data[i].children[j].permissionCode; return; } } } } } //二级菜单默认是否为展开 function showOrHide(){ var lis=$("li"); for (var i = 0; i < lis.length; i++) { var closed = $(lis[i]).attr("closed"); if (closed=="true"||closed=="undefined") { $(lis[i]).children("ul").hide(); }else{ $(lis[i]).children("ul").show(); $(lis[i]).find("#rA").removeClass("rA").addClass("rR"); $(lis[i]).addClass("liHG"); } } } </script> </body> </html>
标签:ast ext show javascrip res class 点击 皮肤 set
原文地址:http://www.cnblogs.com/bxslovewxs/p/7895378.html