Widget:Carousel:修订间差异
来自OGAS数据中枢
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第9行: | 第9行: | ||
.dot.active{background:#fff;transform:scale(1.2)} | .dot.active{background:#fff;transform:scale(1.2)} | ||
</style> | </style> | ||
<div class="w-c" id="carousel" data-w="<!--{$width}-->"> | <div class="w-c" id="carousel" data-w="<!--{$width|default:'100%'}-->" data-t="<!--{$thumb|default:'1000'}-->"> | ||
<button class="c-n n-p" onclick="mv(-1)">❮</button> | <button class="c-n n-p" onclick="mv(-1)">❮</button> | ||
<button class="c-n n-n" onclick="mv(1)">❯</button> | <button class="c-n n-n" onclick="mv(1)">❯</button> | ||
| 第27行: | 第27行: | ||
<script> | <script> | ||
(function(){ | (function(){ | ||
var b='/wiki/',c=document.getElementById('carousel'),is=c.querySelectorAll('.i'),ls=c.querySelectorAll('.l'),dc=document.getElementById('dots-ctx') | var b='/wiki/',c=document.getElementById('carousel'),is=c.querySelectorAll('.i'),ls=c.querySelectorAll('.l'),dc=document.getElementById('dots-ctx'); | ||
var tw=parseInt(c.dataset.t)||1000; | |||
for(var i=0;i<is.length;i++){ | for(var i=0;i<is.length;i++){ | ||
is[i].src=b+'Special:FilePath/'+encodeURIComponent(is[i].dataset.f.trim())+'?width='+ | is[i].src=b+'Special:FilePath/'+encodeURIComponent(is[i].dataset.f.trim())+'?width='+tw; | ||
if(ls[i].dataset.t)ls[i].href=b+encodeURIComponent(ls[i].dataset.t.trim()); | if(ls[i].dataset.t)ls[i].href=b+encodeURIComponent(ls[i].dataset.t.trim()); | ||
var d=document.createElement('div');d.className='dot'+(i===0?' active':'');d.onclick=(function(idx){return function(){gs(idx)}})(i);dc.appendChild(d); | var d=document.createElement('div');d.className='dot'+(i===0?' active':'');d.onclick=(function(idx){return function(){gs(idx)}})(i);dc.appendChild(d); | ||
| 第50行: | 第51行: | ||
} | } | ||
var t=setInterval(function(){mv(1)},5000); | var t=setInterval(function(){mv(1)},5000); | ||
document.getElementById('carousel').onmouseenter=function(){clearInterval(t)}; | |||
document.getElementById('carousel').onmouseleave=function(){t=setInterval(function(){mv(1)},5000)}; | |||
</script> | </script> | ||
</includeonly> | </includeonly> | ||