layui.config({
	base : "../publics/layui/lay/modules/"
}).use(['form','element','layer','jquery'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		element = layui.element(),
		$ = layui.jquery;

	var cfg = {
		path: "js/zeroclipboard.swf",
		copy: function(){
		return $(this).text();
		},
		beforeCopy:function(){
			$(this).css("color","orange");
		},
		afterCopy:function(){
			layer.msg('复制成功', {icon: 1,time: 1000});
		}
	};
    $(".zerocopy").mouseover(function(){
		$(this).css("color","blue");
		if(!$(this).data('init')){$(this).zclip(cfg);$(this).data('init',true)}
	})
	$(".zerocopy").mouseout(function(){
        $(this).css("color","");
    })
	//修改系统变量
	form.on('submit(sysinfosave)', function(data){
		var param = data.field;
		$.post('sys_info.php', param, function(data){
			if(data.status == 1){
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				}, function(){
					location.href = data.gourl;
				});
			}else{
				layer.alert(data.msg, {
					icon: 2
				});
			}
		});
		return false;
	});
	//添加新变量
	form.on('submit(sysinfoadd)', function(data){
		var param = data.field;
		$.post('sys_info.php', param, function(data){
			if(data.status == 1){
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				}, function(){
					location.href = data.gourl;
				});
			}else{
				layer.alert(data.msg, {
					icon: 2
				});
			}
		});
		return false;
	});
	//删除变量
	$("body").on("click",".sys_del",function(){
		var _this = $(this);
		layer.confirm('确定删除？',{icon:3, title:'提示信息'},function(index){
			$.post('sys_info.php?dopost=del', {'aid':_this.attr("data-id")}, function(data){
				if(data.status == 1){
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function(){
						if(data.gourl != '-1')
						location.href = data.gourl;
					});
					layer.close(index);
				}else{
					layer.alert(data.msg, {
						icon: 2
					});
				}
			});
		});
	})
})
