MonthView.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import * as moment from 'moment'
  2. import { distributeHeight } from '../util'
  3. import BasicView from './BasicView'
  4. import MonthViewDateProfileGenerator from './MonthViewDateProfileGenerator'
  5. /* A month view with day cells running in rows (one-per-week) and columns
  6. ----------------------------------------------------------------------------------------------------------------------*/
  7. export default class MonthView extends BasicView {
  8. // Overrides the default BasicView behavior to have special multi-week auto-height logic
  9. setGridHeight(height, isAuto) {
  10. // if auto, make the height of each row the height that it would be if there were 6 weeks
  11. if (isAuto) {
  12. height *= this.dayGrid.rowCnt / 6
  13. }
  14. distributeHeight($(this.dayGrid.rowEls), height, !isAuto) // if auto, don't compensate for height-hogging rows
  15. }
  16. isDateInOtherMonth(date, dateProfile) {
  17. return date.month() !== moment.utc(dateProfile.currentUnzonedRange.startMs).month() // TODO: optimize
  18. }
  19. }
  20. MonthView.prototype.dateProfileGeneratorClass = MonthViewDateProfileGenerator