You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.5 KiB

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- {if $pictures}-->
<div class="clearfix" class="goods_picture"> <span class="scrleft" onmouseover="moveLeft()" onmousedown="clickLeft()" onmouseup="moveLeft()" onmouseout="scrollStop()"></span>
<div class="gallery">
<div id="demo">
<div id="demo1" style="float:left;">
<ul id="goods_gallery">
<!-- {foreach from=$pictures item=picture}-->
<li>
<a href="{if $picture.img_url}{$picture.img_url}{else}{$picture.thumb_url}{/if}" rel="zoom-id: zoom;" rev="{if $picture.img_url}{$picture.img_url}{else}{$picture.thumb_url}{/if}" title="{$picture.img_desc|escape:html}" {if $smarty.foreach.pictures.iteration eq 1}class="gallery_img_cur"{/if}>
<img src="{if $picture.thumb_url}{$picture.thumb_url}{else}{$picture.img_url}{/if}" alt="{$goods.goods_name}" class="B_blue" />
</a>
</li>
<!--{/foreach}-->
</ul>
</div>
<div id="demo2" style="display:inline; overflow:visible;"></div>
</div>
</div>
<span class="scrright" onmouseover="moveRight()" onmousedown="clickRight()" onmouseup="moveRight()" onmouseout="scrollStop()" class="spanR"></span>
<script>
function $gg(id){
return (document.getElementById) ? document.getElementById(id): document.all[id]
}
var boxwidth=60;//跟图片的实际尺寸相符
var box=$gg("demo");
var obox=$gg("demo1");
var dulbox=$gg("demo2");
obox.style.width=obox.getElementsByTagName("li").length*boxwidth+'px';
dulbox.style.width=obox.getElementsByTagName("li").length*boxwidth+'px';
box.style.width=obox.getElementsByTagName("li").length*boxwidth*6+'px';
var canroll = false;
if (obox.getElementsByTagName("li").length >= 6) {
canroll = true;
dulbox.innerHTML=obox.innerHTML;
}
var step=5;temp=1;speed=50;
var awidth=obox.offsetWidth;
var mData=0;
var isStop = 1;
var dir = 1;
function s(){
if (!canroll) return;
if (dir) {
if((awidth+mData)>=0)
{
mData=mData-step;
}
else
{
mData=-step;
}
} else {
if(mData>=0)
{
mData=-awidth;
}
else
{
mData+=step;
}
}
obox.style.marginLeft=mData+"px";
if (isStop) return;
setTimeout(s,speed)
}
function moveLeft() {
var wasStop = isStop;
dir = 1;
speed = 50;
isStop=0;
if (wasStop) {
setTimeout(s,speed);
}
}
function moveRight() {
var wasStop = isStop;
dir = 0;
speed = 50;
isStop=0;
if (wasStop) {
setTimeout(s,speed);
}
}
function scrollStop() {
isStop=1;
}
function clickLeft() {
var wasStop = isStop;
dir = 1;
speed = 25;
isStop=0;
if (wasStop) {
setTimeout(s,speed);
}
}
function clickRight() {
var wasStop = isStop;
dir = 0;
speed = 25;
isStop=0;
if (wasStop) {
setTimeout(s,speed);
}
}
</script>
</div>
<!-- {/if}-->