<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = path + "/common/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>素材列表</title>
<link rel="shortcut icon" href="images/wx/wally.jpg"/>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/admin/css/keyset/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/admin/css/keyset/appmsg.css">
<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/admin/css/keyset/theme.css">
<link rel="stylesheet" href="<%=basePath %>/css/admin/css/keyset/font-awesome.css">
<script type="text/javascript" src="<%=basePath %>/js/admin/public/jquery-1.7.2.min.js" ></script>
<script type="text/javascript" src="<%=basePath %>/js/admin/public/bootstrap.js" ></script>

<!-- Demo page code -->
<style type="text/css">
.pagination {
	margin: 0 70px;
	float: right;
}
#first_col {
	display: inline-block;
	zoom: 1;
	*display: inline;
}
#second_col {
	margin-left: 15px;
	display: inline-block;
	zoom: 1;
	*display: inline;
}
.add-btn {
	height: 90px;
	margin: 0 18px;
	color: #b5b5b5;
	background: transparent
		url('/image/admin/body/appmsg-icon.png')
		no-repeat 50% -242px;
}
.multi-access {
	background-position: 50% -342px;
}
ul {
	padding: 0;
	margin: 0;
}
li {
	list-style-type: none;
}
.sub-msg-item {
	padding: 12px 14px;
	overflow: hidden;
	zoom: 1;
	border-top: 1px solid #c6c6c6;
}
.thumb {
	float: right;
	font-size: 0;
}
.thumb .default-tip {
	font-size: 16px;
	color: #c0c0c0;
	width: 70px;
	line-height: 70px;
	border: 1px solid #b2b8bd;
}
.thumb img {
	width: 70px;
	height: 70px;
	border: 1px solid #b2b8bd;
}
.sub-msg-item .msg-t {
	margin-left: 0;
	margin-right: 85px;
	margin-top: 0;
	padding-left: 4px;
	padding-top: 12px;
	line-height: 24px;
	max-height: 48px;
	font-size: 14px;
	overflow: hidden;
}
.sltpic {
	background-color: #82FF8C;
}
</style>

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<script type="text/javascript">
//点击选中图文
function showImg(idx,rid,f){
	var id = f + rid, html = $('#'+id).html(), picid = $("#picid").val();
	$("#picid").val(id);
	if(picid != id){
		$('#_'+picid).removeClass("sltpic");
	}
	$('#_'+id).addClass("sltpic");
	$("#html").val(html);
	$("#rid").val(rid);
	//alert('请点击图文后再点击【确定】按钮!');
	//alert('id = '+id+'<br> html = '+html);
}
//确定选中图文
function slt(){
	//弹窗改为window.open()解决谷歌浏览器不支持弹窗的特性（原做法是windin.showModalDialog()）
	/*var array = new Array();
	array[0] = $("#html").val();
	array[1] = $("#rid").val();
	window.returnValue = array;*/
	//把当前页面中选择的图文在父页面中显示
	this.opener.document.getElementById("preViewDiv").innerHTML = $("#html").val();
	this.opener.document.getElementById("picandtext").value = $("#rid").val();
	window.close();
}
</script>
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body class="">
	<input type="hidden" id="picid">
	<input type="hidden" id="html"/>
	<input type="hidden" id="rid"/>
	<div class="content">
		<div class="container-fluid">
			<div class="container">
		<div class="containerBox">
			<div class="boxHeader">
				<h4>图文素材</h4>
			</div>
			<div class="content">
				<h3 class="page-sub-hd">
					图文列表(共<span id="total_count">${totalCount}</span>条)
				</h3>
				<div class="group page-nav">
					<div class="pagination">
						<ul>
