diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index ac79ae3fb1..efbba06d40 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -510,20 +510,34 @@ var et2_calendar_timegrid = /** @class */ (function (_super) { * Update the 'now' line * @private */ + // @ts-ignore et2_calendar_timegrid.prototype._updateNow = function () { var now = _super.prototype._updateNow.call(this); - if (now === false || this.options.granularity == 0) { + if (now === false || this.options.granularity == 0 || !this.div.is(':visible')) { this.now_div.hide(); return false; } + // Position & show line + var set_line = function (line, now, day) { + line.appendTo(day.getDOMNode()).show(); + var pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes()); + //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); + line.css('top', pos + '%'); + }; + // Showing just 1 day, multiple owners - span all + if (this.daily_owner && this.day_list.length == 1) { + var day = this.day_widgets[0]; + set_line(this.now_div, now, day); + this.now_div.css('width', (this.day_widgets.length * 100) + '%'); + return true; + } + // Find the day of the week for (var i = 0; i < this.day_widgets.length; i++) { var day = this.day_widgets[i]; if (day.getDate() >= now) { day = this.day_widgets[i - 1]; - this.now_div.appendTo(day.getDOMNode()).show(); - var pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes()); - //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); - this.now_div.css('top', pos + '%'); + set_line(this.now_div, now, day); + this.now_div.css('width', '100%'); break; } } diff --git a/calendar/js/et2_widget_timegrid.ts b/calendar/js/et2_widget_timegrid.ts index 186f8c9b6f..48a5e124d9 100644 --- a/calendar/js/et2_widget_timegrid.ts +++ b/calendar/js/et2_widget_timegrid.ts @@ -699,24 +699,43 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet * Update the 'now' line * @private */ + // @ts-ignore public _updateNow() { let now = super._updateNow(); - if(now === false || this.options.granularity == 0) + if(now === false || this.options.granularity == 0 || !this.div.is(':visible')) { this.now_div.hide(); return false; } + + // Position & show line + let set_line = function(line, now, day) + { + line.appendTo(day.getDOMNode()).show(); + let pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes()); + //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); + line.css('top', pos + '%'); + } + + // Showing just 1 day, multiple owners - span all + if(this.daily_owner && this.day_list.length == 1) + { + let day = this.day_widgets[0]; + set_line(this.now_div, now, day); + this.now_div.css('width', (this.day_widgets.length * 100) + '%'); + return true; + } + + // Find the day of the week for(var i = 0; i < this.day_widgets.length; i++) { let day = this.day_widgets[i]; if(day.getDate() >= now) { day = this.day_widgets[i-1]; - this.now_div.appendTo(day.getDOMNode()).show(); - let pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes()); - //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); - this.now_div.css('top', pos + '%'); + set_line(this.now_div, now, day); + this.now_div.css('width','100%'); break; } }