前台辅助jsp goodGoods.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"  prefix="fn"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!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>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS百叶窗焦点图</title>
<script type=text/javascript src="implant/goodGoods/goodGoods.js"></script>
<style type="text/css">
/*公共样式*/
*{ margin:0; padding:0;}
body{ font-family:"宋体"; color:#666; font-size:12px; background:#fff;}
a{ color:#666; text-decoration:none;}
a:hover{ color:#666; text-decoration:none;}
a img{ border:none;}
.f_l{ float:left;}
.f_r{ float:right;}
span{ display:block;}
i{ font-style:normal;}
em{ font-style:normal;}
ul li{ list-style-type:none;}
.c{ clear:both;}

/*百叶窗焦点图样式*/
.goodGoods{ width:1198px; height:275px; border:1px solid #d9d9d9;}
.slide{ width:673px; height:;}
.slide dl{ width:673px; height:275px; position:relative; background:#fff;}
.slide dl dt{ width:311px; height:275px; float:left;}
.slide dl dt img{ padding-left:32px; padding-top:35px;}
.slide dl dd{ width:362px; height:275px; float:left;}
.slide dl dd h3{ height:32px; line-height:32px; font-family:"微软雅黑"; margin-top:28px;}
.slide dl dd h3 em{ color:#f60; font-weight:bold;}
.slide dl dd h3 a{ font-weight:normal; color:#333; text-decoration:none;}
.slide dl dd h3 a:hover{ font-weight:normal; color:#333; text-decoration:underline;}
.slide dl dd p{ color:#676767; line-height:21px; font-family:"Arial"; width:334px; height:135px; word-break:break-all;}
.slide dl dd i{ color:#676767; font-family:"Arial"; padding-right:80px;}
.slide dl .portrait{ position:absolute; left:603px; top:196px;}

/*id控制*/
#center { }
#slider { position: absolute; width: 1198px; height: 275px; overflow: hidden; top: 0px; left: 0px}
#slider .slide { position: absolute; border-left:1px solid #d9d9d9; width: 673px; height: 275px; overflow: hidden; top: 0px; cursor: default; left: 22px;text-align:left;}
#slider .title { color: #f80; font-size: 1.2em; font-weight: bold; margin-right: 1.5em; text-decoration: none;}
#slider .text {	position: absolute; text-align: justify; width: 470px; display: none; font-family: verdana, arial, helvetica, sans-serif; color: #fff; font-size: 0.9em; top: 100%; left: 10px;}
#slider .diapo { position: absolute; filter: alpha(opacity=100); visibility: visible; opacity: 1;}
#apdiv1 { z-index: 1; position: absolute; background-color: #000000; width: 820px; height: 30px; overflow: hidden; top: 0px; left: 0px;}
#apdiv2 { z-index: 3; position: absolute; width: 860px; height: 35px; overflow: hidden; top: 216px; left: -429px;}

</style>
</head>

<body>

<div id="center">
<div class="goodGoods" id="slider">
	<c:forEach var="item" items="${cList}" varStatus="i" begin="0" end="0">
	<div class=slide>
    	<dl>
        	<dt><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem1.introduce} 分类:${pItem1.classify} 品牌:${pItem1.brand} 型号: ${pItem1.model}"><img src="images/share/${piItem1.products_large }" width="250" height="187" class=diapo 
	border=0 /></a></dt>
        	<dd>
            	<h3><em>推荐度100%</em><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem1.introduce} 分类:${pItem1.classify} 品牌:${pItem1.brand} 型号: ${pItem1.model}"> ${fn:substring(pItem1.introduce,0,24)}</a></h3>
                <p>${fn:substring(item.ne_content,0,143)}...</p>
                <i class="f_r">${item.ne_user_id}</i>
            </dd>
            <img src="implant/goodGoods/portrait.jpg" width="60" height="60" class="portrait" />
        </dl>
		<div class=text></div>
    </div>
    </c:forEach>
    <c:forEach var="item" items="${cList}" varStatus="i" begin="1" end="1">
	<div class=slide>
    	<dl>
        	<dt><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem2.introduce} 分类:${pItem2.classify} 品牌:${pItem2.brand} 型号: ${pItem2.model}"><img src="images/share/${piItem2.products_large }" width="250" height="187" class=diapo 
	border=0 /></a></dt>
        	<dd>
            	<h3><em>推荐度100%</em><a href="goods?id=${item.ne_products_id}"  target="_blank"  title="${pItem2.introduce} 分类:${pItem2.classify} 品牌:${pItem2.brand} 型号: ${pItem2.model}"> ${fn:substring(pItem2.introduce,0,24)}</a></h3>
                <p>${fn:substring(item.ne_content,0,143)}...</p>
                <i class="f_r">${item.ne_user_id}</i>
            </dd>
            <img src="implant/goodGoods/portrait.jpg" width="60" height="60" class="portrait" />
        </dl>
		<div class=text></div>
    </div>
    </c:forEach>
    <c:forEach var="item" items="${cList}" varStatus="i" begin="2" end="2">
	<div class=slide>
    	<dl>
        	<dt><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem3.introduce} 分类:${pItem3.classify} 品牌:${pItem3.brand} 型号: ${pItem3.model}"><img src="images/share/${piItem3.products_large }" width="250" height="187" class=diapo 
	border=0 /></a></dt>
        	<dd>
            	<h3><em>推荐度100%</em><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem3.introduce} 分类:${pItem3.classify} 品牌:${pItem3.brand} 型号: ${pItem3.model}"> ${fn:substring(pItem3.introduce,0,24)}</a></h3>
                <p>${fn:substring(item.ne_content,0,143)}...</p>
                <i class="f_r">${item.ne_user_id}</i>
            </dd>
            <img src="implant/goodGoods/portrait.jpg" width="60" height="60" class="portrait" />
        </dl>
		<div class=text></div>
    </div>
    </c:forEach>
    <c:forEach var="item" items="${cList}" varStatus="i" begin="3" end="3">
	<div class=slide>
    	<dl>
        	<dt><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem4.introduce} 分类:${pItem4.classify} 品牌:${pItem4.brand} 型号: ${pItem4.model}"><img src="images/share/${piItem4.products_large }" width="250" height="187" class=diapo 
	border=0 /></a></dt>
        	<dd>
            	<h3><em>推荐度100%</em><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem4.introduce} 分类:${pItem4.classify} 品牌:${pItem4.brand} 型号: ${pItem4.model}"> ${fn:substring(pItem4.introduce,0,24)}</a></h3>
                <p>${fn:substring(item.ne_content,0,143)}...</p>
                <i class="f_r">${item.ne_user_id}</i>
            </dd>
            <img src="implant/goodGoods/portrait.jpg" width="60" height="60" class="portrait" />
        </dl>
		<div class=text></div>
    </div>
    </c:forEach>
    <c:forEach var="item" items="${cList}" varStatus="i" begin="4" end="4">
	<div class=slide>
    	<dl>
        	<dt><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem5.introduce} 分类:${pItem5.classify} 品牌:${pItem5.brand} 型号: ${pItem5.model}"><img src="images/share/${piItem5.products_large }" width="250" height="187" class=diapo 
	border=0 /></a></dt>
        	<dd>
            	<h3><em>推荐度100%</em><a href="goods?id=${item.ne_products_id}" target="_blank"  title="${pItem5.introduce} 分类:${pItem5.classify} 品牌:${pItem5.brand} 型号: ${pItem5.model}"> ${fn:substring(pItem5.introduce,0,24)}</a></h3>
                <p>${fn:substring(item.ne_content,0,143)}...</p>
                <i class="f_r">${item.ne_user_id}</i>
            </dd>
            <img src="implant/goodGoods/portrait.jpg" width="60" height="60" class="portrait" />
        </dl>
		<div class=text></div>
    </div>
    </c:forEach>
</div>
</div>

<script type=text/javascript>
slider.init();
</script>

</body>
</html>

 

/* ==== slider nameSpace ==== */
var slider = function() {
	/* ==== private methods ==== */
	function getElementsByClass(object, tag, className) {
		var o = object.getElementsByTagName(tag);
		for ( var i = 0, n = o.length, ret = []; i < n; i++) {
			if (o[i].className == className) ret.push(o[i]);
		}
		if (ret.length == 1) ret = ret[0];
		return ret;
	}
	function setOpacity (obj,o) {
		if (obj.filters) obj.filters.alpha.opacity = Math.round(o);
		else obj.style.opacity = o / 100;
	}
	/* ==== Slider Constructor ==== */
	function Slider(oCont, speed, iW, iH, oP) {
		this.slides = [];
		this.over   = false;
		this.S      = this.S0 = speed;
		this.iW     = iW;
		this.iH     = iH;
		this.oP     = oP;
		this.oc     = document.getElementById(oCont);
		this.frm    = getElementsByClass(this.oc, 'div', 'slide');
		this.NF     = this.frm.length;
		this.resize();
		for (var i = 0; i < this.NF; i++) {
			this.slides[i] = new Slide(this, i);
		}
		this.oc.parent = this;
		this.view      = this.slides[0];
		this.Z         = this.mx;
		/* ==== on mouse out event ==== */
		this.oc.onmouseout = function () {
			this.parent.mouseout();
			return false;
		}
	}
	Slider.prototype = {
		/* ==== animation loop ==== */
		run : function () {
			this.Z += this.over ? (this.mn - this.Z) * .5 : (this.mx - this.Z) * .5;
			this.view.calc();
			var i = this.NF;
			while (i--) this.slides[i].move();
		},
		/* ==== resize  ==== */
		resize : function () {
			this.wh = this.oc.clientWidth;
			this.ht = this.oc.clientHeight;
			this.wr = this.wh * this.iW;
			this.r  = this.ht / this.wr;
			this.mx = this.wh / this.NF;
			this.mn = (this.wh * (1 - this.iW)) / (this.NF - 1);
		},
		/* ==== rest  ==== */
		mouseout : function () {
			this.over      = false;
			setOpacity(this.view.img, this.oP);
		}
	}
	/* ==== Slide Constructor ==== */
	Slide = function (parent, N) {
		this.parent = parent;
		this.N      = N;
		this.x0     = this.x1 = N * parent.mx;
		this.v      = 0;
		this.loaded = false;
		this.cpt    = 0;
		this.start  = new Date();
		this.obj    = parent.frm[N];
		this.txt    = getElementsByClass(this.obj, 'div', 'text');
		this.img    = getElementsByClass(this.obj, 'img', 'diapo');
		this.bkg    = document.createElement('div');
		this.bkg.className = 'backgroundText';
		this.obj.insertBefore(this.bkg, this.txt);
		if (N == 0) this.obj.style.borderLeft = 'none';
		this.obj.style.left = Math.floor(this.x0) + 'px';
		setOpacity(this.img, parent.oP);
		/* ==== mouse events ==== */
		this.obj.parent = this;
		this.obj.onmouseover = function() {
			this.parent.over();
			return false;
		}
	}
	Slide.prototype = {
		/* ==== target positions ==== */
		calc : function() {
			var that = this.parent;
			// left slides
			for (var i = 0; i <= this.N; i++) {
				that.slides[i].x1 = i * that.Z;
			}
			// right slides
			for (var i = this.N + 1; i < that.NF; i++) {
				that.slides[i].x1 = that.wh - (that.NF - i) * that.Z;
			}
		},
		/* ==== HTML animation : move slides ==== */
		move : function() {
			var that = this.parent;
			var s = (this.x1 - this.x0) / that.S;
			/* ==== lateral slide ==== */
			if (this.N && Math.abs(s) > .5) {
				this.obj.style.left = Math.floor(this.x0 += s) + 'px';
			}
			/* ==== vertical text ==== */
			var v = (this.N < that.NF - 1) ? that.slides[this.N + 1].x0 - this.x0 : that.wh - this.x0;
			if (Math.abs(v - this.v) > .5) {
				this.bkg.style.top = this.txt.style.top = Math.floor(2 + that.ht - (v - that.Z) * that.iH * that.r) + 'px';
				this.v = v;
				this.cpt++;
			} else {
				if (!this.pro) {
					/* ==== adjust speed ==== */
					this.pro = true;
					var tps = new Date() - this.start;
					if(this.cpt > 1) {
						that.S = Math.max(2, (28 / (tps / this.cpt)) * that.S0);
					}
				}
			}
			if (!this.loaded) {
				if (this.img.complete) {
					this.img.style.visibility = 'visible';
					this.loaded = true;
				}
			}
		},
		/* ==== light ==== */
		over : function () {
			this.parent.resize();
			this.parent.over = true;
			setOpacity(this.parent.view.img, this.parent.oP);
			this.parent.view = this;
			this.start = new Date();
			this.cpt = 0;
			this.pro = false;
			this.calc();
			setOpacity(this.img, 100);
		}
	}
	/* ==== public method - script initialization ==== */
	return {
		init : function() {
			// create instances of sliders here
			// parameters : HTMLcontainer name, speed (2 fast - 20 slow), Horizontal ratio, vertical text ratio, opacity
			this.s1 = new Slider("slider", 12, 1.84/3, 1/3.2, 70);
			setInterval("slider.s1.run();", 16);
		}
	}
}();

 

效果图:
前台辅助jsp goodGoods.jsp_第1张图片
 

 

 

 

 

你可能感兴趣的:(jsp)