<%@page trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="gen" uri="http://help.jspgen.com/taglib/jstl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1" />
<title>调查</title>
<!-- 当前页面 -->
<link type="text/css" href="${config.statie}ui/admin/images/admin.css" rel="stylesheet">
<link type="text/css" href="${config.statie}ui/cms/admin/images/content-model.css" rel="stylesheet">
<!-- 编辑器插件 -->
<link type="text/css" href="${config.statie}js/kindeditor/themes/default/default.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
  <div class="area">
    <h2>
      <ul class="area-genre">
        <li class="hover">基本信息</li>
        <li>高级属性</li>
      </ul>
      <i><gen:if test='${!param.copy}'><gen:if test='${empty param.id}'>添加<gen:else />编辑</gen:if><gen:else />复制</gen:if>调查</i></h2>
      <form id="form" name="form" method="post" action="<gen:if test='${empty param.id || param.copy}'>${model.id}!save.gen<gen:else />${model.id}!update.gen</gen:if>">
      <div class="area-content">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td width="20%" align="right"><span class="red">*</span>&nbsp;节点：</td>
            <td><a href="javascript:void(0);" class="nodeChoose" to="nodeId" modelId="${model.id}"><gen:if test='${empty node}'>选择<gen:else />${node.name}</gen:if></a>
              <input name="nodeId" type="hidden" value="${node.id}" />&nbsp;&nbsp;
              同时引用到：<a href="javascript:void(0);" class="nodesChoose" to="nodeIds" modelId="${model.id}" nodeId="nodeId" toTxt="#nodesText">选择</a>
              <input name="nodeIds" type="hidden" value="" />&nbsp;&nbsp;
              <span id="nodesText" class="span-text hide"></span></td>
          </tr>
          <tr class="border-top">
            <td align="right"><span class="red">*</span>&nbsp;标题：</td>
            <td><span class="field">
              <input id="title" name="title" type="text" class="text small" value="${content.title}" size="60" maxlength="60" />
              <span id="titleCount">0</span>字&nbsp;&nbsp;<a href="javascript:void(0);" id="colorChoose" title="颜色" style="background-color:${content.color}; width:13px; height:13px; display:inline-block;"><img src="${config.statie}ui/cms/admin/images/color-ico.gif" border="0" /></a>&nbsp;&nbsp;
              <input type="hidden" id="color" name="color" value="${content.color}" /></span>
              <label for="title" generated="true" class="tip normal" tip=""></label></td>
          </tr>
          <tr class="border-top">
            <td align="right"><span class="red">*</span>&nbsp;Tags：</td>
            <td><input id="tags" name="tags" type="text" class="text small" value="${content.tags}" size="50" maxlength="60" />
              <label for="tags" generated="true" class="tip normal" tip="多个用 , 半角逗号间隔，最多5个"></label></td>
          </tr>
          <tr class="border-top">
            <td align="right">编辑：</td>
            <td><input name="editor" type="text" class="text small" value="<gen:if test='${not empty content.editor}'>${content.editor}<gen:else />${loginAdmin.name}</gen:if>" size="10" /></td>
          </tr>
          <tr class="border-top">
            <td align="right" valign="top">摘要：</td>
            <td valign="top"><textarea name="description" class="text small textarea general ignore" maxlength="255">${content.description}</textarea></td>
          </tr>
          <tr class="border-top">
            <td align="right">缩略图：</td>
            <td><span class="field">
              <input type="text" name="thumb" config="content" class="text small" value="${content.thumb}" size="50" />
              <input type="button" name="browse" to="thumb" class="button gray small blue-hover" value="浏览" />
              <input type="button" name="upload" to="thumb" class="button gray small blue-hover" value="上传" />
              </span></td>
          </tr>
          <tr class="border-top">
            <td align="right" valign="top">调查说明：</td>
            <td><textarea id="content" name="content" class="text small textarea general ignore">${survey.content}</textarea></td>
          </tr>
          <tr class="templateTr border-top">
          	<td align="right">自定义模板：</td>
          	<td><input id="template" name="template" type="text" class="text small" value="${content.template}" size="50" />
            &nbsp;<a href="javascript:void(0);" title="选择模板" genre="model/vote" to="template" class="choose">选择</a>&nbsp;<a href="javascript:void(0);" title="编辑模板" to="template" class="edit">编辑</a></td>
          </tr>
          <tr class="border-top">
            <td align="right">日期限制：</td>
            <td><input name="startDate" type="text" class="text small ignore" id="startDate" value="${gen:dateTime(survey.startDate, 'yyyy-MM-dd', config.timezoneid)}" size="20" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')||\'2080-12-12\'}'});" />
              <label for="startDate" generated="true" class="ico-tips date-picker"></label>
              &nbsp;至&nbsp;
              <input name="endDate" type="text" class="text small ignore" id="endDate" value="${gen:dateTime(survey.endDate, 'yyyy-MM-dd', config.timezoneid)}" size="20" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'});" />
              <label for="endDate" generated="true" class="ico-tips date-picker"></label></td>
          </tr>
          <tr class="border-top">
            <td align="right">人数限制：</td>
            <td><input name="pv" type="text" class="text small" value="${survey.maxCount}" size="10" /> 人，超过此数量将不能再提交</td>
          </tr>
          <tr class="border-top">
            <td align="right">防刷限制：</td>
            <td><input name="pv" type="text" class="text small" value="${survey.interval}" size="10" /> 小时，同IP在此时间段内不能重复提交</td>
          </tr>
          <tr class="border-top">
            <td align="right">结果：</td>
            <td><label><input type="checkbox" name="isShow" value="1" <gen:if test='${survey.isShow == 1}'>checked</gen:if> />
                允许显示</label></td>
          </tr>
          <tr class="border-top">
            <td align="right">排序：</td>
            <td><label>
                <input name="sort" type="text" class="text small" value="${content.sort}" size="5" />
                数值越大越靠后</label></td>
          </tr>
         
          <tr class="border-top">
            <td align="right" valign="middle">属性：</td>
            <td valign="middle"><input type="hidden" name="areaId" value="${area.id}" />
                <a href="javascript:void(0);" class="areaChoose" to="areaId"><gen:if test='${empty area}'>选择区域<gen:else />${area.name}</gen:if></a>
                <gen:if test='${platAdmin}'>&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="departmentId" value="${department.id}" />
                <a href="javascript:void(0);" class="departmentChoose" to="departmentId"><gen:if test='${empty department}'>选择部门<gen:else />${department.name}</gen:if></a>
                </gen:if></td>
          </tr> <gen:if test='${platAdmin}'>
          <tr class="border-top">
            <td align="right" valign="top">推荐：</td>
            <td valign="top"><a href="javascript:void(0);" id="commendChoose">选择</a><br />
              <ul id="commendData" class="list-commend list-info clearfix hide">${commendLi}</ul></td>
          </tr></gen:if><gen:if test='${isSpecial}'>
          <tr class="border-top">
            <td align="right" valign="top">专题：</td>
            <td valign="top"><a href="javascript:void(0);" id="columnChoose">选择</a>
            <ul id="columnData" class="list-info hide">${columnLi}</ul></td>
          </tr></gen:if>
          <jsp:include page="content_status.jsp" />
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td width="20%" align="right">浏览量：</td>
            <td><input name="pv" type="text" class="text small" value="${content.pv}" size="10" /></td>
          </tr>
          <tr class="border-top">
            <td align="right">上线：</td>
            <td><input name="publishTime" type="text" class="text small ignore" id="publishTime" value="${gen:dateTime(content.publishTime, 'yyyy-MM-dd HH:mm:ss', config.timezoneid)}" size="20" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'unpublishTime\')||\'2080-12-12 00:00:00\'}'});" />
              <label for="publishTime" generated="true" class="ico-tips date-picker"></label>
              &nbsp;&nbsp;
              下线：
              <input name="unpublishTime" type="text" class="text small ignore" id="unpublishTime" value="${gen:dateTime(content.unpublishTime, 'yyyy-MM-dd HH:mm:ss', config.timezoneid)}" size="20" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'publishTime\')}'});" />
              <label for="unpublishTime" generated="true" class="ico-tips date-picker"></label></td>
          </tr>
          <tr class="border-top">
            <td align="right" valign="top">相关：</td>
            <td valign="top"><a href="javascript:void(0);" id="relatedChoose">选择</a>
              <ul id="relatedData" class="list-info hide">${relatedLi}</ul></td>
          </tr>
        </table>
      </div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
        <tr class="border-top">
          <td class="push txt-c"><input type="hidden" name="formHash" value="${formHash}"/><input type="hidden" name="clearWord" value="true" />
            <input type="hidden" name="id" value="${content.id}" />
            <input type="hidden" name="modelId" value="${model.id}" />
            <input name="submit" class="button blue small" type="submit" value="确 定" />
            &nbsp;&nbsp;&nbsp;&nbsp;
            <input name="reset" class="button gray small" type="reset" value="取 消" /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<!-- 必备插件 -->
