/左侧菜单点击/
$(".side-menu").on(‘click’, ‘li a’, function(e) {
var animationSpeed = 300;
var $this = $(this);
var checkElement = $this.next();
if (checkElement.is('.menu-item-child') && checkElement.is(':visible')) {
checkElement.slideUp(animationSpeed, function() {
checkElement.removeClass('menu-open');
});
checkElement.parent("li").removeClass("active");
}
//如果菜单是不可见的
else if ((checkElement.is('.menu-item-child')) && (!checkElement.is(':visible'))) {
//获取上级菜单
var parent = $this.parents('ul').first();
//从父级开始找所有打开的菜单并关闭
var ul = parent.find('ul:visible').slideUp(animationSpeed);
//在父级中移出menu-open标记
ul.removeClass('menu-open');
//获取父级li
var parent_li = $this.parent("li");
//打开菜单时添加menu-open标记
checkElement.slideDown(animationSpeed, function() {
//添加样式active到父级li
checkElement.addClass('menu-open');
parent.find('li.active').removeClass('active');
parent_li.addClass('active');
});
}
//防止有链接跳转
e.preventDefault();
addIframe($this);
});
/添加iframe/
function addIframe(cur){
var $this = cur;
var h = $this.attr(“href”),
m = $this.data(“index”),
label = $this.find(“span”).text(),
isHas = false;
if (h == “” || $.trim(h).length == 0) {
return false;
}
var fullWidth = $(window).width();
if(fullWidth >= 750){
$(".layout-side").show();
}else{
$(".layout-side").hide();
}
$(".content-tab").each(function() {
if ($(this).data("id") == h) {
if (!$(this).hasClass("active")) {
$(this).addClass("active").siblings(".content-tab").removeClass("active");
addTab(this);
}
isHas = true;
}
});
if(isHas){
$(".body-iframe").each(function() {
if ($(this).data("id") == h) {
$(this).show().siblings(".body-iframe").hide();
}
});
}
if (!isHas) {
var tab = "<a href='javascript:;' class='content-tab active' data-id='"+h+"'>"+ label +" <i class='icon-font'></i></a>";
$(".content-tab").removeClass("active");
$(".tab-nav-content").append(tab);
var iframe = "<iframe class='body-iframe' name='iframe"+ m +"' width='100%' height='99%' src='"+ h +"' frameborder='0' data-id='"+ h +"' seamless></iframe>";
$(".layout-main-body").find("iframe.body-iframe").hide().parents(".layout-main-body").append(iframe);
addTab($(".content-tab.active"));
}
return false;
}
/添加tab/
function addTab(cur) {
var prev_all = tabWidth( ( c u r ) . p r e v A l l ( ) ) , n e x t a l l = t a b W i d t h ( (cur).prevAll()), next_all = tabWidth( (cur).prevAll()),nextall=tabWidth((cur).nextAll());
var other_width =tabWidth($(".layout-main-tab").children().not(".tab-nav"));
var navWidth = ( " . l a y o u t − m a i n − t a b " ) . o u t e r W i d t h ( t r u e ) − o t h e r w i d t h ; / / 可 视 宽 度 v a r h i d e w i d t h = 0 ; i f ( (".layout-main-tab").outerWidth(true)-other_width;//可视宽度 var hidewidth = 0; if ( (".layout−main−tab").outerWidth(true)−otherwidth;//可视宽度varhide