diff --git a/calendar/js/app.js b/calendar/js/app.js index d9a7972b4a..e35feafeb2 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -609,7 +609,10 @@ app.classes.calendar = AppJS.extend( .css({"transform": '',height: '', width:'',overflow:''}); wrapper.parent().css({overflow: '', width: original_size.width, height: original_size.height}); original.css("display",""); - wrapper[0].offsetHeight; + if(wrapper.length) + { + wrapper[0].offsetHeight; + } wrapper.css({ "transition-duration": "", "transition-delay": "" @@ -3300,6 +3303,13 @@ jQuery.extend(app.classes.calendar,{ return state.sortby ? state.sortby : 0; }, start_date: function(state) { + // If there is no planner_days and a start date, just keep it + if(!state.planner_days && state.first && ( + !state.date || state.first < state.date && state.last > state.date + )) + { + return state.first; + } var d = app.calendar.View.start_date.call(this, state); if(state.sortby && state.sortby === 'month') { @@ -3307,10 +3317,6 @@ jQuery.extend(app.classes.calendar,{ } else if (!state.planner_days) { - if(d.getUTCDate() < 15) - { - d.setUTCDate(1); - } d = app.calendar.date.start_of_week(d); d.setUTCHours(0); d.setUTCMinutes(0); @@ -3321,6 +3327,26 @@ jQuery.extend(app.classes.calendar,{ return d; }, end_date: function(state) { + // If no planner days and an end date, just keep it + if(!state.planner_days && state.last && state.last > state.first) + { + // Handle listview before / after a little more nicely + if(app.calendar.state.view == 'listview' && ( + state.filter == 'before' || state.filter == 'after' + )) + { + var d = app.calendar.View.end_date.call(this, state); + d.setUTCDate(d.getUTCDate() + 30); + d = app.calendar.date.end_of_week(d); + return d; + } + return state.last; + } + // Avoid end date before start date + if(state.last && state.first && state.last <= state.first && !state.planner_days) + { + state.planner_days = 30; + } var d = app.calendar.View.end_date.call(this, state); if(state.planner_days) { @@ -3337,24 +3363,14 @@ jQuery.extend(app.classes.calendar,{ delete state.planner_days; } // Avoid killing the view by not showing more than 100 days - else if (state.last && (new Date(state.last) - new Date(state.first)) < (100 * 24 * 3600 * 1000) ) + else if (state.last && state.last > state.first && (new Date(state.last) - new Date(state.first)) < (100 * 24 * 3600 * 1000) ) { d = new Date(state.last); d = app.calendar.date.end_of_week(d); } else if (!state.planner_days) { - if (d.getUTCDate() < 15) - { - d.setUTCDate(0); - d.setUTCMonth(d.getUTCMonth()+1); - d = app.calendar.date.end_of_week(d); - } - else - { - d.setUTCMonth(d.getUTCMonth()+1); - d = app.calendar.date.end_of_week(d); - } + d = app.calendar.date.end_of_week(d); } return d; }, diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index cae7cfc93a..65ca5b972e 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -843,7 +843,10 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize } // Adjust header if there's a scrollbar - this.gridHeader.css('margin-right', (this.rows.width() - this.rows.children().first().width()) + 'px') + if(this.rows.children().first().length) + { + this.gridHeader.css('margin-right', (this.rows.width() - this.rows.children().first().width()) + 'px'); + } this.value = []; }, @@ -893,23 +896,6 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize var title = app.calendar.egw.lang(date('F',start))+' '+date('Y',start)+' - '+ app.calendar.egw.lang(date('F',end))+' '+date('Y',end); - // calculate date for navigation links - var time = new Date(start); - time.setUTCFullYear(time.getUTCFullYear()-1); - var last_year = time.toJSON(); - time.setUTCMonth(time.getUTCMonth()+11); - var last_month = time.toJSON(); - time.setUTCMonth(time.getUTCMonth()+2); - var next_month = time.toJSON(); - time.setUTCMonth(time.getUTCMonth()+11); - var next_year = time.toJSON(); - - title = this._scroll_button('first',last_year) + - this._scroll_button('left', last_month) + - title + - this._scroll_button('right', next_month) + - this._scroll_button('last', next_year); - content += '"; content += ""; // end of plannerScale @@ -960,33 +946,6 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize if (days_in_month > 10) { title += ' '+t.getUTCFullYear(); - - // previous links - var prev = new Date(t); - prev.setUTCMonth(prev.getUTCMonth()-1); - if(prev.valueOf() < start.valueOf() - (20 * 1000*3600*24)) - { - var full = prev.toJSON(); - prev.setUTCDate(prev.getUTCDate() + 15); - //prev.setUTCDate(start.getUTCDate() < 15 ? 1 : 15); - var half = prev.toJSON(); - title = this._scroll_button('first',full) + this._scroll_button('left',half) + title; - } - - // show next scales, if there are less then 10 days in the next month or there is no next month - var days_until_end = (end - t) / (1000 * 3600 * 24); - if (days_until_end - days_in_month <= 10 || end.getUTCMonth() === t.getUTCMonth() && end.getUTCFullYear() === t.getUTCFullYear()) - { - // next links - var next = new Date(t); - next.setUTCMonth(next.getUTCMonth()+1); - full = next.toJSON(); - next.setUTCDate(next.getUTCDate() - 15); - //next.setUTCDate(next.getUTCDate() < 15 ? 1 : 15); - half = next.toJSON(); - - title += this._scroll_button('right',half) + this._scroll_button('last',full); - } } else { @@ -1048,24 +1007,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize state.setUTCHours(0); state.setUTCMinutes(0); state = state.toJSON(); - if (days <= 7) - { - // prev. week - var left = new Date(t); - left.setUTCHours(0); - left.setUTCMinutes(0); - left.setUTCDate(left.getUTCDate() - 7); - // next week - var right = new Date(t); - right.setUTCHours(0); - right.setUTCMinutes(0); - right.setUTCDate(right.getUTCDate() + 7); - - title = this._scroll_button('left',app.calendar.date.start_of_week(left).toJSON()) + - title + - this._scroll_button('right',app.calendar.date.start_of_week(right).toJSON()); - } if(days_in_week > 1) { content += '"; @@ -1118,25 +1060,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize title = app.calendar.egw.lang(date('D',t)).substr(0,2)+'
'+date('j',t); } state = new Date(t.valueOf() - start.getTimezoneOffset() * 60 * 1000).toJSON(); - if (days < 5) - { - if (!i) // prev. day only for the first day - { - var prev = new Date(t); - prev.setUTCDate(prev.getUTCDate() - 1); - prev.setUTCHours(0); - prev.setUTCMinutes(0); - title = this._scroll_button('left',prev.toJSON()) + title; - } - if (i == days-1) // next day only for the last day - { - var next = new Date(t); - next.setUTCDate(next.getUTCDate() + 1); - next.setUTCHours(0); - next.setUTCMinutes(0); - title += this._scroll_button('right',next.toJSON()); - } - } + content += '\n"; @@ -1190,15 +1114,6 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize return content; }, - /** - * Create a pagination button, and inserts it - * - */ - _scroll_button: function(image, date) - { - return ''; - }, - /** * Applies class for today, and any holidays for current day * diff --git a/calendar/templates/default/sidebox.xet b/calendar/templates/default/sidebox.xet index bae6b64b13..4aa923a7f1 100644 --- a/calendar/templates/default/sidebox.xet +++ b/calendar/templates/default/sidebox.xet @@ -40,14 +40,17 @@ Egroupware