132 lines
6.4 KiB
Plaintext
132 lines
6.4 KiB
Plaintext
<div class="w-event_news widget-event_news-4 w-event_news widget-event_news-15" style="position:relative;">
|
|
<div class="w-event_news__more-wrap clearfix">
|
|
<h2 class="w-event_news__widget-title">
|
|
<span>{{widget-title}}</span>
|
|
</h2>
|
|
<a class="w-event_news__more btn btn-primary pull-right" href="{{more_url}}"><%= (I18n.locale.to_s =="zh_tw") ? "更多最新消息" : "More NEWS" %></a>
|
|
</div>
|
|
<div style="position: absolute;top: 50%;bottom: 50%;width:100%;">
|
|
<button class="btn-left" title = "<%= (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev" %>" style="float: left;height: 2.5em; width: 2.5em;background: url(/assets/left-01.png) no-repeat;border: 0;background-size: contain;position: absolute;transition:.3s; left: 0.6%;"></button>
|
|
<button class="btn-right" title = "<%= (I18n.locale.to_s =="zh_tw") ? "下一張" : "next" %>" style="float: right;;height: 2.5em; width: 2.5em;background: url(/assets/right-01.png) no-repeat;background-size: contain;border: 0;position: absolute;transition:.3s;right: 0.6%;"></button>
|
|
</div>
|
|
<ul class="w-event_news__list row" data-level="0" data-list="event_news">
|
|
<li class="w-event_news__item col-md-4">
|
|
<div class="w-event_news__img-wrap bullseye">
|
|
<img class="w-event_news__img" src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
|
|
</div>
|
|
<div class="w-event_news__content-wrap">
|
|
<div class="w-event_news__meta">
|
|
<span class="w-event_news__status-wrap" data-list="statuses" data-level="1">
|
|
<span class="w-event_news__status label {{status-class}}">{{status}}</span>
|
|
</span>
|
|
<span class="w-event_news__postdate-wrap" date-format="%Y-%m-%d">
|
|
<i class="fa fa-calendar-o"></i>
|
|
<span class="w-event_news__postdate">{{postdate}}</span>
|
|
</span>
|
|
<span class="w-event_news__category-wrap">
|
|
<i class="fa fa-tasks"></i>
|
|
<span class="w-event_news__category">{{category}}</span>
|
|
</span>
|
|
</div>
|
|
<h4 class="w-event_news__entry-title">
|
|
<a class="w-event_news__title" href="{{link_to_show}}">{{title}}</a>
|
|
</h4>
|
|
<p class="w-event_news__subtitle">{{subtitle}}</p>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
|
<script>
|
|
function combineul(){
|
|
for(var i=1;i<$('.widget-event_news-4 ul.w-event_news__list').length;i++)
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(0).find('>li').eq(-1).after($('.widget-event_news-4 ul.w-event_news__list').eq(i).html());
|
|
var ullength = $('.widget-event_news-4 ul.w-event_news__list').length;
|
|
for(var i = 1;i < ullength;i++)
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(-1).remove();
|
|
};
|
|
var lilength = $('.widget-event_news-4 li.w-event_news__item').length;
|
|
var num;
|
|
function reorganize(num){
|
|
combineul();
|
|
for(var i=1;i< Math.ceil(lilength/num);i++){
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(-1).after('<ul class="w-event_news__list row" data-level="0" data-list="event_news"></ul>')
|
|
var lihtml="";
|
|
//var liheight=new Array(num);
|
|
if(i != (Math.ceil(lilength/num)-1)){
|
|
for(var j=0;j<num;j++){
|
|
lihtml += "<li class='w-event_news__item col-md-4'>"+$('.widget-event_news-4 li.w-event_news__item').eq(i*num+j).html()+"</li>"
|
|
//liheight[j] = $('.widget-event_news-4 li.w-event_news__item').eq(i*num+j).height()+20;//20=>margin-top+margin-bottom
|
|
};
|
|
}else{
|
|
for(var j=0;j< lilength - num *(Math.ceil(lilength/num)-1) ;j++){
|
|
lihtml += "<li class='w-event_news__item col-md-4'>"+$('.widget-event_news-4 li.w-event_news__item').eq(i*num+j).html()+"</li>"
|
|
//liheight[j] = $('.widget-event_news-4 li.w-event_news__item').eq(i*num+j).height()+20;//20=>margin-top+margin-bottom
|
|
};
|
|
};
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(-1).html(lihtml);
|
|
};
|
|
if(Math.ceil(lilength/num) != 1 )
|
|
for(var i=0;i< lilength -num ; i++ )
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(0).find("li.w-event_news__item").eq(num).remove();
|
|
for(var i=0;i< Math.ceil(lilength/num);i++)
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(i).attr("index",i);
|
|
$('.widget-event_news-4 ul.w-event_news__list').css("display","none");
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(0).css("display","flex");
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(0).addClass("active");
|
|
$('.widget-event_news-4 ul.w-event_news__list').css('padding','0 1.125em');
|
|
$('.widget-event_news-4 button').css('z-index','10');
|
|
$('.widget-event_news-4 ul.w-event_news__list >li').css('width','calc('+100/num+'% - '+20/16+'em)'); //20px=>li的margin
|
|
$('.widget-event_news-4 ul.w-event_news__list >li').css('float','left');
|
|
};
|
|
$(window).resize(function(){
|
|
if($(window).width()>1024){
|
|
reorganize(3);
|
|
num=3;
|
|
}else if($(window).width()>576){
|
|
reorganize(2);
|
|
num=2;
|
|
}else{
|
|
reorganize(1);
|
|
num=1;
|
|
}
|
|
})
|
|
$(document).ready(function(){
|
|
if($(window).width()>1024){
|
|
reorganize(3);
|
|
num=3;
|
|
}else if($(window).width()>576){
|
|
reorganize(2);
|
|
num=2;
|
|
}else{
|
|
reorganize(1);
|
|
num=1;
|
|
}
|
|
var flag=false;
|
|
$('.btn-left').click(function(){
|
|
if(!flag){
|
|
var currentul = Number($('.widget-event_news-4 ul.w-event_news__list.active').attr("index"));
|
|
$('.widget-event_news-4 ul.w-event_news__list').css('display','none');
|
|
if(currentul - 1 < 0)
|
|
currentul += Math.ceil(lilength/num);
|
|
$('.widget-event_news-4 ul.w-event_news__list').removeClass("active");
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(currentul-1).addClass("active");
|
|
flag=true;
|
|
$('.widget-event_news-4 ul.w-event_news__list.active').eq(0).effect("slide", { direction: "left", mode: 'show', duration: 500},function(){flag=false;});
|
|
};
|
|
});
|
|
$('.btn-right').click(function(){
|
|
if(!flag){
|
|
var currentul = Number($('.widget-event_news-4 ul.w-event_news__list.active').attr("index"));
|
|
$('.widget-event_news-4 ul.w-event_news__list').css("display","none");
|
|
if(currentul + 1 > Math.ceil(lilength/num) - 1)
|
|
currentul -= Math.ceil(lilength/num);
|
|
$('.widget-event_news-4 ul.w-event_news__list').removeClass("active");
|
|
$('.widget-event_news-4 ul.w-event_news__list').eq(currentul+1).addClass("active");
|
|
flag=true;
|
|
$('.widget-event_news-4 ul.w-event_news__list.active').eq(0).effect("slide", { direction: "right", mode: 'show', duration: 500},function(){flag=false;});
|
|
};
|
|
});
|
|
});
|
|
</script>
|