add setting

This commit is contained in:
chiu 2021-09-05 18:56:57 +08:00
parent df5d702633
commit cb51768c5a
16 changed files with 1383 additions and 330 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,601 @@
var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
_this = this;
var events = {}
var template = dom.find(".month_template"),
month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"],
monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'],
initialDate = date,
subpartid = subpart,
index_url = url,
fetchInterval = null,
month = date.getMonth(),
year = date.getFullYear(),
first_target_day = new Date(Date.UTC(year,month,1)),
last_target_day = new Date(Date.UTC(year,month+1,0)),
firstDay = new Date(Date.UTC(year,month,1)),
lastDay = new Date(Date.UTC(year,month+1,0)),
today = date.getDate(),
last_inserted_date = 1,
monthDom = $("<div data-year='"+year+"' data-month='"+month+"'></div>"),
eventHTML = dom.find('div.calendar-events')[0],
event_template = dom.find('div.calendar-events .event').prop('outerHTML'),
prevMonthFunc,
nextMonthFunc,
toggle_data,
hover_step=10,
hover_step_max=10,
hover_max_height=19.2,
toggling=false,
switching=false,
tp1,
tp2;
monthDom.html(template);
var format_time = function(date){
var hours = date.getHours(),
minutes = date.getMinutes();
if (hours < 10) {hours = "0"+hours}
if (minutes < 10) {minutes = "0"+minutes}
return hours+':'+minutes;
}
function rgb2hex(rgb) {
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
if (rgb){
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}else{
return "#000000";
}
}
function hexToRGB(hex, alpha) {
if (hex){
var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16);
if (alpha) {
return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
} else {
return "rgb(" + r + ", " + g + ", " + b + ")";
}
}else{
return ''
}
}
function lighten_color(my_hex,percent){
if (my_hex[0] == '#'){
my_hex = my_hex.slice(1)
}
var comp = ''
var rgb = []
var batch_size = Math.ceil(my_hex.length/3)
for (var i=0;i<3;i++){
rgb.push(my_hex.slice(batch_size*i,batch_size*(i+1)))
}
$.each(rgb,function(){
var a = this
var tmp
tmp = Math.ceil(parseInt(a,16)*(1+percent/100))
if (tmp>255) tmp = 255
if (tmp < 0) tmp = 0
tmp = tmp.toString(16)
for (var i=0;i<2-tmp.length;i++){
tmp = '0' + tmp
}
comp = comp + tmp
})
return '#'+comp
}
var format_date = function(date){
var y = date.getFullYear(),
m = date.getMonth() + 1,
d = date.getDate();
if (m < 10) {m = "0"+m}
if (d < 10) {d = "0"+d}
return y+'/'+m+'/'+d;
}
var formate_datetime = function(date){
date = new Date(date)
return [format_date(date),format_time(date)]
}
$(window).resize(function(){
var window_w = $(window).width()
$('.widget-calendar-2 div.calendar-events').each(function(){
var this_w = $(this).parents('.widget-calendar-2').width()
if (this_w>=728 && window_w>=768){
if (!$(this).hasClass('width-50')){
$(this).removeClass('width-100')
$(this).addClass('width-50')
$(this).css('width','50%')
$(this).parents('div[data-module="calendar"]').find('div').eq(0).css('width','50%')
}
}else{
if (!$(this).hasClass('width-100')){
$(this).addClass('width-100')
$(this).removeClass('width-50')
$(this).css('width','100%')
$(this).parents('div[data-module="calendar"]').find('div').eq(0).css('width','100%')
}
}
})
})
var show_event = function(date,ele){
var event_div = $(ele).parents('div[data-module="calendar"]').find('div.calendar-events')
$(ele).parents('.w-calendar').find('td.shown').removeClass('shown')
$(ele).addClass('shown')
function set_event(date,active_flag){
var date_split = date.split('-')
var event_temp = $(event_template)
var read_more_text = $('html').attr('lang')=='zh_tw' ? '查看詳情' : 'Read more'
event_temp.find('.event-header .date .month').text(month_names[parseInt(date_split[1])])
event_temp.find('.event-header .date .day').text(parseInt(date_split[0]))
$.each(events[date],function(k,v){
var tp
if (v.url_linked==''){
var time_string = ''
if(v.allDay) {
var end_time
var start_time = formate_datetime(v.start)[0]
if(v.end)
end_time = formate_datetime(v.end)[0]
else
end_time = start_time
time_string = (start_time==end_time ? "<p class='start-date'><i class='icons-calendar' /> " + start_time + "</p>" : "<i class='icons-calendar' /> " + start_time + " <i class='icons-arrow-right-5' /> " + end_time + "")
}else{
var st = formate_datetime(v.start),
et = formate_datetime(v.end),
start_time = st[0],
end_time = et[0],
same = (start_time==end_time),
etime = et[1],
stime = st[1]
time_string = (same ? "<p class='date'><i class='icons-calendar' /> " + start_time + "</p><p class='time'><i class='icons-clock' /> " + stime + " <i class='icons-arrow-right-5' /> " + etime : "<p class='start-date'><i class='icons-arrow-right-2' /> " + start_time + "<span class='pull-right'>" + stime + "</span></p><p class='end-date'><i class='icons-arrow-left-2' /> " + end_time + "<span class='pull-right'>" + etime + "</p>");
}
var modal_tp = ('<div class="dialog_event" style="display: none;">' +
'<div class="modal-header">' +
'<h3>' + v.title + '</h3>' +
'</div>' +
'<div class="modal-body">' +
'<div class="event_summary">' + time_string + '</div>' +
v.note +
'</div>' +
'</div>')
tp = $('<div class="event-container-one has-dialog"><div class="title_temp"></div><div class="duration_temp"></div><div class="event-content"></div>'+modal_tp+'</div>')
}else{
tp = $('<a class="event-container-one"><div class="title_temp"></div><div class="duration_temp"></div><div class="event-content"></div></a>').attr('href',v.url_linked)
}
var sd = formate_datetime(v.start),
ed = formate_datetime(v.end),
duration = '';
if(v.allDay){
if (sd[0]!=ed[0]){
duration = sd[0]+'>'+ed[0] +'<br>'
}
}else if (sd[0]==ed[0]){
duration = sd[1]+'>'+ed[1] +'<br>'
}else{
duration = sd[0]+' '+sd[1]+'>'+ed[0]+' '+ed[1] +'<br>'
}
tp.css('color',hexToRGB(v.color,0.45))
tp.find('.event-content').html(v.note || read_more_text)
tp.find('.title_temp').html(v.title)
tp.find('.duration_temp').html(duration)
if (k==0){
tp.addClass('active')
event_temp.find('.event-header .event-inner-title').html(v.title)
event_temp.find('.event-header .duration').html(duration)
}
event_temp.find('.event-containers').append(tp)
})
if (active_flag){
event_temp.addClass('active')
}
if (events[date] && events[date].length>1){
var switch_button_wraper = $("<div class=\"switch_button_wraper\"> <button class=\"switch_button\" for=\"prev\" type=\"button\">&lt;</button>"
+"<button class=\"switch_button\" for=\"next\" type=\"button\">&gt;</button>"
+"</div>")
switch_button_wraper.find('button').click(function(){
if (!switching){
var showing_event = $(this).parents('.event-wraper').find('.event-container-one.active')
var next_event
showing_event.css('position','')
showing_event.css('right','0')
showing_event.removeClass('active')
if ($(this).attr('for')=='prev'){
next_event = showing_event.prev('.event-container-one')
if (next_event.length==0){
next_event = $(this).parents('.event-wraper').find('.event-container-one').eq(-1)
}
next_event.addClass('active')
next_event.css('right','100%')
switching = true
next_event.animate({'right': '0%'},function(){
$(this).css('right','')
if ($(this).find('.event-content').height()>$(this).height()){
$(this).css('position','relative')
}
})
showing_event.animate({'right': '-100%'},function(){
switching = false
})
}else{
next_event = showing_event.next('.event-container-one')
if (next_event.length==0){
next_event = $(this).parents('.event-wraper').find('.event-container-one').eq(0)
}
next_event.addClass('active')
next_event.css('right','-100%')
switching = true
next_event.animate({'right': '0%'},function(){
$(this).css('right','')
if ($(this).find('.event-content').height()>$(this).height()){
$(this).css('position','relative')
}
})
showing_event.animate({'right': '100%'},function(){
switching = false
})
}
$(this).parents('.event').eq(0).find('.event-header .event-inner-title').html(next_event.find('.title_temp').html())
$(this).parents('.event').eq(0).find('.event-header .duration').html(next_event.find('.duration_temp').html())
}
})
event_temp.find('.event-wraper').eq(0).append(switch_button_wraper)
}
event_div.append(event_temp)
}
event_div.html('')
set_event(date,true)
var all_event_in_table = $(ele).parents('table').eq(0).find('td.w-calendar-event')
var ele_index = all_event_in_table.index(ele)
var next_ele = all_event_in_table.eq(ele_index+1)
if (next_ele.length){
set_event(next_ele.data('date-node'),false)
}
event_div.find('.has-dialog').click(function(){
var tmp=$(this).find('.dialog_event').clone().dialog({dialogClass: 'calendar-dialog'});
$('.ui-dialog button').blur();
})
function event_hover(){
if (!$(this).hasClass('active')){
tp1 = $(this).parents('.calendar-events').eq(0).find('.event.active .event-containers')
tp2 = $(this).find('.event-containers')
if (!toggling){
tp2.css('height','0')
tp2.css('min-height','0')
hover_step = hover_step_max
}else{
hover_step = hover_step_max - hover_step
}
$(this).addClass('active')
function toggle_height(){
tp1.css('height',(hover_step*hover_max_height/hover_step_max)+'em')
tp2.css('height',(hover_max_height-hover_step*hover_max_height/20)+'em')
hover_step = hover_step-1;
if (hover_step>=0){
setTimeout(toggle_height,50)
}else{
tp1.css('min-height','')
tp2.css('min-height','')
tp1.css('height','')
tp2.css('height','')
toggling = false
}
}
if (!toggling){
setTimeout(toggle_height,50)
}
tp1.css('height',tp1.height())
tp1.css('min-height','0')
tp1.parents('.event').removeClass('active')
toggling = true
}
}
event_div.find('.event').hover(event_hover)
event_div.find('.event').click(event_hover)
$(ele).parents('div[data-module="calendar"]').css('display','flex')
if ($(ele).parents('div[data-module="calendar"]').width()>=728 && $(window).width()>=768){
event_div.css('width','50%')
event_div.addClass('width-50')
event_div.removeClass('width-100')
$(ele).parents('div[data-module="calendar"]').find('div').eq(0).css('width','50%')
}else{
event_div.css('width','100%')
event_div.addClass('width-100')
event_div.removeClass('width-50')
$(ele).parents('div[data-module="calendar"]').find('div').eq(0).css('width','100%')
}
event_div.show()
}
var hide_event = function(ele){
$(ele).parents('.w-calendar').find('td.shown').removeClass('shown')
var event_div = $(ele).parents('div[data-module="calendar"]').find('div.calendar-events')
$(ele).parents('div[data-module="calendar"]').css('display','block')
$(ele).parents('div[data-module="calendar"]').find('div').eq(0).css('width','')
event_div.hide()
//$(ele).parents('div[data-module="calendar"]').find('td.w-calendar-toggle').removeClass('w-calendar-toggle')
event_div.find('.event-container-one').remove()
}
var renderMonth = function(){
var num_of_rows = getNumberOfRows(),
head_title = monthDom.find("h4 span.text"),
table_body = monthDom.find("table.table tbody");
table_body.html("");
for(var i = 0; i < num_of_rows; i++){
var tr = null;
if(i == 0){
tr = makeRow("first");
}else if(i == (num_of_rows - 1)){
tr = makeRow("last");
}else{
tr = makeRow("middle");
}
if(tr == null){
break;
}
table_body.append(tr);
head_title.text(monthNames[firstDay.getMonth()] + " " + firstDay.getFullYear());
}
}
var getNumberOfRows = function() {
var day = 1,
sat_counter = 0,
sunday_counter = 0,
date = new Date(year, month, day);
while(date.getMonth() === month) {
if(date.getDay() === 0) {
sunday_counter++;
}else if(date.getDay() === 6) {
sat_counter++;
}
day++;
date = new Date(year, month, day);
}
return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5);
}
var makeRow = function(position){
if(last_inserted_date <= lastDay.getDate()){
var row = $("<tr></tr>");
switch (position){
case "first":
var first_line_first_day = new Date(year,month,firstDay.getDate()-firstDay.getDay())
var first_line_first_date = first_line_first_day.getDate()
var first_line_first_month = first_line_first_day.getMonth()
var first_line_first_year = first_line_first_day.getFullYear()
first_target_day = new Date(first_line_first_year,first_line_first_month,first_line_first_date)
for(var i = 0;i < 7;i++){
var td = $("<td><div></div></td>");
if(i >= firstDay.getDay()){
if(today != 0 && last_inserted_date == today){
td.addClass("w-calendar-today");
}
td.find('div').html(last_inserted_date<10 ? "&nbsp;"+last_inserted_date+"&nbsp;" : last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
}else{
td.find('div').text(first_line_first_date+i)
td.attr("data-date-node",(first_line_first_date+i)+"-"+first_line_first_month+"-"+first_line_first_year);
td.addClass("w-calendar-other-month")
}
row.append(td);
}
break;
case "middle":
for(var i = 0;i < 7;i++){
var td = $("<td><div></div></td>");
if(today != 0 && last_inserted_date == today){
td.attr("class","w-calendar-today");
}
td.find('div').html(last_inserted_date<10 ? "&nbsp;"+last_inserted_date+"&nbsp;" : last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
row.append(td);
}
break;
case "last":
var next_month = month+1,
next_year = year;
if (next_month==12){
next_month = 0;
next_year = next_year + 1;
}
last_target_day = new Date(next_year,next_month,6-lastDay.getDay())
for(var i = 0;i < 7;i++){
var td = $("<td><div></div></td>");
if(i <= lastDay.getDay()){
if(today != 0 && last_inserted_date == today){
td.attr("class","w-calendar-today");
}
td.find('div').html(last_inserted_date<10 ? "&nbsp;"+last_inserted_date+"&nbsp;" : last_inserted_date);
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
last_inserted_date++;
}else{
td.find('div').text(i-lastDay.getDay())
td.attr("data-date-node",(i-lastDay.getDay())+"-"+next_month+"-"+next_year);
td.addClass("w-calendar-other-month")
}
row.append(td);
}
break;
}
}else{
var row = null;
}
return row;
}
function toggle_event(ele,type){
$(ele).parents('.month_template').find('td').removeClass('w-calendar-toggle')
var toggle_month
if ($(ele).length==1){
$(ele).addClass('w-calendar-toggle')
toggle_data = $(ele).data('date-node')
toggle_month = $(ele).data('date-node').split('-')[1]
}
if (toggle_month==month || $(ele).length!=1){
if (type=='show'){
show_event($(ele).data('date-node'),ele)
}else{
hide_event(ele)
}
}
else if(toggle_month==month+1 || toggle_month==0){
nextMonthFunc(toggle_data)
}else{
prevMonthFunc(toggle_data)
}
}
var fetchEvents = function(){
var usd = Math.round(firstDay/1000),
usd_target = Math.round(first_target_day/1000),
ued_target = Math.round(last_target_day/1000);
$.ajax({
url : "/xhr/event_news/agenda",
data : {"month_start" : usd,"unix_start" : usd_target, "unix_end" : ued_target, "subpart_id" : subpartid, "locale" : $('html').attr('lang')},
dataType : "json",
type : "get"
}).done(function(data){
events = {}
$(dom).find('.w-calendar-title span').eq(-1).html(data['calendar_title'])
$.each(data.events,function(index,eve){
var sd = new Date(eve.start),
ed = new Date(eve.end),
sd_date = new Date(formate_datetime(eve.start)[0]),
ed_date = new Date(formate_datetime(eve.end)[0]),
timeDiff = ed_date.getTime() - sd_date.getTime(),
dayDiff = Math.round(timeDiff / (1000 * 3600 * 24));
if(eve.allDay && dayDiff < 1){
dayDiff = 1
}
if(dayDiff > 0){
var inserting_date = sd.getDate();
for(var i = 0;i <= dayDiff; i++){
var dt = inserting_date + "-" + sd.getMonth() + "-" + sd.getFullYear(),
td = dom.find("td[data-date-node=" + dt + "]");
if (events[dt]==undefined){
events[dt]=[]
}
events[dt].push(eve)
td.addClass("w-calendar-event");
if(events[dt] && events[dt].length==1){
td.click(function(){
toggle_event(this,'show')
})
}
inserting_date++;
if(inserting_date > lastDay.getDate() || (ed.getMonth() == month && inserting_date > ed.getDate())){
break;
}
}
}else{
var dt = sd.getDate() + "-" + sd.getMonth() + "-" + sd.getFullYear();
td = dom.find("td[data-date-node=" + dt + "]");
if (events[dt]==undefined){
events[dt]=[]
}
events[dt].push(eve)
if(events[dt] && events[dt].length==1){
td.click(function(){
toggle_event(this,'show')
})
}
td.addClass("w-calendar-event");
}
})
if (!toggle_data){
if (dom.find('td.w-calendar-today').length != 0){
toggle_event(dom.find('td.w-calendar-today'),'show')
}else{
toggle_event(dom.find('td'),'hide')
}
}
dom.find('td:not(td.w-calendar-event)').click(function(){
toggle_event(this,'hide')
})
var clicked_color = dom.find('.w-calendar-event').css('background-color')
if (clicked_color){
var hex_color = rgb2hex(clicked_color)
if (hex_color != '#000000'){
clicked_color = lighten_color(hex_color,-45)
dom.find('table').append($('<style>.widget-calendar-2 table.w-calendar-table .w-calendar-toggle{ background-color:'+clicked_color+';color: white;}</style>'))
}
}
monthDom.find("i.loading").addClass("hide");
})
}
this.currentMonth = function(){
renderMonth();
var div_tag = $('<div></div>')
var widge_title = dom.find('.w-calendar-title').eq(0)
div_tag.html(monthDom)
div_tag.prepend(widge_title)
dom.html(div_tag);
monthDom.find("i.loading").removeClass("hide");
fetchInterval = setTimeout(fetchEvents,300);
dom.find('div').eq(0).after(eventHTML)
}
this.nextMonth = function(toggle_flag){
clearTimeout(fetchInterval);
monthDom.find("i.loading").removeClass("hide");
month++;
if(month == 12){
year++;
month = 0;
}
firstDay = new Date(Date.UTC(year,month,1));
lastDay =new Date(Date.UTC(year,month+1,0));
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
last_inserted_date = 1;
var toggle_type,ele;
if (toggle_data && toggle_flag){
ele = dom.find('td[data-date-node="'+toggle_data+'"]')
toggle_type = (ele.hasClass('w-calendar-event') ? 'show' : 'hide')
}else{
toggle_data = undefined
}
renderMonth();
dom.find("table.w-calendar-table tbody").html(monthDom.find("tbody").html());
if (ele){
ele = dom.find('td[data-date-node="'+toggle_data+'"]')
toggle_event(ele,toggle_type)
}
fetchInterval = setTimeout(fetchEvents,300);
}
nextMonthFunc = this.nextMonth;
this.prevMonth = function(toggle_flag){
clearTimeout(fetchInterval);
monthDom.find("i.loading").removeClass("hide");
month--;
if(month == -1){
year--;
month = 11;
}
firstDay = new Date(Date.UTC(year,month,1));
lastDay = new Date(Date.UTC(year,month+1,0));
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
last_inserted_date = 1;
var toggle_type,ele;
if (toggle_data && toggle_flag){
ele = dom.find('td[data-date-node="'+toggle_data+'"]')
toggle_type = (ele.hasClass('w-calendar-event') ? 'show' : 'hide')
}else{
toggle_data = undefined
}
renderMonth();
dom.find("table.w-calendar-table tbody").html(monthDom.find("tbody").html());
if (ele){
ele = dom.find('td[data-date-node="'+toggle_data+'"]')
toggle_event(ele,toggle_type)
}
fetchInterval = setTimeout(fetchEvents,300);
}
prevMonthFunc = this.prevMonth;
}

View File

@ -0,0 +1,234 @@
.widget-event-news-calendar-2.w-calendar{
.w-calendar-table {
table-layout: fixed;
width: 100%;
}
a.event-container-one{
color: inherit;
}
.close_box{
font-weight: bold;
position: relative;
float: right;
padding: 0.5em;
cursor: pointer;
}
.close_box:hover{
color: red;
}
.event-bullet-event {
width: 100%;
height: 100%;
border-radius: 50%;
}
.event-bullet-event {
width: 2em;
height: 2em;
border-radius: 1em;
}
.event-header{
width: 100%;
text-align: center;
font-size: 1.7em;
font-weight: bold;
padding: 0.35em 0;
}
.event-info{
padding-left: 15%;
}
.calendar-events{
position: relative;
background: #fbfbfb;
}
.month_template{
position: relative;
}
flex-wrap: wrap;
margin-top: 2em;
margin-bottom: 1em;
.w-calendar-table td:hover {
background-color: #eaeaea;
color: #333;
}
.w-calendar-table td {
background: inherit;
color: inherit;
cursor: pointer;
border: 0;
}
.w-calendar-table td div{
display: inline-flex;
justify-content: center;
align-items: center;
margin: auto;
padding: 10%;
line-height: 1.2;
}
.w-calendar-table th {
background: unset;
color: unset;
border: 0;
padding: 1.5% 0.5%;
}
.widget-title {
padding: 0.2em;
font-size: 1.5em;
}
table.w-calendar-table td.w-calendar-toggle div, table.w-calendar-table td.w-calendar-toggle div{
background: #6f0007;
border-radius: 50%;
color: white;
}
.w-calendar-table td.w-calendar-event div{
border: 1px #6f0007 solid;
border-radius: 50%;
background: #eee;
}
.w-calendar-title{
background: rgb(146, 8, 17);
color: rgb(255, 255, 255);
padding: 0px 10%;
display: flex;
flex-flow: row-reverse wrap;
line-height: 2em;
justify-content: center;
font-size: 1.85em;
width: 100%;
}
.calendar-dialog div.ui-dialog-content {
max-height: 20em !important;
overflow-wrap: break-word;
}
table td.w-calendar-other-month {
color: #999797;
}
.event-header{
display: flex;
background: #dadada;
cursor: default;
}
.event-header .date{
width: 30%;
}
.event.active .event-header .day{
color: #bf1f1f;
}
.event.active .event-header .date{
color: #202427;
}
.event .event-header .day{
font-size: 1.4em;
}
.event .event-header .month{
font-size: 0.7em;
}
.event .event-header .date{
color: #a08a70;
}
.event-title{
width: 70%;
display: inline-flex;
flex-direction: column;
justify-content: space-between;
}
.event-title .duration{
font-size: 0.7em;
text-align: left;
color: #a0a1a1;
}
.duration_temp,.title_temp{
display: none;
}
.event-inner-title{
line-height: 2em;
text-align: left;
}
.event-containers{
height: 0;
min-height: unset;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
margin: 0 10%;
}
.event-container-one {
position: absolute;
align-items: center;
justify-content: center;
display: flex;
width: calc(100% - 0.7em);;
height: calc(100% - 0.7em);
flex-wrap: wrap;
border-radius: 10px;
margin-bottom: 1em;
cursor: pointer;
padding: 0;
margin: 0;
color: rgba(50, 50, 50, 0.45);
}
.event-container-one:hover {
background-color: #fff;
box-shadow: 0 0.1em 0.7em 0em;
}
.event-container-one .event-content{
color: #000000;
}
button.switch_button {
margin: 10%;
width: 2.5em;
height: 2.5em;
border-radius: 1.25em;
border: 0;
background: #96231a;
color: white;
outline: 0;
}
.switch_button:hover {
background: #c07b76;
}
.switch_button_wraper{
position: absolute;
right: 0%;
margin-right: 2%;
width: 3em;
margin-bottom: 2%;
bottom: 0;
display: flex;
flex-direction: column;
}
.event-wraper{
position: relative;
overflow: hidden;
}
.event-container-one:not(.active) {
right: -100%;
}
.event.active .event-containers{
min-height: 19.2em;
height: auto;
}
.calendar-events.width-100 .switch_button_wraper{
width: 100%;
height: 100%;
margin: 0;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.calendar-events.width-100 .switch_button{
margin: 2%;
}
.calendar-events.width-100 .event-containers{
z-index: 3;
}
.month_template .widget-title {
border: 0;
border-bottom: 0.0625em solid #ddd;
}
&>div:first-child {
box-shadow: 0em 0.1em 0.3em 0em;
margin-bottom: 0.25em;
}
}

View File

@ -0,0 +1,152 @@
.full-size-img img {
width: 100%;
}
.full-size-img {
width: 100%;
}
.s-annc__sub-img.pull-right {
margin-left: 2em;
}
.s-annc__sub-img.pull-left {
margin-right: 2em;
}
strong.carousel__description {
color: white;
}
@media (max-width: 767px){
.carousel_images{
width: 100%;
}
}
.carousel_img_item{
display: none;
float: left;
}
.controlplay {
position: absolute;
right: 1em;
top: 3%;
z-index: 200;
}
.controlplay a {
display: inline-block;
margin-right: 0.25em;
cursor: pointer;
padding: 5px 10px;
border: 1px solid rgba(255,255,255,0.5);
background: rgba(0,0,0,0.2);
}
.controlplay a i {
font-family: FontAwesome;
position: relative;
font-size: 1rem;
line-height: 1;
color: #FFF;
vertical-align: middle;
font-style: unset;
}
.controlplay .resume-slide i::before {
content: "\f04b";
}
.controlplay .pause-slide i::before {
content: "\f04c";
}
ul.button-mid .prev-button {
transition: 0.4s;
position: relative;
float: left;
left: 0.5rem;
width: 2.5rem;
height: 2.5rem;
font-size: 2.2rem;
color: #ffffff;
background: rgba(0,0,0,0.2);
text-align: center;
line-height: 2.5rem;
top: 50%;
position: absolute;
transform: translateY(-50%);
z-index: 999;
}
ul.button-mid .next-button {
float: right;
transition: 0.4s;
position: relative;
right: 0.5rem;
width: 2.5rem;
height: 2.5rem;
font-size: 2.2rem;
color: #fff;
background: rgba(0,0,0,0.2);
text-align: center;
line-height: 2.5rem;
top: 50%;
position: absolute;
transform: translateY(-50%);
z-index: 999;
}
.carousel_images_slide{
padding: 3em;
}
.carousel_img_item img{
cursor: pointer;
}
@media (max-width: 479px){
.carousel_img_item:nth-child(-n+1){
display: block;
width: 100%;
float: left;
}
.carousel_img_item{
width: 100%;
}
}
@media (min-width: 480px){
.carousel_img_item:nth-child(-n+2){
display: block;
width: 50%;
float: left;
}
.carousel_img_item{
width: 50%;
}
}
@media (min-width: 768px){
.carousel_img_item:nth-child(-n+3){
display: block;
width: 33%;
float: left;
}
.carousel_img_item{
width: 33%;
}
}
@media (min-width: 1280px){
.carousel_img_item:nth-child(-n+4){
display: block;
width: 25%;
float: left;
}
.carousel_img_item{
width: 25%;
}
}
.w-ba-banner .controlplay .resume-slide.active i{
color: #32D9C3;
}
.w-ba-banner .controlplay .pause-slide.active i{
color: #ff4500;
}
.w-ba-banner .controlplay{
width: auto;
}
.w-ba-banner .button-mid{
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.next-button,.prev-button{
cursor: pointer;
}

View File

@ -807,4 +807,33 @@ class EventNewsController < ApplicationController
render :layout => false
end
def agenda
I18n.with_locale(params[:locale]||I18n.locale) do
if !params[:subpart_id].nil?
subpartid = params[:subpart_id]
subpart = SubPart.find(subpartid)
all_cats = subpart.categories
all_cats = ['all'] if all_cats.length==0
all_tags = subpart.tags
all_tags = ['all'] if all_tags.length==0
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
page = Page.where(:module => "event_news").first rescue nil if page.nil?
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
read_more_url = read_more_url + "?" + {"category"=>all_cats,"tags"=> all_tags}.to_param if read_more_url != ""
end
if params[:unix_start].present? && params[:unix_end].present?
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
events = EventNews.agenda_events(agenda_start,agenda_end)
end
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
end
end
def get_calendar_title(now_date=nil)
now_date = Time.now.utc if now_date.nil?
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("event_news.month_name.#{now_date.month}")
I18n.t("event_news.calendar_title",year: now_date.year,month: month_name)
end
end

View File

@ -471,4 +471,56 @@ module EventNewsHelper
end
layout_types
end
def render_ad_banner(event_carousel_images,data)
("<div class=\"carousel_images\">
<div class=\"w-ba-banner ba-banner-widget-1\">
<div class=\"w-ba-banner__wrap cycle-slideshow\"
data-list=\"event_carousel_images\"
data-level=\"0\"
data-cycle-slides=\".event_carousel_slide\"
data-cycle-log=\"false\"
data-cycle-auto-height=\"0\"
data-cycle-speed=\"300\"
data-cycle-timeout=\"5000\"
data-cycle-fx=\"fade\"
data-pager-active-class=\"active-slide\"
data-cycle-swipe=true
data-cycle-swipe-fx=\"scrollHorz\"
>" +
event_carousel_images.collect do |e|
"<div class=\"w-ba-banner__slide event_carousel_slide\"
data-cycle-title=\"#{e['description_text']}\"
>
<img class=\"w-ba-banner__image banner-responsive\" src=\"#{e['src']}\" alt=\"#{e['description_text']}\">
<div class=\"ad-overlay w-ad-banner__overlay event_carousel__overlay\">
<p><strong class=\"carousel__description\">#{e['description']}</strong></p>
</div>
<div class=\"transitionfade\"></div>
</div>"
end.join+
"</div>
<ul class=\"controlplay\"><a class=\"resume-slide\" title = \"#{data['resume_btn_title']}\"><i></i></a><a class=\"pause-slide\" title = \"#{data['pause_btn_title']}\"><i></i></a></ul>
<ul class=\"button-mid\">
<i class=\"fa fa-angle-left prev-button\" aria-hidden=\"true\" title = \"#{data['prev_btn_title']}\"></i>
<i class=\"fa fa-angle-right next-button\" aria-hidden=\"true\" title = \"#{data['next_btn_title']}\"></i>
</ul>
</div>
<div style=\"position: relative;\">
<h4><span class=\"active_slide\">1</span>/#{data['carousel_count']}</h4>
<ul class=\"carousel_images_slide w-annc__list row list-unstyled\" data-level=\"0\" data-list=\"event_carousel_images\">" +
event_carousel_images.collect do |e|
"<li class=\"carousel_img_item col-sm-3\">
<div class=\"carousel_img-wrap\">
<img class=\"carousel_img\" src=\"#{e['src']}\" alt=\"#{e['description_text']}\">
</div>
</li>"
end.join +
"</ul>
<ul class=\"button-mid\">
<i class=\"fa fa-angle-left prev-button prev_img\" aria-hidden=\"true\" title = \"#{data['prev_btn_title']}\"></i>
<i class=\"fa fa-angle-right next-button next_img\" aria-hidden=\"true\" title = \"#{data['next_btn_title']}\"></i>
</ul>
</div>
</div>").html_safe
end
end

View File

@ -28,7 +28,7 @@ class EventNews
field :speaker, type: String, localize: true
field :host, type: String, localize: true
field :subtitle, localize: true
field :text, localize: true
field :text, localize: true, default: ''
field :notes, localize: true
field :create_user_id
field :update_user_id
@ -206,4 +206,23 @@ class EventNews
def carousel_image_width
(self.custom_carousel_image_width.blank? ? AnnouncementSetting.last.carousel_image_width : self.custom_carousel_image_width)
end
def self.agenda_events(agenda_start, agenda_end)
events = self.monthly_event(agenda_start, agenda_end).convert_front
end
def self.monthly_event(start_date,end_date)
self.any_of({:event_date.lte => start_date,:event_end_date.gte => start_date},{:event_date.gte => start_date,:event_end_date.lte => end_date},{:event_date.lte => end_date,:event_end_date.gte => end_date}).asc(:event_date)
end
def self.convert_front
self.all.collect do |re|
{:id => re.id.to_s,
:title=>re.title,
:note=>re.subtitle || "",
:allDay => false,
:color => nil,
:url_linked => (re.is_external_link? ? re.external_link : OrbitHelper.widget_item_url(re.to_param) rescue ""),
:start => re.event_date,
:end => re.event_end_date}
end
end
end

View File

@ -1,23 +1,37 @@
<%
require 'event_news_helper'
data = action_data
params = OrbitHelper.params
page = Page.where(url:params['url']).first
@ad_banner_location = 2
@show_back_and_next_flag = 0
if page.methods.include? 'select_option_items'.to_sym
ModuleApp.all.select{|tmp| tmp.key.to_s=='event_news'}.each do |modile_app|
@show_option_items = modile_app.show_option_items rescue nil
ModuleApp.all.select{|tmp| tmp.key.to_s=='event_news'}.each do |module_app|
@show_option_items = module_app.show_option_items rescue nil
end
page.select_option_items.each do |select_option_item|
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_news.not_show')
@show_back_and_next_flag = 0
elsif tmp == t('event_news.show_top')
@show_back_and_next_flag = 1
elsif tmp == t('event_news.show_bottom')
@show_back_and_next_flag = 2
if !(@show_option_items.nil?)
if select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_news.not_show')
@show_back_and_next_flag = 0
elsif tmp == t('event_news.show_top')
@show_back_and_next_flag = 1
elsif tmp == t('event_news.show_bottom')
@show_back_and_next_flag = 2
end
end
elsif select_option_item.field_name == @show_option_items.keys[2].to_s
value = YAML.load(select_option_item.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('event_news.show_top')
@ad_banner_location = 1
elsif tmp == t('event_news.show_bottom')
@ad_banner_location = 2
end
end
end
end
@ -43,7 +57,14 @@
content = ''
end
end
ad_banner_content = render_ad_banner(data['event_carousel_images'],data['data'])
%>
<style type="text/css">
.carousel_images{
<%= data['data']['carousel_display_style'] %>
}
</style>
<%= stylesheet_link_tag 'event_news_front.css' %>
<% if @show_back_and_next_flag!=0 %>
<style type="text/css">
.see_more_boxTitle{
@ -70,7 +91,147 @@
<% if @show_back_and_next_flag==1 %>
<%= content %>
<% end %>
<% if @ad_banner_location==1 %>
<%= ad_banner_content %>
<% end %>
<%= render_view %>
<% if @ad_banner_location==2 %>
<%= ad_banner_content %>
<% end %>
<% if @show_back_and_next_flag==2 %>
<%= content %>
<% end %>
<% end %>
<script>
(function($) {
function hideEmptyEl(el, elParent) {
if( el.length === 0) {
elParent.addClass('hide');
}
}
// Hiding parent element when children elements are not present
// Tags
hideEmptyEl($('.s-annc__tag'), $('.s-annc__tag-wrap'));
// Attachments
hideEmptyEl($('.s-annc__flie-title'), $('.s-annc__related-file'));
// Links
hideEmptyEl($('.s-annc__link-title'), $('.s-annc__related-link'));
$("img[src='']").remove();
$('.pause-slide').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
$(this).addClass('active');
$(this).parents('.carousel_images').find('.resume-slide').removeClass('active');
});
$('.resume-slide').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
$(this).addClass('active');
$(this).parents('.carousel_images').find('.pause-slide').removeClass('active');
});
$('.next-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
})
$('.prev-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
})
window.active_slide = 0;
$('.prev_img').off('click').on('click',function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
if(carousel_images_slide.find(">li").length > content_size && active_slide > 0){
active_slide -= content_size;
carousel_images_slide.find(">li").css("display","none");
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
}
})
$('.next_img').off('click').on('click',function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
var li_length = carousel_images_slide.find(">li").length;
if(li_length > content_size){
active_slide += content_size;
active_slide = Math.min(active_slide,li_length - 1);
carousel_images_slide.find(">li").css("display","none");
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
}
})
$(".carousel_img_item img").off("click").on("click",function(){
$(".carousel_images .cycle-slideshow").cycle($(this).index(".carousel_img_item img"));
})
$(document).ready(function(){
$(".carousel_images .cycle-slideshow").cycle('pause');
var carousel_image_block_width = $('.carousel_images').width();
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
$(".carousel_images .cycle-slideshow").cycle('resume');
$('.carousel_images .resume-slide').addClass('active');
$('.cycle-slideshow').on('cycle-after',function(){
$(".active_slide").text($('.event_carousel_slide.cycle-slide-active').index());
})
})
$(window).on("load",function(){
$(".carousel_images .cycle-slideshow").cycle('pause');
var carousel_image_block_width = $('.carousel_images').width();
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
$(".carousel_images .cycle-slideshow").cycle('resume');
})
$(window).resize(function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
carousel_images_slide.find(">li").css("display","none");
var active_count = carousel_images_slide.find(">li").length - active_slide;
if(active_count < content_size){
active_slide -= (content_size - active_count);
}
active_slide = Math.max(active_slide,0);
console.log(content_size)
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
var carousel_image_block_width = $('.carousel_images').width();
$(".event_carousel_slide").css("height",'');
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
})
}(jQuery));
</script>

