<%@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">
</head>
<body>
<div id="wrapper">
  <div class="push">
    <ul class="list-info">
      <gen:if test="${not empty list}">
        <li>&nbsp;
          <label>
            <input type="checkbox" name="check" for="id" value="0">
            全选/取消</label>
        </li>
        <c:forEach items="${list}" var="map">
          <li title="${map.name}">&nbsp;
            <label>
              <input type="checkbox" name="id" value="${map.id}">
              ${map.name}
            </label>
          </li>
        </c:forEach>
        <gen:else />
        <li>&nbsp;暂无数据</li>
      </gen:if>
    </ul>
  </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>
<!-- 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">
// document.domain = "jspgen.com";// 调用
$(document).ready(function(){
	// 变量
	var $check = $('input[name="check"]');
	var $checkItem = $('input[name="'+$check.attr('for')+'"]');
	
	// 全选/反选
	$check.bind('click', function () {
		var $this = $(this);
		return grapes.check($this, $this.attr('for'));
	});
	// checkItem
	$checkItem.bind('click', function () {
		$check.prop("checked", $checkItem.length == $checkItem.filter(':checked').length);
	});
	
	// 默认值
	var $idsArr = '${param.ids}'.split(',');
	if(grapes.isNotEmpty($idsArr)){
		$checkItem.each(function() {
			var value = $(this).attr('value');
			if(grapes.inArray(value, $idsArr)) $(this).prop('checked', true);
		});
	}
	
	// 确定按钮(批量)
	$dialogApi.button({id:'valueOk', name:'确定', callback:ok});
	function ok() {
		var arr = [];
		$checkItem.filter(':checked').each(function(){
			var obj = {}, $li = $(this).closest('li');
			obj.id = $(this).prop('value');
			obj.name = $li.prop('title');
			arr.push(obj);
		});
		$dialogApi.callback(arr);
		//$dialogApi.close();
	}
});
</script>
</body>
</html>