')
}else{
tp = $('').attr('href',v.url_linked)
}
var sd = [format_date(v.start), format_time(v.start)],
ed = [format_date(v.end), format_time(v.end)],
duration = '';
if(v.allDay){
if (sd[0]!=ed[0]){
duration = sd[0]+'>'+ed[0] +' '
}
}else if (sd[0]==ed[0]){
duration = sd[1]+' > '+ed[1] +' '
}else{
duration = sd[0]+' '+sd[1]+' > '+ed[0]+' '+ed[1] +' '
}
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 = $("
"
+""
+"
")
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(){
var event_doc = $(this).parents('.event').eq(0);
if (!event_doc.hasClass('active')){
tp1 = event_doc.parents('.calendar-events').eq(0).find('.event.active .event-containers');
tp2 = event_doc.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;
}
event_doc.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/hover_step_max)+'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 .event-header').hover(event_hover);
event_div.find('.event .event-header').click(event_hover);
$(ele).parents('div.w-calendar').css('display','flex');
if ($(ele).parents('div.w-calendar').width()>=728 && $(window).width()>=768){
event_div.css('width','50%')
event_div.addClass('width-50')
event_div.removeClass('width-100')
$(ele).parents('div.w-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.w-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.w-calendar').find('div.calendar-events')
$(ele).parents('div.w-calendar').css('display','block')
$(ele).parents('div.w-calendar').find('div').eq(0).css('width','')
event_div.hide()
//$(ele).parents('div.w-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(getDateString(firstDay, calendar_variable.month_year_format));
}
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 = $("
");
switch (position){
case "first":
var offset = firstDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
var first_line_first_day = new Date(year,month,firstDay.getDate() - offset)
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 = $("