Optimization: set event handler on minicalendar container and use target check to handle week number clicks
This commit is contained in:
parent
f7c12cb456
commit
59f9b422ac
2 changed files with 21 additions and 19 deletions
|
@ -1859,7 +1859,6 @@ function rcube_calendar_ui(settings)
|
||||||
window.setTimeout(function(){ $('div.fc-content').css('overflow', view.name == 'month' ? 'auto' : 'hidden') }, 10);
|
window.setTimeout(function(){ $('div.fc-content').css('overflow', view.name == 'month' ? 'auto' : 'hidden') }, 10);
|
||||||
if (minical) {
|
if (minical) {
|
||||||
minical.datepicker('refresh');
|
minical.datepicker('refresh');
|
||||||
window.setTimeout(init_week_events, 10);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
windowResize: function(view) {
|
windowResize: function(view) {
|
||||||
|
@ -1868,21 +1867,23 @@ function rcube_calendar_ui(settings)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// event handler for clicks on calendar week cell of the datepicker widget
|
// set event handler for clicks on calendar week cell of the datepicker widget
|
||||||
var init_week_events = function(){
|
var init_week_events = function(){
|
||||||
$('#datepicker table.ui-datepicker-calendar td.ui-datepicker-week-col').click(function(e){
|
$('#datepicker').click(function(e){
|
||||||
var base_date = minical.datepicker('getDate');
|
var cell = $(e.target);
|
||||||
var day_off = base_date.getDay() - 1;
|
if (e.target.tagName == 'TD' && cell.hasClass('ui-datepicker-week-col')) {
|
||||||
if (day_off < 0) day_off = 6;
|
var base_date = minical.datepicker('getDate');
|
||||||
var base_kw = $.datepicker.iso8601Week(base_date);
|
var day_off = base_date.getDay() - 1;
|
||||||
var kw = parseInt($(this).html());
|
if (day_off < 0) day_off = 6;
|
||||||
var diff = (kw - base_kw) * 7 * DAY_MS;
|
var base_kw = $.datepicker.iso8601Week(base_date);
|
||||||
// select monday of the chosen calendar week
|
var kw = parseInt(cell.html());
|
||||||
var date = new Date(base_date.getTime() - day_off * DAY_MS + diff);
|
var diff = (kw - base_kw) * 7 * DAY_MS;
|
||||||
fc.fullCalendar('gotoDate', date).fullCalendar('setDate', date).fullCalendar('changeView', 'agendaWeek');
|
// select monday of the chosen calendar week
|
||||||
minical.datepicker('setDate', date);
|
var date = new Date(base_date.getTime() - day_off * DAY_MS + diff);
|
||||||
window.setTimeout(init_week_events, 10);
|
fc.fullCalendar('gotoDate', date).fullCalendar('setDate', date).fullCalendar('changeView', 'agendaWeek');
|
||||||
}).css('cursor', 'pointer');
|
minical.datepicker('setDate', date);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// initialize small calendar widget using jQuery UI datepicker
|
// initialize small calendar widget using jQuery UI datepicker
|
||||||
|
@ -1895,10 +1896,8 @@ function rcube_calendar_ui(settings)
|
||||||
ignore_click = true;
|
ignore_click = true;
|
||||||
var d = minical.datepicker('getDate'); //parse_datetime('0:0', dateText);
|
var d = minical.datepicker('getDate'); //parse_datetime('0:0', dateText);
|
||||||
fc.fullCalendar('gotoDate', d).fullCalendar('select', d, d, true);
|
fc.fullCalendar('gotoDate', d).fullCalendar('select', d, d, true);
|
||||||
window.setTimeout(init_week_events, 10);
|
|
||||||
},
|
},
|
||||||
onChangeMonthYear: function(year, month, inst) {
|
onChangeMonthYear: function(year, month, inst) {
|
||||||
window.setTimeout(init_week_events, 10);
|
|
||||||
var d = minical.datepicker('getDate');
|
var d = minical.datepicker('getDate');
|
||||||
d.setYear(year);
|
d.setYear(year);
|
||||||
d.setMonth(month - 1);
|
d.setMonth(month - 1);
|
||||||
|
@ -1917,7 +1916,6 @@ function rcube_calendar_ui(settings)
|
||||||
var fullcalendar_update = function() {
|
var fullcalendar_update = function() {
|
||||||
var d = fc.fullCalendar('getDate');
|
var d = fc.fullCalendar('getDate');
|
||||||
minical.datepicker('setDate', d);
|
minical.datepicker('setDate', d);
|
||||||
window.setTimeout(init_week_events, 10);
|
|
||||||
};
|
};
|
||||||
$("#calendar .fc-button-prev").click(fullcalendar_update);
|
$("#calendar .fc-button-prev").click(fullcalendar_update);
|
||||||
$("#calendar .fc-button-next").click(fullcalendar_update);
|
$("#calendar .fc-button-next").click(fullcalendar_update);
|
||||||
|
@ -2071,7 +2069,7 @@ function rcube_calendar_ui(settings)
|
||||||
if (rcmail.env.autocomplete_threads > 0) {
|
if (rcmail.env.autocomplete_threads > 0) {
|
||||||
ac_props = {
|
ac_props = {
|
||||||
threads: rcmail.env.autocomplete_threads,
|
threads: rcmail.env.autocomplete_threads,
|
||||||
sources: rcmail.env.autocomplete_sources,
|
sources: rcmail.env.autocomplete_sources
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
rcmail.init_address_input_events($('#edit-attendee-name'), ac_props);
|
rcmail.init_address_input_events($('#edit-attendee-name'), ac_props);
|
||||||
|
|
|
@ -56,6 +56,10 @@ body.calendarmain {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#datepicker td.ui-datepicker-week-col {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
#sidebartoggle {
|
#sidebartoggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 244px;
|
left: 244px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue