You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.4 KiB
JavaScript
98 lines
3.4 KiB
JavaScript
$(document).ready(function() {
|
|
var clisn = $('#calendar').data('clino') || '';
|
|
if(clisn.length < 3){
|
|
return;
|
|
}
|
|
$('#calendar').fullCalendar({
|
|
header: {
|
|
left: '',
|
|
center: 'prev title next',
|
|
right: ''
|
|
},
|
|
titleFormat: 'YYYY MMMM',
|
|
dayNamesShort: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
|
|
height: 480,
|
|
weekMode: 'liquid',
|
|
events: {
|
|
url: '/chapi/gettourprice/'+clisn+'?site=cht',
|
|
error: function() {
|
|
console.log('json err');
|
|
},
|
|
className: 'eventcls',
|
|
},
|
|
eventRender: function(event, element) {
|
|
element.children().find('.fc-title').html(event.title);
|
|
element.attr('href','javascript:;');
|
|
var eventdate = event.start._i.toString();
|
|
if (event.holidays) {
|
|
$('.fc-day-number').each(function(index, ele) {
|
|
if ($(this).data('date').toString() == eventdate) {
|
|
$(this).append(' <i class="holiday fa fa-star" data-festival="' + event.holidays + '"></i>');
|
|
}
|
|
});
|
|
}
|
|
$('.fc-other-month').each(function(index, eles) {
|
|
if ($(this).data('date').toString() == eventdate) {
|
|
element.addClass('moved');
|
|
}
|
|
});
|
|
},
|
|
eventAfterAllRender: function() {
|
|
$('.moved').remove();
|
|
$('.fc-other-month').text('');
|
|
var holiday = new Array();
|
|
var holidaystr = '';
|
|
$('.holiday').each(function(index, el) {
|
|
holidaystr = $(this).data('festival') || null;
|
|
holiday.push(holidaystr);
|
|
});
|
|
var f_html = '';
|
|
holiday = unique(holiday);
|
|
if (holiday.length > 0) {
|
|
var holidays_arr = unique(holiday);
|
|
var i = 0;
|
|
var clsname = 'holiday_color1';
|
|
for (var k in holidays_arr) {
|
|
if (i > 0) {
|
|
clsname = 'holiday_color2';
|
|
}
|
|
if (holidays_arr[k] != '') {
|
|
i++;
|
|
f_html += '<span class="' + clsname + '"><i class="fa fa-star"></i> ' + holidays_arr[k] + ' </span>';
|
|
$('.holiday').each(function(index, element) {
|
|
if ($(this).data('festival') == holidays_arr[k]) {
|
|
$(this).parent().addClass(clsname);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if (typeof $('#fhtml').html() == 'undefined') {
|
|
$('#calendar').append('<div class="whatHoliday" id="fhtml"></div>');
|
|
}
|
|
$('#fhtml').html(f_html);
|
|
},
|
|
eventClick: function(calEvent, jsEvent, view) {
|
|
var postdata = calEvent.url_post || 'e';
|
|
if(postdata == 'e'){
|
|
return false;
|
|
}else{
|
|
jsGetToPost(postdata);
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
function unique(arr) {
|
|
var result = [],
|
|
hash = {};
|
|
for (var i = 0, elem;
|
|
(elem = arr[i]) != null; i++) {
|
|
if (!hash[elem]) {
|
|
result.push(elem);
|
|
hash[elem] = true;
|
|
}
|
|
}
|
|
return result;
|
|
} |