#include("./header.html", {active:'nodes', title:'添加新节点'})
<div class=main-content>
	<div class="panel mb25">
		<div class="panel-heading border">添加新节点</div>
		<div class="panel-body">
			<div class="row no-margin">
				<div class="col-lg-12">
					<form class="form-horizontal bordered-group" role="form" method="post" action="${base_url('/admin/nodes/add')}">
						
						<div class="form-group">
							<label class="col-sm-2 control-label">节点名称</label>
							<div class="col-sm-10">
								<input class="form-control" name="node_name"
								placeholder="请输入节点名称，比如：开发工具" required="required" autofocus="autofocus"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">唯一标识</label>
							<div class="col-sm-10">
								<input class="form-control" name="node_slug" placeholder="请输入节点唯一标识，比如：ide" required="required"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">节点介绍</label>
							<div class="col-sm-10">
								<textarea class="form-control" name="description" rows="3" placeholder="请输入节点介绍"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">选择父节点</label>
							<div class="col-sm-10">
								<select class="form-control" name="pid">
									<option value="0">无父节点</option>
									#for(node : nodes)
									<option value="${node.nid}">${node.title}</option>
									#end
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">上传节点图标</label>
							<div class="col-sm-10">
								<input type="hidden" name="node_pic" id="node_pic" />
								<img id="upload_img" src="" width="73" height="73" onclick="doUpload()" style="cursor: pointer;"/>
								<input type="file" name="fileUpload" class="fileUpload" accept="image/png,image/jpg,image/jpeg" style="display: none;"/>
								<p class="help-block">选择一个图片作为节点图标</p>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">&nbsp;</label>
							<div class="col-sm-10">
								<button type="submit" class="btn btn-success">添加节点</button>
								<a href="/admin/nodes" type="button" class="btn btn-default btn-outline">取消操作</a>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
#include("./footer.html")
<script type="text/javascript" src="${cdn}/assets/scripts/jquery.liteuploader.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){
		
	$(".fileUpload").liteUploader({
	    script: "${base_url('/uploadimg')}",
	    params: {type:'node'},
	    rules: {
	        allowedFileTypes: "image/jpeg,image/png,image/jpeg",
	        maxSize: 512000
		}
	}).on("lu:success", function (e, data) {
		  //console.log(data);
		  if(data){
			  $("#upload_img").attr('src', data.url);
			  $("#node_pic").val(data.savepath);
		  }
	}).on("lu:errors", function (e, errors) {
		console.log(errors);
	});
	
	$(".fileUpload").change(function () {
	    $(this).data("liteUploader").startUpload();
	});
	
});

//上传方法
function doUpload() {
	$(".fileUpload").click();
}
</script>
</body>
</html>