Show holidays & birthdays as events on mobile

This commit is contained in:
nathangray 2016-06-13 19:08:56 -06:00
parent 218831f76d
commit b8f8d59793
2 changed files with 71 additions and 22 deletions

View File

@ -120,16 +120,6 @@ class calendar_uiviews extends calendar_ui
*/ */
var $allowEdit = true; var $allowEdit = true;
/**
* Display holidays as event, currenlty only used in day-view
*
* @var array
*/
var $display_holiday_event_types = array(
'bdays' => false,
'hdays' => false
);
/** /**
* Constructor * Constructor
* *

View File

@ -417,16 +417,67 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte
{ {
if (typeof holidays[i]['birthyear'] !== 'undefined') if (typeof holidays[i]['birthyear'] !== 'undefined')
{ {
this.title.addClass('calendar_calBirthday'); // Show holidays as events on mobile
if(egwIsMobile())
{
// Create event
this._parent.date_helper.set_value(this.options.date.substring(0,4)+'-'+
(this.options.date.substring(4,6))+'-'+this.options.date.substring(6,8)+
'T00:00:00Z');
var event = et2_createWidget('calendar-event',{
id:'event_'+holidays[i].name,
value: {
title: holidays[i].name,
whole_day: true,
whole_day_on_top: true,
start: new Date(this._parent.date_helper.get_value()),
end: this.options.date,
owner: this.options.owner,
participants: this.options.owner,
app: 'calendar'
},
readonly: true,
class: 'calendar_calBirthday'
},this);
event.doLoadingFinished();
event._update();
}
else
{
//If the birthdays are already displayed as event, don't //If the birthdays are already displayed as event, don't
//show them in the caption //show them in the caption
if (!this.options.display_birthday_as_event) this.title.addClass('calendar_calBirthday');
{
holiday_list.push(holidays[i]['name']); holiday_list.push(holidays[i]['name']);
} }
} }
else else
{
// Show holidays as events on mobile
if(egwIsMobile())
{
// Create event
this._parent.date_helper.set_value(this.options.date.substring(0,4)+'-'+
(this.options.date.substring(4,6))+'-'+this.options.date.substring(6,8)+
'T00:00:00Z');
var event = et2_createWidget('calendar-event',{
id:'event_'+holidays[i].name,
value: {
title: holidays[i].name,
whole_day: true,
whole_day_on_top: true,
start: new Date(this._parent.date_helper.get_value()),
end: this.options.date,
owner: this.options.owner,
participants: this.options.owner,
app: 'calendar'
},
readonly: true,
class: 'calendar_calHoliday'
},this);
event.doLoadingFinished();
event._update();
}
else
{ {
this.title.addClass('calendar_calHoliday'); this.title.addClass('calendar_calHoliday');
this.title.attr('data-holiday', holidays[i]['name']); this.title.attr('data-holiday', holidays[i]['name']);
@ -440,6 +491,7 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte
} }
} }
} }
}
this.title.attr('title', holiday_list.join(',')); this.title.attr('title', holiday_list.join(','));
}, },
@ -498,6 +550,13 @@ var et2_calendar_daycol = (function(){ "use strict"; return et2_valueWidget.exte
} }
} }
// Show holidays as events on mobile
if(egwIsMobile())
{
this.day_class_holiday();
}
// Apply styles to hidden events // Apply styles to hidden events
this._out_of_view(); this._out_of_view();
}, },