View File

@ -158,3 +158,18 @@ en:
show_page: Show pagination
URL: URL
copy: Copy
month_name:
'1': 'January'
'2': 'February'
'3': 'March'
'4': 'April'
'5': 'May'
'6': 'June'
'7': 'July'
'8': 'August'
'9': 'September'
'10': 'October'
'11': 'November'
'12': 'December'
calendar_title: "%{month} %{year}"
ad_banner_location: Ad Banner Location(Need to Upload in Edit Page)

View File

@ -160,4 +160,6 @@ zh_tw:
url_generate: 網址生成
show_page: 顯示頁碼
URL: 網址
copy: 複製
copy: 複製
calendar_title: "%{year}年%{month}月"
ad_banner_location: 廣告輪播位置(需於編輯頁面上傳)

View File

@ -35,7 +35,7 @@ Rails.application.routes.draw do
get ':slug_title-:uid', to: 'event_news#show', as: :display
end
end
get '/xhr/event_news/agenda' => 'event_news#agenda'
get "/xhr/event_news/feed/:uid" => "event_news_feeds#feed"
get "/xhr/event_news/rssfeed/:uid" => "event_news_feeds#rssfeed"
get "/xhr/event_news/feeds" => "event_news_feeds#feeds"

View File

@ -29,9 +29,10 @@ if bundle_update_flag
update_flag = false
last_index = widget_info[-1]["filename"].match(/\d+/)[0].to_i rescue nil
if !last_index.nil?
idx_regex = /^(\d+[\. \t]*)|[ \t]+$/
default_event_news_widget_info.each do |h|
name_without_index = h["name"]["zh_tw"].sub(/\d+/,'')
widget_info_index = (widget_info.index{|hh| hh["name"]["zh_tw"].include?(name_without_index)} rescue -1)
name_without_index = h["name"]["zh_tw"].gsub(idx_regex,'')
widget_info_index = (widget_info.index{|hh| hh["name"]["zh_tw"].gsub(idx_regex,'') == name_without_index}||-1 rescue -1)
if widget_info_index == -1
update_flag = true
copy_h = h.dup