<%
	String start = (String) request.getAttribute("start");
	Integer totalCount = (Integer) request.getAttribute("totalCount");
	//System.out.println("start: " + start + " == total: " + totalCount);
	Integer currPage = Integer.parseInt(start) / 10;
	Integer totalPage = totalCount / 10;
	if(currPage == 0) {
%>
							<li class="disabled"><span>上一页</span></li>
<%		
	} else {
%>
							<li><a
								href="<%=basePath %>admin/material/list?start=<%=Integer.parseInt(start) - 10 %>&limit=10">上一页</a></li>
							<%
	}
	for (int i = 0; i < totalPage + 1; i++) {
		if (i == currPage) {
		%>
							<li class="active"><span><%=i + 1 %></span></li>
							<%
		} else {
		%>
							<li><a
								href="<%=basePath %>admin/material/list?start=<%=i * 10 %>&limit=10"><%=i + 1 %></a></li>
							<%
		}
	}
	
	if( currPage < totalPage) {
%>
							<li><a
								href="<%=basePath %>admin/material/list?start=<%=(currPage + 1) * 10  %>&limit=10">下一页</a></li>
							<%
	}
%>
						</ul>
					</div>
					<div class="clr"></div>
				</div>
				
				<div class="page-bd">
					<div class="tj msg-list">
								<!-- 偶数内容 -->
								<div id="first_col" class="b-dib vt msg-col">
									<c:forEach items="${resultList }" var="entry" varStatus="st">
										<c:choose>
											<c:when test="${st.index%2==0}">
												<c:choose>
													<c:when test="${entry.imagetexttype==2}">
														<div class="msg-item-wrapper" id="evmore${entry.imagetextno}" onclick="showImg('${st.index}','${entry.imagetextno}','evmore')">
															<div class="msg-item multi-msg" id="_evmore${entry.imagetextno}">
																<div class="appmsgItem">
																	<h4 class="msg-t">
																		<a href="javascript:void();" class="i-title" target="_blank">${entry.title}</a>
<%-- 																		<a href="<%=basePath %>admin/material/detail?type=1&id=${entry.imagetextno}" class="i-title" target="_blank">${entry.title}</a> --%>
																	</h4>
																	<p class="msg-meta">
																		<span class="msg-date"><fmt:formatDate value="${entry.createtime}"/></span>
																	</p>
																	<div class="cover">
																		<p class="default-tip" style="display: none">封面图片</p>
																		<img src="${entry.imageurl}" class="i-img" style="">
																	</div>
																	<p class="msg-text"></p>
																</div>

																<c:forEach items="${entry.subVoList }" varStatus="s" var="sub">
																	<!-- 子图文：封面url,id -->
																	<div class="rel sub-msg-item appmsgItem">
																		<span class="thumb"> <img src="${sub.imageUrl}" class="i-img" style="">
																		</span>
																		<h4 class="msg-t">
																			<a href="javascript:void();" target="_blank" class="i-title">${sub.title}</a>
																		</h4>
																	</div>
																</c:forEach>
															</div>
														</div>
													</c:when>
													<c:otherwise>
														<div class="msg-item-wrapper" id="evone${entry.imagetextno}" onclick="showImg('${st.index}','${entry.imagetextno}','evone')">
															<div class="msg-item" id="_evone${entry.imagetextno}">
																<!-- 详细地址id，创建时间，封面url,删除编辑的data-rid -->
																<h4 class="msg-t">
																	<a href="javascript:void();" class="i-title" target="_blank">${entry.title}</a>
<%-- 																	<a href="<%=basePath %>admin/material/detail?type=1&id=${entry.imagetextno}" class="i-title" target="_blank">${entry.title}</a> --%>
																</h4>
																<p class="msg-meta">
																	<span class="msg-date"><fmt:formatDate value="${entry.createtime}"/></span>
																</p>
																<div class="cover">
																	<p class="default-tip" style="display: none">封面图片</p>
																	<img src="${entry.imageurl}" class="i-img" style="">
																</div>
																<%-- <p class="msg-text">${entry.digest}</p> --%>
															</div>
														</div>
													</c:otherwise>
												</c:choose>
											</c:when>
										</c:choose>
									</c:forEach>
								</div>

								<!-- 奇数内容 -->
								<div id="second_col" class="b-dib vt msg-col">
									<c:forEach items="${resultList}" var="entry" varStatus="st">
										<c:choose>
											<c:when test="${st.index%2!=0}">
												<c:choose>
													<c:when test="${entry.imagetexttype==2}">
														<div class="msg-item-wrapper" id="odmore${entry.imagetextno}" onclick="showImg('${st.index}','${entry.imagetextno}','odmore')">
															<div class="msg-item multi-msg" id="_odmore${entry.imagetextno}">
																<div class="appmsgItem">
																	<h4 class="msg-t">
																		<a href="javascript:void();" class="i-title" target="_blank">${entry.title}</a>
