|
|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
var BasicView = View.extend({
|
|
|
|
|
|
+ dayGridClass: DayGrid, // class the dayGrid will be instantiated from (overridable by subclasses)
|
|
|
dayGrid: null, // the main subcomponent that does most of the heavy lifting
|
|
|
|
|
|
dayNumbersVisible: false, // display day numbers on each day cell?
|
|
|
@@ -18,8 +19,17 @@ var BasicView = View.extend({
|
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
- this.dayGrid = new DayGrid(this);
|
|
|
- this.coordMap = this.dayGrid.coordMap; // the view's date-to-cell mapping is identical to the subcomponent's
|
|
|
+ this.dayGrid = this.instantiateDayGrid();
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Generates the DayGrid object this view needs. Draws from this.dayGridClass
|
|
|
+ instantiateDayGrid: function() {
|
|
|
+ // generate a subclass on the fly with BasicView-specific behavior
|
|
|
+ // TODO: cache this subclass
|
|
|
+ var subclass = this.dayGridClass.extend(basicDayGridMethods);
|
|
|
+
|
|
|
+ return new subclass(this);
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -114,73 +124,6 @@ var BasicView = View.extend({
|
|
|
},
|
|
|
|
|
|
|
|
|
- // Generates the HTML that will go before the day-of week header cells.
|
|
|
- // Queried by the DayGrid subcomponent when generating rows. Ordering depends on isRTL.
|
|
|
- headIntroHtml: function() {
|
|
|
- if (this.weekNumbersVisible) {
|
|
|
- return '' +
|
|
|
- '<th class="fc-week-number ' + this.widgetHeaderClass + '" ' + this.weekNumberStyleAttr() + '>' +
|
|
|
- '<span>' + // needed for matchCellWidths
|
|
|
- htmlEscape(this.opt('weekNumberTitle')) +
|
|
|
- '</span>' +
|
|
|
- '</th>';
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // Generates the HTML that will go before content-skeleton cells that display the day/week numbers.
|
|
|
- // Queried by the DayGrid subcomponent. Ordering depends on isRTL.
|
|
|
- numberIntroHtml: function(row) {
|
|
|
- if (this.weekNumbersVisible) {
|
|
|
- return '' +
|
|
|
- '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '>' +
|
|
|
- '<span>' + // needed for matchCellWidths
|
|
|
- this.dayGrid.getCell(row, 0).start.format('w') +
|
|
|
- '</span>' +
|
|
|
- '</td>';
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // Generates the HTML that goes before the day bg cells for each day-row.
|
|
|
- // Queried by the DayGrid subcomponent. Ordering depends on isRTL.
|
|
|
- dayIntroHtml: function() {
|
|
|
- if (this.weekNumbersVisible) {
|
|
|
- return '<td class="fc-week-number ' + this.widgetContentClass + '" ' +
|
|
|
- this.weekNumberStyleAttr() + '></td>';
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // Generates the HTML that goes before every other type of row generated by DayGrid. Ordering depends on isRTL.
|
|
|
- // Affects helper-skeleton and highlight-skeleton rows.
|
|
|
- introHtml: function() {
|
|
|
- if (this.weekNumbersVisible) {
|
|
|
- return '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '></td>';
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- // Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
|
|
|
- // The number row will only exist if either day numbers or week numbers are turned on.
|
|
|
- numberCellHtml: function(cell) {
|
|
|
- var date = cell.start;
|
|
|
- var classes;
|
|
|
-
|
|
|
- if (!this.dayNumbersVisible) { // if there are week numbers but not day numbers
|
|
|
- return '<td/>'; // will create an empty space above events :(
|
|
|
- }
|
|
|
-
|
|
|
- classes = this.dayGrid.getDayClasses(date);
|
|
|
- classes.unshift('fc-day-number');
|
|
|
-
|
|
|
- return '' +
|
|
|
- '<td class="' + classes.join(' ') + '" data-date="' + date.format() + '">' +
|
|
|
- date.date() +
|
|
|
- '</td>';
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
// Generates an HTML attribute string for setting the width of the week number column, if it is known
|
|
|
weekNumberStyleAttr: function() {
|
|
|
if (this.weekNumberWidth !== null) {
|
|
|
@@ -318,3 +261,68 @@ var BasicView = View.extend({
|
|
|
}
|
|
|
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+var basicDayGridMethods = {
|
|
|
+
|
|
|
+
|
|
|
+ // Generates the HTML that will go before the day-of week header cells
|
|
|
+ getHeadIntroHtml: function() {
|
|
|
+ var view = this.view;
|
|
|
+
|
|
|
+ if (view.weekNumbersVisible) {
|
|
|
+ return '' +
|
|
|
+ '<th class="fc-week-number ' + view.widgetHeaderClass + '" ' + view.weekNumberStyleAttr() + '>' +
|
|
|
+ '<span>' + // needed for matchCellWidths
|
|
|
+ htmlEscape(view.opt('weekNumberTitle')) +
|
|
|
+ '</span>' +
|
|
|
+ '</th>';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
|
|
|
+ getNumberIntroHtml: function(row) {
|
|
|
+ var view = this.view;
|
|
|
+
|
|
|
+ if (view.weekNumbersVisible) {
|
|
|
+ return '' +
|
|
|
+ '<td class="fc-week-number" ' + view.weekNumberStyleAttr() + '>' +
|
|
|
+ '<span>' + // needed for matchCellWidths
|
|
|
+ this.getCellDate(row, 0).format('w') +
|
|
|
+ '</span>' +
|
|
|
+ '</td>';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Generates the HTML that goes before the day bg cells for each day-row
|
|
|
+ getBgIntroHtml: function() {
|
|
|
+ var view = this.view;
|
|
|
+
|
|
|
+ if (view.weekNumbersVisible) {
|
|
|
+ return '<td class="fc-week-number ' + view.widgetContentClass + '" ' +
|
|
|
+ view.weekNumberStyleAttr() + '></td>';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // Generates the HTML that goes before every other type of row generated by DayGrid.
|
|
|
+ // Affects helper-skeleton and highlight-skeleton rows.
|
|
|
+ getIntroHtml: function() {
|
|
|
+ var view = this.view;
|
|
|
+
|
|
|
+ if (view.weekNumbersVisible) {
|
|
|
+ return '<td class="fc-week-number" ' + view.weekNumberStyleAttr() + '></td>';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+};
|