<%@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">
<style type="text/css">
.span-text {padding:0 2px; color:#FFFFFF; background:#9AC621; border-radius:3px; max-width:120px;}
</style>
</head>
<body>
<div id="wrapper">
  <div class="area">
    <h2><i>内容转移</i></h2>
    <div class="area-content">
      <form id="form" name="form" method="post" action="content!updateNode.gen">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td width="30%" align="right">原节点：</td>
            <td><a href="javascript:void(0);" class="nodesChoose">选择</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" valign="middle">含子级：</td>
            <td><label><input name="ischild" type="checkbox" value="0" />
                包含子级内容</label></td>
          </tr>-->
          <tr class="border-top">
            <td align="right" valign="middle">目标节点：</td>
            <td><a href="javascript:void(0);" class="nodeChoose">选择</a>
              <input name="nodeId" type="hidden" value="" /></td>
          </tr>
          <tr class="border-top">
            <td colspan="2" class="push txt-c"><input type="hidden" name="formHash" value="${formHash}"/>
              <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>
</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/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">
// document.domain = "baidu.com";

// 调用
$(document).ready(function(){
	// 原节点
	var $nodesChoose = $('.nodesChoose'), $nodesText = $('#nodesText'), $nodeIds = $('input[name="nodeIds"]');
	$nodesChoose.bind('click',function(){
		var dialog = $dialog.iframe(jspgen.dynamie + jspgencms.id + '/admin/node!choose.gen?ids='+$nodeIds.prop('value')+'&names='+$nodesText.text(),
			{title: '原节点', width:'230px', height:'300px', resize: false});
		dialog.callback = function(obj) {
			$nodeIds.prop('value', obj.ids);
			$nodesText.text(obj.names).toggle(grapes.isNotEmpty(obj.names));
		}
	});
	// 目标节点
	var $nodeChoose = $('.nodeChoose'), $nodeId = $('input[name="nodeId"]');
	$nodeChoose.bind('click',function(){
		var dialog = $dialog.iframe(jspgen.dynamie + jspgencms.id + '/admin/node!choose.gen?radio=true&ids='+$nodeId.prop('value')+'&names='+$nodeChoose.text(),
			{title: '目标节点', width:'230px', height:'300px', resize: false});
		dialog.callback = function(obj) {
			if(grapes.isNotEmpty(obj.ids) && grapes.isNotEmpty(obj.names)){
				$nodeId.prop('value', obj.ids);
				$nodeChoose.text(obj.names);
			}
		}
	});
	
	var $form = $('#form'), $reset = $('input:reset');
	// 表单验证
	var validate = $form.validate({
		submitHandler: function(form) {
			var $nodeIds = $('input[name="nodeIds"]'), $nodeId = $('input[name="nodeId"]');
			if(grapes.isEmpty($nodeIds.val())){
				alert('请选择要转移的内容原节点！'); return false;
			}
			if(grapes.isEmpty($nodeId.val())){
				alert('请选择目标节点！'); return false;
			}
			$(form).ajaxSubmit($.extend({
				success: function(result) {
					// {'status':false,'message':'message', 'store':{'id':'id'}}
					if (result) {
						if (result.status) {
							$dialog.success(result.message, function() {
								$reset.click();
							});
						}else{
							$dialog.error(result.message);
						}
					}
				}
			}, formOptions));
			
			// 阻止表单默认提交
			return false;
		}
	});
	$reset.bind('click', function () {
		reflesh();
	});
});
</script>
</body>
</html>