Calendar: Fix unable to create events by clicking a time

This commit is contained in:
nathan 2022-06-03 08:48:47 -06:00
parent 5859ce0c37
commit 0e1aa738eb

View File

@ -2163,16 +2163,8 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet
var day = null; var day = null;
var time = null; var time = null;
var node = document.elementFromPoint(x,y); let nodes = document.elementsFromPoint(x, y);
var $node = jQuery(node);
// Ignore high level & non-time (grid itself, header parent & week label)
if([this.node, this.gridHeader[0], this._labelContainer[0]].indexOf(node) !== -1 ||
// Day labels
this.gridHeader.has(node).length && !$node.hasClass("calendar_calDayColAllDay") && !$node.hasClass('calendar_calDayColHeader'))
{
return [];
}
for(var id in this.gridHover[0].dataset) { for(var id in this.gridHover[0].dataset) {
delete this.gridHover[0].dataset[id]; delete this.gridHover[0].dataset[id];
} }
@ -2180,48 +2172,50 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet
{ {
this.gridHover.css('height',''); this.gridHover.css('height','');
} }
while(node && node != this.node && node.tagName != 'BODY' && path.length < 10) for(let i = 0; i < nodes.length && nodes[i].tagName != 'FORM'; i++)
{ {
path.push(node); let node = nodes[i];
node.style.display = 'none'; let $node = jQuery(node);
$node = jQuery(node); // Ignore high level & non-time (grid itself, header parent & week label)
if($node.hasClass('calendar_calDayColHeader')) { if([this.node, this.gridHeader[0], this._labelContainer[0]].indexOf(node) !== -1 ||
for(var id in node.dataset) { // Day labels
this.gridHeader.has(node).length && !$node.hasClass("calendar_calDayColAllDay") && !$node.hasClass('calendar_calDayColHeader'))
{
continue;
}
if(node.classList.contains('calendar_calDayColHeader'))
{
for(var id in node.dataset)
{
this.gridHover[0].dataset[id] = node.dataset[id]; this.gridHover[0].dataset[id] = node.dataset[id];
} }
this.gridHover.css({ this.gridHover.css({
position: 'absolute',
top: '', top: '',
bottom: '0px', bottom: '0px',
// Use 100% height if we're hiding the day labels to avoid // Use 100% height if we're hiding the day labels to avoid
// any remaining space from the hidden labels // any remaining space from the hidden labels
height: $node.height() > parseInt($node.css('line-height')) ? height: $node.height() > parseInt($node.css('line-height')) ?
$node.css('padding-bottom') : '100%' $node.css('padding-bottom') : '100%'
}); });
day = node; day = node;
this.gridHover this.gridHover
.attr('data-non_blocking','true'); .attr('data-non_blocking', 'true');
break; break;
} }
if($node.hasClass('calendar_calDayCol')) if(node.classList.contains('calendar_calDayCol'))
{ {
day = node; day = node;
this.gridHover this.gridHover
.attr('data-date',day.dataset.date); .attr('data-date', day.dataset.date);
} }
if($node.hasClass('calendar_calTimeRowTime')) if(node.classList.contains('calendar_calTimeRowTime'))
{ {
time = node; time = node;
this.gridHover this.gridHover
.attr('data-hour',time.dataset.hour) .attr('data-hour', time.dataset.hour)
.attr('data-minute',time.dataset.minute); .attr('data-minute', time.dataset.minute);
break; break;
} }
node = document.elementFromPoint(x,y);
}
for(var i = 0; i < path.length; i++)
{
path[i].style.display = '';
} }
if(!day) if(!day)
@ -2230,12 +2224,13 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet
} }
this.gridHover this.gridHover
.show() .show()
.css("position", "absolute")
.appendTo(day); .appendTo(day);
if(time) if(time)
{ {
this.gridHover this.gridHover
.height(this.rowHeight) .height(this.rowHeight)
.position({my:'left top', at: 'left top', of: time}); .css("top", time.offsetTop + "px");
} }
this.gridHover.css('left',''); this.gridHover.css('left','');
return this.gridHover; return this.gridHover;