public.component.assets.custom.home_tabs.js Maven / Gradle / Ivy
addMenuTab = function(id,url,title,close){
if(close == undefined){
close = true;
}
var options ={"id":id,"title":title,"url":url,"close": close,iframe:false};
addTabs(options);
}
var addTabs = function (options) {
id = "tab_" + options.id;
$(".active").filter(".mtab").removeClass("active");
//如果TAB不存在,创建一个新的TAB
if (!$("#" + id)[0]) {
//固定TAB中IFRAME高度
mainHeight = $(document.body).height() - 90;
//创建新TAB的title
title = '' + options.title;
//是否允许关闭
if (options.close) {
title += ' ';
}
title += ' ';
//是否指定TAB内容
if(options.iframe){
content = '';
$("#homeMainTab").append(content);
}else{
var $content = $('' + '');
$("#homeMainTab").append($content);
$.ajax({
url: options.url,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("ajax", true);
}
}).
error(function(XMLHttpRequest){
$.loy.statusErrorShow(XMLHttpRequest.status)
})
.done(function(result) {
$content.empty().html(result);
});
}
//加入TABS
$("#homeMainNav").append(title);
}
//激活TAB
$("#tab_" + id).addClass('active mtab');
$("#" + id).addClass("active mtab");
$(document).trigger('mainTabClick');
};
var closeTab = function (id) {
//如果关闭的是当前激活的TAB,激活他的前一个TAB
if ($("li.active").attr('id') == "tab_" + id) {
$("#tab_" + id).prev().addClass('active');
$("#" + id).prev().addClass('active');
}
//关闭TAB
$("#tab_" + id).remove();
$("#" + id).remove();
};
DynamicLoad.loadFileList(jsCssFile,function(){
$.homeGlobal =HomeGlobal;
$(function () {
mainHeight = $(document.body).height() - 45;
$('.main-left,.main-right').height(mainHeight);
$("[addtabs]").click(function () {
addTabs({ id: $(this).attr("id"), title: $(this).attr('title'), close: true });
});
$("#homeMainNav").on("click", "[tabclose]", function (e) {
id = $(this).attr("tabclose");
closeTab(id);
});
});
var home = new Home();
home.offsetHeight = function(){
return 330;
};
home.getSelfPage = function(){
return "home_tabs.html";
};
home.initSidebar();
home.buildMenu = function(data){
addMenuTab("Index",data.defaultPage,$.i18n.prop("home_page"),false);
var menuData = data.menuData;
var menuBuffer = [];
if(menuData){
for(var i=0;i');
menuBuffer.push('');
menuBuffer.push('');
menuBuffer.push('');
menuBuffer.push('');
menuBuffer.push(' ');
menuBuffer.push('');
menuBuffer.push(' ');
menuBuffer.push('');
}
}
var menuStr = menuBuffer.join(' ');
$('#menuDiv').html(menuStr);
};
home.init();
});
© 2015 - 2025 Weber Informatics LLC | Privacy Policy