<script type="text/javascript" src="${config.statie}js/jquery.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.form.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.grapes.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.timers.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.tablecolor.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.tabs.js"></script>
<!-- 颜色选择器插件 -->
<script type="text/javascript" src="${config.statie}js/colorPicker/jquery.colorPicker.js"></script>
<!-- 编辑器插件 -->
<script type="text/javascript" src="${config.statie}js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="${config.statie}js/kindeditor/lang/zh_CN.js"></script>
<!-- 日期插件 -->
<script type="text/javascript" src="${config.statie}js/datePicker/WdatePicker.js"></script>
<!-- 弹窗插件 -->
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.js?self=true"></script>
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.plugins.js"></script>
<!-- 表单验证插件 -->
<script type="text/javascript" src="${config.statie}js/validate/jquery.validate.js"></script>
<script type="text/javascript" src="${config.statie}js/validate/validate.expand.js"></script>
<script type="text/javascript" src="${config.statie}js/validate/messages_zh.js"></script>
<!-- UI界面必备 -->
<script type="text/javascript" src="${config.statie}ui/js/jspgen.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ajax.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ready.js"></script>
<!-- 当前页面 -->
<script type="text/javascript" src="${config.statie}ui/cms/js/jspgencms.js"></script>
<script type="text/javascript" src="${config.statie}ui/cms/admin/js/content-model.js"></script>
<script type="text/javascript" src="${config.statie}ui/cms/admin/js/template-edit.js"></script>
<script type="text/javascript">
// document.domain = "baidu.com";

