UNPKG

@progress/kendo-angular-scheduler

Version:

Kendo UI Scheduler Angular - Outlook or Google-style angular scheduler calendar. Full-featured and customizable embedded scheduling from the creator developers trust for professional UI components.

83 lines (82 loc) 2.58 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { EventEmitter } from '@angular/core'; import { isDocumentAvailable } from '@progress/kendo-angular-common'; /** * @hidden */ export class BaseSlotService { containerSize = 0; slotsChange = new EventEmitter(); groups = []; registerItem(component) { const group = this.itemGroup(component); group.registerItem(component); } unregisterItem(component, id) { id = id || { index: component.index, resourceIndex: component.resourceIndex, rangeIndex: component.rangeIndex }; const group = this.groups[id.resourceIndex]; if (group) { group.unregisterItem(component, id); } } registerSlot(slot) { const group = this.slotGroup(slot); group.registerSlot(slot); } unregisterSlot(slot) { const group = this.groups[slot.id.resourceIndex]; if (group) { group.unregisterSlot(slot); } } invalidate() { this.clearEmptyGroups(); this.cleanRanges(); this.slotsChange.emit(); this.forEachSlot(slot => { slot.invalidate(); }); } cleanRanges() { this.groups.forEach(group => { group.cleanRanges(); }); } clearEmptyGroups() { const groups = this.groups; let index = this.groups.length - 1; while (index > 0 && !groups[index].hasSlots) { groups.splice(index, 1); index--; } } itemGroup(item) { const index = item.resourceIndex; if (!this.groups[index]) { this.groups[index] = this.createGroup(index); } return this.groups[index]; } slotGroup(slot) { const index = slot.id.resourceIndex; if (!this.groups[index]) { this.groups[index] = this.createGroup(index); } return this.groups[index]; } calculateScaleX() { if (!isDocumentAvailable()) { return; } const schedulerEl = document.querySelector('.k-scheduler'); const scaleX = schedulerEl.getBoundingClientRect().width / schedulerEl.offsetWidth; return scaleX; } }