| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /* A month view with day cells running in rows (one-per-week) and columns
- ----------------------------------------------------------------------------------------------------------------------*/
- setDefaults({
- fixedWeekCount: true,
- eventLimit: false,
- eventLimitText: 'more',
- eventLimitClick: 'popover',
- dayPopoverFormat: 'LL'
- });
- fcViews.month = MonthView; // register the view
- function MonthView(calendar) {
- BasicView.call(this, calendar); // call the super-constructor
- }
- MonthView.prototype = createObject(BasicView.prototype); // define the super-class
- $.extend(MonthView.prototype, {
- name: 'month',
- incrementDate: function(date, delta) {
- return date.clone().stripTime().add(delta, 'months').startOf('month');
- },
- render: function(date) {
- var rowCnt;
- this.intervalStart = date.clone().stripTime().startOf('month');
- this.intervalEnd = this.intervalStart.clone().add(1, 'months');
- this.start = this.intervalStart.clone();
- this.start = this.skipHiddenDays(this.start); // move past the first week if no visible days
- this.start.startOf('week');
- this.start = this.skipHiddenDays(this.start); // move past the first invisible days of the week
- this.end = this.intervalEnd.clone();
- this.end = this.skipHiddenDays(this.end, -1, true); // move in from the last week if no visible days
- this.end.add((7 - this.end.weekday()) % 7, 'days'); // move to end of week if not already
- this.end = this.skipHiddenDays(this.end, -1, true); // move in from the last invisible days of the week
- rowCnt = Math.ceil( // need to ceil in case there are hidden days
- this.end.diff(this.start, 'weeks', true) // returnfloat=true
- );
- if (this.isFixedWeeks()) {
- this.end.add(6 - rowCnt, 'weeks');
- rowCnt = 6;
- }
- this.title = this.calendar.formatDate(this.intervalStart, this.opt('titleFormat'));
- BasicView.prototype.render.call(this, rowCnt, this.getCellsPerWeek(), true); // call the super-method
- },
- // Overrides the default BasicView behavior to have special multi-week auto-height logic
- setGridHeight: function(height, isAuto) {
- var eventLimit = this.opt('eventLimit');
- isAuto = isAuto || this.opt('weekMode') === 'variable'; // LEGACY: weekMode is deprecated
- // if auto, make the height of each row the height that it would be if there were 6 weeks
- if (isAuto) {
- height *= this.rowCnt / 6;
- }
- this.dayGrid.destroySegPopover(); // kill the "more" popover if displayed
- // is the event limit a constant level number?
- if (eventLimit && typeof eventLimit === 'number') {
- this.dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
- }
- distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
- // is the event limit dynamically calculated?
- if (eventLimit && typeof eventLimit !== 'number') {
- this.dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
- }
- },
- isFixedWeeks: function() {
- var weekMode = this.opt('weekMode'); // LEGACY: weekMode is deprecated
- if (weekMode) {
- return weekMode === 'fixed'; // if any other type of weekMode, assume NOT fixed
- }
- return this.opt('fixedWeekCount');
- },
- // If dynamically limiting events, signals that all rows need to be a constant height.
- hasRigidRows: function() {
- var eventLimit = this.opt('eventLimit');
- return eventLimit && typeof eventLimit !== 'number';
- }
- });
|