<?php include $this->admin_tpl('meta', 'admin');?>
<title>TAG标签选择 - YzmCMS内容管理系统</title>
<style>
	.yzm_tags{margin-top:12px;}
	.yzm_tags a{color:#666;margin-right:10px;cursor: pointer;}
	.yzm_tags a:hover{color:red;}
	.tag_val{margin-top:10px}
</style>
</head>
<body>
<article class="page-container">
	<form action="" method="get" id="search">
    	 <input type="text" name="searinfo" class="input-text" style="width:200px;height:27px;line-height:27px" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo'];?>">
    	 <button name="dosubmit" class="btn btn-success size-S" type="submit" value="1"><i class="Hui-iconfont">&#xe665;</i> 搜索</button> 
	</form>	
	<div class="yzm_tags">	
			<?php 
			foreach($data as $val){
				echo '<a onclick="set_val(\''.$val['tag'].'\')">#'.$val['tag'].'</a>';
			}
		    ?>
	</div>
	<div class="tag_val">
		<p>已选择的TAG：</p>
		<input type="text" class="input-text" name="" id="tags">
	</div>
	

	<div style="position: fixed;bottom: 20px;right: 10px;z-index: 99;">
            <button onclick="dosub()" name="dosubmit" class="btn btn-primary radius" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp;
			<button onclick="yzmcms_close()" class="btn btn-default radius" type="button">&nbsp;&nbsp;关闭&nbsp;&nbsp;</button>
	</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">
	function set_val(val) { 
		var v = $("#tags").val();
		v = v ? v+','+val : val;
		$("#tags").val(v);
	}


	function dosub(){
		var v = $("#tags").val();
		if (v == ''){
		   layer.alert('请选择TAG！');
		   return false;
		}

		var str = '';
		var strs= new Array();
		strs = v.split(","); 
		for (i=0;i<strs.length ;i++ ){
			str += '<span class="Hui-tags-token">'+ strs[i] +'</span>';;
		}
		
		var index = parent.layer.getFrameIndex(window.name);
		parent.$("#tag_default").append(str);

		var taglist = parent.$("#taglist").val();
		if(taglist != ''){
			parent.$("#taglist").val(v + ',' + taglist);
		}else{
			parent.$("#taglist").val(v+',');
		}

		parent.change_keyword();
		parent.layer.close(index);
	}	
</script> 

</body>
</html>