View File

@ -59,6 +59,7 @@ module EventNewsMod
end
key_item1[k] = v[0]['event_news']['showing_back_and_next']
key_item2[k] = v[0]['event_news']['enable_search']
key_item3[k] = v[0]['event_news']['ad_banner_location']
value_item1[k] = v[0]['event_news']['not_show']
value_item2[k] = v[0]['event_news']['show_bottom']
value_item3[k] = v[0]['event_news']['show_top']
@ -71,6 +72,7 @@ module EventNewsMod
data[key4] = key4_attr
data_item[key_item1] = [value_item1,value_item2,value_item3]
data_item[key_item2] = [value2_item1,value2_item2]
data_item[key_item3] = [value_item2,value_item3]
require File.expand_path('../../../app/models/event_news_cache', __FILE__)
if defined? EventNewsCache
EventNewsCache.destroy_all

View File

@ -0,0 +1,80 @@
<div class="w-calendar widget-calendar-2 widget-event-news-calendar-2" data-module="event_news">
<div class="w-calendar-title">
<span>{{widget-title}}</span>
</div>
<div class='month_template'>
<h4 class="widget-title ">
<span class="text"><span style="display: none;">placeholder</span></span>
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
</h4>
<div class="w-calendar-nav">
<a href="#" class="w-calendar-nav-prev">
<i class="fa fa-chevron-left"></i>
<span class="w-calendar-nav-prev-text hide">Prev</span>
</a>
<a href="#" class="w-calendar-nav-next">
<i class="fa fa-chevron-right"></i>
<span class="w-calendar-nav-next-text hide">Next</span>
</a>
</div>
<table class="table table-condensed w-calendar-table">
<thead>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="calendar-events" style="display: none;">
<div class="event">
<div class="event-header">
<div class="date">
<div class="day"></div>
<div class="month"></div>
</div>
<div class="event-title">
<div class="event-inner-title"></div>
<div class="duration"></div>
</div>
</div>
<div class="event-wraper">
<div class="event-containers">
</div>
</div>
</div>
</div>
</div>
<%= stylesheet_link_tag "event_news_calendar_widget2" %>
<script>
if(document.getElementById("event-news-calendar-widget_module2") == null){
var tag = document.createElement('script');
tag.setAttribute("id", "event-news-calendar-widget_module2");
tag.src = "/assets/event_news_calendar_widget2.js";
tag.onload = function(){
$("div.widget-calendar-2[data-module=event_news]").each(function(index){
var calendar = $(this),
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
cmi.currentMonth();
calendar.find("div.w-calendar-nav a").on("click",function(){
var el = $(this);
if(el.hasClass("w-calendar-nav-prev")){
cmi.prevMonth();
}else if(el.hasClass("w-calendar-nav-next")){
cmi.nextMonth();
}
return false;
})
})
}
var head = document.getElementsByTagName("head");
head[0].appendChild(tag);
}
</script>