var $editor;
KindEditor.ready(function(K) {
	$editor = K.create('textarea[name="content"]', {
		cssPath:['${config.statie}js/kindeditor/plugins/code/prettify.css','${config.statie}js/kindeditor/themes/common/ke-iframe.css'],
		allowPreviewEmoticons : false,
		${editorUpload}
		resizeType:1,
		items:[
			'source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
			'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			'justifyfull', 'selectall', 'clearhtml', 'quickformat', '|', 'fullscreen', '/',
			'bold','italic', 'underline', 'strikethrough', 'removeformat', '|',
			'emoticons', 'image', 'flash', 'media', 'insertfile', 'table', 'hr',
			'link', 'unlink', '|', 'code', 'preview'
		],
		afterBlur: function(){this.sync();}
	});
});

// 调用
$(document).ready(function(){	
	var $form = $('#form'), $reset = $('input:reset');
	// 表单验证
	var validate = $form.validate({
		rules: {
			title: {
				required: true
			},
			tags: {
				required: true
			}
		},
		messages: {
			title: {
				required: '标题不允许为空！'
			},
			tags: {
				required: 'Tags不允许为空！'
			}
		},
		submitHandler: function(form) {
			$(form).ajaxSubmit($.extend({
				success: function(result) {
					// {'status':false,'message':'message', 'store':{'id':'id'}}
					if (result) {
						if (result.status) {
							$dialog.success(result.message, function() {
								refleshFromTab(); removeTab();
							});
						}else{
							$dialog.error(result.message);
						}
					}
				}
			}, formOptions));
			
			// 阻止表单默认提交
			return false;
		}
	});
	$reset.bind('click', function () {
		validate.resetForm();
	});
});
</script>
</body>
</html>