<%-- 																		<a href="<%=basePath %>admin/material/detail?type=1&id=${entry.imagetextno}" class="i-title" target="_blank">${entry.title}</a> --%>
																	</h4>
																	<p class="msg-meta">
																		<span class="msg-date"><fmt:formatDate value="${entry.createtime}"/></span>
																	</p>
																	<div class="cover">
																		<p class="default-tip" style="display: none">封面图片</p>
																		<img src="${entry.imageurl}" class="i-img" style="">
																	</div>
																	<p class="msg-text"></p>
																</div>

																<c:forEach items="${entry.subVoList}" varStatus="s" var="sub">
																	<!-- 子图文：封面url,id -->
																	<div class="rel sub-msg-item appmsgItem">
																		<span class="thumb"> <img src="${sub.imageUrl}" class="i-img" style="">
																		</span>
																		<h4 class="msg-t">
																			<a href="javascript:void();" target="_blank" class="i-title">${sub.title}</a>
<%-- 																			<a href="<%=basePath %>admin/material/detail?type=2&id=${sub.moreImageTextNo}" target="_blank" class="i-title">${sub.title}</a> --%>
																		</h4>
																	</div>
																</c:forEach>
															</div>
														</div>
													</c:when>
													<c:otherwise>
															<div class="msg-item-wrapper" id="odone${entry.imagetextno}" onclick="showImg('${st.index}','${entry.imagetextno}','odone')">
																<div class="msg-item" id="_odone${entry.imagetextno}">
																<!-- 详细地址id，创建时间，封面url,删除编辑的data-rid -->
																<h4 class="msg-t">
																	<a href="javascript:void();" class="i-title" target="_blank">${entry.title}</a>
<%-- 																	<a href="<%=basePath %>admin/material/detail?type=1&id=${entry.imagetextno}" class="i-title" target="_blank">${entry.title}</a> --%>
																</h4>
																<p class="msg-meta">
																	<span class="msg-date"><fmt:formatDate value="${entry.createtime}"/></span>
																</p>
																<div class="cover">
																	<p class="default-tip" style="display: none">封面图片</p>
																	<img src="${entry.imageurl}" class="i-img" style="">
																</div>
																<p class="msg-text">${entry.digest}</p>
															</div>
														</div>
													</c:otherwise>
												</c:choose>
											</c:when>
										</c:choose>
									</c:forEach>

								</div>
								<!-- 奇数内容结束 -->
							</div>
				</div>
				<!-- page_bg 结束 -->

			</div>
			<!-- content 结束 -->
			<!--  	
			<div class="sideBar">
			   	<div class="menu">
			   		<ul class="nav nav-list">
					  <li class="active"><a href="/admin/content/article?action=list" target="main">图文消息(8)</a></li>
					  <li><a href="/admin/content/voice?action=list" target="main">语音(120)</a></li>
					  <li><a href="account/pay.jsp" target="main">视频(0)</a></li>
					</ul>
			   	</div>
			</div>
-->
			<div class="clr"></div>
		</div>
	</div>
	</div>
	</div>
<div style="position: fixed; top: 90%; left: 80%;">
	<input type="button" class="btn btn-primary" value="确定" onclick="slt();" />
	<input type="button" class="btn" value="取消" onclick="javascript:window.close();" />
</div>
</body>
</html>