View File

@ -281,6 +281,15 @@
"en" : "16. Standard Table List (EventDate, status, title, speaker, host, notes)"
},
"thumbnail" : "event_news_widget13_thumbs.png"
},
{
"filename" : "event_news_widget18",
"name" : {
"zh_tw" : "18. 日歷",
"en" : "18. Calendar"
},
"force_cover" : "true",
"thumbnail" : "event_news_widget13_thumbs.png"
}
]
}

View File

@ -1,143 +1,3 @@
<style type="text/css">
.full-size-img img {
width: 100%;
}
.full-size-img {
width: 100%;
}
.s-annc__sub-img.pull-right {
margin-left: 2em;
}
.s-annc__sub-img.pull-left {
margin-right: 2em;
}
strong.carousel__description {
color: white;
}
.carousel_images{
{{carousel_display_style}}
}
@media (max-width: 767px){
.carousel_images{
width: 100%;
}
}
</style>
<style type="text/css">
.carousel_img_item{
display: none;
float: left;
}
.controlplay {
position: absolute;
right: 1em;
top: 3%;
z-index: 200;
}
.controlplay a {
display: inline-block;
margin-right: 0.25em;
cursor: pointer;
padding: 5px 10px;
border: 1px solid rgba(255,255,255,0.5);
background: rgba(0,0,0,0.2);
}
.controlplay a i {
font-family: FontAwesome;
position: relative;
font-size: 1rem;
line-height: 1;
color: #FFF;
vertical-align: middle;
font-style: unset;
}
.controlplay .resume-slide i::before {
content: "\f04b";
}
.controlplay .pause-slide i::before {
content: "\f04c";
}
ul.button-mid .prev-button {
transition: 0.4s;
position: relative;
float: left;
left: 0.5rem;
width: 2.5rem;
height: 2.5rem;
font-size: 2.2rem;
color: #ffffff;
background: rgba(0,0,0,0.2);
text-align: center;
line-height: 2.5rem;
top: 50%;
position: absolute;
transform: translateY(-50%);
z-index: 999;
}
ul.button-mid .next-button {
float: right;
transition: 0.4s;
position: relative;
right: 0.5rem;
width: 2.5rem;
height: 2.5rem;
font-size: 2.2rem;
color: #fff;
background: rgba(0,0,0,0.2);
text-align: center;
line-height: 2.5rem;
top: 50%;
position: absolute;
transform: translateY(-50%);
z-index: 999;
}
.carousel_images_slide{
padding: 3em;
}
.carousel_img_item img{
cursor: pointer;
}
@media (max-width: 479px){
.carousel_img_item:nth-child(-n+1){
display: block;
width: 100%;
float: left;
}
.carousel_img_item{
width: 100%;
}
}
@media (min-width: 480px){
.carousel_img_item:nth-child(-n+2){
display: block;
width: 50%;
float: left;
}
.carousel_img_item{
width: 50%;
}
}
@media (min-width: 768px){
.carousel_img_item:nth-child(-n+3){
display: block;
width: 33%;
float: left;
}
.carousel_img_item{
width: 33%;
}
}
@media (min-width: 1280px){
.carousel_img_item:nth-child(-n+4){
display: block;
width: 25%;
float: left;
}
.carousel_img_item{
width: 25%;
}
}
</style>
<article class="s-annc show-annc">
<h1 class="s-annc__show-title">{{title}}</h1>
@ -199,176 +59,5 @@
</div>
</li>
</ul>
</article>
<div class="carousel_images">
<div class="w-ba-banner ba-banner-widget-1">
<div class="w-ba-banner__wrap cycle-slideshow"
data-list="event_carousel_images"
data-level="0"
data-cycle-slides=".event_carousel_slide"
data-cycle-log="false"
data-cycle-auto-height="0"
data-cycle-speed="300"
data-cycle-timeout="5000"
data-cycle-fx="fade"
data-pager-active-class="active-slide"
data-cycle-swipe=true
data-cycle-swipe-fx="scrollHorz"
>
<div class="w-ba-banner__slide event_carousel_slide"
data-cycle-title="{{description_text}}"
>
<img class="w-ba-banner__image banner-responsive" src="{{src}}" alt="{{description_text}}">
<div class="ad-overlay w-ad-banner__overlay event_carousel__overlay">
<p><strong class="carousel__description">{{description}}</strong></p>
</div>
<div class="transitionfade"></div>
</div>
</div>
<ul class="controlplay"><a class="resume-slide" title = "{{resume_btn_title}}"><i></i></a><a class="pause-slide" title = "{{pause_btn_title}}"><i></i></a></ul>
<ul class="button-mid">
<i class="fa fa-angle-left prev-button" aria-hidden="true" title = "{{prev_btn_title}}"></i>
<i class="fa fa-angle-right next-button" aria-hidden="true" title = "{{next_btn_title}}"></i>
</ul>
</div>
<div style="position: relative;">
<h4><span class="active_slide">1</span>/{{carousel_count}}</h4>
<ul class="carousel_images_slide w-annc__list row list-unstyled" data-level="0" data-list="event_carousel_images">
<li class="carousel_img_item col-sm-3">
<div class="carousel_img-wrap">
<img class="carousel_img" src="{{src}}" alt="{{description_text}}">
</div>
</li>
</ul>
<ul class="button-mid">
<i class="fa fa-angle-left prev-button prev_img" aria-hidden="true" title = "{{prev_btn_title}}"></i>
<i class="fa fa-angle-right next-button next_img" aria-hidden="true" title = "{{next_btn_title}}"></i>
</ul>
</div>
</div>
{{link_to_edit}}
<script>
(function($) {
function hideEmptyEl(el, elParent) {
if( el.length === 0) {
elParent.addClass('hide');
}
}
// Hiding parent element when children elements are not present
// Tags
hideEmptyEl($('.s-annc__tag'), $('.s-annc__tag-wrap'));
// Attachments
hideEmptyEl($('.s-annc__flie-title'), $('.s-annc__related-file'));
// Links
hideEmptyEl($('.s-annc__link-title'), $('.s-annc__related-link'));
$("img[src='']").remove();
$('.pause-slide').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
});
$('.resume-slide').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
});
$('.next-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
})
$('.prev-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
})
window.active_slide = 0;
$('.prev_img').off('click').on('click',function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
if(carousel_images_slide.find(">li").length > content_size && active_slide > 0){
active_slide -= content_size;
carousel_images_slide.find(">li").css("display","none");
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
}
})
$('.next_img').off('click').on('click',function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
var li_length = carousel_images_slide.find(">li").length;
if(li_length > content_size){
active_slide += content_size;
active_slide = Math.min(active_slide,li_length - 1);
carousel_images_slide.find(">li").css("display","none");
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
}
})
$(".carousel_img_item img").off("click").on("click",function(){
$(".carousel_images .cycle-slideshow").cycle($(this).index(".carousel_img_item img"));
})
$(document).ready(function(){
$(".carousel_images .cycle-slideshow").cycle('pause');
var carousel_image_block_width = $('.carousel_images').width();
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
$(".carousel_images .cycle-slideshow").cycle('resume');
$('.cycle-slideshow').on('cycle-after',function(){
$(".active_slide").text($('.event_carousel_slide.cycle-slide-active').index());
})
})
$(window).on("load",function(){
$(".carousel_images .cycle-slideshow").cycle('pause');
var carousel_image_block_width = $('.carousel_images').width();
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
$(".carousel_images .cycle-slideshow").cycle('resume');
})
$(window).resize(function(){
var carousel_images_slide = $('.carousel_images_slide');
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
if(carousel_images_slide_first_child.length > 0){
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
content_size = Math.max(content_size,1);
carousel_images_slide.find(">li").css("display","none");
var active_count = carousel_images_slide.find(">li").length - active_slide;
if(active_count < content_size){
active_slide -= (content_size - active_count);
}
active_slide = Math.max(active_slide,0);
console.log(content_size)
for(var i = active_slide; i < active_slide + content_size;i++){
carousel_images_slide.find(">li").eq(i).css("display","block");
}
}
var carousel_image_block_width = $('.carousel_images').width();
$(".event_carousel_slide").css("height",'');
var heights = $(".event_carousel_slide").map(function(i,v){
return $(v).height() * carousel_image_block_width / $(v).width();
})
var max_height = Math.max.apply(null,heights);
$(".event_carousel_slide").each(function(i,v){
$(v).height(max_height);
})
})
}(jQuery));
</script>
{{link_to_edit}}