home.js 1.96 KB
define(function(){
	return function(){
		var body=$(document.body);
		var layout=body.children(".rs-base").children(".rs-layout");
		var west=layout.layout("panel","west");
		var btnMenu=west.find(".btn-menu");
		
		var panel = getSelectedPanel();//初始化面板
		var homeLayout=panel.children('.pl-home-page').layout({
			fit:true
		});
		var center=homeLayout.layout("panel","center");
		var east=homeLayout.layout("panel","east");
		
		center.rs_load().rs_load("show");
		$.post("./menu/select/system.json",function(json){
			if(responseUtils(json)){
				center.rs_load("hide");
				$.each(json.list,addSystemModule);
			}
		});
		
		east.panel("setTitle",resource.home.otherPlatformTitle);
		var items=east.children(".item");
		if(items.length==0){
			east.append('<div class="item">'+resource.home.noPlatform+'</div>');
		}else{
			items.bind("click.home",function(){
				var btn=$(this);
				$.messager.confirm(resource.msg_title, resource.home.changePlatformTitle, function(r){
					if (r){
						window.location.href="./platform?id="+btn.attr("options");
					}
				});
			});
		}		
		
		function addSystemModule(i,item){
			var btn=$('<a class="pl-home-module '+(i==0?"selected":"")+'" href="javascript:void(0);" options="'+item.id+'"></a>').appendTo(center);
			var icon=$('<span class="icon'+(item.icon?' '+item.icon:'')+'"></span>').appendTo(btn);
			var text=$('<span class="text"></span>').appendTo(btn);
			text.html(item.name);
			if(item.url&&$.trim(item.url)!=''){
				btn.attr("href",item.url+(item.url.indexOf('?')>0?'&':'?')+'platid='+global.platId+'&pltid='+global.platTypeId);
				btn.attr("target","_blank");
			}else{
				btn.bind("click.home",function(){
					var obj=$(this);
					if(!obj.hasClass("selected")){
						obj.parent().children(".pl-home-module").removeClass("selected");
						obj.addClass("selected");
						menuReloadUtils($(this).attr("options"));
					}
					if(!btnMenu.hasClass("shrink")){
						btnMenu.triggerHandler("click");
					}
				});
			}
		}
	}
});